Skip to content

Commit 6e35f09

Browse files
authored
Merge pull request #435 from namcios/patch-1
Update src/ files and their references
2 parents bb370fa + 1a5e569 commit 6e35f09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+42
-42
lines changed

16_1_Accessing_Bitcoind_with_C.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ bitcoinrpc_global_cleanup();
147147

148148
### Test the Test Code
149149

150-
Test code can be found at [15_1_testbitcoin.c in the src directory](src/15_1_testbitcoin.c). Download it to your testnet machine, then insert the correct RPC password (and change the RPC user if you didn't create your server with StandUp).
150+
Test code can be found at [16_1_testbitcoin.c in the src directory](src/16_1_testbitcoin.c). Download it to your testnet machine, then insert the correct RPC password (and change the RPC user if you didn't create your server with StandUp).
151151

152152
You can compile and run this as follows:
153153
```
@@ -213,7 +213,7 @@ printf("Block Count: %d\n",blocks);
213213
214214
### Test the Info Code
215215

216-
Retrieve the test code from [the src directory](src/15_1_getmininginfo.c).
216+
Retrieve the test code from [the src directory](src/16_1_getmininginfo.c).
217217
```
218218
$ cc getmininginfo.c -lbitcoinrpc -ljansson -o getmininginfo
219219
$ ./getmininginfo

16_2_Programming_Bitcoind_with_C.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> :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.
44
5-
[§15.1](15_1_Accessing_Bitcoind_with_C.md) laid out the methodology for creating C programs using RPC and JSON libraries. We're now going to show the potential of those C libraries by laying out a simplistic, first cut of an actual Bitcoin program.
5+
[§16.1](16_1_Accessing_Bitcoind_with_C.md) laid out the methodology for creating C programs using RPC and JSON libraries. We're now going to show the potential of those C libraries by laying out a simplistic, first cut of an actual Bitcoin program.
66

77
## Plan for Your Code
88

@@ -324,7 +324,7 @@ The entire code, with a _little_ more error-checking appears in the Appendix.
324324

325325
## Test Your Code
326326

327-
The complete code can be found in the [src directory](src/15_2_sendtoaddress.c).
327+
The complete code can be found in the [src directory](src/16_2_sendtoaddress.c).
328328

329329
Compile this as usual:
330330
```

16_3_Receiving_Bitcoind_Notifications_with_C.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Of course when you're done, you should clean up:
121121

122122
### Test the Notification Code
123123

124-
The source code is in the [src directory](src/15_3_chainlistener.c) as usual. You should compile it:
124+
The source code is in the [src directory](src/16_3_chainlistener.c) as usual. You should compile it:
125125
```
126126
$ cc -o chainlistener chainlistener.c -I/usr/local/include -L/usr/local/lib -lzmq -lczmq
127127
```

17_1_Setting_Up_Libwally.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ In both cases, the argument is for flags, but is currently set to `0`.
129129

130130
## Test a Test Libwally Program
131131

132-
The src directory contains [testwally.c](src/16_1_testwally.c), which just shows how the initialize and cleanup functions work.
132+
The src directory contains [testwally.c](src/17_1_testwally.c), which just shows how the initialize and cleanup functions work.
133133

134134
You can compile it as follows:
135135
```

17_2_Using_BIP39_in_Libwally.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All Bitcoin keys start with entropy. This first use of Libwally, and its BIP39 m
1414

1515
> :book: ***What is Entropy?*** Entropy is a fancy way of saying randomness, but it's a carefully measured randomness that's used as the foundation of a true-random-number generated (TRG). Its measured in "bits", with more bits of entropy resulting in more randomness (and thus more protection for what's being generated). For Bitcoin, entropy is the foundation of your seed, which in an HD wallet generates all of your addresses.
1616
17-
You'll always start work with Libwally by initializing the library and testing the results, as first demonstrated in [§16.1](16_1_Setting_Up_Libwally.md):
17+
You'll always start work with Libwally by initializing the library and testing the results, as first demonstrated in [§17.1](17_1_Setting_Up_Libwally.md):
1818
```
1919
int lw_response;
2020
@@ -82,7 +82,7 @@ If you've done everything right, you should get back a 64-byte seed. (That's the
8282
8383
## Test Mnemonic Code
8484

85-
The full code for generating entropy, generating a BIP39 mnemonic, validating the mnemonic, and generating a seed can be found in the [src directory](src/16_2_genmnemonic.c). Download it and compile:
85+
The full code for generating entropy, generating a BIP39 mnemonic, validating the mnemonic, and generating a seed can be found in the [src directory](src/17_2_genmnemonic.c). Download it and compile:
8686
```
8787
$ cc genmnemonic.c -lwallycore -lsodium -o genmnemonic
8888
```
@@ -99,7 +99,7 @@ BIP39 allows you generate a set of 12-24 Mnemonic words from a seed (and the Lib
9999

100100
> :fire: ***What is the power of BIP39?*** Bitcoin seeds and private keys are prone to all sorts of lossage. You mistype a single digit, and your money is gone forever. Mnemonic Words are a much more user-friendly way of representing the same data, but because they're words in the language of the user's choice, they're less prone to mistakes. The power of BIP39 is thus to improve the accessibility, usability, and safety of Bitcoin.
101101
102-
> :fire: ***What is the power of BIP39 in Libwally?*** Bitcoind doesn't currently support mnemonic words, so using Libwally can allow you to generate mnemonic words in conjunction with addresses held by `bitcoind` (though as we'll see in §16.7, it requires a bit of a work-around at present to import your keys into Bitcoin Core).
102+
> :fire: ***What is the power of BIP39 in Libwally?*** Bitcoind doesn't currently support mnemonic words, so using Libwally can allow you to generate mnemonic words in conjunction with addresses held by `bitcoind` (though as we'll see in §17.7, it requires a bit of a work-around at present to import your keys into Bitcoin Core).
103103
104104
## What's Next?
105105

17_3_Using_BIP32_in_Libwally.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ There is also a `wally_bip32_key_to_address` function, which can be used to gene
115115

116116
## Test HD Code
117117

118-
The code for these HD example can, as usual, be found in the [src directory](src/16_3_genhd.c).
118+
The code for these HD example can, as usual, be found in the [src directory](src/17_3_genhd.c).
119119

120120
You can compile and test it:
121121
```

17_4_Using_PSBTs_in_Libwally.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Obviously, there's a lot more you could look at in the PSBTs. In fact, looking i
116116
117117
### Test Your PSBT Reader
118118

119-
Again, the code for this (extremely rudimentary and specific) PSBT reader is in the [src directory](src/16_4_examinepsbt.c).
119+
Again, the code for this (extremely rudimentary and specific) PSBT reader is in the [src directory](src/17_4_examinepsbt.c).
120120

121121
You can compile it as normal:
122122
```
@@ -289,7 +289,7 @@ But what you have is not yet a legal PSBT, because of the lack of inputs. You ca
289289
```
290290
### Test Your PSBT Creation
291291

292-
At this point, you should have an empty, but working PSBT, which you can see by compiling and running [the program](src/16_4_createemptypsbt.c).
292+
At this point, you should have an empty, but working PSBT, which you can see by compiling and running [the program](src/17_4_createemptypsbt.c).
293293
```
294294
$ cc createemptypsbt.c -lwallycore -o createemptypsbt
295295
$ ./createemptypsbt

17_5_Using_Scripts_in_Libwally.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ As you might expect, you then add that input to your transaction:
9898
lw_response = wally_tx_add_input(tx,tx_input);
9999
```
100100

101-
> **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).
101+
> **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](17_7_Integrating_Libwally_and_Bitcoin-CLI.md).
102102
103103
### Print a Transaction
104104

@@ -113,7 +113,7 @@ We'll show how to make use of that in §16.7.
113113

114114
## Test Your Replacement Script
115115

116-
You can grab the test code from the [src directory](src/16_5_replacewithscript.c) and compile it:
116+
You can grab the test code from the [src directory](src/17_5_replacewithscript.c) and compile it:
117117
```
118118
$ cc replacewithscript.c -lwallycore -o replacewithscript
119119
```

17_6_Using_Other_Functions_in_Libwally.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Some relate to the wallet import format (WIF):
4545

4646
## Use BIP32 Functions
4747

48-
There are additional BIP32 HD-wallet functions, beyond what was covered in [§16.3: Using BIP32 in Libwally](16_3_Using_BIP32_in_Libwally.md).
48+
There are additional BIP32 HD-wallet functions, beyond what was covered in [§17.3: Using BIP32 in Libwally](17_3_Using_BIP32_in_Libwally.md).
4949

5050
* `bip32_key_get_fingerprint` — Generate a BIP32 fingerprint for an extended key
5151
* `bip32_key_serialize` — Transform an extended key into serialized bytes
@@ -65,19 +65,19 @@ The main functions are:
6565

6666
## Use BIP39 Functions
6767

68-
A few BIP39 mnemonic-word functions were just overviewed in [§16.2: Using BIP39 in Libwally](16_2_Using_BIP39_in_Libwally.md):
68+
A few BIP39 mnemonic-word functions were just overviewed in [§17.2: Using BIP39 in Libwally](17_2_Using_BIP39_in_Libwally.md):
6969

7070
* `bip39_get_languages` — See a list of supported languages
7171
* `bit39_get_word` — Retrieve a specific word from a language's word list
7272
* `bip39_get_wordlist` — See a list of words for a language
7373

7474
## Use PSBT Functions
7575

76-
Listings of most PSBT functions can be found in [16.4: Using PSBTs in Libwally](16_4_Using_PSBTs_in_Libwally.md).
76+
Listings of most PSBT functions can be found in [17.4: Using PSBTs in Libwally](17_4_Using_PSBTs_in_Libwally.md).
7777

7878
## Use Script Functions
7979

80-
[§16.5: Using Scripts in Libwally](16_5_Using_Scripts_in_Libwally.md) just barely touched upon Libwally's Scripts functions.
80+
[§17.5: Using Scripts in Libwally](17_5_Using_Scripts_in_Libwally.md) just barely touched upon Libwally's Scripts functions.
8181

8282
There's another function that lets you determine the sort of script found in a transaction:
8383

@@ -102,7 +102,7 @@ Then there are a slew of functions that create `scriptPubKey` from bytes, `scrip
102102

103103
## Use Transaction Functions
104104

105-
We also just barely touched upon the functions that can be used to create and convert functions in [§16.5](16_5_Using_Scripts_in_Libwally.md).
105+
We also just barely touched upon the functions that can be used to create and convert functions in [§17.5](17_5_Using_Scripts_in_Libwally.md).
106106

107107
There are numerous informational functions, some of the more interesting of which are:
108108

17_7_Integrating_Libwally_and_Bitcoin-CLI.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This final section will offer some examples of using Libwally programs to comple
88

99
## Share a Transaction
1010

11-
[§16.5: Using Scripts in Libwally](16_5_Using_Scripts_in_Libwally.md) detailed how Libwally could be used to rewrite an existing transaction, to do something that `bitcoin-cli` can't: produce a transaction that contains a unique P2SH. Obviously, this is a building block; if you decide to dig further into Libwally you'll create entire transactions on your own. But, this abbreviated methodology also has its own usage: it shows how transactions can be passed back and forth between `bitcoin-cli` and Libwally, demonstrating a first example of using them in a complementary fashion.
11+
[§17.5: Using Scripts in Libwally](17_5_Using_Scripts_in_Libwally.md) detailed how Libwally could be used to rewrite an existing transaction, to do something that `bitcoin-cli` can't: produce a transaction that contains a unique P2SH. Obviously, this is a building block; if you decide to dig further into Libwally you'll create entire transactions on your own. But, this abbreviated methodology also has its own usage: it shows how transactions can be passed back and forth between `bitcoin-cli` and Libwally, demonstrating a first example of using them in a complementary fashion.
1212

1313
To fully demonstrate this methodology, you'll create a transaction with `bitcoin-cli`, using this UTXO:
1414
```
@@ -33,7 +33,7 @@ $ utxo_vout=$(bitcoin-cli listunspent | jq -r '.[0] | .vout')
3333
$ recipient=tb1qycsmq3jas5wkhf8xrfn8k7438cm5pc8h9ae2k0
3434
$ rawtxhex=$(bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]''' outputs='''{ "'$recipient'": 0.0009 }''')
3535
```
36-
Though you placed a recipient and an amount in the output, it's irrelevent, because you'll be rewriting those. A fancier bit of code could read the existing `vout` info before rewriting, but we're keeping things very close to our [original code](src/16_5_replacewithscript.c).
36+
Though you placed a recipient and an amount in the output, it's irrelevent, because you'll be rewriting those. A fancier bit of code could read the existing `vout` info before rewriting, but we're keeping things very close to our [original code](src/17_5_replacewithscript.c).
3737

3838
Here's the one change necessary, to allow you to specify the satoshi `vout`, without having to hardcode it, as in the original:
3939
```
@@ -170,7 +170,7 @@ $ bitcoin-cli decoderawtransaction $signedtx
170170
```
171171
Voila! That's the power of Libwally with `bitcoin-cli`.
172172

173-
Obviously, you can also pass around a PSBT using the functions described in [§16.4](16_4_Using_PSBTs_in_Libwally.md) and that's a more up-to-date methodology for the modern-day usage of Bitcoin, but in either example, the concept of passing transactions from `bitcoin-cli` to Libwally code and back should be similar.
173+
Obviously, you can also pass around a PSBT using the functions described in [§17.4](17_4_Using_PSBTs_in_Libwally.md) and that's a more up-to-date methodology for the modern-day usage of Bitcoin, but in either example, the concept of passing transactions from `bitcoin-cli` to Libwally code and back should be similar.
174174

175175
## Import & Export BIP39 Seeds
176176

@@ -182,7 +182,7 @@ Unfortunately, not all interactions between Libwally and `bitcoin-cli` go as smo
182182
183183
## Import Private Keys
184184

185-
Fortunately, you can do much the same thing by importing a private key generated in Libwally. Take a look at [genhd-for-import.c](src/16_7_genhd_for_import.c), a simplified version of the `genhd` program from [§16.3](16_3_Using_BIP32_in_Libwally.md) that also uses the `jansson` library from [§15.1](15_1_Accessing_Bitcoind_with_C.md) for regularized output.
185+
Fortunately, you can do much the same thing by importing a private key generated in Libwally. Take a look at [genhd-for-import.c](src/17_7_genhd_for_import.c), a simplified version of the `genhd` program from [§17.3](17_3_Using_BIP32_in_Libwally.md) that also uses the `jansson` library from [§16.1](15_1_Accessing_Bitcoind_with_C.md) for regularized output.
186186

187187
The updated code also contains one change of note: it requests a fingerprint from Libwally so that it can properly create a derivation path:
188188
```
@@ -195,7 +195,7 @@ The updated code also contains one change of note: it requests a fingerprint fro
195195

196196
> :warning: **WARNING:** Remember that the fingerprint in derivation paths is arbitrary. Because Libwally provides one, we're using it, but if you didn't have one, you could add an arbitrary 4-byte hexcode as a fingerprint to your derivation path.
197197
198-
Be sure to compile the new code with the `jansson` library, after installing it (if necessary) per [§15.1](15_1_Accessing_Bitcoind_with_C.md).
198+
Be sure to compile the new code with the `jansson` library, after installing it (if necessary) per [§16.1](15_1_Accessing_Bitcoind_with_C.md).
199199
```
200200
$ cc genhd-for-import.c -lwallycore -lsodium -ljansson -o genhd-for-import
201201
```

0 commit comments

Comments
 (0)