diff options
author | Determinant <[email protected]> | 2020-08-19 21:02:34 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-08-19 21:02:34 -0400 |
commit | b9b9f523b3a745ca0c5809ea2d1c76c80a4134cb (patch) | |
tree | e9a5143f71f3b2ee7aedca07138aab04de13533e /plugin/evm | |
parent | 1e9599e88a5d88e0090b0ebddfae756e343e605a (diff) |
finish flow-checking
Diffstat (limited to 'plugin/evm')
-rw-r--r-- | plugin/evm/import_tx.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go index a61adaa..0e77efc 100644 --- a/plugin/evm/import_tx.go +++ b/plugin/evm/import_tx.go @@ -94,7 +94,22 @@ func (tx *UnsignedImportTx) SemanticVerify( if err := tx.Verify(vm.avm, vm.ctx, vm.txFee, vm.avaxAssetID); err != nil { return permError{err} } - // TODO: verify using avax.VerifyTx(vm.txFee, vm.avaxAssetID, tx.Ins, outs) + + // do flow-checking + fc := avax.NewFlowChecker() + fc.Produce(vm.avaxAssetID, vm.txFee) + + for _, out := range tx.Outs { + fc.Produce(vm.avaxAssetID, out.Amount) + } + + for _, in := range tx.ImportedInputs { + fc.Consume(in.AssetID(), in.Input().Amount()) + } + if err := fc.Verify(); err != nil { + return permError{err} + } + // TODO: verify UTXO inputs via gRPC (with creds) return nil } |