From 4ebac5a069e8824ee3aa325a724be2338bed5c92 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 14 May 2020 11:33:53 +0300 Subject: [PATCH] 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. --- pkg/core/blockchain.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 35a8a07fc..8d0ab3a1e 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -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 {