BTC搭建钱包节点

2019-08-05  本文已影响0人  Pecksniff1994

服务器配置

节点设置

tar -xzvf bitcoin-0.16.1-x86_64-linux-gnu.tar.gz -C /usr/local
# This config should be placed in following path:
# ~/.bitcoin/bitcoin.conf 
# [core]
# Specify a non-default location to store blockchain and other data.
datadir=/data/btc_data
# 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=10240
# Maintain a full transaction index, used by the getrawtransaction rpc call.
txindex=1 

# [rpc]
# Enable Add Witness Address RPC 

deprecatedrpc=addwitnessaddress 

# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1
# 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=127.0.0.1:8332 

rpcuser=btcuser
rpcpassword=btcpassword 

# rpcallowip=0.0.0.0
bitcoind -daemon
bitcoin-cli stop
# 查看网络状态:
bitcoin-cli getnetworkinfo
# 查看网络节点:
bitcoin-cli getpeerinfo
# 查看区块链信息:如同步进度、
bitcoin-cli getblockchaininfo
# 查看所有命令
bitcoin-cli help
> #环境 ubuntu 16.4
> #硬盘500GB
> #截止2018-12-31磁盘占用超过230GB

### #客户端安装

 #下载页面
 #https://bitcoin.org/zh_CN/download

cd /opt/
wget https://bitcoin.org/bin/bitcoin-core-0.17.0.1/bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz

 #解压,软连接
tar zxf bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
ln -fs /opt/bitcoin-0.17.0 /opt/bitcoin
ln -fs /opt/bitcoin-0.17.0/bin/bitcoind /usr/local/bin/bitcoind
ln -fs /opt/bitcoin-0.17.0/bin/bitcoin-cli /usr/local/bin/bitcoin-cli


### #创建配置

mkdir -p /data/btc_data
mkdir ~/.bitcoin
vim ~/.bitcoin/bitcoin.conf

 # ~/.bitcoin/bitcoin.conf
datadir=/data/btc_data
dbcache=10240
txindex=1
rpcuser=btc
rpcpassword=btc2018
daemon=1
server=1
rest=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts


### #后台启动

bitcoind -daemon

### #关闭

bitcoin-cli stop

### #查看区块链同步

bitcoin-cli getblockchaininfo
bitcoin-cli getmininginfo

> #区块浏览器
> # [https://btc.com/](https://btc.com/)

### # rpc api访问

#curl访问rpc测试
curl -s -X POST --user btc:btc2018  \
  -H 'content-type: text/plain;' http://127.0.0.1:8332/ \
  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' 
#查询最新区块高度
curl -s -X POST --user btc:btc2018  \
  -H 'content-type: text/plain;' http://127.0.0.1:8332/ \
  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' \
  |awk -F '[:,]' '{print $3}'


### #配置参数

rpcuser     远程访问的认证用户
rpcpassword 远程访问密码
daemon      在后台运行
rpcallowip  远程访问的ip或网段
txindex     所有交易进行索引;否则只保留钱包地址交易索引记录  
deprecatedrpc=accounts 启用账户"account"API ,V0.18版将被完全移除,新版"标签-label"API

> #注意事项
> #关闭后,再次启动时报错
> #Cannot obtain a lock on wallet directory
> #删除data目录.lock文件后,再次启动
> #不配置datadir时,默认保存在 ~/.bitcoin/
以centos为例,其环境安装顺序:安装nodejs -> 安装zeromq -> 安装bitcore

硬盘最好在500G以上,比特币节点较大。

安装nodejs自行百度~

安装zeromq之前,必须保证安装了如下依赖:

yum install libtool

yum install gcc

yum install gcc-c++

yum install make

 

yum install autoconfig

yum install automake

然后进行源码安装zeromq:

 

wget https://github.com/zeromq/zeromq4-1/releases/download/v4.1.5/zeromq-4.1.5.tar.gz

tar zxf zeromq-4.1.5.tar.gz

cd zeromq-4.1.5

./configure

make && make install

安装bitcore(注:国内服务器会被墙,因为需要请求亚马逊服务器,请自行设置代理或者使用国外服务器)

npm install -g bitcore

不用使用root权限安装,否则会出现下载时权限不足的错误。

启动节点:

./bitcored
上一篇 下一篇

猜你喜欢

热点阅读