mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
Update 04_2__Interlude_Using_JQ.md
signrawtransaction is deprecated, should be signrawtransactionwithwallet
This commit is contained in:
parent
547bae454b
commit
4d7b7fe828
@ -21,7 +21,7 @@ _What is JQ?_ The repository explains it best, saying "jq is like sed for JSON d
|
|||||||
|
|
||||||
In the previous section, the use of `signrawtransaction` offered an example of not being able to easily capture data into variables due to the use of JSON output:
|
In the previous section, the use of `signrawtransaction` offered an example of not being able to easily capture data into variables due to the use of JSON output:
|
||||||
```
|
```
|
||||||
$ bitcoin-cli signrawtransaction $rawtxhex
|
$ bitcoin-cli signrawtransactionwithwallet $rawtxhex
|
||||||
{
|
{
|
||||||
"hex": "0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000",
|
"hex": "0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000",
|
||||||
"complete": true
|
"complete": true
|
||||||
@ -33,18 +33,18 @@ To use JQ, run `jq` at the backend of a pipe, and always use the standard invoca
|
|||||||
|
|
||||||
To capture a specific value from a JSON object, you just list the key after the `.`:
|
To capture a specific value from a JSON object, you just list the key after the `.`:
|
||||||
```
|
```
|
||||||
$ bitcoin-cli signrawtransaction $rawtxhex | jq -r '.hex'
|
$ bitcoin-cli signrawtransactionwithwallet $rawtxhex | jq -r '.hex'
|
||||||
0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000
|
0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000
|
||||||
```
|
```
|
||||||
With that tool in hand, you can capture information from JSON objects to command-line variables:
|
With that tool in hand, you can capture information from JSON objects to command-line variables:
|
||||||
```
|
```
|
||||||
$ signedtx=$(bitcoin-cli signrawtransaction $rawtxhex | jq -r '.hex')
|
$ signedtx=$(bitcoin-cli signrawtransactionwithwallet $rawtxhex | jq -r '.hex')
|
||||||
$ echo $signedtx
|
$ echo $signedtx
|
||||||
0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000
|
0200000001735dfa1584b930a78ad2c1d6db72dd2a80ae5e5d552ad97e19f1d50d41fdd6d8000000006a47304402202210ce4b2a037da02622c380278cd79fec4e0e016e66f3eb894a2dcbb9ee998f02202cac167e6abdbbf08af139fb7c6b86e9d2e58e5516cd566ae2d54953ead9923b012102111bb978a3c93a00038ae344a1a017d7fee8a9be9d0558b5793ce6f440704a96ffffffff01b0e78604000000001976a914e7c1345fc8f87c68170b3aa798a956c2fe6a9eff88ac00000000
|
||||||
```
|
```
|
||||||
You can then use those variables easily and without error:
|
You can then use those variables easily and without error:
|
||||||
```
|
```
|
||||||
$ bitcoin-cli sendrawtransaction $signedtx
|
$ bitcoin-cli sendrawtransactionwithwallet $signedtx
|
||||||
3f9ccb6e16663e66dc119de1866610cc4f7a83079bfec2abf0598ed3adf10a78
|
3f9ccb6e16663e66dc119de1866610cc4f7a83079bfec2abf0598ed3adf10a78
|
||||||
```
|
```
|
||||||
## Use JQ to Access Single JSON Object Values in an Array by Key
|
## Use JQ to Access Single JSON Object Values in an Array by Key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user