1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-12 19:08:56 +00:00

p2sh section

This commit is contained in:
Andreas M. Antonopoulos 2014-06-24 20:27:02 -04:00
parent c14c56c23d
commit 67a77f49cf

View File

@ -375,7 +375,22 @@ A valid transaction can have only one OP_RETURN output. However, a single OP_RET
==== Pay to Script Hash (P2SH)
Pay-to-Script-Hash (P2SH) was introduced in the winter of 2012 as a powerful new type of transaction that greatly simplifies the use of complex transaction scripts. To explain the need for P2SH, let's look at a practical example.
Pay-to-Script-Hash (P2SH) was introduced in the winter of 2012 as a powerful new type of transaction that greatly simplifies the use of complex transaction scripts. To explain the need for P2SH, let's look at a practical example.
In chapter 1 we introduced Mohammed, an electronics importer based in Dubai. Mohammed's company uses bitcoin's multi-signature feature extensively for its corporate accounts. Multi-signature accounts are used protect the company's treasury funds, accounts receivable funds and for large inventory expenses, such as large orders of electronics. Mohammed wants to use bitcoin's multi-signature to collect a payment from a customer who is importing a very large order of electronics. The payment from the customer will be "locked" by a multi-signature locking script that requires at least two signatures, from a pool of three public keys that include Mohammed's key, his customer's key and a third-party acting as an escrow agent for the order.
The resulting script is quite long and looks like this:
2 <Mohammed's Public Key> <Customer Public Key> <Escrow Agent Public Key> 3 OP_CHECKMULTISIG
The script encoded in hex is also quite long:
+522102b89c96990d66f92b0d80de10
0e0cd95239d83611e868dcfaf355ff
2a4e3a6f37210346119060d1a37e30
f14188d7b593e462e1999e40217ded
2fc31bb38df83938802103fb20a2bc
d01f5cb1707153f7175a17576b0541
59eebeaa6e3aad6d2ef53cc60753ae+
* Complex scripts replaced by shorter fingerprint in the output
* Scripts can be coded as an address, so the sender and the sender's wallet don't need complex engineering to implement