Browse Source

Never receive negative amounts

xno
codesoap 9 months ago
parent
commit
50d6ff0d5e
  1. 4
      account_info.go

4
account_info.go

@ -118,6 +118,10 @@ func (i *AccountInfo) Receive(pending Pending) (Block, error) { @@ -118,6 +118,10 @@ func (i *AccountInfo) Receive(pending Pending) (Block, error) {
err := fmt.Errorf("cannot parse '%s' as an integer", pending.Amount)
return Block{}, err
}
if amount.Sign() < 1 {
err := fmt.Errorf("amount '%s' is not positive", pending.Amount)
return Block{}, err
}
updatedBalance.Add(updatedBalance, amount)
block := Block{
Type: "state",

Loading…
Cancel
Save