mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2026-02-16 14:12:48 +00:00
Made suggested corrections along with making an epub version of the entire course.
This commit is contained in:
parent
d51c46b2ea
commit
aa35b3dc87
@ -89,7 +89,7 @@ ELSE
|
||||
ENDIF
|
||||
|
||||
```
|
||||
Remember your reverse Polish notation! That `IF` statement if referring to the `OP_EQUAL` before it, not the `OP_CHECKSIG` after it!
|
||||
Remember your reverse Polish notation! That `IF` statement is referring to the `OP_EQUAL` before it, not the `OP_CHECKSIG` after it!
|
||||
|
||||
#### Run the True Branch
|
||||
|
||||
@ -136,7 +136,7 @@ Stack: [ True ]
|
||||
```
|
||||
#### Run the False Branch
|
||||
|
||||
Here's how it actally runs if unlocked with `<signatureB> <pubKeyB>`:
|
||||
Here's how it actually runs if unlocked with `<signatureB> <pubKeyB>`:
|
||||
```
|
||||
Script: <signatureB> <pubKeyB> OP_DUP OP_HASH160 <pubKeyHashA> OP_EQUAL IF OP_CHECKSIG ELSE OP_DUP OP_HASH160 <pubKeyHashB> OP_EQUALVERIFY OP_CHECKSIG ENDIF
|
||||
Stack: [ ]
|
||||
|
||||
@ -78,7 +78,7 @@ Also see: `OP_CODESEPARATOR` (0xab), `OP_CHECKSIGVERIFY` (0xad), and `OP_CHECKMU
|
||||
|
||||
## Summary: Using Other Script Commands
|
||||
|
||||
Bitcoin Script includes a wide array of arithemetic, stack, and cryptographic opcodes. Most of these additional opcodes are probably not as common as the ones discussed in previous sections, but nonetheless they're available if they're just what you need to write your Script!
|
||||
Bitcoin Script includes a wide array of arithmetic, stack, and cryptographic opcodes. Most of these additional opcodes are probably not as common as the ones discussed in previous sections, but nonetheless they're available if they're just what you need to write your Script!
|
||||
|
||||
## What's Next?
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Chapter 13: Designing Real Bitcoin Scripts
|
||||
|
||||
Our Bitcoin Scripts to date have been largely theoretical examples, because we've still been putting together the puzzle pieces. Now, with the full Bitcoin Script repetoire in hand, we're ready to dig into several real-world Bitcoin Scripts and see how they work.
|
||||
Our Bitcoin Scripts to date have been largely theoretical examples, because we've still been putting together the puzzle pieces. Now, with the full Bitcoin Script repertoire in hand, we're ready to dig into several real-world Bitcoin Scripts and see how they work.
|
||||
|
||||
## Objectives for This Chapter
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ See [Bitcoin Onion Nodes](https://github.com/emmanuelrosa/bitcoin-onion-nodes) f
|
||||
|
||||
Afterward, restart `tor` and `bitcoind`.
|
||||
|
||||
You should now be communicating exlusively on Tor. But, unless you are in a hostile state, this level of anonymity is probably not required. It also is not particularly recommended: you might greatly decrease your number of potential peers, inviting problems of censorship or even correlation. You may also see lag. And, this setup may give you a false sense of anonymity that really doesn't exist on the Bitcoin network.
|
||||
You should now be communicating exclusively on Tor. But, unless you are in a hostile state, this level of anonymity is probably not required. It also is not particularly recommended: you might greatly decrease your number of potential peers, inviting problems of censorship or even correlation. You may also see lag. And, this setup may give you a false sense of anonymity that really doesn't exist on the Bitcoin network.
|
||||
|
||||
> :warning: **WARNING:** This setup is untested! Use at your own risk!
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ The creator role is tasked with creating a PSBT with at least one input.
|
||||
A PSBT is created with a simple use of `wally_psbt_init_alloc`, telling it how many inputs and outputs you will eventually add:
|
||||
```
|
||||
struct wally_psbt *psbt;
|
||||
lw_response = wally_psbt_init_alloc(0,1,1,0,&psbt);
|
||||
lw_response = wally_psbt_init_alloc(0,1,1,0,0,&psbt);
|
||||
```
|
||||
But what you have is not yet a legal PSBT, because of the lack of inputs. You can create those by creating a transaction and setting it as the global transaction in the PSBT, which updates all the inputs and outputs:
|
||||
```
|
||||
|
||||
@ -41,7 +41,7 @@ a9 / 14 / 3f58b4f7b14847a9083694b9b3b52a4cea2569ed / 87
|
||||
```
|
||||
That's our old friend `OP_HASH160 3f58b4f7b14847a9083694b9b3b52a4cea2569ed OP_EQUAL`.
|
||||
|
||||
Basically, Libwally took your serialized redeem script, hashed it for you with SHA-256 and RIPEMD-160, and the applied the standard framing to turn it into a proper P2SH; You did similar work in [§10.2](10_2_Building_the_Structure_of_P2SH.md), but with an excess of shell commands.
|
||||
Basically, Libwally took your serialized redeem script, hashed it for you with SHA-256 and RIPEMD-160, and then applied the standard framing to turn it into a proper P2SH; You did similar work in [§10.2](10_2_Building_the_Structure_of_P2SH.md), but with an excess of shell commands.
|
||||
|
||||
In fact, you can double-check your work using the same commands from §10.2:
|
||||
```
|
||||
|
||||
@ -316,7 +316,6 @@ $ bitcoin-cli getaddressesbylabel "LibwallyWO"
|
||||
"purpose": "receive"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Summary: Integrating Libwally and Bitcoin-CLI
|
||||
|
||||
@ -242,7 +242,7 @@ tb1qutkcj34pw0aq7n9wgp3ktmz780szlycwddfmza
|
||||
|
||||
### Decode an Address
|
||||
|
||||
Creating an address took a look extra work, in specifying the appropiate chain. Using an address also will because you'll have to decode it prior to use.
|
||||
Creating an address took a little extra work, in specifying the appropriate chain. Using an address also will because you'll have to decode it prior to use.
|
||||
|
||||
The means that you'll have to import both the ```"github.com/btcsuite/btcutil"``` and ```"github.com/btcsuite/btcd/chaincfg"``` libraries.
|
||||
* ```btcutil``` allows for a Bitcoin address to be decoded in a way that the`rpcclient` can understand. This is necessary when working with addresses in `rpcclient`.
|
||||
|
||||
@ -85,7 +85,7 @@ Obviously, your `user` and `pass` should again match what's in your `~/.bitcoin/
|
||||
|
||||
Using BCRPC, you can use the same RPC commands you would usually use via ```bitcoin-cli``` with your `RpcAgent`, except they need to be in camelCase. For example, ```getblockhash``` would be ```getBlockHash``` instead.
|
||||
|
||||
To print the newest block number, you just call `getBlockCount` thourgh your `RpcAgent`:
|
||||
To print the newest block number, you just call `getBlockCount` through your `RpcAgent`:
|
||||
|
||||
```
|
||||
agent.getBlockCount(function (err, blockCount) {
|
||||
|
||||
@ -41,7 +41,7 @@ import logging
|
||||
```
|
||||
`pprint` will pretty print the `json` response from `bitcoind`.
|
||||
|
||||
`logging` will print out the call you make to `bitcoind` and `bitcoind`'s respose, which is useful when you make a bunch of calls together. If you don't want the excessive output in the terminal just comment out the `logging` block.
|
||||
`logging` will print out the call you make to `bitcoind` and `bitcoind`'s response, which is useful when you make a bunch of calls together. If you don't want the excessive output in the terminal just comment out the `logging` block.
|
||||
|
||||
## Build Your Connection
|
||||
|
||||
@ -357,7 +357,7 @@ There are five steps:
|
||||
|
||||
### 1. Select UTXO & Set Transaction Details
|
||||
|
||||
In the folowing code snippet you first select the UTXO which we want to spend. Then you get its address, transaction id, and the vector index of the output.
|
||||
In the following code snippet you first select the UTXO which we want to spend. Then you get its address, transaction id, and the vector index of the output.
|
||||
|
||||
```py
|
||||
utxos = rpc_client.listunspent()
|
||||
|
||||
@ -56,7 +56,7 @@ rpcpassword=ebVCeSyyM0LurvgQyi0exWTqm4oU0rZU
|
||||
```
|
||||
## Build Your Connection by Hand
|
||||
|
||||
At the time of this writing, there isn't an up-to-date, simple-to-use Bitcoin RPC Library that's specific for Swift, something that you can drop in and immediately start using. Thus, you're're going to do something you're never done before: build an RPC connection by hand.
|
||||
At the time of this writing, there isn't an up-to-date, simple-to-use Bitcoin RPC Library that's specific for Swift, something that you can drop in and immediately start using. Thus, you're going to do something you're never done before: build an RPC connection by hand.
|
||||
|
||||
### Write the RPC Transmitter
|
||||
|
||||
|
||||
BIN
Bitcoin_Command_line.epub
Normal file
BIN
Bitcoin_Command_line.epub
Normal file
Binary file not shown.
@ -11,7 +11,7 @@ int main(void) {
|
||||
|
||||
char *psbt_64;
|
||||
|
||||
lw_response = wally_psbt_init_alloc(0,1,1,0,&psbt);
|
||||
lw_response = wally_psbt_init_alloc(0,1,1,0,0,&psbt);
|
||||
|
||||
if (lw_response) {
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
struct wally_psbt *psbt;
|
||||
|
||||
lw_response = wally_psbt_from_base64(psbt_64,&psbt);
|
||||
lw_response = wally_psbt_from_base64(psbt_64,WALLY_PSBT_PARSE_FLAG_STRICT,&psbt);
|
||||
|
||||
if (lw_response) {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user