mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-07-23 18:05:37 +00:00
Update 3_2_Knowing_Your_Bitcoin_Setup.md
This commit is contained in:
parent
6765bb7e63
commit
750e6ff1ab
@ -1,6 +1,29 @@
|
|||||||
# 3.2: Knowing Your bitcoin-cli Setup
|
# 3.2: Knowing Your Bitcoin Setup
|
||||||
|
|
||||||
## Get Help
|
> **NOTE:** This is a draft in progress, so that I can get some feedback from early reviewers. It is not yet ready for learning.
|
||||||
|
|
||||||
|
Before you start playing with Bitcoin, you may always want to come to a better understanding of your setup.
|
||||||
|
|
||||||
|
## Know Your Directory
|
||||||
|
|
||||||
|
If your bitcoind is running and you've downloaded all the blocks, you're probably ready to go. However, it's best to look at the main ~/.bitcoin directory, both to make sure everything is there and to understand for yourself how everything works.
|
||||||
|
|
||||||
|
The main directory just contains your config file and the testnet directory:
|
||||||
|
```
|
||||||
|
$ ls ~/.bitcoin
|
||||||
|
bitcoin.conf testnet3
|
||||||
|
```
|
||||||
|
The testnet3 directory then contains all of the guts:
|
||||||
|
```
|
||||||
|
$ ls ~/.bitcoin/testnet3
|
||||||
|
banlist.dat blocks database debug.log wallet.dat
|
||||||
|
bitcoind.pid chainstate db.log peers.dat
|
||||||
|
```
|
||||||
|
You shouldn't mess with most of these files and directories — particularly not the blocks and chainstate directories, which contain all of the blockchain data. However, do take careful note of the db.log and debug.log file, which you should refer to if you ever have problems with your setup.
|
||||||
|
|
||||||
|
> **TESTNET vs MAINNET:** If you're using mainnet, then _everything_ will instead be placed in the main ~/.bitcoin directory. These various setups _do_ elegantly stack, so if you are using mainnet, testnet, and regtest, you'll find that ~/.bitcoin contains your config file and your mainnet data, ~/.bitcoin/testnet3 contains your testnet data, and ~/.bitcoin/regtest contains your regtest data.
|
||||||
|
|
||||||
|
## Know Your Bitcoin-cli Commands
|
||||||
|
|
||||||
Most of your work will be done with the "bitcoin-cli" command. If you ever want more information on its usage, just run the help argument. Without any other arguments, it shows you ever possible command:
|
Most of your work will be done with the "bitcoin-cli" command. If you ever want more information on its usage, just run the help argument. Without any other arguments, it shows you ever possible command:
|
||||||
```
|
```
|
||||||
@ -140,7 +163,7 @@ 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/
|
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
|
||||||
```
|
```
|
||||||
## Optional: Get More Info
|
## Optional: Know Your Bitcoin Info
|
||||||
|
|
||||||
A variety of commands will give oyu move info on your setup:
|
A variety of commands will give oyu move info on your setup:
|
||||||
```
|
```
|
||||||
@ -152,40 +175,7 @@ $ bitcoin-cli getwalletinfo
|
|||||||
```
|
```
|
||||||
Feel free to play with any of these, and use "bitcoin-cli help" if you want more information on what any of them do.
|
Feel free to play with any of these, and use "bitcoin-cli help" if you want more information on what any of them do.
|
||||||
|
|
||||||
## Optional: Know Your Server Types
|
|
||||||
|
|
||||||
> **TESTNET vs MAINNET:** When you set up your node, you choose to create it as either a Mainnet, Testnet, or Regtest node. Though this document presumes a testnet setup, it's worth understanding how you might access and use the other setup types — even all on the same machine!
|
|
||||||
|
|
||||||
The type of setup is mainly controlled through the ~/.bitcoin/bitcoin.conf file. If you're running testnet, it probably contains this line:
|
|
||||||
```
|
|
||||||
testnet=1
|
|
||||||
```
|
|
||||||
While if you're running regtest, it probably contains this line:
|
|
||||||
```
|
|
||||||
regtest=1
|
|
||||||
```
|
|
||||||
However, if you want to run several different sorts of nodes simultaneously, you should leave the testnet (or regtest) flag out of your configuration file. You can then choose whether you're using the mainnet, the testnet, or your regtest every time you run bitcoind or bitcoin-cli.
|
|
||||||
|
|
||||||
Here's a set of aliases that would make that easier by creating a specific alias for starting and stopping the bitcoind, for going to the bitcoin directory, and for running bitcoin-cli, for each of the mainnet (which has no extra flags), the testnet (which is -testnet), or your regtest (which is -regtest).
|
|
||||||
```
|
|
||||||
alias bcstart="bitcoind -daemon"
|
|
||||||
alias btstart="bitcoind -testnet -daemon"
|
|
||||||
alias brstart="bitcoind -regtest -daemon"
|
|
||||||
|
|
||||||
alias bcstop="bitcoin-cli stop"
|
|
||||||
alias btstop="bitcoin-cli -testnet stop"
|
|
||||||
alias brstop="bitcoin-cli -regtest -stop"
|
|
||||||
|
|
||||||
alias bcdir="cd ~/.bitcoin/" #linux default bitcoin path
|
|
||||||
alias btdir="cd ~/.bitcoin/testnet" #linux default bitcoin testnet path
|
|
||||||
alias brdir="cd ~/.bitcoin/regtest" #linux default bitcoin regtest path
|
|
||||||
|
|
||||||
alias bc="bitcoin-cli"
|
|
||||||
alias bt="bitcoin-cli -testnet"
|
|
||||||
alias br="bitcoin-cli -regtest"
|
|
||||||
```
|
|
||||||
For even more complexity, you could have each of your 'start' aliases use the -conf flag to load configuration from a different file. This goes far beyond the scope of this tutorial, but we offer it as a starting point for when your explorations of Bitcoin reach the next level.
|
|
||||||
## Summary: Verifying Your bitcoin-cli Setup
|
## Summary: Verifying Your bitcoin-cli Setup
|
||||||
|
|
||||||
Before you start playing with bitcoin, you should make sure that the bitcoind is running and that all the blocks have been downloaded. You might get additional help from the `bitcoin-cli help` command or from files in the ~/.bitcoin directory.
|
Before you start playing with bitcoin, you should make sure that the bitcoind is running and that all the blocks have been downloaded. You might get additional help from the `bitcoin-cli help` command or from files in the ~/.bitcoin directory.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user