From e515da4a7c2078a0cf864b9e43a3b0bd94bd7812 Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:02:12 -0300 Subject: [PATCH 01/11] Fix summary indication Summary was mentioning the previous file instead of this one. --- 10_2_Building_the_Structure_of_P2SH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_2_Building_the_Structure_of_P2SH.md b/10_2_Building_the_Structure_of_P2SH.md index 5beb23c..c66b0d9 100644 --- a/10_2_Building_the_Structure_of_P2SH.md +++ b/10_2_Building_the_Structure_of_P2SH.md @@ -171,7 +171,7 @@ Depending on your API, you might be able to enter this as an `asm`-style `script Note that the `hex scriptPubKey` for P2SH Script transaction will _always_ start with an `a914`, which is the `OP_HASH160` followed by an `OP_PUSHDATA` of 20 bytes (hex: `0x14`); and it will _always_ end with a `87`, which is an `OP_EQUAL`. So all you have to do is put your hashed redeem script in between those numbers. -## Summary: Understanding the Foundation of P2SH +## Summary: Building the Structure of P2SH Actually creating the P2SH locking script dives further into the guts of Bitcoin than you've ever gone before. Though it's helpful to know how all of this works at a very low level, it's most likely that you'll have an API taking care of all of the heavy-lifting for you. Your task will simply be to create the Bitcoin Script to do the locking ... which is the main topic of chapters 9 and 11-12. From 5746b96ddb43f9288d4688b2174f9eb00434213a Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:24:07 -0300 Subject: [PATCH 02/11] Fix link and file name Link redirected to 404, and since 10_1 isn't about building, I'm assuming the correct one to link to is 10_2: Building the Structure of P2SH. --- 10_4_Scripting_a_Multisig.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_4_Scripting_a_Multisig.md b/10_4_Scripting_a_Multisig.md index 669a3a8..4f41026 100644 --- a/10_4_Scripting_a_Multisig.md +++ b/10_4_Scripting_a_Multisig.md @@ -22,7 +22,7 @@ The requirement for that `0` as the first operand for `OP_CHECKMULTISIG` is a co ## Create a Raw Multisig -As discussed in [§10.1: Building a Bitcoin Script with P2SH](10_1_Building_a_Bitcoin_Script_with_P2SH.md), multisigs are one of the standard Bitcoin transaction types. A transaction can be created with a locking script that uses the raw `OP_CHECKMULTISIG` command, and it will be accepted into a block. This is the classic methodology for using multisigs in Bitcoin. +As discussed in [§10.2: Building the Structure of P2SH](10_2_Building_the_Structure_of_P2SH.md), multisigs are one of the standard Bitcoin transaction types. A transaction can be created with a locking script that uses the raw `OP_CHECKMULTISIG` command, and it will be accepted into a block. This is the classic methodology for using multisigs in Bitcoin. As an example, we will revisit the multisig created in [§8.1](08_1_Sending_a_Transaction_to_a_Multisig.md) one final time and build a new locking script for it using this methodology. As you may recall, that was a 2-of-2 multisig built from `$address1` and `$address2`. From 523d3e6a120d7cf7bc442c987ebf6ae5a478e130 Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:29:33 -0300 Subject: [PATCH 03/11] Update chapter number and link --- 10_4_Scripting_a_Multisig.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_4_Scripting_a_Multisig.md b/10_4_Scripting_a_Multisig.md index 4f41026..d41aa67 100644 --- a/10_4_Scripting_a_Multisig.md +++ b/10_4_Scripting_a_Multisig.md @@ -30,7 +30,7 @@ As as `OP_CHECKMULTISIG` locking script requires the "m" (`2`), the addresses, a ``` 2 $address1 $address2 2 OP_CHECKMULTISIG ``` -If this looks familiar, that's because it's the multisig that you deserialized in [§8.2: Building the Structure of P2SH](08_2_Building_the_Structure_of_P2SH.md). +If this looks familiar, that's because it's the multisig that you deserialized in [§10.2: Building the Structure of P2SH](10_2_Building_the_Structure_of_P2SH.md). ``` 2 02da2f10746e9778dd57bd0276a4f84101c4e0a711f9cfd9f09cde55acbdd2d191 02bfde48be4aa8f4bf76c570e98a8d287f9be5638412ab38dede8e78df82f33fa3 2 OP_CHECKMULTISIG ``` From 604163a8b268178a1ab45779f42867eb2d73c64d Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:55:00 -0300 Subject: [PATCH 04/11] Update summary title for file's title --- 10_5_Scripting_a_Segwit_Script.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_5_Scripting_a_Segwit_Script.md b/10_5_Scripting_a_Segwit_Script.md index e9f3fb2..21e4cac 100644 --- a/10_5_Scripting_a_Segwit_Script.md +++ b/10_5_Scripting_a_Segwit_Script.md @@ -114,7 +114,7 @@ This works just like a P2WPKH address, the only difference being that instead of There is also one more variant, a P2WSH script embedded in a P2SH script, which works much like the P2SH-Segwit described above, but for nested P2WSH scripts. (Whew!) -## Summary: Scripting a Pay to Witness Public Key Hash +## Summary: Scripting a Segwit Script There are two sorts of P2SH scripts that relate to Segwit. From 392b66c0de2adfa18fac46aba473406882ab2562 Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 12:03:12 -0300 Subject: [PATCH 05/11] Update 6_2 title The 6_2 title is different from the file name, the former says "with" and the latter says "to" --- 10_6_Spending_a_P2SH_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_6_Spending_a_P2SH_Transaction.md b/10_6_Spending_a_P2SH_Transaction.md index 444bcb9..1a75de6 100644 --- a/10_6_Spending_a_P2SH_Transaction.md +++ b/10_6_Spending_a_P2SH_Transaction.md @@ -4,7 +4,7 @@ Before we close out this overview of P2SH transactions, we're going to touch upo ## Use the Redeem Script -As we saw in [§6.2: Spending a Transaction to a Multisig](06_2_Spending_a_Transaction_to_a_Multisig.md), spending a P2SH transaction is all about having that serialized version of the locking script, the so-called _redeemScript_. So, the first step in being able to spend a P2SH transaction is making sure that you save the _redeemScript_ before you give out the P2SH address to everyone. +As we saw in [§6.2: Spending a Transaction with a Multisig](06_2_Spending_a_Transaction_to_a_Multisig.md), spending a P2SH transaction is all about having that serialized version of the locking script, the so-called _redeemScript_. So, the first step in being able to spend a P2SH transaction is making sure that you save the _redeemScript_ before you give out the P2SH address to everyone. ### Collect Your Variables From 58a40b8559906f8335db96a32d0307bdf74bb54c Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 12:06:08 -0300 Subject: [PATCH 06/11] Update 6_3 title --- 10_6_Spending_a_P2SH_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_6_Spending_a_P2SH_Transaction.md b/10_6_Spending_a_P2SH_Transaction.md index 1a75de6..39d96c8 100644 --- a/10_6_Spending_a_P2SH_Transaction.md +++ b/10_6_Spending_a_P2SH_Transaction.md @@ -8,7 +8,7 @@ As we saw in [§6.2: Spending a Transaction with a Multisig](06_2_Spending_a_Tra ### Collect Your Variables -Because P2SH addresses other than the special multisig and nested Segwit addresses aren't integrated into `bitcoin-cli` there will be no short-cuts for P2SH spending like you saw in [§6.3: Sending an Automated Multisig](6_3_Sending_an_Automated_Multisig.md). You're going to need to collect all the more complex variables on your own! +Because P2SH addresses other than the special multisig and nested Segwit addresses aren't integrated into `bitcoin-cli` there will be no short-cuts for P2SH spending like you saw in [§6.3: Sending & Spending an Automated Multisig](6_3_Sending_an_Automated_Multisig.md). You're going to need to collect all the more complex variables on your own! This means that you need to collect: From ca406ce081e89d4980622c16dfbfb2eb86231b1b Mon Sep 17 00:00:00 2001 From: namcios <82450345+namcios@users.noreply.github.com> Date: Thu, 5 Aug 2021 12:08:31 -0300 Subject: [PATCH 07/11] Fix summary title --- 10_6_Spending_a_P2SH_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_6_Spending_a_P2SH_Transaction.md b/10_6_Spending_a_P2SH_Transaction.md index 39d96c8..b7722e9 100644 --- a/10_6_Spending_a_P2SH_Transaction.md +++ b/10_6_Spending_a_P2SH_Transaction.md @@ -33,7 +33,7 @@ $ bitcoin-cli -named signrawtransactionwithkey hexstring=$rawtxhex prevtxs='''[ ``` With any other sort of P2SH you're going to be including a different `redeemscript`, but otherwise the practice is exactly the same. The only difference is that after two chapters of work on Scripts you now understand what the `scriptPubKey` is and what the `redeemScript` is, so hopefully what were mysterious elements four chapters ago are now old hat. -## Summary: Spending a Transaction with a Bitcoin Script +## Summary: Spending a P2SH Transaction You already spent a P2SH back in Chapter 6, when you resent a multsig transaction the hard way, which required lining up the `scriptPubKey` and `redeemScript` information. Now you know that the `scriptPubKey` is a standardized P2SH locking script, while the `redeemScript` matches a hash in that locking script and that you need to be able to run it with the proper variables to receive a `True` result. But other than knowing more, there's nothing new in spending a P2SH transaction, because you already did it! From e5d6eec796e7bc3a7c53f2585363451cd14570c1 Mon Sep 17 00:00:00 2001 From: wodry Date: Fri, 6 Aug 2021 08:31:18 +0200 Subject: [PATCH 08/11] Fix typo in i2p service doc --- 15_1_i2p_service.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/15_1_i2p_service.md b/15_1_i2p_service.md index 33dacf5..76b2ac2 100644 --- a/15_1_i2p_service.md +++ b/15_1_i2p_service.md @@ -76,10 +76,10 @@ Follow the below steps to run Bitcoin Core i2p service: ## Summary: Bitcoin Core as an I2P (Invisible Internet Project) service -It is always good to have alternatives for privacy and not depend only on Tor to run Bitcoin Core as hidden service. Since i2p was recently added in Bitcoin Core, less people use it, experiment with it and report bugs if you find any issues. +It is always good to have alternatives for privacy and not depend only on Tor to run Bitcoin Core as hidden service. Since i2p was recently added in Bitcoin Core, not many people use it. Experiment with it and report bugs if you find any issues. > :information_source: **NOTE:** _i2pd_ (C++) is different from _i2prouter_ (Java), you will need `i2pd` for Bitcoin Core. Move on to "Programming with RPC" with [Chapter Sixteen: Talking to Bitcoind with C](16_0_Talking_to_Bitcoind.md). -Or, if you're not a programmer, you can skip to [Chapter Nineteen: Understanding Your Lightning Seutp](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/19_0_Understanding_Your_Lightning_Setup.md) to continue your command-line education with the Lightning Network. \ No newline at end of file +Or, if you're not a programmer, you can skip to [Chapter Nineteen: Understanding Your Lightning Seutp](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/19_0_Understanding_Your_Lightning_Setup.md) to continue your command-line education with the Lightning Network. From 89aa4ce0c4c48e755eab25ff549c27ac3a554e6a Mon Sep 17 00:00:00 2001 From: Cesar Alvarez Vallero Date: Fri, 6 Aug 2021 12:49:47 -0300 Subject: [PATCH 09/11] Correct type of transaction in table --- 09_5_Scripting_a_P2WPKH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_5_Scripting_a_P2WPKH.md b/09_5_Scripting_a_P2WPKH.md index 2afb181..fb3ced1 100644 --- a/09_5_Scripting_a_P2WPKH.md +++ b/09_5_Scripting_a_P2WPKH.md @@ -63,7 +63,7 @@ Here's a comparison of our two examples: | Type | PubKeyHash | PubKey | Signature | |----------------|----------|-------------|---------| | SegWit | 92a0db923b3a13eb576a40c4b35515aa30206cba | 03839e6035b33e37597908c83a2f992ec835b093d65790f43218cb49ffe5538903 | 3044022064f633ccfc4e937ef9e3edcaa9835ea9a98d31fbea1622c1d8a38d4e7f8f6cb602204bffef45a094de1306f99da055bd5a603a15c277a59a48f40a615aa4f7e5038001 | -| SegWit | 06b5c6ba5330cdf738a2ce91152bfd0e71f9ec39 | 0315a0aeb37634a71ede72d903acae4c6efa77f3423dcbcd6de3e13d9fd989438b | 04402201cc39005b076cb06534cd084fcc522e7bf937c4c9654c1c9dfba68b92cbab7d1022066f273178febc7a37568e2e9f4dec980a2e9a95441abe838c7ef64c39d85849c | +| non-SegWit | 06b5c6ba5330cdf738a2ce91152bfd0e71f9ec39 | 0315a0aeb37634a71ede72d903acae4c6efa77f3423dcbcd6de3e13d9fd989438b | 04402201cc39005b076cb06534cd084fcc522e7bf937c4c9654c1c9dfba68b92cbab7d1022066f273178febc7a37568e2e9f4dec980a2e9a95441abe838c7ef64c39d85849c | So how does this work? It depends on old code interpreting this as a valid transaction and new code knowing to check the new "witness" information From 4a6ce39532c97f04319daa149a320cc966b3becf Mon Sep 17 00:00:00 2001 From: Cesar Alvarez Vallero Date: Fri, 6 Aug 2021 21:45:22 -0300 Subject: [PATCH 10/11] Fix link to chapter 10.4 --- 10_1_Understanding_the_Foundation_of_P2SH.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/10_1_Understanding_the_Foundation_of_P2SH.md b/10_1_Understanding_the_Foundation_of_P2SH.md index ff76003..c37e33d 100644 --- a/10_1_Understanding_the_Foundation_of_P2SH.md +++ b/10_1_Understanding_the_Foundation_of_P2SH.md @@ -9,7 +9,7 @@ Here's the gotcha for using Bitcoin Scripts: for security reasons, most Bitcoin * __Pay to Public Key (P2PK)__ — An older, deprecated transaction (` OP_CHECKSIG`) that has been replaced by the better security of P2PKH. * __Pay to Public Key Hash (P2PKH)__ — A standard transaction (`OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG`) that pays to the hash of a public key. * __Pay to Witness Public Key hash (P2WPKH)__ — The newest sort of public-key transaction. It's just (`OP_0 Date: Fri, 6 Aug 2021 21:47:03 -0300 Subject: [PATCH 11/11] Fix typo --- 10_1_Understanding_the_Foundation_of_P2SH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/10_1_Understanding_the_Foundation_of_P2SH.md b/10_1_Understanding_the_Foundation_of_P2SH.md index c37e33d..d3b5c49 100644 --- a/10_1_Understanding_the_Foundation_of_P2SH.md +++ b/10_1_Understanding_the_Foundation_of_P2SH.md @@ -8,7 +8,7 @@ Here's the gotcha for using Bitcoin Scripts: for security reasons, most Bitcoin * __Pay to Public Key (P2PK)__ — An older, deprecated transaction (` OP_CHECKSIG`) that has been replaced by the better security of P2PKH. * __Pay to Public Key Hash (P2PKH)__ — A standard transaction (`OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG`) that pays to the hash of a public key. -* __Pay to Witness Public Key hash (P2WPKH)__ — The newest sort of public-key transaction. It's just (`OP_0 `) because it depends on miner consensus to work, as described in [§9.5](09_5_Scripting_a_P2WPKH.md). * __Multisig__ — A transaction for a group of keys, as explained more fully in [§10.4](10_4_Scripting_a_Multisig.md). * __Null Data__ — An unspendable transaction (`OP_RETURN Data`). * __Pay to Script Hash (P2SH)__ — A transaction that pays out to a specific script, as explained more fully here.