core: fix bug in nep5 notifications handling

Native contracts deployment creates `Transfer` notifications and adds
them into interop context. However, these notifications were not stored
for two reasons:
1. typo in `Transfer` (so these notifications were not recognised during
processing of the invocation tx in (*Blockchain).storeBlock(...) method)
2. these notifications have `from` adress setted to null, so conversion
to []byte fails. Same thing could happen with `to`.

Related C# issue: https://github.com/neo-project/neo/issues/1646

For now, made both `transfer` and `Transfer` valid.
This commit is contained in:
Anna Shaleva 2020-05-14 11:33:53 +03:00
parent 45b8bdb51c
commit 4ebac5a069

View file

@ -651,16 +651,26 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
continue
}
op, ok := arr[0].Value().([]byte)
if !ok || string(op) != "transfer" {
if !ok || (string(op) != "transfer" && string(op) != "Transfer") {
continue
}
from, ok := arr[1].Value().([]byte)
if !ok {
continue
var from []byte
fromValue := arr[1].Value()
// we don't have `from` set when we are minting tokens
if fromValue != nil {
from, ok = fromValue.([]byte)
if !ok {
continue
}
}
to, ok := arr[2].Value().([]byte)
if !ok {
continue
var to []byte
toValue := arr[2].Value()
// we don't have `to` set when we are burning tokens
if toValue != nil {
to, ok = toValue.([]byte)
if !ok {
continue
}
}
amount, ok := arr[3].Value().(*big.Int)
if !ok {