aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-08-19 21:02:34 -0400
committerDeterminant <[email protected]>2020-08-19 21:02:34 -0400
commitb9b9f523b3a745ca0c5809ea2d1c76c80a4134cb (patch)
treee9a5143f71f3b2ee7aedca07138aab04de13533e /plugin
parent1e9599e88a5d88e0090b0ebddfae756e343e605a (diff)
finish flow-checking
Diffstat (limited to 'plugin')
-rw-r--r--plugin/evm/import_tx.go17
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
}