P2SH (pay to script hash) within a script?

1

BIP16 P2SH defines special rules to apply on scripts with a specific pattern, namely: OP_HASH160 <scriptHash> OP_EQUAL.

My question is: Can a P2SH be used within a script? So can I e.g. make a scriptPubKey: <420000> OP_CHECKLOCKTIMEVERIFY OP_DROP OP_HASH160 <scriptHash> OP_EQUAL? Or must all additional opcodes be in the redeemScript so that the whole scriptPubKey follows the pattern mentioned in the BIP16 above?

Bjarne

Posted 2016-03-15T21:07:04.937

Reputation: 752

Answers

3

No, P2SH can only be invoked using the exact magic pattern described in BIP16 in the scriptPubKey and not using any variant of it, nor recursively inside the P2SH redeemScript itself.

Earlier proposals (see OP_EVAL) existed that did allow much more flexibility, but it was hard to give strong guarantees about execution time and memory in such a model.

Pieter Wuille

Posted 2016-03-15T21:07:04.937

Reputation: 54 032