From b9b9f523b3a745ca0c5809ea2d1c76c80a4134cb Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 19 Aug 2020 21:02:34 -0400 Subject: finish flow-checking --- plugin/evm/import_tx.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 } -- cgit v1.2.3