节点运维

The Devops documentation.

节点运维文档

信托自建比特币全节点的参考

建议信托节点使用自己搭建的比特币全节点, 推荐的机器配置不低于: CPU 2 核, 内存 4G, SSD 硬盘 500G.

下载最新版本的 bitcoin 二进制包

直接在 bitcoin.org 下载最新版本的 bitcoin 二进制包(或者直接通过发行版的包管理器下载最新的 bitcoin 包),解压并创建软链接

# 指定下载目录
$ cd /opt
# 下载
$ wget https://bitcoin.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-x86_64-linux-gnu.tar.gz
# 解压
$ tar zxvf bitcoin-0.20.1-x86_64-linux-gnu.tar.gz
# 建立软链接
$ ln -fs /opt/bitcoin-0.20.1 /opt/bitcoin
$ ln -fs /opt/bitcoin-0.20.1/bin/bitcoind /usr/local/bin/bitcoind
$ ln -fs /opt/bitcoin-0.20.1/bin/bitcoin-cli /usr/local/bin/bitcoin-cli

创建指定的 data 和 wallets 目录

或者使用默认路径 ~/.bitcoin/data~/.bitcoin/wallets

$ mkdir -p /mnt/bitcoin-mainnet/data
$ mkdir -p /mnt/bitcoin-mainnet/wallets

创建配置文件

或者使用默认路径 ~/.bitcoin/bitcoin.conf

$ touch /mnt/bitcoin-mainnet/bitcoin.conf
$ vim /mnt/bitcoin-mainnet/bitcoin.conf
# Generated by https://jlopp.github.io/bitcoin-core-config-generator/

# [core]
# Set database cache size in megabytes; machines sync faster with a larger cache.
# Recommend setting as high as possible based upon machine's available RAM.
dbcache=4096

# Keep the transaction memory pool below <n> megabytes.
maxmempool=256

# Do not keep transactions in the mempool longer than <n> hours.
mempoolexpiry=12

# Maintain a full transaction index, used by the getrawtransaction rpc call.
txindex=1

# [network]

# [debug]
# Enable debug logging for all categories.
#debug=1

# Log IP Addresses in debug output.
logips=1

# Log timestamps with microsecond precision.
logtimemicros=1

# [relay]
# Maximum size of data in OP_RETURN outputs we relay and mine.
datacarriersize=82

# Fee rates (in BTC/kB) smaller than this are considered zero fee for relaying, mining and transaction creation.
minrelaytxfee=0.000001

# [mining]
# Set lowest fee rate (in BTC/kB) for transactions to be included in block creation.
blockmintxfee=0.000001

# [rpc]
# Enable Accounts RPC
deprecatedrpc=accounts

# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1

# Username and hashed password for JSON-RPC connections.
# The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>.
# RPC clients connect using rpcuser=<USERNAME>/rpcpassword=<PASSWORD> arguments.
# You can generate this value with the share/rpcauth/rpcauth.py script in the Bitcoin Core repository.
# This option can be specified multiple times.
rpcuser=远程访问的认证用户
rpcpassword=远程访问密码

# Allow JSON-RPC connections from specified source.
# Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).
# This option can be specified multiple times.
# 远程访问的ip或网段 建议指定ip范围,不允许陌生ip访问
rpcallowip=0.0.0.0/0

# Set the number of threads to service RPC calls
rpcthreads=16

# [wallet]

# [Sections]
# Most options automatically apply to mainnet, testnet, and regtest networks.
# If you want to confine an option to just one network, you should add it in the relevant section.
# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.

# Options only for mainnet
[main]
# [core]
# Specify a non-default location to store blockchain data.
blocksdir=/mnt/bitcoin-mainnet/data
# Specify a non-default location to store blockchain and other data.
datadir=/mnt/bitcoin-mainnet/data

# [network]
# Listen for incoming connections on non-default port.
port=8333

# [debug]
# Location of the debug log
debuglogfile=/mnt/bitcoin-mainnet/data/debug.log

# [rpc]
# Bind to given address to listen for JSON-RPC connections.
# This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6.
# This option can be specified multiple times. (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)
rpcbind=0.0.0.0
# Listen for JSON-RPC connections on this port
rpcport=8332

# [wallet]
# Specify a non-default location to store wallet data.
walletdir=/mnt/bitcoin-mainnet/wallets

# Options only for testnet
[test]

# Options only for regtest
[regtest]

启动和停止比特币全节点

# 启动
$ bitcoind -conf=/mnt/bitcoin-mainnet/bitcoin.conf -daemon
# 停止
$ bitcoin-cli -conf=/mnt/bitcoin-mainnet/bitcoin.conf stop

测试比特币节点 rpc 服务

$ curl -s -X POST --user rpcuser:rpcpassword -H 'content-type: text/plain;' http://127.0.0.1:8332/ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }'

导入信托冷热多签地址

往钱包导入信托冷热多签地址 每当信托换届或者信托冷热多签地址更换时,需要运维人员将更换的新地址导入到钱包,以便信托节点在使用 ChainX Wallet 构造提现交易时可以获取到该地址的 UTXO 列表。导入命令如下:

$ bitcoin-cli -conf=/mnt/bitcoin-mainnet/bitcoin.conf importaddress 比特币地址 "" true
最后修改 21.04.2022: update (4a1b36b)