native: distribute GAS even for empty transfers

As it's one of the use cases.
This commit is contained in:
Roman Khimov 2020-04-26 12:51:17 +03:00
parent 064636768b
commit 36c6c6690b

View file

@ -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