From 8b6ebc096629c479dec64786ae4c91ded9c66a1a Mon Sep 17 00:00:00 2001 From: Shannon Appelcline Date: Tue, 14 Jun 2022 09:08:03 -1000 Subject: [PATCH] Update 04_4__Interlude_Using_Curl.md --- 04_4__Interlude_Using_Curl.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/04_4__Interlude_Using_Curl.md b/04_4__Interlude_Using_Curl.md index 9a51a39..575e3fb 100644 --- a/04_4__Interlude_Using_Curl.md +++ b/04_4__Interlude_Using_Curl.md @@ -220,7 +220,7 @@ This is almost exactly the same output that you receive when you type `bitcoin-c 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: ``` -$ 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 '.' +$ 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": "mrSqN37TPs89GcidSZTvXmMzjxoJZ6RKoz", "error": null, @@ -228,11 +228,11 @@ $ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc" } ``` -> **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. +> **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! At this point, we can even revert to our standard practice of saving results to variables with additional help from `jq`: ``` -$ 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') +$ 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') $ echo $newaddress mqdfnjgWr2r3sCCeuTDfe8fJ1CnycF2e6R ``` @@ -240,7 +240,7 @@ No need to worry about the downloading info. It'll go to `STDERR` and be display ## Create a Transaction -You're now ready to create a transaction with `curl`, except using `getrawchangeaddress` instead of `getnewaddress`. +You're now ready to create a transaction with `curl`. ### Ready Your Variables