Merge pull request #1901 from nspcc-dev/nep5-tracking-fixes

NEP5 tracking fixes
This commit is contained in:
Roman Khimov 2021-04-12 17:04:55 +03:00 committed by GitHub
commit d8c8593410
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View file

@ -945,9 +945,7 @@ func (bc *Blockchain) processNEP5Transfer(cache *dao.Cached, transfer *state.NEP
return return
} }
bs := balances.Trackers[transfer.Asset] bs := balances.Trackers[transfer.Asset]
if bs.Balance == nil { if bs.Balance != nil {
return
}
bs.Balance.Sub(bs.Balance, transfer.Amount) bs.Balance.Sub(bs.Balance, transfer.Amount)
if bs.Balance.Sign() > 0 { if bs.Balance.Sign() > 0 {
bs.LastUpdatedBlock = transfer.Block bs.LastUpdatedBlock = transfer.Block
@ -955,6 +953,7 @@ func (bc *Blockchain) processNEP5Transfer(cache *dao.Cached, transfer *state.NEP
} else { } else {
delete(balances.Trackers, transfer.Asset) delete(balances.Trackers, transfer.Asset)
} }
}
transfer.Amount.Neg(transfer.Amount) transfer.Amount.Neg(transfer.Amount)
isBig, err := cache.AppendNEP5Transfer(transfer.From, balances.NextTransferBatch, transfer) isBig, err := cache.AppendNEP5Transfer(transfer.From, balances.NextTransferBatch, transfer)

View file

@ -188,6 +188,9 @@ func NEP5TransferFromNotification(ne NotificationEvent, txHash util.Uint256, hei
if !ok { if !ok {
return nil, errors.New("wrong amount type") return nil, errors.New("wrong amount type")
} }
if len(bs) > amountSize {
return nil, errors.New("integer overflow")
}
amount = emit.BytesToInt(bs) amount = emit.BytesToInt(bs)
} }
toAddr := parseUint160(to) toAddr := parseUint160(to)