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:
Evgenii Stratonikov 2020-12-10 16:52:16 +03:00
parent e903e40085
commit e63191d31f
4 changed files with 33 additions and 5 deletions

View file

@ -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.