mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
commit
db09b788a9
@ -20,11 +20,11 @@ EOF
|
||||
|
||||
> **WARNING:** The btcblock alias will not work correctly if you try to place it in your .bash_profile by hand, rather than using the "cat" command as suggested. If you want to enter it by hand, you need to adjust the number of backslashes (usually from three each to one each), so make sure you know what you're doing if you aren't entering the commands exactly as suggested.
|
||||
|
||||
Note that these aliases includes shortcuts for running `bitcoin-cli`, for running `bitcoind`, and for going to the Bitcoin directory. These aliases are mainly meant to make your life easier. We suggest you create other aliases to ease your use of frequent commands (and arguments) and to minimize errors. Aliases of this sort can even more useful if you have a complex setup where you regularly run commands associated with Mainnet, with Testnet, _and_ with Regtest, as explained further below.
|
||||
Note that these aliases includes shortcuts for running `bitcoin-cli`, for running `bitcoind`, and for going to the Bitcoin directory. These aliases are mainly meant to make your life easier. We suggest you create other aliases to ease your use of frequent commands (and arguments) and to minimize errors. Aliases of this sort can be even more useful if you have a complex setup where you regularly run commands associated with Mainnet, with Testnet, _and_ with Regtest, as explained further below.
|
||||
|
||||
With that said, use of these aliases in _this_ document might accidentally obscure the core lessons being taught about Bitcoin, so the only aliases directly used here are `btcinfo` and `btcblock`, because they encapsulate much longer and more complex commands. Otherwise, we show the full commands; adjust for your own use as appropriate.
|
||||
|
||||
> **TESTNET vs MAINNET:** Remember that this tutorial generally assumes that you are using testnet. Tthe `btcblock` alias needs to be slightly different on mainnet, where you can use the simpler "wget -O - http://blockchain.info/q/getblockcount 2>/dev/null".
|
||||
> **TESTNET vs MAINNET:** Remember that this tutorial generally assumes that you are using testnet. The `btcblock` alias needs to be slightly different on mainnet, where you can use the simpler "wget -O - http://blockchain.info/q/getblockcount 2>/dev/null".
|
||||
|
||||
## Run Bitcoind
|
||||
|
||||
|
@ -11,7 +11,7 @@ The first thing you need to do is create an address for receiving payments. This
|
||||
$ bitcoin-cli getnewaddress "" legacy
|
||||
n4cqjJE6fqcmeWpftygwPoKMMDva6BpyHf
|
||||
```
|
||||
Note that this address begins with an "n" (or sometimes an "m"). This signifies that this is a testnet address.
|
||||
Note that this address begins with an "n" (or sometimes an "m"). This signifies that this is a testnet address.
|
||||
|
||||
The "legacy" flag is necessary to generate a traditional address, rather than a p2sh-segwit or bech32 address. The legacy address is currently required from the command line to make sure that signing works correctly.
|
||||
|
||||
@ -36,7 +36,7 @@ H3yMBZaFeSmG2HgnH38dImzZAwAQADcOiMKTC1fryoV6Y93BelqzDMTCqNcFoik86E8qHa6o3FCmTsxW
|
||||
```
|
||||
You'll get the signature as a return.
|
||||
|
||||
_What is a signature?_ A digital signature is a combination of a message and a private key that can then be unlocked with a public key. Since there's a one-to-one correspendence between the elements of a keypair, unlocking with a public key proves that the signer controlled the corresponding private key.
|
||||
_What is a signature?_ A digital signature is a combination of a message and a private key that can then be unlocked with a public key. Since there's a one-to-one correspendence between the elements of a keypair, unlocking with a public key proves that the signer controlled the corresponding private key.
|
||||
|
||||
Another person can then use the `bitcoin-cli verifymessage` command to verify the signature. He inputs the address in question, the signature, and the message:
|
||||
```
|
||||
@ -53,7 +53,7 @@ false
|
||||
|
||||
## Optional: Dump Your Wallet
|
||||
|
||||
It might seem dangerous having all of your irreplacable private keys in a single file. That's what `bitcoin-cli backupwallet` is for. It lets you make a copy of your wallet.dat:
|
||||
It might seem dangerous having all of your irreplaceable private keys in a single file. That's what `bitcoin-cli backupwallet` is for. It lets you make a copy of your wallet.dat:
|
||||
```
|
||||
$ bitcoin-cli backupwallet backup.dat
|
||||
```
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Interlude: Using Command-Line Variables
|
||||
# Interlude: Using Command-Line Variables
|
||||
|
||||
> **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning.
|
||||
|
||||
@ -22,7 +22,7 @@ You can then use your shell's `echo` command to look at your (new) address:
|
||||
$ echo $NEW_ADDRESS_1
|
||||
n4cqjJE6fqcmeWpftygwPoKMMDva6BpyHf
|
||||
```
|
||||
Because you have your address in a variable, you can now easily sign a message for that address, without worrying about typoing the address. You'll of course save that signature into a variable too!
|
||||
Because you have your address in a variable, you can now easily sign a message for that address, without worrying about mistyping the address. You'll of course save that signature into a variable too!
|
||||
```
|
||||
$ NEW_SIG_1=$(bitcoin-cli signmessage $NEW_ADDRESS_1 "Hello, World")
|
||||
```
|
||||
|
@ -21,7 +21,7 @@ After you've requested your money, you should be able to verify it with the 'bit
|
||||
$ bitcoin-cli getbalance
|
||||
0.00000000
|
||||
```
|
||||
But wait, there's no balance yet!?
|
||||
But wait, there's no balance yet!?
|
||||
|
||||
Welcome to the world of Bitcoin latency.The problem is that your transaction hasn't yet been recorded in a block!
|
||||
|
||||
@ -34,7 +34,7 @@ Fortunately, `bitcoin-cli getunconfirmedbalance` should still show your updated
|
||||
$ bitcoin-cli getunconfirmedbalance
|
||||
0.47000000
|
||||
```
|
||||
If that's still showing a zero too, you're probably moving through this tutorial too fast. Wait a second. The coins should show up unconfirmed, then rapidly move to confirmed. Do note that a coin can move from unconfirmedbalance to confirmedbalance almost immediately, so make sure you check both. However, if your `getbalance` and your `getunconfirmedbalance` both still show zero in ten minutes, then there's probably something wrong with the faucet, and you'll need to pick another.
|
||||
If that's still showing a zero too, you're probably moving through this tutorial too fast. Wait a second. The coins should show up unconfirmed, then rapidly move to confirmed. Do note that a coin can move from unconfirmedbalance to confirmedbalance almost immediately, so make sure you check both. However, if your `getbalance` and your `getunconfirmedbalance` both still show zero in ten minutes, then there's probably something wrong with the faucet, and you'll need to pick another.
|
||||
|
||||
### Gain Confidence in Your Money
|
||||
|
||||
@ -162,7 +162,7 @@ $ bitcoin-cli getrawtransaction "88e5d5f3077517d76f5a61491fa52e6aaae078c52bc62d8
|
||||
"n4cqjJE6fqcmeWpftygwPoKMMDva6BpyHf"
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
"value": 0.51869975,
|
||||
"n": 1,
|
||||
@ -183,7 +183,7 @@ $ bitcoin-cli getrawtransaction "88e5d5f3077517d76f5a61491fa52e6aaae078c52bc62d8
|
||||
"blocktime": 1488307692
|
||||
}
|
||||
```
|
||||
Now you can see the full information on the transaction, including all of the inputs ("vin") and all the outputs ("vout). One of the interesting things to note is that though we received .47 BTC in the transaction, another .51869975 was sent to another address. That was probably a change address, a concept that is explored in the next section. It is quite typical for a transaction to have multiple inputs and/or multiple outputs.
|
||||
Now you can see the full information on the transaction, including all of the inputs ("vin") and all the outputs ("vout). One of the interesting things to note is that although we received .47 BTC in the transaction, another .51869975 was sent to another address. That was probably a change address, a concept that is explored in the next section. It is quite typical for a transaction to have multiple inputs and/or multiple outputs.
|
||||
|
||||
> **WARNING:** These commands will not work in some situations. To be able to view a raw transaction on a standard node, some of the money must be unspent, or the transaction must still be in your mempool — which means that this command will work fine for the money you've just received, but not for old stuff. If you want to be able to view older transactions that have been spent, you can do so by maintaining a set of all transactions with the txindex=1 configuration, which is what our scripts suggest for all non-pruned instances. (You can't maintain a transaction index if your node is pruned.)
|
||||
|
||||
@ -191,7 +191,7 @@ Now you can see the full information on the transaction, including all of the in
|
||||
|
||||
Even looking at the verbose information for a transaction can be a little intimidating. The main goal of this tutorial is to teach how to deal with raw transactions from the command line, but we're happy to talk about other tools when they're applicable. One of those tools is a block explorer, which you can use to look at transactions from a web browser in a much friendlier format.
|
||||
|
||||
Currently, our preferred block explorer is [https://live.blockcypher.com/](https://live.blockcypher.com/).
|
||||
Currently, our preferred block explorer is [https://live.blockcypher.com/](https://live.blockcypher.com/).
|
||||
|
||||
You can use it to look up transactions for an address:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user