From 3e5703907e921803f04a6b2ca8230cca0895041b Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:11:51 +1000 Subject: [PATCH 01/20] Use 'whom' instead of 'who' --- 07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md index 6134ff2..d08f350 100644 --- a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md @@ -8,7 +8,7 @@ Partially Signed Bitcoin Transactions (PSBTs) are the newest way to vary the cre ## Understand How PSBTs Work -Multisignatures were great for the very specific case of jointly holding funds and setting rules for who among the joint signers could authenticate the use of those funds. There are many use cases, such as: a spousal joint bank account (a 1-of-2 signature); a fiduciary requirement for dual control (a 2-of-2 signature); and an escrow (a 2-of-3 signature). +Multisignatures were great for the very specific case of jointly holding funds and setting rules for whom among the joint signers could authenticate the use of those funds. There are many use cases, such as: a spousal joint bank account (a 1-of-2 signature); a fiduciary requirement for dual control (a 2-of-2 signature); and an escrow (a 2-of-3 signature). > :book: ***What is a PSBT?*** As the name suggests, a PSBT is a transaction that has not been fully signed. That's important, because once a transaction is signed, its content is locked in. [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) defined an abstracted methodology for putting PSBTs together that describes and standardizes roles in their collaborative creation. A *Creator* proposes a transaction; one or more *Updaters* supplement it; and one or more *Signers* authenticate it; before a *Finalizer* completes it; and an *Extracter* turn it into a transaction for the Bitcoin network. There may also be a *Combiner* who merges parallel PSBTs from different users. From 422d59807a3a09d32a3ac440b9d54c2f2a37151d Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:14:42 +1000 Subject: [PATCH 02/20] Pluralise 'turn' --- 07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md index d08f350..a88d185 100644 --- a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md @@ -10,7 +10,7 @@ Partially Signed Bitcoin Transactions (PSBTs) are the newest way to vary the cre Multisignatures were great for the very specific case of jointly holding funds and setting rules for whom among the joint signers could authenticate the use of those funds. There are many use cases, such as: a spousal joint bank account (a 1-of-2 signature); a fiduciary requirement for dual control (a 2-of-2 signature); and an escrow (a 2-of-3 signature). -> :book: ***What is a PSBT?*** As the name suggests, a PSBT is a transaction that has not been fully signed. That's important, because once a transaction is signed, its content is locked in. [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) defined an abstracted methodology for putting PSBTs together that describes and standardizes roles in their collaborative creation. A *Creator* proposes a transaction; one or more *Updaters* supplement it; and one or more *Signers* authenticate it; before a *Finalizer* completes it; and an *Extracter* turn it into a transaction for the Bitcoin network. There may also be a *Combiner* who merges parallel PSBTs from different users. +> :book: ***What is a PSBT?*** As the name suggests, a PSBT is a transaction that has not been fully signed. That's important, because once a transaction is signed, its content is locked in. [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) defined an abstracted methodology for putting PSBTs together that describes and standardizes roles in their collaborative creation. A *Creator* proposes a transaction; one or more *Updaters* supplement it; and one or more *Signers* authenticate it; before a *Finalizer* completes it; and an *Extracter* turns it into a transaction for the Bitcoin network. There may also be a *Combiner* who merges parallel PSBTs from different users. PSBTs may initially look sort of the same as multi-sigs because they have a single overlapping bit of functionality: the ability to jointly sign a transaction. However, they were created for a totally different use case. PSBTs recognize the need for multiple programs to jointly create a transaction for a number of different reasons, and they provide a regularized format for doing so. They're especially useful for use cases involving hardware wallets (for which, see [§7.3](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/07_3_Integrating_with_Hardware_Wallets.md)), which are protected from full access to the internet and tend to have minimal transaction history. From 3137bc2ffe24b9557724f831b4a1021e5333f1e0 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:16:23 +1000 Subject: [PATCH 03/20] Use 'optionally' instead of 'optional' --- 07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md index a88d185..b3c345e 100644 --- a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md @@ -19,7 +19,7 @@ In general, PSBTs provide a number of functional elements that improve this use 1. They provide a _standard_ for collaboratively creating transactions, whereas previous methodologies (including the multi-sig one from the previous chapter) were implementation dependent. 2. They support a _wider variety of use cases_, including simple joint funding. 3. They support _hardware wallets_ and other cases where a node may not have full transaction history. -4. They optional allow for the combination of _non-serialized transactions_, not requiring an ever-bigger hex code to be passed from user to user. +4. They optionally allow for the combination of _non-serialized transactions_, not requiring an ever-bigger hex code to be passed from user to user. PSBTs do their work by supplementing normal transaction information with a set of inputs and outputs, each of which defines everything you need to know about those UTXOs, so that even an airgapped wallet can make an informed decision about signatures. Thus, an input lists out the amount of money in a UTXO and what needs to be done to spend it, while an output does the same for the UTXOs it's creating. From ddbd6e890904fe9ef636c3d736f301700f0d6545 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:18:11 +1000 Subject: [PATCH 04/20] Add missing 'a' --- 07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md index b3c345e..6395138 100644 --- a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md @@ -28,7 +28,7 @@ This first section will outline the standard PSBT process of: Creator, Updater, ## Create a PSBT the Old-Fashioned Way #### PSBT Role: Creator -The easiest way to create a PSBT is to take an existing transaction and use `converttopsbt` to turn it into a PSBT. This is certainly not the _best_ way since it requires you to make a transaction for one format (a raw transaction) then convert it to another (PSBT), but if you've got old software that can only generate raw transaction, you may need to use it. +The easiest way to create a PSBT is to take an existing transaction and use `converttopsbt` to turn it into a PSBT. This is certainly not the _best_ way since it requires you to make a transaction for one format (a raw transaction) then convert it to another (PSBT), but if you've got old software that can only generate a raw transaction, you may need to use it. You just create your raw transaction normally: From 488a3e915cf029f22edcedac959c02cccdbda5ba Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:31:04 +1000 Subject: [PATCH 05/20] Use 'doesn't build' instead of 'doesn't built' --- 07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md b/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md index 1f2d100..3dbd09c 100644 --- a/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md @@ -425,7 +425,7 @@ Second, it's a lot more scalable. Consider a 3-of-5 multisig. Under the old meth Multisigs like the one used in the previous example are often used to receive payments for collaborative work, whether it be royalties for a book or payments made to a company. In that situation, the above example works great: the two participants receive their money which they then split up. But what about the converse case, where two (or more) participants want to set up a joint venture, and they need to seed it with money? -The traditional answer is to create a multisig, then to have the participants individually send their funds to it. The problem is that the first payer has to depend on the good faith of the second, and that doesn't built on the strength of Bitcoin, which is its _trustlessness_. Fortunately, with the advent of PSBTs, we can now make trustless payments that pool funds. +The traditional answer is to create a multisig, then to have the participants individually send their funds to it. The problem is that the first payer has to depend on the good faith of the second, and that doesn't build on the strength of Bitcoin, which is its _trustlessness_. Fortunately, with the advent of PSBTs, we can now make trustless payments that pool funds. > :book: ***What does trustless mean?*** Trustless means that no participant has to trust any other participant. They instead expect the software protocols to ensure that everything is enacted fairly in an expected manner. Bitcoin is a trustless protocol because you don't need anyone else to act in good faith; the system manages it. Similarly, PSBTs allow for the trustless creation of transactions that pool or split funds. From 224c0a7e42f74ab22610a12053817d84060e7b5a Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:41:08 +1000 Subject: [PATCH 06/20] Fix multiple typos in sentence - Add a missing 'a' - Fix spelling of 'maintaining' --- 07_3_Integrating_with_Hardware_Wallets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_3_Integrating_with_Hardware_Wallets.md b/07_3_Integrating_with_Hardware_Wallets.md index 09a7625..4a5d77a 100644 --- a/07_3_Integrating_with_Hardware_Wallets.md +++ b/07_3_Integrating_with_Hardware_Wallets.md @@ -4,7 +4,7 @@ One of the greatest powers of PSBTs is the ability to hand transactions off to hardware wallets. This will be a great development tool for you if you continue to program with Bitcoin. However, you can't test it out now if you're using one of the configurations we suggest for this course — a VM on Linode per [§2.1](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md) or an even more farflung option such an AWS per [§2.2](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/02_2_Setting_Up_Bitcoin_Core_Other.md) — because obviously you won't have any way to hook a hardware wallet up to your remote, virtual machine. -> :book: ***What is a Hardware Wallet?*** A hardware wallet is an electronic device that improves the security of cryptocurrency by maintaing all the private keys on the device, rather than ever putting them on a computer directly connected to the internet. Hardware wallets have specific protocols for providing online interactions, usually managed by a program talking to the device through a USB port. In this chapter, we'll be managing a hardware wallet with `bitcoin-cli` and the `hwy.py` program. +> :book: ***What is a Hardware Wallet?*** A hardware wallet is an electronic device that improves the security of a cryptocurrency by maintaining all the private keys on the device, rather than ever putting them on a computer directly connected to the internet. Hardware wallets have specific protocols for providing online interactions, usually managed by a program talking to the device through a USB port. In this chapter, we'll be managing a hardware wallet with `bitcoin-cli` and the `hwy.py` program. You have three options for moving through this chapter on hardware wallets: (1) read along without testing the code; (2) install Bitcoin on a local machine to fully test these commands; or (3) skip straight ahead to [Chapter 8: Expanding Bitcoin Transactions in Other Ways](08_0_Expanding_Bitcoin_Transactions_Other.md). We suggest option #1, but if you really want to get your hands dirty we'll also give some support for #2 by talking about using a Macintosh (a hardware-platform supported by [Bitcoin Standup](https://github.com/BlockchainCommons/Bitcoin-Standup)) for testing. From facc43f1e0e2175ab60a1bb3305555c5463c3d38 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:43:33 +1000 Subject: [PATCH 07/20] Use 'progress' instead of 'process' I believe the sentence should read '... while it is in progress ...' not '... while it is in process ...' --- 07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md | 2 +- 07_3_Integrating_with_Hardware_Wallets.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md index 6395138..434ae9a 100644 --- a/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md @@ -4,7 +4,7 @@ Partially Signed Bitcoin Transactions (PSBTs) are the newest way to vary the creation of basic Bitcoin transactions. They do so by introducing collaboration into every step of the process, allowing people (or programs) to not just authenticate transactions together (as with multisigs), but also to easily create, fund, and broadcast collaboratively. -> :warning: **VERSION WARNING:** This is an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in process (though they will still be able to recognize the final transaction). Some updates and upgrades for PSBTs have continued through 0.20.0. +> :warning: **VERSION WARNING:** This is an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in progress (though they will still be able to recognize the final transaction). Some updates and upgrades for PSBTs have continued through 0.20.0. ## Understand How PSBTs Work diff --git a/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md b/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md index 3dbd09c..579817d 100644 --- a/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md +++ b/07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md @@ -6,7 +6,7 @@ Now that you've learned the basic workflow of generating a PSBT, you probably wa Following are three examples of using PSBTs for: multi-sigs, pooling money, and joining coins. -> :warning: **VERSION WARNING:** This is an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in process (though they will still be able to recognize the final transaction). +> :warning: **VERSION WARNING:** This is an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in progress (though they will still be able to recognize the final transaction). ## Use a PSBT to Spend MultiSig Funds diff --git a/07_3_Integrating_with_Hardware_Wallets.md b/07_3_Integrating_with_Hardware_Wallets.md index 4a5d77a..99ec288 100644 --- a/07_3_Integrating_with_Hardware_Wallets.md +++ b/07_3_Integrating_with_Hardware_Wallets.md @@ -8,7 +8,7 @@ One of the greatest powers of PSBTs is the ability to hand transactions off to h You have three options for moving through this chapter on hardware wallets: (1) read along without testing the code; (2) install Bitcoin on a local machine to fully test these commands; or (3) skip straight ahead to [Chapter 8: Expanding Bitcoin Transactions in Other Ways](08_0_Expanding_Bitcoin_Transactions_Other.md). We suggest option #1, but if you really want to get your hands dirty we'll also give some support for #2 by talking about using a Macintosh (a hardware-platform supported by [Bitcoin Standup](https://github.com/BlockchainCommons/Bitcoin-Standup)) for testing. -> :warning: **VERSION WARNING:** PSBTs are an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in process (though they will still be able to recognize the final transaction). The HWI interface appeared in Bitcoin Core v 0.18.0, but as long as you are using our suggested setup with Bitcoin Standup, it should work. +> :warning: **VERSION WARNING:** PSBTs are an innovation from Bitcoin Core v 0.17.0. Earlier versions of Bitcoin Core will not be able to work with the PSBT while it is in progress (though they will still be able to recognize the final transaction). The HWI interface appeared in Bitcoin Core v 0.18.0, but as long as you are using our suggested setup with Bitcoin Standup, it should work. The methodology described in this chapter for integrating with a hardware wallet depends on the [Bitcoin Hardware Wallet Interface](https://github.com/bitcoin-core/HWI) released through Bitcoin Core and builds on the [installation](https://github.com/bitcoin-core/HWI/blob/master/README.md) and [usage](https://github.com/bitcoin-core/HWI/blob/master/docs/bitcoin-core-usage.md) instructions found there. From 5575f96c00c9a825745b3e223f24b611fdb7769b Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:45:55 +1000 Subject: [PATCH 08/20] Fix spelling of 'unintuitive' --- 07_3_Integrating_with_Hardware_Wallets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_3_Integrating_with_Hardware_Wallets.md b/07_3_Integrating_with_Hardware_Wallets.md index 99ec288..3167e98 100644 --- a/07_3_Integrating_with_Hardware_Wallets.md +++ b/07_3_Integrating_with_Hardware_Wallets.md @@ -12,7 +12,7 @@ You have three options for moving through this chapter on hardware wallets: (1) The methodology described in this chapter for integrating with a hardware wallet depends on the [Bitcoin Hardware Wallet Interface](https://github.com/bitcoin-core/HWI) released through Bitcoin Core and builds on the [installation](https://github.com/bitcoin-core/HWI/blob/master/README.md) and [usage](https://github.com/bitcoin-core/HWI/blob/master/docs/bitcoin-core-usage.md) instructions found there. -> :warning: **FRESHNESS WARNING:** The HWI interface is very new and raw around the edges as of Bitcoin Core v 0.20.0. It may be hard to install correctly, and it may have unintuive errors. What follows is a description of a working setup, but it took several tries to get it right, and your setup may vary. +> :warning: **FRESHNESS WARNING:** The HWI interface is very new and raw around the edges as of Bitcoin Core v 0.20.0. It may be hard to install correctly, and it may have unintuitive errors. What follows is a description of a working setup, but it took several tries to get it right, and your setup may vary. ## Install Bitcoin Core on a Local Machine From a5f978cb782473a0570624f90f5e627305b83b96 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:47:09 +1000 Subject: [PATCH 09/20] Use 'Linux' instead of 'UNIX' OsX is UNIX, I think this is meant to read 'Linux' not 'UNIX'. --- 07_3_Integrating_with_Hardware_Wallets.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/07_3_Integrating_with_Hardware_Wallets.md b/07_3_Integrating_with_Hardware_Wallets.md index 3167e98..3cf7b92 100644 --- a/07_3_Integrating_with_Hardware_Wallets.md +++ b/07_3_Integrating_with_Hardware_Wallets.md @@ -16,13 +16,13 @@ The methodology described in this chapter for integrating with a hardware wallet ## Install Bitcoin Core on a Local Machine -_If you just plan to read over this section and not test out these commands until some future date when you have a local development environment, you can skip this subsection, which is about creating a Bitcoin Core installation on a local machine such as a Mac or UNIX machine._ +_If you just plan to read over this section and not test out these commands until some future date when you have a local development environment, you can skip this subsection, which is about creating a Bitcoin Core installation on a local machine such as a Mac or Linux machine._ -There are alternate versions of the Bitcoin Standup script that you used to create your VM that will install on a MacOS or on a non-Linode UNIX machine. +There are alternate versions of the Bitcoin Standup script that you used to create your VM that will install on a MacOS or on a non-Linode Linux machine. If you have MacOS, you can install [Bitcoin Standup MacOS](https://github.com/BlockchainCommons/Bitcoin-Standup-MacOS/blob/master/README.md). -If you have a local UNIX machine, you can install [Bitcoin Standup Linux Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-MacOS/blob/master/README.md). +If you have a local Linux machine, you can install [Bitcoin Standup Linux Scripts](https://github.com/BlockchainCommons/Bitcoin-Standup-MacOS/blob/master/README.md). Once you've gotten Bitcoin Standup running on your local machine, you'll want to sync the "Testnet" blockchain, assuming that you're continuing to follow the standard methodlogy of this course. From e733798af805db52157a261bbe08b1223dddebf4 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Jun 2021 18:54:26 +1000 Subject: [PATCH 10/20] Fix typo 'addresse' -> 'addresses' --- 07_3_Integrating_with_Hardware_Wallets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07_3_Integrating_with_Hardware_Wallets.md b/07_3_Integrating_with_Hardware_Wallets.md index 3cf7b92..5426a2a 100644 --- a/07_3_Integrating_with_Hardware_Wallets.md +++ b/07_3_Integrating_with_Hardware_Wallets.md @@ -190,7 +190,7 @@ $ bitcoin-cli -rpcwallet=ledger importmulti '[{"desc": "wpkh([9a1d520b/84h/1h/0h ``` (Note that HWI helpfully output the derivation path with `h`s to show hardened derivations rather than `'`s, and calculated its checksum accordingly, so that we don't have to do massive quoting like we did in §3.5.) -You _could_ now list all of the watch-only addresse that you received using the `getaddressesbylabel` command. All 1000 of the receive addresses are right there, in the `ledger` wallet! +You _could_ now list all of the watch-only addresses that you received using the `getaddressesbylabel` command. All 1000 of the receive addresses are right there, in the `ledger` wallet! ``` $ bitcoin-cli -rpcwallet=ledger getaddressesbylabel "" | more { From ced4a140577c2b74989f232646cf9052228c7d42 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 19:38:00 +1000 Subject: [PATCH 11/20] Fix two whitespace issues, add and remove --- 08_0_Expanding_Bitcoin_Transactions_Other.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08_0_Expanding_Bitcoin_Transactions_Other.md b/08_0_Expanding_Bitcoin_Transactions_Other.md index d6015d4..d10106f 100644 --- a/08_0_Expanding_Bitcoin_Transactions_Other.md +++ b/08_0_Expanding_Bitcoin_Transactions_Other.md @@ -1,6 +1,6 @@ # Chapter Eight: Expanding Bitcoin Transactions in Other Ways -The definition of basic transactions back in [Chapter Six](06_0_Expanding_Bitcoin_Transactions_Multisigs.md) said that they sent _funds_ _immediately_, but those are both elementsthat can be changed. This final section on Expanding Bitcoin Transactions talks about how to send things other than cash and how to do it at a time other than now. +The definition of basic transactions back in [Chapter Six](06_0_Expanding_Bitcoin_Transactions_Multisigs.md) said that they sent _funds_ _immediately_, but those are both elements that can be changed. This final section on Expanding Bitcoin Transactions talks about how to send things other than cash and how to do it at a time other than now. ## Objectives for This Section From 7c8a226ea5c7085e444a5a1d2ae9f6a1ae44a84b Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 19:48:00 +1000 Subject: [PATCH 12/20] Use 'transaction' instead of 'transition' --- 08_1_Sending_a_Transaction_with_a_Locktime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08_1_Sending_a_Transaction_with_a_Locktime.md b/08_1_Sending_a_Transaction_with_a_Locktime.md index a38ec9a..67a3646 100644 --- a/08_1_Sending_a_Transaction_with_a_Locktime.md +++ b/08_1_Sending_a_Transaction_with_a_Locktime.md @@ -128,7 +128,7 @@ Cancelling a locktime transaction is _very_ simple: you send a new transactions Locktime offers a way to create a transaction that _should_ not be relayable to the network and that _will_ not be accepted into a block until the appropriate time has arrived. In the meantime, it can be cancelled simply by reusing a UTXO. -> :fire: _What is the Power of Locktime?_ The power of locktime may not be immediately obvious because of the ability to cancel it so easily. However, it's another of the bases of Smart Contracts: it has a lot of utility in a variety of custodial or contractual applications. For example, consider a situation where a third party is holding your bitcoins. In order to guarantee the return of your bitcoins if the custodian ever disappeared, they could produce a timelock transition to return the coins to you, then update that every once in a while with a new one, further in the future. If they ever failed to update, then the coins would return to you when the current timelock expired. Locktime could similarly be applied to a payment network, where the network holds coins while they're being exchanged by network participants. Finally, a will offers an example of a more complex contract, where payments are sent out to a number of people. These payments would be built on locktime transactions, and would be continually updated as long as the owner continues to show signs of life. (The unifying factor of all of these applications is, of course, _trust_. Simple locktime transactions only work if the holder of the coins can be trusted to send them out under the appropriate conditions.) +> :fire: _What is the Power of Locktime?_ The power of locktime may not be immediately obvious because of the ability to cancel it so easily. However, it's another of the bases of Smart Contracts: it has a lot of utility in a variety of custodial or contractual applications. For example, consider a situation where a third party is holding your bitcoins. In order to guarantee the return of your bitcoins if the custodian ever disappeared, they could produce a timelock transaction to return the coins to you, then update that every once in a while with a new one, further in the future. If they ever failed to update, then the coins would return to you when the current timelock expired. Locktime could similarly be applied to a payment network, where the network holds coins while they're being exchanged by network participants. Finally, a will offers an example of a more complex contract, where payments are sent out to a number of people. These payments would be built on locktime transactions, and would be continually updated as long as the owner continues to show signs of life. (The unifying factor of all of these applications is, of course, _trust_. Simple locktime transactions only work if the holder of the coins can be trusted to send them out under the appropriate conditions.) ## What's Next? From f1bb218f43d56bb274aafb1ee34e6f508241a9d6 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 19:55:43 +1000 Subject: [PATCH 13/20] Fix spelling of 'demonstrating' --- 08_2_Sending_a_Transaction_with_Data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/08_2_Sending_a_Transaction_with_Data.md b/08_2_Sending_a_Transaction_with_Data.md index 6b35da7..83fbe46 100644 --- a/08_2_Sending_a_Transaction_with_Data.md +++ b/08_2_Sending_a_Transaction_with_Data.md @@ -114,7 +114,7 @@ You may note a warning about the data being in an "unknown protocol". If you wer You can use an `OP_RETURN` opcode to store up to 80 bytes of data on the blockchain. You do this with the `data` codeword for a `vout`. You still have to send money along too, but you just send it back to a change address, minus a transaction fee. -> :fire: _What is the Power of OP_RETURN?_ The OP_RETURN opens up whole new possibilities for the blockchain, because you can embed data that proves that certain things happened at certain times. Various organizations have used OP_RETURNs for proof of existence, for copyright, for colored coins, and [for other purposes](https://en.bitcoin.it/wiki/OP_RETURN). Though 80 bytes might not seem a lot, it can be quite effective if OP_RETURNs are used to store hashes of the actual data. Then, you can prove the existence of your digital data by deminstrating that the hash of it matches the hash on the blockchain. +> :fire: _What is the Power of OP_RETURN?_ The OP_RETURN opens up whole new possibilities for the blockchain, because you can embed data that proves that certain things happened at certain times. Various organizations have used OP_RETURNs for proof of existence, for copyright, for colored coins, and [for other purposes](https://en.bitcoin.it/wiki/OP_RETURN). Though 80 bytes might not seem a lot, it can be quite effective if OP_RETURNs are used to store hashes of the actual data. Then, you can prove the existence of your digital data by demonstrating that the hash of it matches the hash on the blockchain. Note that there is some controversy over using the Bitcoin blockchain in this way. From 11ccda91f01b98c30a603932ca3ec05a6b404ca8 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:21:45 +1000 Subject: [PATCH 14/20] Use 'section' instead of 'Part' --- 09_3_Testing_a_Bitcoin_Script.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_3_Testing_a_Bitcoin_Script.md b/09_3_Testing_a_Bitcoin_Script.md index 57ba116..84a22e3 100644 --- a/09_3_Testing_a_Bitcoin_Script.md +++ b/09_3_Testing_a_Bitcoin_Script.md @@ -2,7 +2,7 @@ Bitcoin Scripting allows for considerable additional control over Bitcoin transactions, but it's also somewhat dangerous. As we'll describe in [§10.1](10_1_Understanding_the_Foundation_of_P2SH.md), the actual Scripts are somewhat isolated from the Bitcoin network, which means that it's possible to write a script and have it accepted by the network even if it's impossible to redeem from that script! So, you need to thoroughly test your Scripts before you put your money into them. -This chapter thus describes a prime method for testing Bitcoin Scripts, which we'll also be using for occasional examples throughout the rest of this Part. +This chapter thus describes a prime method for testing Bitcoin Scripts, which we'll also be using for occasional examples throughout the rest of this section. ## Install btcdeb From 3b70f86c7965f197b4983b0fbf7e39523574a433 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:25:37 +1000 Subject: [PATCH 15/20] Use 'a 03' instead of 'an 03' --- 09_3_Testing_a_Bitcoin_Script.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_3_Testing_a_Bitcoin_Script.md b/09_3_Testing_a_Bitcoin_Script.md index 84a22e3..cd15774 100644 --- a/09_3_Testing_a_Bitcoin_Script.md +++ b/09_3_Testing_a_Bitcoin_Script.md @@ -96,7 +96,7 @@ script | stack --------+-------- | 03 ``` -And that's where our script ends, with nothing more to execute and an `03` sitting on top of our stack as the result of the Script. +And that's where our script ends, with nothing more to execute and a `03` sitting on top of our stack as the result of the Script. > :note: **NOTE:** `btcdeb` allows you to repeat the previous command by hitting enter. We will be doing this in subsequent examples, so don't be surprised about `btcdeb>` prompts with nothing as input. It is simply repeating the previous (often `step`) command. From 5a9ba9c59bfd779a06a57ee25bc8aaf309af3539 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:31:45 +1000 Subject: [PATCH 16/20] Use past tense 'disapeared' --- 09_3_Testing_a_Bitcoin_Script.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_3_Testing_a_Bitcoin_Script.md b/09_3_Testing_a_Bitcoin_Script.md index cd15774..b5bce3a 100644 --- a/09_3_Testing_a_Bitcoin_Script.md +++ b/09_3_Testing_a_Bitcoin_Script.md @@ -186,7 +186,7 @@ Using these commands can make it easier to see what's going on and where you are There are also a few web simulators that you can use to test scripts online. They can be superior to a command-line tool by offering a more graphical output, but we also find that they tend to have shortcomings. -In the past we've tried to give extensive guidelines on using sites such as the [Script Playground](http://www.crmarsh.com/script-playground/) or the [Bitcoin Online Script Debugger](https://bitcoin-script-debugger.visvirial.com/), but they become out of date and/or disappear too quickly to keep up with them. +In the past we've tried to give extensive guidelines on using sites such as the [Script Playground](http://www.crmarsh.com/script-playground/) or the [Bitcoin Online Script Debugger](https://bitcoin-script-debugger.visvirial.com/), but they become out of date and/or disappeared too quickly to keep up with them. Assume that these debuggers have the nice advantage of showing things visually and explicitly telling you whether a script succeeds (unlocks) or fails (stays locked). Assume that they have disadvantages with signatures, where many of them either always return `true` for signature tests or else have very cumbersome mechanisms for incorporating them. From dceb9b68cfbf27533636cb4a4821c70e599637e9 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:38:46 +1000 Subject: [PATCH 17/20] Use caps 'ALL' as in the scipt --- 09_4_Scripting_a_P2PKH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_4_Scripting_a_P2PKH.md b/09_4_Scripting_a_P2PKH.md index cc86fb9..5b677e5 100644 --- a/09_4_Scripting_a_P2PKH.md +++ b/09_4_Scripting_a_P2PKH.md @@ -45,7 +45,7 @@ $ bitcoin-cli -named decoderawtransaction hexstring=$signedtx ] } ``` -You can see that its `scriptSig` unlocking script has two values. That's a `` (and an `[all]`) and a ``: +You can see that its `scriptSig` unlocking script has two values. That's a `` (and an `[ALL]`) and a ``: ``` 304402201cc39005b076cb06534cd084fcc522e7bf937c4c9654c1c9dfba68b92cbab7d1022066f273178febc7a37568e2e9f4dec980a2e9a95441abe838c7ef64c39d85849c[ALL] 0315a0aeb37634a71ede72d903acae4c6efa77f3423dcbcd6de3e13d9fd989438b ``` From 0d1070fd8f35dbfec068fd57246548898c189363 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:47:42 +1000 Subject: [PATCH 18/20] Use 'through' instead of 'those' --- 09_4_Scripting_a_P2PKH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_4_Scripting_a_P2PKH.md b/09_4_Scripting_a_P2PKH.md index 5b677e5..2512eb3 100644 --- a/09_4_Scripting_a_P2PKH.md +++ b/09_4_Scripting_a_P2PKH.md @@ -346,7 +346,7 @@ error: Signature is found in scriptCode ``` (Unfortunately this checking may or may not be working at any point due to vagaries of the Bitcoin Core and `btcdeb` code.) -As is shown, a P2PKH is quite simple: its protection comes about those the strength of its cryptography. +As is shown, a P2PKH is quite simple: its protection comes about through the strength of its cryptography. ### How to Look Up a Pub Key & Signature by Hand From 80467579f97ca1b16325043d1ceb52f81bf6ae91 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:54:09 +1000 Subject: [PATCH 19/20] Capitialise 'SegWit' instead of 'Segwit' --- 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 a4ab991..2afb181 100644 --- a/09_5_Scripting_a_P2WPKH.md +++ b/09_5_Scripting_a_P2WPKH.md @@ -2,7 +2,7 @@ > :information_source: **NOTE:** This section has been recently added to the course and is an early draft that may still be awaiting review. Caveat reader. -P2PKHs are fine for explaining the fundamental way that Bitcoin Scripts work, but what about native Segwit P2WPKH scripts, which are increasingly becoming the majority of Bitcoin transactions? As it turns out, P2WPKH addresses don't use Bitcoin Scripts like traditional Bitcoin addresses do, and so this section is really a digression from the scripting of this chapter — but an important one, because it outlines the _other_ major way in which Bitcoins can be transacted. +P2PKHs are fine for explaining the fundamental way that Bitcoin Scripts work, but what about native SegWit P2WPKH scripts, which are increasingly becoming the majority of Bitcoin transactions? As it turns out, P2WPKH addresses don't use Bitcoin Scripts like traditional Bitcoin addresses do, and so this section is really a digression from the scripting of this chapter — but an important one, because it outlines the _other_ major way in which Bitcoins can be transacted. ## View a P2WPKH Script From 9df990412988f6ec099dd36e387e3fcfdc0a72ce Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 8 Jun 2021 20:28:40 +1000 Subject: [PATCH 20/20] Remove ':note:', it does not render in markdown --- 09_3_Testing_a_Bitcoin_Script.md | 2 +- 16_2_Using_BIP39_in_Libwally.md | 2 +- 16_5_Using_Scripts_in_Libwally.md | 2 +- 17_1_Accessing_Bitcoind_with_Go.md | 6 +++--- 17_5_Accessing_Bitcoind_with_Rust.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/09_3_Testing_a_Bitcoin_Script.md b/09_3_Testing_a_Bitcoin_Script.md index b5bce3a..29d9f92 100644 --- a/09_3_Testing_a_Bitcoin_Script.md +++ b/09_3_Testing_a_Bitcoin_Script.md @@ -98,7 +98,7 @@ script | stack ``` And that's where our script ends, with nothing more to execute and a `03` sitting on top of our stack as the result of the Script. -> :note: **NOTE:** `btcdeb` allows you to repeat the previous command by hitting enter. We will be doing this in subsequent examples, so don't be surprised about `btcdeb>` prompts with nothing as input. It is simply repeating the previous (often `step`) command. +> **NOTE:** `btcdeb` allows you to repeat the previous command by hitting enter. We will be doing this in subsequent examples, so don't be surprised about `btcdeb>` prompts with nothing as input. It is simply repeating the previous (often `step`) command. ### Use btcdeb for a Subtraction Example diff --git a/16_2_Using_BIP39_in_Libwally.md b/16_2_Using_BIP39_in_Libwally.md index 8f61253..16e90bc 100644 --- a/16_2_Using_BIP39_in_Libwally.md +++ b/16_2_Using_BIP39_in_Libwally.md @@ -49,7 +49,7 @@ This example, which will be the only way we use the `libsodium` library, creates ``` Note that you have to pass along the byte size, so if you were to increase the size of your entropy, to generate a longer mnemonic phrase, you'd also need to increase the value in this function. -> :note: **NOTE:** There are mnemonic word lists for different languages! The default is to use the English-language list, which is the `NULL` variable in these Libwally mnemonic commands, but you can alternatively request a different language! +> **NOTE:** There are mnemonic word lists for different languages! The default is to use the English-language list, which is the `NULL` variable in these Libwally mnemonic commands, but you can alternatively request a different language! That's it! You've created a mnemonic phrase! diff --git a/16_5_Using_Scripts_in_Libwally.md b/16_5_Using_Scripts_in_Libwally.md index 09c5453..ec0a791 100644 --- a/16_5_Using_Scripts_in_Libwally.md +++ b/16_5_Using_Scripts_in_Libwally.md @@ -98,7 +98,7 @@ As you might expect, you then add that input to your transaction: lw_response = wally_tx_add_input(tx,tx_input); ``` -> :note: **NOTE** Obviously, you'll want to be able to create your own inputs if you're using Libwally for real applications, but this is intended as a first step. And, it can actually be useful for integrating with `bitcoin-cli`, as we'll see in [§16.7](16_7_Integrating_Libwally_and_Bitcoin-CLI.md). +> **NOTE** Obviously, you'll want to be able to create your own inputs if you're using Libwally for real applications, but this is intended as a first step. And, it can actually be useful for integrating with `bitcoin-cli`, as we'll see in [§16.7](16_7_Integrating_Libwally_and_Bitcoin-CLI.md). ### Print a Transaction diff --git a/17_1_Accessing_Bitcoind_with_Go.md b/17_1_Accessing_Bitcoind_with_Go.md index 5ea6038..6b60be6 100644 --- a/17_1_Accessing_Bitcoind_with_Go.md +++ b/17_1_Accessing_Bitcoind_with_Go.md @@ -126,7 +126,7 @@ Every `bitcoind` function in Go begins with creating the RPC connection, using t ``` The ```connCfg``` parameters allow you to choose the Bitcoin RPC port, username, password and whether you are on testnet or mainnet. -> :note: **NOTE:** Again, be sure to substitute the `User` and `Pass` with the one found in your `~/.bitcoin/bitcon.conf`. +> **NOTE:** Again, be sure to substitute the `User` and `Pass` with the one found in your `~/.bitcoin/bitcon.conf`. The```rpcclient.New(connCfg, nil)``` function then configures ```client``` to connect to your Bitcoin node. @@ -268,7 +268,7 @@ The defaultNet variable is now used to specify whether your Bitcoin node is on t } ``` -> :note: **NOTE:** Change the address (`mpGpCMX6SuUimDZKiVViuhd7EGyVxkNnha`) for one actually your wallet; you can use `bitcoin-cli listunspent` to find some addresses with funds for this test. If you want to be really fancy, modify the Go code to take an argument, then write a script that runs `listunspent`, saves the info to a variable, and runs the Go code on that. +> **NOTE:** Change the address (`mpGpCMX6SuUimDZKiVViuhd7EGyVxkNnha`) for one actually your wallet; you can use `bitcoin-cli listunspent` to find some addresses with funds for this test. If you want to be really fancy, modify the Go code to take an argument, then write a script that runs `listunspent`, saves the info to a variable, and runs the Go code on that. Only afterward do you use the `getreceivedbyaddress` RPC, on your decoded address: ``` @@ -378,7 +378,7 @@ func main() { fmt.Println(transactions) } ``` -> :note: **NOTE:** Again, you'll want to change out the txid for one actually recognized by your system. +> **NOTE:** Again, you'll want to change out the txid for one actually recognized by your system. When you run [the code](17_1_lookuptransaction.go) it will print out the details associated with a transaction, such as its amount and how many times it has been confirmed: diff --git a/17_5_Accessing_Bitcoind_with_Rust.md b/17_5_Accessing_Bitcoind_with_Rust.md index d2f9d27..a6ea9fc 100644 --- a/17_5_Accessing_Bitcoind_with_Rust.md +++ b/17_5_Accessing_Bitcoind_with_Rust.md @@ -131,7 +131,7 @@ Here's the complete code to retrieve a block hash, turn that into a block, and p println!("{:?}", block); ``` -> :note: **NOTE:** Another possible call that we considered for this section was `get_address_info`, but unfortunately as of this writing, the `bitcoincore-rpc` function doesn't work with recent versions of Bitcoin Core due to the crate not addressing the latest API changes in Bitcoin Core. We expect this will be solved in the next crate's release, but in the meantime, _caveat programmer_. +> **NOTE:** Another possible call that we considered for this section was `get_address_info`, but unfortunately as of this writing, the `bitcoincore-rpc` function doesn't work with recent versions of Bitcoin Core due to the crate not addressing the latest API changes in Bitcoin Core. We expect this will be solved in the next crate's release, but in the meantime, _caveat programmer_. ### Run Your Code