aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/import_tx.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm/import_tx.go')
-rw-r--r--plugin/evm/import_tx.go35
1 files changed, 24 insertions, 11 deletions
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 {