pull down to refresh

Types of bitcoin payment scripts:
  • P2PK - (Pay To Pubkey) is a script pattern that locks an output to a public key. Provide the pubkey and a digital signature to unlock.
  • P2PKH - (Pay to Pubkey Hash) similar to P2PK, but the lock contains the hash of a public key instead (and not the public key itself). Key is not revealed until coins are unlocked.
  • P2MS - (Pay to MultiSig) is a script pattern that allows you to lock bitcoins to multiple public keys, and require signatures for some (or all) of those public keys to unlock it. Limited to 3 pubkeys, no address format.
  • P2SH - (Pay to Script Hash) - transactions are locked behind the hash of an unlocking script. Unlocking script must equal hash and the script must evaluate to true to unlock the coins.
  • NULL DATA - Allows one to attach arbitrary data on the blockchain. This locking script cannot be unlocked.
I had a question about P2SH. Suppose P2SH is being used for a 2-of-3 multisig locking script. There are multiple ways to unlock the script. But don't you have to commit to one when generating the script hash? Essentially turning that 2-of-3 multisig into a 2-of-2, whichever pubkeys were picked for the unlocking script?
That's for sharing this resource. This is great!
reply
Cool website, thanks for sharing!
reply
When you create the unlocking script of a P2SH, you push both the original locking script and any combination of op codes that allow you to unlock it (eg one of the ways to unlock the script). As your unlocking script still contains the locking one, with all its unlocking ways, it's still a 2-of-3 multisig in my opinion. But the opcode pushed on top of the locking script would indeed be the same between a 2-of-2 and a 2-of-3 (if the 2 keys are the same of course). See https://learnmeabitcoin.com/technical/p2sh (same website, which is indeed fantastic!).
reply
Okay, I think my confusion was that the parameters are not included in the hash. Thank you.
reply
My pleasure! Btw, the fact that you have to reveal the entire locking script each time you spend from a P2SH is one of the reasons behind the implementation of Taproot on Bitcoin. With Taproot, you're able to only reveal the path you actually use to spend the bitcoins, not all of them.
reply
How complex can the scripts get??
reply
The locking script complexity is only limited by the fees you are willing to pay to spend from it.
reply
I would add the Segwit versions: P2WPKH and P2WSH, which can also be wrapped in P2SH scripts.
The P2TR format introduced by Taproot allows combining a PK spending path with a script spending path in the same output. When spending from the PK a valid signature must be provided. For script spending path you need to reveal the branch of the script (and a Merkle proof that you committed to this script) you want to execute instead of the full script.
reply