赵小福

赵小福

Bitcoin Installation in Linux Environment

Playing with Bitcoin now is considered a late entry, but it doesn't prevent us from understanding it. We don't aim to make money, just satisfy our curiosity.

So how do we play? First, we need a wallet. Previously, there were various trading platforms in China that didn't require us to install a wallet to trade. However, most of them have now been shut down, and it doesn't feel good to have our wallets controlled by others.

Why do we need to install the wallet in a Linux system? Because the Bitcoin wallet is large. How large? We'll talk about it below. Also, it needs to synchronize with the network nodes. When running the wallet for the first time, it needs to connect to the internet to synchronize data. The specific time depends on your computer's performance.

Taking my 4-core, 4GB RAM, 5MB bandwidth cloud server as an example: It took about two days to complete the synchronization. If you install it on your Windows 10, your computer needs to be on for two days and two nights, and the CPU will be occupied during the synchronization process. These two days, the computer won't be very pleasant to use, and most importantly, it will occupy your precious hard disk space o_o...

Without further ado, let's start teaching everyone how to install the wallet:
Personal opinion: I think Bitcoin, Ethereum, Monero, and other cryptocurrencies are too complicated. I advise beginners not to play with them. However, their blockchain technology is likely to be the future of the internet, at least a part of it.

Installing the Bitcoin Wallet (v0.21.0)#

Installing the Bitcoin Core full node requires 400GB of hard disk space. If there is not enough space, you can install the Bitcoin Core light node. We will discuss how to choose between a full node and a light node later. Using a light node requires approximately 7GB of hard disk space.

  1. Download Bitcoin
    https://bitcoincore.org/en/download/
wget https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
  1. Download and extract
tar xzf bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
  1. Install using the graphical interface
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.21.0/bin/*

/usr/local/bin/bitcoin-qt
  1. Installation is complete, start synchronizing blocks (at this point, you can close the GUI program and continue with command line operations)

Bitcoin Configuration#

  1. The default configuration directory for Bitcoin is ~/.bitcoin/bitcoin.conf. Fill in the following configuration:
# ~/.bitcoin/bitcoin.conf
datadir=/opt/btc/datadir
# Set the database cache size
dbcache=10240

# Transaction index txindex=1 represents a full node, not filling it means a light node
# txindex=1

# Enable pruning mode (https://bitcoin.org/en/full-node#reduce-storage)
prune=10240

# RPC access user
rpcuser=zhaoyang

# RPC access password
rpcpassword=zy980355088

# Run in the background
daemon=1
server=1
rest=1

rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts

# The following two lines are required for the Lightning Network
# Allow broadcasting raw block information on port 28332
zmqpubrawblock=tcp://127.0.0.1:28332
# Allow broadcasting raw transaction information on port 28333
zmqpubrawtx=tcp://127.0.0.1:28333

Command Usage Instructions#

Start Bitcoin

bitcoind -daemon

To stop Bitcoin, use the following command. Otherwise, it may cause data anomalies and require resynchronization of data.

bitcoin-cli stop

Some other commands

# Create a wallet
bitcoin-cli createwallet "zhaoyang"
# Generate a wallet address
bitcoin-cli getnewaddress "test"  #"test" is the account label entered
# Get all wallet addresses and their account names
bitcoin-cli listreceivedbyaddress 1 true
# Check network status:
bitcoin-cli getnetworkinfo
# Check network nodes:
bitcoin-cli getpeerinfo
# Check blockchain information, such as synchronization progress:
bitcoin-cli getblockchaininfo
# View all commands
bitcoin-cli help

After starting, the wallet will automatically synchronize blocks. You can open the log to view the specific synchronization progress.

tail -f nohup.out

Enter the Bitcoin installation directory

cd $HOME/.bitcoin
ls
banlist.dat  bitcoind.pid  blocks  chainstate  debug.log  peers.dat  wallets
ls wallets/
database  db.log  wallet.dat
bitcoind.pid bitcoind   Running process file
 
blocks  Blockchain data file
 
chainstate Database for storing blockchain state using LevelDB
 
db.log Database log file
 
debug.log Runtime log file
 
wallet.dat Wallet file (This is important, as it contains the private keys generated by our wallet. It is recommended to back it up daily using shell scripts or background programs.)

Wallet command introduction

bitcoin-cli getwalletinfo   View wallet details. In version 0.18, the previous getinfo command has been removed.
{
  "walletname": "",
  "walletversion": 169900,              Wallet version
  "balance": 0.00000000,                Wallet balance
  "unconfirmed_balance": 0.00000000,    Unconfirmed balance
  "immature_balance": 0.00000000,       This is currently unclear
  "txcount": 0,                         Number of transactions in the wallet
  "keypoololdest": 1562826486,          Earliest key creation time in the key pool
  "keypoolsize": 1000,                  Key pool size
  "keypoolsize_hd_internal": 1000,
  "paytxfee": 0.00000000,               Transaction fee rate (this is important, will be discussed separately later)
  "hdseedid": "ed13b2019c2e28e9dc84cf7124ba2e36cebcb656",
  "private_keys_enabled": true
}
 
bitcoin-cli getblockchaininfo   View blockchain details
{
  "chain": "main",
  "blocks": 238558,                     Current blocks in the wallet (After Bitcoin installation and startup, it usually takes 1-2 days to synchronize to the latest block height)
  "headers": 584893,                    Current latest block height
  ....  There is more information later, but we don't need to focus on it for now
}
 
bitcoin-cli sendtoaddress   Transfer interface (will be discussed in detail later)
Response:
1. "address"            (string, required) Receiving address
2. "amount"             (numeric or string, required) Transfer amount
 
Result:
"txid"                  (string) Unique identifier tx_id
 
Examples:
> bitcoin-cli sendtoaddress "bc1q7wuvm9q4s0gr9mtqtn2wamjx0462hg43g8h8ak" 0.1
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["bc1q7wuvm9q4s0gr9mtqtn2wamjx0462hg43g8h8ak", 0.1] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

GitHub Repository#

Official Website#

https://bitcoincore.org/en/download/

https://bitcoincore.org/bin/

Monero#

  1. Official Website (Download Wallet): https://www.getmonero.org/downloads/
  2. Download Mining Program: https://github.com/xmrig/xmrig/releases
  3. Mining Pool: mine.c3pool.com:13333
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.