Skip to content

Commit 8b6ebc0

Browse files
authored
Update 04_4__Interlude_Using_Curl.md
1 parent b31f033 commit 8b6ebc0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

04_4__Interlude_Using_Curl.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,27 +220,27 @@ This is almost exactly the same output that you receive when you type `bitcoin-c
220220

221221
After you know where your funds are, the next step in crafting a transaction is to get a change address. By now you've probably got the hang of this, and you know that for simple RPC commands, all you need to do is adjust the `method` is the `curl` command:
222222
```
223-
$ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["", "legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
223+
$ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
224224
{
225225
"result": "mrSqN37TPs89GcidSZTvXmMzjxoJZ6RKoz",
226226
"error": null,
227227
"id": "curltest"
228228
}
229229
```
230230

231-
> **WARNING:** The parameters order is important when you are sending RPC commands using curl. For example here, if we had sent `"params": ["legacy"]` instead of `"params": ["", "legacy"]`, we would get a `bech32` address with a label of `"legacy"` instead of a `legacy` address, so pay attention to the order.
231+
> **WARNING:** The parameters order is important when you are sending RPC commands using curl. There's only one argument for `getrawchangeaddress`, but consider its close cousin `getnewaddress`. That takes two arguments: first label, then type. If we sent that same `"params": ["legacy"]` instead of `"params": ["", "legacy"]`, we would get a `bech32` address with a label of `"legacy"` instead of a `legacy` address, so pay attention to the order!
232232
233233
At this point, we can even revert to our standard practice of saving results to variables with additional help from `jq`:
234234
```
235-
$ newaddress=$(curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["", "legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.result')
235+
$ newaddress=$(curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.result')
236236
$ echo $newaddress
237237
mqdfnjgWr2r3sCCeuTDfe8fJ1CnycF2e6R
238238
```
239239
No need to worry about the downloading info. It'll go to `STDERR` and be displayed on your screen, while the results go to `STDOUT` and are saved in your variable.
240240

241241
## Create a Transaction
242242

243-
You're now ready to create a transaction with `curl`, except using `getrawchangeaddress` instead of `getnewaddress`.
243+
You're now ready to create a transaction with `curl`.
244244

245245
### Ready Your Variables
246246

0 commit comments

Comments
 (0)