From 36c6c6690b19f2b75a4a4e1ed522ee2adb3e05f0 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sun, 26 Apr 2020 12:51:17 +0300 Subject: [PATCH] native: distribute GAS even for empty transfers As it's one of the use cases. --- pkg/core/native/native_neo.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 9e480e0ff..c77e679fe 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -158,14 +158,15 @@ func (n *NEO) increaseBalance(ic *interop.Context, h util.Uint160, si *state.Sto if err != nil { return err } - if sign := amount.Sign(); sign == 0 { - return nil - } else if sign == -1 && acc.Balance.Cmp(new(big.Int).Neg(amount)) == -1 { + if amount.Sign() == -1 && acc.Balance.Cmp(new(big.Int).Neg(amount)) == -1 { return errors.New("insufficient funds") } if err := n.distributeGas(ic, h, acc); err != nil { return err } + if amount.Sign() == 0 { + return nil + } acc.Balance.Add(&acc.Balance, amount) si.Value = acc.Bytes() return nil