Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cygan on September 12, 2023, 01:45:51 PM



Title: [INFO - DISCUSSION] Pay-to-script-hash (P2SH) (BIP13)
Post by: cygan on September 12, 2023, 01:45:51 PM
with these 4 slides i would like to present you one of the first bips. this script which was created by Gavin Andresen in october 2011 was standardized in april 2012.
this method is the most difficult to understand in contrast to p2pk, p2pkh, or p2wpk. it helps to keep in mind that payments in themselves do not have a recipient, but only define a rule how the sent coins can be spent.
here, the receiver defines a rule (the script) and forms the hash from it. the sender can simply pay to a hash, and the receiver can spend the coins when he submits the script from which the specified hash is derived.
p2sh was introduced primarily to enable multisignature transactions, transactions that require not just one party to sign, but multiple parties.

Quote
BIP: 13
  Layer: Applications
  Title: Address Format for pay-to-script-hash
  Author: Gavin Andresen <gavinandresen@gmail.com>
  Comments-Summary: No comments yet.
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0013
  Status: Final
  Type: Standards Track
  Created: 2011-10-18
https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki (https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki)

https://www.talkimg.com/images/2023/09/12/6SP85.jpeg https://www.talkimg.com/images/2023/09/12/6STAz.jpeg
https://www.talkimg.com/images/2023/09/12/6SNUP.jpeg https://www.talkimg.com/images/2023/09/12/6SERq.jpeg
https://twitter.com/BTCillustrated (https://twitter.com/BTCillustrated)


Title: Re: [INFO - DISCUSSION] Pay-to-script-hash (P2SH) (BIP13)
Post by: pooya87 on September 12, 2023, 02:10:31 PM
BIP-16 (Pay to Script Hash) was the first time complexity was added into the simple FORTH (https://en.wikipedia.org/wiki/Forth_(programming_language)) like Bitcoin script system. Before BIP16 you'd just read each "command" from left to right and execute them using a stack. After BIP16 you first have to analyze the output-script to see if it matches the predefined patterns which will then tell you if you need to take "extra steps" before doing what you were doing before.
Today more complexity is added, for example if the output-script matches the OP_N <data> pattern, the code has to execute the branch related to SegWit where some OP codes like OP_CHECKSIG are acting differently.