Skip to content

Commit

Permalink
txscript: Optimize new engine push only script.
Browse files Browse the repository at this point in the history
This modifies the check for whether or not a pay-to-script-hash
signature script is a push only script to make use of the new and more
efficient raw script function.

Also, since the script will have already been checked further above when
the ScriptVerifySigPushOnly flags is set, avoid checking it again in
that case.
  • Loading branch information
davecgh committed Mar 26, 2019
1 parent 9e8bfd2 commit af67951
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions txscript/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,11 @@ func NewEngine(scriptPubKey []byte, tx *wire.MsgTx, txIdx int, flags ScriptFlags
// The signature script must only contain data pushes for P2SH which is
// determined based on the form of the public key script.
if isAnyKindOfScriptHash(scriptPubKey) {
// Only accept input scripts that push data for P2SH.
if !isPushOnly(vm.scripts[0]) {
// Notice that the push only checks have already been done when the flag
// to verify signature scripts are push only is set above, so avoid
// checking again.
alreadyChecked := vm.hasFlag(ScriptVerifySigPushOnly)
if !alreadyChecked && !IsPushOnlyScript(scriptSig) {
return nil, scriptError(ErrNotPushOnly,
"pay to script hash is not push only")
}
Expand Down

0 comments on commit af67951

Please sign in to comment.