mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
native: add calling script hash to NEP5 transfer witness check
Fix transfers from contract's address.
This commit is contained in:
parent
d4c3a17883
commit
59be6bcd24
1 changed files with 8 additions and 6 deletions
|
@ -175,13 +175,15 @@ func (c *nep5TokenNative) transfer(ic *interop.Context, from, to util.Uint160, a
|
|||
return errors.New("negative amount")
|
||||
}
|
||||
|
||||
ok, err := runtime.CheckHashedWitness(ic, from)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !ok {
|
||||
return errors.New("invalid signature")
|
||||
caller := ic.ScriptGetter.GetCallingScriptHash()
|
||||
if caller.Equals(util.Uint160{}) || !from.Equals(caller) {
|
||||
ok, err := runtime.CheckHashedWitness(ic, from)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !ok {
|
||||
return errors.New("invalid signature")
|
||||
}
|
||||
}
|
||||
|
||||
isEmpty := from.Equals(to) || amount.Sign() == 0
|
||||
inc := amount
|
||||
if isEmpty {
|
||||
|
|
Loading…
Reference in a new issue