1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-30 03:48:31 +00:00

Made changes to ch05.asciidoc

This commit is contained in:
drusselloctal@gmail.com 2014-10-30 14:03:19 -07:00
parent 3dae081739
commit 757395a3aa

View File

@ -392,7 +392,7 @@ image::images/msbt_0504.png["Tx_Script_P2PubKeyHash_2"]
[[p2pk]] [[p2pk]]
==== Pay-to-Public-Key ==== Pay-to-Public-Key
Pay-to-Public-Key is a simpler form of a bitcoin payment than Pay-to-Public-Key-Hash. With this script form, the public key itself is stored in the locking script, rather than a public-key-hash as with P2PKH above, which is much shorter. Pay-to-Public-Key-Hash was invented by Satoshi to make bitcoin addresses shorter, for ease of use. Pay-to-Public-Key is now most often seen in coinbase transactions, generated by older mining software that has not been updated to use P2PKH. Pay-to-Public-Key is a simpler form of a bitcoin payment than Pay-to-Public-Key-Hash. With this script form, the public key itself is stored in the locking script, rather than a public-key-hash as with P2PKH earlier, which is much shorter. Pay-to-Public-Key-Hash was invented by Satoshi to make bitcoin addresses shorter, for ease of use. Pay-to-Public-Key is now most often seen in coinbase transactions, generated by older mining software that has not been updated to use P2PKH.
A Pay-to-Public-Key locking script looks like this: A Pay-to-Public-Key locking script looks like this:
---- ----
@ -404,17 +404,17 @@ The corresponding unlocking script that must be presented to unlock this type of
<Signature from Private Key A> <Signature from Private Key A>
---- ----
The combined script, which is validated by the transaction validation software is: The combined script, which is validated by the transaction validation software, is:
---- ----
<Signature from Private Key A> <Public Key A> OP_CHECKSIG <Signature from Private Key A> <Public Key A> OP_CHECKSIG
---- ----
The script above is a simple invocation of the CHECKSIG operator which validates the signature as belonging to the correct key and returns TRUE on the stack. This script is a simple invocation of the +CHECKSIG+ operator, which validates the signature as belonging to the correct key and returns TRUE on the stack.
[[multisig]] [[multisig]]
==== Multi-Signature ==== Multi-Signature
Multi-signature scripts set a condition where N public keys are recorded in the script and at least M of those must provide signatures to release the encumbrance. This is also known as an M-of-N scheme, where N is the total number of keys and M is the threshold of signatures required for validation. For example, a 2-of-3 multi-signature is one where 3 public keys are listed as potential signers and at least 2 of those must be used to create signatures for a valid transaction to spend the funds. At this time, standard multi-signature scripts are limited to at most 15 listed public keys, meaning you can do anything from a 1-of-1 to a 15-of-15 multi-signature or any combination within that range. The limitation to 15 listed keys may be lifted by the time of publication of this book, so check the +isStandard()+ function to see what is currently accepted by the network. Multi-signature scripts set a condition where N public keys are recorded in the script and at least M of those must provide signatures to release the encumbrance. This is also known as an M-of-N scheme, where N is the total number of keys and M is the threshold of signatures required for validation. For example, a 2-of-3 multi-signature is one where three public keys are listed as potential signers and at least two of those must be used to create signatures for a valid transaction to spend the funds. At this time, standard multi-signature scripts are limited to at most 15 listed public keys, meaning you can do anything from a 1-of-1 to a 15-of-15 multi-signature or any combination within that range. The limitation to 15 listed keys may be lifted by the time of publication of this book, so check the +isStandard()+ function to see what is currently accepted by the network.
The general form of a locking script setting an M-of-N multi-signature condition is: The general form of a locking script setting an M-of-N multi-signature condition is:
@ -428,15 +428,16 @@ A locking script setting a 2-of-3 multi-signature condition looks like this:
2 <Public Key A> <Public Key B> <Public Key C> 3 OP_CHECKMULTISIG 2 <Public Key A> <Public Key B> <Public Key C> 3 OP_CHECKMULTISIG
---- ----
The locking script above can be satisfied with an unlocking script containing pairs of signatures and public keys: The preceding locking script can be satisfied with an unlocking script containing pairs of signatures and public keys:
---- ----
OP_0 <Signature B> <Signature C> OP_0 <Signature B> <Signature C>
---- ----
or any combination of two signatures from the private keys corresponding to the three listed public keys. or any combination of two signatures from the private keys corresponding to the three listed public keys.
_Note: The prefix OP_0 is required because of a bug in the original implementation of CHECKMULTISIG where one item too many is popped off the stack. It is ignored by CHECKMULTISIG and is simply a placeholder._ NOTE
The prefix +OP_0+ is required because of a bug in the original implementation of +CHECKMULTISIG+ where one item too many is popped off the stack. It is ignored by +CHECKMULTISIG+ and is simply a placeholder.
The two scripts together would form the combined validation script below: The two scripts together would form the combined validation script:
---- ----
OP_0 <Signature B> <Signature C>\ OP_0 <Signature B> <Signature C>\
2 <Public Key A> <Public Key B> <Public Key C> 3 OP_CHECKMULTISIG 2 <Public Key A> <Public Key B> <Public Key C> 3 OP_CHECKMULTISIG