From 0b934ef60fd652de038a21e6f25691b11cea7121 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 19 Aug 2020 21:20:58 -0400 Subject: remove base_tx.go --- plugin/evm/import_tx.go | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'plugin/evm/import_tx.go') diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go index 0e77efc..2e49493 100644 --- a/plugin/evm/import_tx.go +++ b/plugin/evm/import_tx.go @@ -31,7 +31,18 @@ var ( // UnsignedImportTx is an unsigned ImportTx type UnsignedImportTx struct { - BaseTx `serialize:"true"` + avax.Metadata + // true iff this transaction has already passed syntactic verification + syntacticallyVerified bool + // ID of the network on which this tx was issued + NetworkID uint32 `serialize:"true" json:"networkID"` + // ID of this blockchain. In practice is always the empty ID. + // This is only here to match avm.BaseTx's format + BlockchainID ids.ID `serialize:"true" json:"blockchainID"` + // Outputs + Outs []EVMOutput `serialize:"true" json:"outputs"` + // Memo field contains arbitrary bytes, up to maxMemoSize + Memo []byte `serialize:"true" json:"memo"` // Which chain to consume the funds from SourceChain ids.ID `serialize:"true" json:"sourceChain"` @@ -67,10 +78,16 @@ func (tx *UnsignedImportTx) Verify( return errWrongChainID case len(tx.ImportedInputs) == 0: return errNoImportInputs + case tx.NetworkID != ctx.NetworkID: + return errWrongNetworkID + case !ctx.ChainID.Equals(tx.BlockchainID): + return errWrongBlockchainID } - if err := tx.BaseTx.Verify(ctx); err != nil { - return err + for _, out := range tx.Outs { + if err := out.Verify(); err != nil { + return err + } } for _, in := range tx.ImportedInputs { @@ -178,7 +195,6 @@ func (vm *VM) newImportTx( return nil, errNoFunds // No imported UTXOs were spendable } - ins := []*avax.TransferableInput{} outs := []EVMOutput{} if importedAmount < vm.txFee { // imported amount goes toward paying tx fee // TODO: spend EVM balance to compensate vm.txFee-importedAmount @@ -192,14 +208,11 @@ func (vm *VM) newImportTx( // Create the transaction utx := &UnsignedImportTx{ - BaseTx: BaseTx{ - NetworkID: vm.ctx.NetworkID, - BlockchainID: vm.ctx.ChainID, - Outs: outs, - Ins: ins, - }, - SourceChain: chainID, + NetworkID: vm.ctx.NetworkID, + BlockchainID: vm.ctx.ChainID, + Outs: outs, ImportedInputs: importedInputs, + SourceChain: chainID, } tx := &Tx{UnsignedTx: utx} if err := tx.Sign(vm.codec, signers); err != nil { -- cgit v1.2.3