mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
core: hangle CallingScriptHash correctly
When using native contracts, script hash of second-to-top context on invocation stack does not always correspond to a real calling contract.
This commit is contained in:
parent
e903e40085
commit
e63191d31f
4 changed files with 33 additions and 5 deletions
|
@ -22,8 +22,13 @@ func GetExecutingScriptHash(ic *interop.Context) error {
|
|||
}
|
||||
|
||||
// GetCallingScriptHash returns calling script hash.
|
||||
// While Executing and Entry script hashes are always valid for non-native contracts,
|
||||
// Calling hash is set explicitly when native contracts are used, because when switching from
|
||||
// one native to another, no operations are performed on invocation stack.
|
||||
func GetCallingScriptHash(ic *interop.Context) error {
|
||||
return ic.VM.PushContextScriptHash(1)
|
||||
h := ic.VM.GetCallingScriptHash()
|
||||
ic.VM.Estack().PushVal(h.BytesBE())
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetEntryScriptHash returns entry script hash.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue