mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 07:56:31 +00:00
Fix: section 4 typos
This commit is contained in:
parent
81d8760a8c
commit
490c3bd90f
@ -8,11 +8,11 @@ The `bitcoin-cli` offers three major ways to send coins: as a simple command; as
|
||||
|
||||
Before you send any money on the Bitcoin network, you should think about what transaction fees you're going to pay.
|
||||
|
||||
_What is a transaction fee?_ There's no such thing as a free lunch. Miners incorporate transactions into blocks because they're paid to do so. Not only do they get paid by the network for making the block, but they also get paid by transactors for including their transactions. If you don't pay a fee, your transaction might get stuck ... forever (or, until saved by some of the tricks in section five).
|
||||
_What is a transaction fee?_ There's no such thing as a free lunch. Miners incorporate transactions into blocks because they're paid to do so. Not only do they get paid by the network for making the block, but they also get paid by transactors for including their transactions. If you don't pay a fee, your transaction might get stuck ... forever (or, until saved by some of the tricks in section five).
|
||||
|
||||
When you're using the simple and automated methods for creating transactions, as outlined here and in [§4.5: Sending Coins with Automated Raw Transactions](04_5_Sending_Coins_with_Automated_Raw_Transactions.md), Bitcoin will calculate transaction fees for you. This is done using Floating Fees, where the `bitcoind` watches how long transactions are taking to confirm and automatically calculates for you what to spend.
|
||||
|
||||
You can help control this by putting rational values into your ~/.bitcoin/bitcoin.conf. The following low-cost values would ensure that there was a minimum transaction fee of 10,000 satoshis per kByte of data in your transaction and request that the floating fees figure out a good amount to get your transaction somewhere into the next six blocks.
|
||||
You can help control this by putting rational values into your ~/.bitcoin/bitcoin.conf. The following low-cost values would ensure that there was a minimum transaction fee of 10,000 satoshis per kByte of data in your transaction and request that the floating fees figure out a good amount to get your transaction somewhere into the next six blocks.
|
||||
```
|
||||
mintxfee=0.0001
|
||||
txconfirmtarget=6
|
||||
@ -28,7 +28,7 @@ After you've edited your bitcoin.conf file, you'll want to kill and restart bitc
|
||||
|
||||
## Get an Address
|
||||
|
||||
You need somewhere to send your coins to. Usually, someone would send you an address, and perhaps give you a signature to prove they own that address. Alternatively, they might give you a QR code to scan, so that you can'tmake mistakes when typing in the address. In our case, we're going to send coins to `n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi`, which is a return address for TP's TestNet faucet.
|
||||
You need somewhere to send your coins to. Usually, someone would send you an address, and perhaps give you a signature to prove they own that address. Alternatively, they might give you a QR code to scan, so that you can't make mistakes when typing in the address. In our case, we're going to send coins to `n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi`, which is a return address for TP's TestNet faucet.
|
||||
|
||||
_What is a QR code?_ A QR code is just an encoding of a Bitcoin address. Many wallets will generate QR codes for you, while some sites will convert from an address to a QR code. Obviously, you should only accept a QR code from a site that you absolutely trust. A payer can use a bar-code scanner to read in the QR code, then pay to it.
|
||||
|
||||
@ -40,7 +40,7 @@ $ txid=$(bitcoin-cli sendtoaddress n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi 0.1)
|
||||
$ echo $txid
|
||||
586b3ff591d43948ed4107216be52d831c551747b469626a6b7c84bbf1639f76
|
||||
```
|
||||
Make sure the address you write in is where you want the money to go. Make _double_ sure. If you make mistakes in Bitcoin, there's no going back.
|
||||
Make sure the address you write in is where you want the money to go. Make _double_ sure. If you make mistakes in Bitcoin, there's no going back.
|
||||
|
||||
You'll receive a txid back when you issue this command.
|
||||
|
||||
|
@ -16,7 +16,7 @@ Here's the trick: _all of the UTXOs that you gather are spent in full!_ That mea
|
||||
|
||||
## List Your Unspent Transactions
|
||||
|
||||
In order to create a new raw transaction, you must know what UTXOs you have on-hand to spent. You can determine this information with the `bitcoin-cli listunspent` command:
|
||||
In order to create a new raw transaction, you must know what UTXOs you have on-hand to spend. You can determine this information with the `bitcoin-cli listunspent` command:
|
||||
```
|
||||
$ bitcoin-cli listunspent
|
||||
[
|
||||
@ -30,7 +30,7 @@ $ bitcoin-cli listunspent
|
||||
"confirmations": 2,
|
||||
"spendable": true,
|
||||
"solvable": true
|
||||
},
|
||||
},
|
||||
{
|
||||
"txid": "c1abb6951e6a9aae7e384412b69b69e59c10daac9397d01d0c52b7bc6278d589",
|
||||
"vout": 1,
|
||||
@ -41,7 +41,7 @@ $ bitcoin-cli listunspent
|
||||
"confirmations": 1,
|
||||
"spendable": true,
|
||||
"solvable": true
|
||||
},
|
||||
},
|
||||
{
|
||||
"txid": "ab7ca727055b812df882298f4e6e10ec699fb6250d843c813623171781f896d8",
|
||||
"vout": 0,
|
||||
@ -92,7 +92,7 @@ $ echo $utxo_vout
|
||||
$ echo $recipient
|
||||
n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi
|
||||
```
|
||||
That recipient is particularly important, because if you mess it up, your money is _gone_! So triple check it.
|
||||
That recipient is particularly important, because if you mess it up, your money is _gone_! So triple check it.
|
||||
|
||||
### Write the Raw Transaction
|
||||
|
||||
@ -100,7 +100,7 @@ You're now ready to create the raw transaction. This uses the `createrawtransact
|
||||
|
||||
Here's the standard format:
|
||||
```
|
||||
$ bitcoin-cli createrawtransaction
|
||||
$ bitcoin-cli createrawtransaction
|
||||
'''[
|
||||
{
|
||||
"txid": "'$your_txid'",
|
||||
@ -112,7 +112,7 @@ $ bitcoin-cli createrawtransaction
|
||||
}'''
|
||||
```
|
||||
Yeah, there are all kinds of crazy quotes there, but trust that they'll do the right thing. Use `'''` to mark the start and end of the JSON array and the JSON object. Protect normal words like `"this"` and normal numbers like `0`. If they're variables, insert single quotes, like `"'$this_word'"` and `'$this_num'`. (Whew. You'll get used to it.)
|
||||
|
||||
|
||||
Here's a command that creates a raw transaction to send your $utxo to your $recipient
|
||||
```
|
||||
$ rawtxhex=$(bitcoin-cli createrawtransaction '''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]''' '''{ "'$recipient'": 0.0795 }''')
|
||||
@ -126,7 +126,7 @@ You'll note that we didn't send the whole .08 BTC to our recipient. That's becau
|
||||
|
||||
> **WARNING:** This is the very dangerous part of raw transactions!! Because you automatically expend all of the amount in the UTXOs that you use, it's critically important to make sure that you know: (1) precisely what UTXOs you're using; (2) exactly how much money they contain; (3) exactly how much money you're sending out; and (4) what the difference is. If you mess up and you use the wrong UTXO (with more money than you thought) or if you send out too little money, the excess is lost. Forever. Don't make that mistake! Know your inputs and outputs _precisely_. Or better, don't use raw transactions except as part of a carefully considered and triple-checked program.
|
||||
|
||||
_How much should you spend on transaction fees?_ [Bitcoin Fees](https://bitcoinfees.21.co/) has a nice live assessment. It says that the "fastest and cheapest transaction fee is currently 220 satoshis/byte" and that "For the median transaction size of 226 bytes, this results in a fee of 49,720 satoshis".
|
||||
_How much should you spend on transaction fees?_ [Bitcoin Fees](https://bitcoinfees.21.co/) has a nice live assessment. It says that the "fastest and cheapest transaction fee is currently 220 satoshis/byte" and that "For the median transaction size of 226 bytes, this results in a fee of 49,720 satoshis".
|
||||
|
||||
That basic info is what we used to construct our raw transaction. We just subtracted 50,000 satoshis, which is .0005 BTC, from the amount we were sending: .0800 BTC - .0005 BC= .0795, which is what we sent. (Often transactions don't need to be the "fastest" and can get away with much lower transaction fees; we opted not to because we don't want to delay working through this tutorial.)
|
||||
|
||||
@ -213,7 +213,7 @@ $ bitcoin-cli listunspent
|
||||
"confirmations": 12,
|
||||
"spendable": true,
|
||||
"solvable": true
|
||||
},
|
||||
},
|
||||
{
|
||||
"txid": "ab7ca727055b812df882298f4e6e10ec699fb6250d843c813623171781f896d8",
|
||||
"vout": 0,
|
||||
|
@ -129,9 +129,9 @@ ec0598918f6f5476cb90365651e8a2724ef26f949290bbf196f41ed96092a52f
|
||||
0
|
||||
1.95
|
||||
```
|
||||
This makes it easy to decide which UTXOs to spend in a raw transaction, but it's not very pretty.
|
||||
This makes it easy to decide which UTXOs to spend in a raw transaction, but it's not very pretty.
|
||||
|
||||
Fortunately, JQ also lets you be fancy. You can use `{}`s to create new JSON objects (either for additional parsing or for pretty output). You also get to define the name of the new key for each of your values. The resulting output should be much more intuitive and less prone to error (though obviously, less useful for dumping info straight into variables).
|
||||
Fortunately, JQ also lets you be fancy. You can use `{}`s to create new JSON objects (either for additional parsing or for pretty output). You also get to define the name of the new key for each of your values. The resulting output should be much more intuitive and less prone to error (though obviously, less useful for dumping info straight into variables).
|
||||
|
||||
The following example shows the exact same parsing of `listunspent`, but with the each old JSON object rebuilt as a new, abridged JSON object, with all of the new values named with their old keys:
|
||||
```
|
||||
@ -196,7 +196,7 @@ $ $ bitcoin-cli decoderawtransaction $rawtxhex
|
||||
"hex": ""
|
||||
},
|
||||
"sequence": 4294967295
|
||||
},
|
||||
},
|
||||
{
|
||||
"txid": "c7c7f6371ec19330527325908a544bbf8401191645598301d24b54d37e209e7b",
|
||||
"vout": 1,
|
||||
@ -220,7 +220,7 @@ $ $ bitcoin-cli decoderawtransaction $rawtxhex
|
||||
"mzTWVv2QSgBNqXx7RC56zEhaQPve8C8VS9"
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"value": 0.04500000,
|
||||
"n": 1,
|
||||
@ -274,7 +274,7 @@ $ echo ${usedvout[1]}
|
||||
```
|
||||
The only real trick here is how we saved the information using the bash shell. Rather than saving to a variable with `$(command)`, we instead saved to an array with `($(command))`. We were then able to access the individual bash array elements with a `${variable[n]}` construction. We could instead access the whole array with `${variable[@]}`. (Yeah, no one ever said bash was pretty.)
|
||||
|
||||
> **WARNING:** Always remember that a UTXO is a transaction _plus_ a vout. We missed the vout the first time we wrote this JQ example, and it stopped working when we ended up with a situation where we'd been sent two `vouts` from the same transaction.
|
||||
> **WARNING:** Always remember that a UTXO is a transaction _plus_ a vout. We missed the vout the first time we wrote this JQ example, and it stopped working when we ended up with a situation where we'd been sent two `vouts` from the same transaction.
|
||||
|
||||
### Retrieve the Related Object(s)
|
||||
|
||||
@ -338,7 +338,7 @@ Note that we used yet another bit of array ugliness `${#usedtxid[*]}` to determi
|
||||
|
||||
**Usage Example:** _Automatically calculate the value of the UTXOs used in a transaction._
|
||||
|
||||
You can now go one step further, and request the .amount (or any other JSON key-value) from the UTXOs you're retrieving.
|
||||
You can now go one step further, and request the .amount (or any other JSON key-value) from the UTXOs you're retrieving.
|
||||
|
||||
This example repeats the usage the `$usedtxid` and `$usedvout` arrays that were set as follows:
|
||||
```
|
||||
@ -362,7 +362,7 @@ Whew!
|
||||
|
||||
**Usage Example:** _Calculate the fee for a transaction._
|
||||
|
||||
To figure out the complete transaction fee at this point just requires one more bit of math: determining how much money is going through the .vout. That's a simple use of JQ where you just use `awk` to sum up the `value` of all the `vout` information:
|
||||
Figuring out the complete transaction fee at this point just requires one more bit of math: determining how much money is going through the .vout. That's a simple use of JQ where you just use `awk` to sum up the `value` of all the `vout` information:
|
||||
```
|
||||
$ bitcoin-cli decoderawtransaction $rawtxhex | jq -r '.vout [] | .value' | awk '{s+=$1} END {print s}'
|
||||
1.045
|
||||
@ -386,7 +386,7 @@ For more JSON magic (and if any of this isn't clear), please read the [JSON Manu
|
||||
|
||||
## Make Some New Aliases
|
||||
|
||||
JQ code can be a little unwieldly, so you should consider adding some longer and more interesting invocations to your ~/.bash_profile.
|
||||
JQ code can be a little unwieldy, so you should consider adding some longer and more interesting invocations to your ~/.bash_profile.
|
||||
|
||||
Any time you're looking through a large mass of information in a JSON object output by a `bitcoin-cli` command, consider writing an alias to strip it down to just what you want to see.
|
||||
```
|
||||
@ -435,5 +435,3 @@ You may also want to create an alias:
|
||||
```
|
||||
alias btctxfee="~/txfee-calc.sh"
|
||||
```
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ myrK8U3SE1nWh9y9XPho5aTrKYW6n8qSQv
|
||||
```
|
||||
Note that this uses a new function: `getrawchangeaddress`. It's largely the same as `getnewaddress` but is optimized for use as a change address in a raw transaction, so it doesn't do things like make entries in your address book.
|
||||
|
||||
You now have an additional address inside your wallet, so that you can receive change from a UTXO! In order to use it, you'll need to create a raw transaction with two outputs.
|
||||
You now have an additional address inside your wallet, so that you can receive change from a UTXO! In order to use it, you'll need to create a raw transaction with two outputs.
|
||||
|
||||
## Pick Sufficient UTXOs
|
||||
|
||||
@ -42,7 +42,7 @@ $ bitcoin-cli listunspent
|
||||
"confirmations": 9551,
|
||||
"spendable": true,
|
||||
"solvable": true
|
||||
},
|
||||
},
|
||||
{
|
||||
"txid": "3470e5fe08633583d136b9cd49bb1a224c9d9313a0b4584fd3b7438dbdf34dbd",
|
||||
"vout": 0,
|
||||
@ -70,10 +70,10 @@ n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi
|
||||
```
|
||||
We also need to record the txid and vout for each of our two UTXOs. Having identified the UTXOs that we want to spend, we can use our JQ techniques to make sure accessing them is error free:
|
||||
```
|
||||
$ utxo_txid_1=$(bitcoin-cli listunspent | jq -r '.[0] | .txid')
|
||||
$ utxo_vout_1=$(bitcoin-cli listunspent | jq -r '.[0] | .vout')
|
||||
$ utxo_txid_2=$(bitcoin-cli listunspent | jq -r '.[1] | .txid')
|
||||
$ utxo_vout_2=$(bitcoin-cli listunspent | jq -r '.[1] | .vout')
|
||||
$ utxo_txid_1=$(bitcoin-cli listunspent | jq -r '.[0] | .txid')
|
||||
$ utxo_vout_1=$(bitcoin-cli listunspent | jq -r '.[0] | .vout')
|
||||
$ utxo_txid_2=$(bitcoin-cli listunspent | jq -r '.[1] | .txid')
|
||||
$ utxo_vout_2=$(bitcoin-cli listunspent | jq -r '.[1] | .vout')
|
||||
```
|
||||
|
||||
### Write the Transaction
|
||||
@ -84,7 +84,7 @@ Here's the example. Note the multiple inputs after the `inputs` arg and the mult
|
||||
```
|
||||
$ rawtxhex2=$(bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'$utxo_txid_1'", "vout": '$utxo_vout_1' }, { "txid": "'$utxo_txid_2'", "vout": '$utxo_vout_2' } ]''' outputs='''{ "'$recipient'": 4.0, "'$changeaddress'": 1.8495 }''')
|
||||
```
|
||||
We were _very_ careful figuring out our money math. These two UTXOs contain 5.85 BTC. After sending 4.0 BTC, we'll have 1.85 BTC left. We again chose .0005 BTC for the transaction fee. To accomodate that fee, we set our change to 1.8495 BTC. If we'd messed up our math and instead set our change to 1.7495 BTC, that additional .1 BTC would be lost. That's $100 gone to the miners! If we'd forgot to make change at all, then the whole 1.85 BTC ($2000!) would have disappeared. So, again, _be careful_.
|
||||
We were _very_ careful figuring out our money math. These two UTXOs contain 5.85 BTC. After sending 4.0 BTC, we'll have 1.85 BTC left. We again chose .0005 BTC for the transaction fee. To accommodate that fee, we set our change to 1.8495 BTC. If we'd messed up our math and instead set our change to 1.7495 BTC, that additional .1 BTC would be lost. That's $100 gone to the miners! If we'd forgot to make change at all, then the whole 1.85 BTC ($2000!) would have disappeared. So, again, _be careful_.
|
||||
|
||||
Fortunately, we can triple-check with the `btctxfee` alias from the JQ Interlude:
|
||||
```
|
||||
@ -118,7 +118,7 @@ $ bitcoin-cli listunspent
|
||||
"confirmations": 2,
|
||||
"spendable": true,
|
||||
"solvable": true
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
@ -34,18 +34,18 @@ Result:
|
||||
}
|
||||
|
||||
Examples:
|
||||
> bitcoin-cli getmininginfo
|
||||
> bitcoin-cli getmininginfo
|
||||
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
|
||||
```
|
||||
And there's the `curl` command, at the end of the help screen! This somewhat lengthy command has four major parts: (1) a listing of your user name; (2) a `--data-binary` flag; (3) a JSON object that tells `bitcoind` what to do, including a JSON array of parameters; and (4) an HTTP header that includes the `bitcoind` URL.
|
||||
And there's the `curl` command, at the end of the help screen! This somewhat lengthy command has four major parts: (1) a listing of your user name; (2) a `--data-binary` flag; (3) a JSON object that tells `bitcoind` what to do, including a JSON array of parameters; and (4) an HTTP header that includes the `bitcoind` URL.
|
||||
|
||||
When you are working with `curl`, most of these arguments to `curl` will stay the same from command to command; only the `method` and `params` entries in the JSON array will typically change. However, you need to know how to fill in your username and your URL address in order to make it work in the first place!
|
||||
|
||||
_Whenever you're unusure about how to curl an RPC command, just look at the bitcoin-cli help and go from there._
|
||||
_Whenever you're unsure about how to curl an RPC command, just look at the bitcoin-cli help and go from there._
|
||||
|
||||
### Know Your User Name
|
||||
|
||||
In order to speak with the `bitcoind` port, you need a user name and password. These were created as part of your initial Bitcoin setup, and can be found in `~/.bitcoin/bitcoin.conf`.
|
||||
In order to speak with the `bitcoind` port, you need a user name and password. These were created as part of your initial Bitcoin setup, and can be found in `~/.bitcoin/bitcoin.conf`.
|
||||
|
||||
For example, here's our current setup:
|
||||
```
|
||||
@ -89,7 +89,7 @@ The port should be easy, it's the `http://127.0.0.1:8332/` shown in the tutorial
|
||||
|
||||
With all of that in hand, you're ready to send off standard RPC commands with `curl` ... but you still need to know how to incorporate the two elements that tend to change in the `curl` command.
|
||||
|
||||
The first is `method`, which is the RPC method being used. This should generally match the command names you've been feeding into `bitcoin-cli` for ages.
|
||||
The first is `method`, which is the RPC method being used. This should generally match the command names you've been feeding into `bitcoin-cli` for ages.
|
||||
|
||||
The second is `params`, which is a JSON array of parameters. These are the same as the arguments (or named arguments) that you've been using. They're also the most confusing part of `curl`, in large part because they're a structured array rather than a simple list.
|
||||
|
||||
@ -136,7 +136,7 @@ $ curl --user bitcoinrpc:73bd45ba60ab8f9ff9846b6404769487 --data-binary '{"jsonr
|
||||
"id": "curltest"
|
||||
}
|
||||
```
|
||||
You'll see a bit of connectivity reporting as the data is downloaded, then when that data hits `jq`, everything will be output in a correctly indented form. (We'll be omiting the download information in future examples.)
|
||||
You'll see a bit of connectivity reporting as the data is downloaded, then when that data hits `jq`, everything will be output in a correctly indented form. (We'll be omitting the download information in future examples.)
|
||||
|
||||
## Manipulate Your Wallet
|
||||
|
||||
@ -147,7 +147,7 @@ Though you're accessing `bitcoind` directly, you'll still get access to wallet f
|
||||
Use the `getaddressesbyaccount` RPC to list all of your current addresses:
|
||||
```
|
||||
$ curl --user bitcoinrpc:73bd45ba60ab8f9ff9846b6404769487 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaddressesbyaccount", "params": [""] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
|
||||
|
||||
|
||||
{
|
||||
"result": [
|
||||
"mg7YqyvK8HUFvpgZ5iYTfZ5vjfaJWnNTd9",
|
||||
@ -248,7 +248,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 bitcoinrpc:73bd45ba60ab8f9ff9846b6404769487 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
|
||||
|
||||
|
||||
{
|
||||
"result": "mznccEt2ozGFN6oVaYU5BGgTzcdH8Zj8wf",
|
||||
"error": null,
|
||||
@ -270,7 +270,7 @@ You're now ready to create a transaction with `curl`.
|
||||
|
||||
### Ready Your Variables
|
||||
|
||||
Just as with `bitcoin-cli`, in order to create a transaction by curling RPC commands, you should first save your variables. The only change here is that `curl` creates a JSON object that includes a `result` key-value, so you always need to pipe through the `.result` tag before you do anything else.
|
||||
Just as with `bitcoin-cli`, in order to create a transaction by curling RPC commands, you should first save your variables. The only change here is that `curl` creates a JSON object that includes a `result` key-value, so you always need to pipe through the `.result` tag before you do anything else.
|
||||
|
||||
This example sets up our variables for using the 1.2985 BTC in funds listed in the first unspent transaction above:
|
||||
```
|
||||
@ -294,7 +294,7 @@ mmDWRH3CbeXwCqBwdHCj7E9d3oWTuuizxc
|
||||
The transaction created with `curl` is very similar to the transaction created with `bitcoin-cli`, but with a few subtle differences:
|
||||
```
|
||||
$ curl --user bitcoinrpc:73bd45ba60ab8f9ff9846b6404769487 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "createrawtransaction", "params": [''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]'', ''{ "'$recipient'": 0.298, "'$changeaddress'": 1.0}'']}' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
|
||||
|
||||
|
||||
{
|
||||
"result": "02000000010e7ffd317318792fec2b3d88b303a15326d541f0d631489f1830fa072f4a186a0000000000ffffffff0240b6c601000000001976a914ac19d3fd17710e6b9a331022fe92c693fdf6659588ac00e1f505000000001976a9143e84156731d67c80c3dff6c1cc3b4f58460e642388ac00000000",
|
||||
"error": null,
|
||||
@ -335,4 +335,3 @@ $ curl --user bitcoinrpc:73bd45ba60ab8f9ff9846b6404769487 --data-binary '{"jsonr
|
||||
Having finished this section, you may feel that accessing `bitcoind` via `curl` is very much like accessing it through `bitcoin-cli` ... but more cumbersome. And, you'd be right. `bitcoin-cli` has pretty complete RPC functionality, so anything that you do through `curl` you can probably do through `bitcoin-cli`.
|
||||
|
||||
_What is the power of curl?_ Most obviously, `curl` takes out one level of indirection. Instead of working with `bitcoin-cli` which sends RPC commands to `bitcoind`, you're sending those RPC commands directly. This allows for more robust programming, because you don't have to worry about what unexpected things that `bitcoin-cli` might do or how it might change over time. However, you're also taking your first steps toward using a more comprehensive programming language than the poor options offered by a shell script. But for that, you'll need to use a `curl` library within a more familiar language like C. In other words, command-line `curl` was just the first step, the basis to better explain what you're doing as you move forward.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user