您当前的位置: 首页 > 
  • 3浏览

    0关注

    212博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

omn core 测试网部署

杰哥的技术杂货铺 发布时间:2021-04-09 14:22:59 ,浏览量:3

文章目录
  • 一、镜像生成
  • 二、容器生成
  • 三、查看服务是否部署成功
  • 四、获取测试币
官方rpc文档:https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md#omni_sendcanceltradesbypair

一、镜像生成
  • 1.下载基础镜像
# docker pull buildpack-deps:jessie-curl
  • 2.编写Dockerfile
# vim Dockerfile 

FROM buildpack-deps:jessie-curl
RUN wget -O omnicore.tar.gz https://github.com/OmniLayer/omnicore/releases/download/v0.9.0/omnicore-0.9.0-x86_64-linux-gnu.tar.gz \
        && tar -xzvf omnicore.tar.gz \
        && cd omnicore-0.9.0/bin \
        && mv bitcoin-tx omnicore-cli omnicored omnicore-qt  /usr/local/bin \
        && apt-get update \
        && apt-get install net-tools \
        && cd / \
        && rm -Rfv omnicore*
EXPOSE 18333 18332
WORKDIR /root/.bitcoin
ENTRYPOINT ["omnicored"]
  • 3.生成镜像
# docker build . -t btc/omnicore:0.9.0
二、容器生成
  • 1.创建数据目录
# mkdir /opt/docker/omni-testnet/data/ -p
  • 2.启动容器
docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name omni-testnet -v $(pwd)/data:/root/.bitcoin/testnet3 -p 18332:18332 -p 18333:18333 btc/omnicore:0.9.0 -testnet=1 -server=1 -rpcuser=admin -rpcpassword=123456  -logtimestamps=1  -txindex=1 -omnidebug=tally -omnidebug=packets -omnidebug=pending -paytxfee=0.0005 -deprecatedrpc=generate -rpcworkqueue=1000 -rpcport=18332 -rpcallowip=0.0.0.0/0 -port=18333 -rpcbind=0.0.0.0:18332

参数解释

-testnet=1            同步比特币测试网数据
-server=1             启动JSON-RPC接口
-rpcuser              JSON-RPC 连接使用的用户名
-rpcpassword          JSON-RPC 连接使用的密码
-txindex=1             表示对所有的交易进行索引;否则默认只对与钱包地址有关的交易索引 
-logtimestamps=1       添加隔离见证地址
-omnidebug=pending     启用或禁用日志类别,可以"all","none",可不写
-paytxfee              交易手续费率
三、查看服务是否部署成功
  • 1.查看容器是否成功启动
# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                                      NAMES
dba702b3d725        btc/omnicore:0.9.0           "omnicored -testnet=…"   14 seconds ago      Up 14 seconds       0.0.0.0:28332->8332/tcp, 0.0.0.0:28333->8333/tcp                           omni-testnet
  • 2.查看服务启动日志是否正常
# tail -f /opt/docker/omni-testnet/data/debug.log 
2021-04-06T07:44:11Z Omni Core version v0.9.0 (release build)
2021-04-06T07:44:11Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures.
2021-04-06T07:44:11Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463
  • 3.同步区块数据 (同步时间根据自身节点配置决定)
)
2021-04-06T07:45:51Z UpdateTip: new best=000000000026cdb17c180e638925c845c783d4577d8f6f2751eaba6aa9bcf62f height=688183 version=0x00000004 log2_work=66.907597 tx=9384527 date='2016-02-12T22:46:50Z' progress=0.128331 cache=0.3MiB(1637txo)
2021-04-06T07:45:51Z UpdateTip: new best=00000000074dba665e436fc99cd20394e4d5626422db6c7231baa381309e27fd height=688184 version=0x00000004 log2_work=66.907597 tx=9384528 date='2016-02-12T22:46:43Z' progress=0.128331 cache=0.3MiB(1638txo)
2021-04-06T07:45:51Z UpdateTip: new best=000000001b548da0241b4118e7754f3e6a85206c6bb080aad4adef0458a5c151 height=688185 version=0x00000004 log2_work=66.907597 tx=9384529 date='2016-02-12T22:46:44Z' progress=0.128331 cache=0.3MiB(1639txo)
2021-04-06T07:45:51Z UpdateTip: new best=000000001305c1028c421165e5b7f3ff5d2c9dd20b2ff25aca2e1ae1bc51f581 height=688186 version=0x00000004 log2_work=66.907597 tx=9384530 date='2016-02-12T22:46:45Z' progress=0.128331 cache=0.3MiB(1640txo)
四、获取测试币

