22
9
BIP16 gives the following example to explain "Pay to Script Hash":
scriptSig: [signature] {[pubkey] OP_CHECKSIG}
scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ] OP_EQUAL
But I don't get what's happening here. I've tried executing the script on paper (and assumed the parts in squared/curly brackets are treated as constants):
[signature]and{[pubkey] OP_CHECKSIG}are pushed onto the stackOP_HASH160hashes{[pubkey] OP_CHECKSIG}- The same hash comes from the
scriptPubKeyonto the stack - Consequently
OP_EQUALgivesTrue - The
[signature]is not checked at all!
If the {[pubkey] OP_CHECKSIG} is executed, the scriptSig would only give True, which makes even less sense.
To frame a clear question: How do "Pay to Script Hash" scripts work, especially this example case?
4i'd like a more comprehensive walkthrough, or a link to one. i still don't get it. – mulllhausen – 2015-08-19T14:05:21.430
4This doesn't really answer the question at all as to how the pushed script bytes get executed. I assume BIP16 defies somewhere in it's complex language a definition for how the network identifies a "serialized script", since it is just data. Why would signatures, public keys, etc not be attempted to be interpreted as scripts as well given this definition? – Earlz – 2016-11-18T12:50:42.293