- Pay-to-Script-Hash output commits to a specific embedded script.
- Any output script can be embedded into a P2SH output.
- The embedded script must be supplied during spending, but is not disclosed beforehand.
- P2SH output is spendable by the embedded script and its unlocking script
- Embedded script in input is verified against the hash-digest in the output script.
- If preimage verification successful: Embedded script is run separately with the unlocking script operations loaded to the script machine stack.
P2SH Script Run
- 1) Input & Output Scripts are run
- Embedded script must hash to hash digest in P2SH script.
- 2) P2SH pattern is recognised
- If embedded script hashes correctly, it is now loaded and run.
- 3) Embedded script run
- The stack with the remaining unlocking script operations is carried over and the embedded script is run.
- 4) Final stack evaluation