待节点同步完成后,开始以下步骤(截止2021年4月9日,测试网数据约为:34G)

  • 4.1 创建地址
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["mytest"] }' -H 'content-type: text/plain;' http://127.0.0.1:28332/
{"result":"2MwZ1HT4LwNcmu1Jo22Qg211bWUdDaworVQ","error":null,"id":"curltest"}

指定了账户名称为 mytest,命令会返回账户地址信息。

  • 4.2 获取测试币 先给账户充一些测试比特币,需要使用水龙头网站,当前测试以下网站可用:

  • https://testnet.coinfaucet.eu/en/

  • https://bitcoinfaucet.uo1.net/

以下是从上面两个网站获取到的比特币

交易哈希1:1d4d51532962f4bb461c11a2068a769c56d480c78e2d43fa0686d9d7308ddcef
获取金额:0.01675209 tBTC

交易哈希2:240a2f41bb8a7eb216462ef0ea38e28264598a5057bb1cadf46671f2ac13d5df
获取金额:0.00089 tBTC

以上交易哈希也可以在比特币测试浏览器中进行查询:https://blockstream.info/testnet/

  • 4.3 查询交易哈希
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "gettransaction", "params": ["1d4d51532962f4bb461c11a2068a769c56d480c78e2d43fa0686d9d7308ddcef"] }' -H 'content-type: text/plain;' http://127.0.0.1:28332/
  • 4.4 查询钱包总余额
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbalance", "params": [] }' -H 'content-type: text/plain;' http://localhost:28332
{"result":0.01764209,"error":null,"id":"curltest"}
  • 4.5 查看拥有btc余额的地址
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listaddressgroupings", "params": [] }' -H 'content-type: text/plain;' http://localhost:28332
{"result":[[["2MwZ1HT4LwNcmu1Jo22Qg211bWUdDaworVQ",0.01764209,"mytest"]]],"error":null,"id":"curltest"}
  • 4.6 omni_usdt测试币获取

这时我们有了测试比特币,需要给moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP转一些测试比特币,然后会自动收到测试的 omni 币,如下:

# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP", 0.001] }' -H 'content-type: text/plain;' http://127.0.0.1:28332
{"result":"a959ddb9ddff47be831f3cd488817a11cec1b1b6c08b36f61082fb8c0b16c18e","error":null,"id":"curltest"}

再次获取:

# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP", 0.01] }' -H 'content-type: text/plain;' http://127.0.0.1:28332
{"result":"743e56d331aef8a820c768a24e047f8f804dd51071f907f7db547f2026d7c1bc","error":null,"id":"curltest"}

注:通过以上的两笔btc转账兑换omni_usdt,得到结果:1、转出btc时,不确定转出的地址是哪个,所以需要通过交易哈希查看from地址,因为omni_usdt会转到此地址中;2、0.01 BTC可兑换 1 omni_usdt; 3、btc转出后,需等待交易上链后,才能获得omni_usdt

  • 4.7 omni_usdt转账

现在我们将2MwZ1HT4LwNcmu1Jo22Qg211bWUdDaworVQ的0.1 omni_usdt转给2MuBZ3uREYdWkXSpACxykvY3sbAWLYAb3M6

# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "omni_send", "params": ["2MwZ1HT4LwNcmu1Jo22Qg211bWUdDaworVQ","2MuBZ3uREYdWkXSpACxykvY3sbAWLYAb3M6",2,"0.1"] }' -H 'content-type: text/plain;' http://127.0.0.1:28332
{"result":"8536e9a0db07afb1c909ef5c61e135ed6a7a13d01eaa38f8380a4df7b6b65263","error":null,"id":"curltest"}

参数解释

from地址:2MwZ1HT4LwNcmu1Jo22Qg211bWUdDaworVQ
to地址:2MuBZ3uREYdWkXSpACxykvY3sbAWLYAb3M6
chain ID:2 (测试网)
amount:0.1 
  • 4.8 查看omni_usdt余额
#  curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "omni_getbalance", "params": ["2MuBZ3uREYdWkXSpACxykvY3sbAWLYAb3M6",2] }' -H 'content-type: text/plain;' http://127.0.0.1:28332
{"result":{"balance":"1.10000000","reserved":"0.00000000","frozen":"0.00000000"},"error":null,"id":"curltest"}
关注
打赏
1666063422
查看更多评论
立即登录/注册

微信扫码登录

0.0382s