diff --git a/pkg/vm/context.go b/pkg/vm/context.go index 8fa7afd98..bfbf2f2bb 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -41,6 +41,9 @@ type Context struct { // Script hash of the prog. scriptHash util.Uint160 + // Caller's contract script hash. + callingScriptHash util.Uint160 + // Call flags this context was created with. callFlag smartcontract.CallFlag } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 1c201dfd7..90d16014b 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -276,9 +276,11 @@ func (v *VM) LoadScriptWithFlags(b []byte, f smartcontract.CallFlag) { // given script hash directly into the Context to avoid its recalculations. It's // up to user of this function to make sure the script and hash match each other. func (v *VM) LoadScriptWithHash(b []byte, hash util.Uint160, f smartcontract.CallFlag) { + shash := v.GetCurrentScriptHash() v.LoadScriptWithFlags(b, f) ctx := v.Context() ctx.scriptHash = hash + ctx.callingScriptHash = shash } // Context returns the current executed context. Nil if there is no context, @@ -1607,7 +1609,7 @@ func (v *VM) bytesToPublicKey(b []byte) *keys.PublicKey { // GetCallingScriptHash implements ScriptHashGetter interface func (v *VM) GetCallingScriptHash() util.Uint160 { - return v.getContextScriptHash(1) + return v.Context().callingScriptHash } // GetEntryScriptHash implements ScriptHashGetter interface