比特币私有链集群环境部署及omni usdt代币创建

  • 时间:
  • 浏览:61
  • 来源:区块链技术网

一、omni usdt私有链集群环境部署

1.1 omni usdt 镜像构建

  • omni usdt 镜像Dockerfile编写
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
  • omni usdt 镜像构建
# ./build.sh
  • 查看生成后的omni usdt镜像
# docker images
REPOSITORY           TAG           IMAGE ID       CREATED         SIZE
btc/omnicore         0.11.0        4ad861a48bbe   4 hours ago     295MB

1.2 omni usdt节点1部署

  • 数据目录创建
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

1.3 omni usdt节点2部署

  • 数据目录创建
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

二、omni usdt私有链集群环境验证

2.1 数据同步验证

  • 在节点1中进行挖矿
// 创建地址
# 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"}
  • 节点2获取区块高度
# 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块以后,才会显示余额

2.2 转账交易验证

  • 在节点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:18332/
{"result":"2NFzDPvsyzpsTxNfPicRVHG6seT9n8UN6yV","error":null,"id":"curltest"}
  • 从节点1的钱包中向节点2地址转账

# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["2NFzDPvsyzpsTxNfPicRVHG6seT9n8UN6yV", 0.5] }' -H 'content-type: te...

猜你喜欢

零时科技 | OMNI遭到黑客攻击,损失超1300ETH

0x1事件背景OMNI是一个用于创建和交易自定义数字资产和货币的平台。零时科技区块链安全情报平台监控到消息,北京时间2022年7月10日,OMNI遭到黑客攻击,损失超1300E

2022-07-30

重入攻击+闪电贷—NFT金融协议Omni被黑事件分析

重入攻击+闪电贷—NFT金融协议Omni被黑事件分析7月10日,NFT金融协议Omni因智能合约漏洞遭到黑客闪电贷攻击,耗尽了1300ETH,损失约143万美元。近期NFT流动

2022-07-30

Omni Core v0.11.0 rpc-api

JSON-RPCAPIOmniCore是BitcoinCore的一个分支,在上面添加了Omni协议功能支持作为一个新的功能层。因此,与API的交互以与比特币核心相同的方式(JS

2022-07-30

比特币私有链集群环境部署及omni usdt代币创建

一、omniusdt私有链集群环境部署1.1omniusdt镜像构建omniusdt镜像Dockerfile编写mkdir/opt/docker/usdt-image/0.11

2022-07-30

科普—下USDT三兄弟OMNI、ERC-20、TRC-20的相同和不同之处!

很多新人玩家每次充提币的时候,都是一脸懵逼,为何同是usdt,却又有不同的代币,不知如何下手才好,那么我今天就在这里给大家科普一下关于usdt三兄弟的最基本常识,不懂的可以收藏

2022-07-30