比特币私有链集群环境部署及omni usdt代币创建
mkdir /opt/docker/usdt-image/0.11
cd /opt/docker/usdt-image/0.11
# vim Dockerfile
FROM buildpack-deps:jessie-curl
RUN wget -O omnicore.tar.gz https://github.com/OmniLayer/omnicore/releases/download/v0.11.0/omnicore-0.11.0-x86_64-linux-gnu.tar.gz \
&& tar -xzvf omnicore.tar.gz \
&& cd omnicore-0.11.0/bin \
&& mv bitcoin-tx omnicore-cli omnicored omnicore-qt /usr/local/bin \
&& apt-get update \
&& apt-get install net-tools
EXPOSE 8333 8332
WORKDIR /root/.bitcoin
ENTRYPOINT ["omnicored"]
# cat build.sh
#!/bin/bash
docker build . -t btc/omnicore:0.11.0
# ./build.sh
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
btc/omnicore 0.11.0 4ad861a48bbe 4 hours ago 295MB
mkdir /opt/docker/usdt-0.8-1
cd /opt/docker/usdt-0.8-1
mkdir data
# cat run.sh
#!/bin/bash
docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name usdt-0.11-1 -v $(pwd)/data:/root/.bitcoin -p 8332:8332 -p 8333:8333 btc/omnicore:0.11.0 -regtest=1 -server=1 -rpcuser=admin -rpcpassword=123456 -logtimestamps=1 -txindex=1 -omnidebug=tally -omnidebug=packets -omnidebug=pending -paytxfee=0.0002 -deprecatedrpc=generate -rpcworkqueue=1000 -addnode=192.168.1.3:18333 -rpcport=8332 -rpcallowip=0.0.0.0/0 -port=8333 -rpcbind=0.0.0.0:8332
注:
regtest=1 以私有链模式运行
server=1 启动JSON-RPC接口
rpcuser 远程访问的认证用户
rpcpassword 远程访问密码
txindex=1 所有交易进行索引;否则只保留钱包地址交易索引记录
paytxfee 每次发送比特币时的交易费率
deprecatedrpc=generate 启用挖矿
rpcworkqueue=1000 一个工作队列能够容纳的请求数量,默认是16个
daemon 在后台运行
rpcallowip 远程访问的ip或网段
rpcport rpc接口的监听端口
rpcallowip rpc访问白名单
port p2p监听端口
rpcbind rpc接口的监听地址,默认绑定到所有IP
/opt/docker/usdt-0.11-1/run.sh
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f40676a3835d btc/omnicore:0.11.0 "omnicored -regtest=…" 2 seconds ago Up 1 second 0.0.0.0:8332-8333->8332-8333/tcp, :::8332-8333->8332-8333/tcp usdt-0.11-1
mkdir /opt/docker/usdt-0.11-2
cd /opt/docker/usdt-0.11-2
mkdir data
# cat run.sh
#!/bin/bash
docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name usdt-0.11-2 -v $(pwd)/data:/root/.bitcoin -p 18332:8332 -p 18333:8333 btc/omnicore:0.11.0 -regtest=1 -server=1 -rpcuser=admin -rpcpassword=123456 -logtimestamps=1 -txindex=1 -omnidebug=tally -omnidebug=packets -omnidebug=pending -paytxfee=0.0002 -deprecatedrpc=generate -rpcworkqueue=1000 -listen=0 -connect=192.168.1.3:8333 -rpcport=18332 -rpcallowip=0.0.0.0/0 -port=18333 -rpcbind=0.0.0.0:8332 -rpcbind=0.0.0.0:8333
/opt/docker/usdt-0.8-2/run.sh
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aa0ab14d90a0 btc/omnicore:0.11.0 "omnicored -regtest=…" 3 seconds ago Up 2 seconds 0.0.0.0:18332->8332/tcp, :::18332->8332/tcp, 0.0.0.0:18333->8333/tcp, :::18333->8333/tcp usdt-0.11-2
// 创建地址
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["test"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":"2NEyUD5nGJmNKKzvoXiXKstSRLBetEXVCHr","error":null,"id":"curltest"}
//挖矿
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "generatetoaddress", "params": [6,"2NEyUD5nGJmNKKzvoXiXKstSRLBetEXVCHr"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":["3fc3f75c7cdcb753696bdc3337b8569760aaab74568d5d50c6f8e7a57d4c1905","0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54","1cccdcf72b17d7530b84156d5db75f787a2c9ffa41fcf41f8a0d7b1681f87240","4a988d2e16fd176f67bd1c3e87f8b27d83a553457016a6e106b1a3b8406f7d11","5bd634ba3b2f3a74d775bcfad795bc557f741b65808f0d3967d9157346299e2a","173fd1b63f249f38a2746f4d89cc15f77c3d71c5bcde872ea39578f14eee8a30"],"error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
{"result":6,"error":null,"id":"curltest"}
#获取指定高度的区块哈希:
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockhash", "params": [2] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":"0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54","error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockhash", "params": [2] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
{"result":"0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54","error":null,"id":"curltest"}
#查询指定区块哈希的区块信息
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":{"hash":"0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54","confirmations":5,"strippedsize":214,"size":250,"weight":892,"height":2,"version":536870912,"versionHex":"20000000","merkleroot":"c678533eaf04484b2e485479af1d525716fdb95c595a3261b3608cefa6ff0d85","tx":["c678533eaf04484b2e485479af1d525716fdb95c595a3261b3608cefa6ff0d85"],"time":1646035694,"mediantime":1646035693,"nonce":0,"bits":"207fffff","difficulty":4.656542373906925e-10,"chainwork":"0000000000000000000000000000000000000000000000000000000000000006","nTx":1,"previousblockhash":"3fc3f75c7cdcb753696bdc3337b8569760aaab74568d5d50c6f8e7a57d4c1905","nextblockhash":"1cccdcf72b17d7530b84156d5db75f787a2c9ffa41fcf41f8a0d7b1681f87240"},"error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
{"result":{"hash":"0c0f84987d48383e42c2fda6dfc7ea555de17472cf8ca6e86c7d7d92031e6d54","confirmations":5,"strippedsize":214,"size":250,"weight":892,"height":2,"version":536870912,"versionHex":"20000000","merkleroot":"c678533eaf04484b2e485479af1d525716fdb95c595a3261b3608cefa6ff0d85","tx":["c678533eaf04484b2e485479af1d525716fdb95c595a3261b3608cefa6ff0d85"],"time":1646035694,"mediantime":1646035693,"nonce":0,"bits":"207fffff","difficulty":4.656542373906925e-10,"chainwork":"0000000000000000000000000000000000000000000000000000000000000006","nTx":1,"previousblockhash":"3fc3f75c7cdcb753696bdc3337b8569760aaab74568d5d50c6f8e7a57d4c1905","nextblockhash":"1cccdcf72b17d7530b84156d5db75f787a2c9ffa41fcf41f8a0d7b1681f87240"},"error":null,"id":"curltest"}
注:挖矿所得的coinbase交易中的奖励必须要在100个区块深度之后才能花费。 即节点中必须要至少100块以后,才会显示余额
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["test"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
{"result":"2NFzDPvsyzpsTxNfPicRVHG6seT9n8UN6yV","error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["2NFzDPvsyzpsTxNfPicRVHG6seT9n8UN6yV", 0.5] }' -H 'content-type: te...
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!