From 7f3392680df7cd9672d309602ed52dab5847abeb Mon Sep 17 00:00:00 2001 From: alexvanin Date: Tue, 12 May 2020 16:30:31 +0300 Subject: [PATCH] examples: Use "or" operator in transfer check of NEP5 token CanTransfer function checks if "to" and "from" values are correct script hashes. If one of these values is correct and one incorrect, then function returns false positive result. It uses "and" operator which requires both "to" and "from" script hashes to be incorrect to fail transaction. Instead transaction must fail if at least one argument is incorrect, so it should be "or" operator. --- examples/token/nep5/nep5.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/token/nep5/nep5.go b/examples/token/nep5/nep5.go index 96a465b6d..742e0e3df 100644 --- a/examples/token/nep5/nep5.go +++ b/examples/token/nep5/nep5.go @@ -58,7 +58,7 @@ func (t Token) Transfer(ctx storage.Context, from []byte, to []byte, amount int) // CanTransfer returns the amount it can transfer func (t Token) CanTransfer(ctx storage.Context, from []byte, to []byte, amount int) int { - if len(to) != 20 && !IsUsableAddress(from) { + if len(to) != 20 || !IsUsableAddress(from) { return -1 }