Start regtest mode network cluster between Bitcoin and Omnilayer(USDT)
As we all know, omnicore is a fork of the bitcoin-core codebase. Few part of USDT was issued as ERC20 token in Ethereum platform, due to historical reasons, The most popularest stable coin usdt was build on omnilayer - TetherUS. If you guy work on cryptocurrency wallet as your bussiness, supporting USDT wallet is necessary way to attract more users. This article introduce how to start a regtest mode private network between bitcoin-core and omnicore client.
Why we need do that
Most people would say, switching between Omni Core and Bitcoin Core may be supported, each one can maintain a bitcoin chaindata for development. Yep! In most case you can. Omni protocol is build on and uses the Bitcoin Blockchain. As such, the omni core client is build over the bitcoin core codebase 0.13.2 at the beginning. There are many features have been updating in bitcoin-core since omnicore forked.
One of differences between bitcoincore and omnicore Like getblock
rpc method:
- Latest omnicore v0.3.1 second argument for getblock rpc method is boolean type: (boolean, optional, default=true) true for a json object, false for the hex encoded data
- Latest bitcoin-core 0.17.1 second argument for getblock rpc method is numeric type: (numeric, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data
bitcoin-core getblock rpc method accept numeric type verbosity argument, which is very usefull to iterator the detail transactions of a block. As such, we need start a regtest mode network between bitcoin and omnilayer client at the same time. Generating and accepting valid blcok between them.
How to start Bitcoin and OmniLayer regtest Model network cluster
Assume that you have instlled latest bitcoind
and omnicored
. run the following bash script to start the Network cluster:
cat ~/start-bitcoinregtest-network.sh
bitcoind --daemon -whitelist=127.0.0.1 -addnode=127.0.0.1:8332 -connect=127.0.0.1:8332 -server -listen -port=8331 -rpcuser=btcrpc -rpcpassword=123456 -rpcallowip=0.0.0.0/24 -rpcport=8431 -regtest=1 -addresstype=legacy -datadir=/home/ubuntu/bitcoin/regtest_btc
omnicored --daemon -server -listen -port=8332 -addnode=127.0.0.1:8331 -connect=127.0.0.1:8331 -rpcuser=btcrpc -rpcpassword=123456 -rpcallowip=0.0.0.0/24 -rpcport=8432 -regtest=1 -addresstype=legacy -datadir=/home/ubuntu/bitcoin/regtest_omni -txindex
./start-bitcoinregtest-network.sh
After do that, the processes of bitcoind and omnicored running as we expected, is everything work as normal? Let's generate some mined blocks to verify that does omnicore and bitcoind can broadcast block between each other.
# omnicore generate block, bitcoind accept block
ERROR: ProcessNewBlock: AcceptBlock FAILED (bad-witness-nonce-size, ContextualCheckBlock : invalid witness reserved value size (code 16))
ERROR: AcceptBlock: bad-witness-nonce-size, ContextualCheckBlock : invalid witness reserved value size (code 16)
# bitcoind generate block, omnicored accept block
ERROR: ContextualCheckBlock : unexpected witness data found
ERROR: AcceptBlock: unexpected-witness (code 16)
What's wrong with that, bitcoind and omnicored mined block is incompatible with each other in regtest mode.
As the above log show that, I think it was caused by segwit, getblockchaininfo
I figure out bitcoind segwit is actived, on the contray the omnicored is not. After doing reaching by Google, I found out before 0.16.0 the segwit is actived at least 432 blocks in regtest mode, as omnicore was 0.13.2 codebase of bitcoin core, segwit actived rule follow the same. The importance is that, after 0.16.0, segwit was actived default in regtest mode. See the pull request: Support having SegWit always active in regtest (sipa, ajtowns, jnewbery) . To sum up: the latest bitcoin-core segwit is actived by default but omnicore is actived until until 432 blocks was mined.
There are two ways we can do to start regtest mode network cluster between Bitcoin and Omnilayer:
- Modify omnicore, active segwit by default in regtest Model
- Bitcoin core downgrade to 0.15.2, closest release to 0.16.0
downgrade to 0.15.2, restart bitcoin and omnicore cluster:
ubuntu@10-8-36-35:~$ cat start-bitcoinregtest-network.sh
/home/ubuntu/code/bitcoin-0.15.2/bin/bitcoind --daemon -whitelist=127.0.0.1 -addnode=127.0.0.1:8332 -connect=127.0.0.1:8332 -server -listen -port=8331 -rpcuser=btcrpc -rpcpassword=123456 -rpcallowip=0.0.0.0/24 -rpcport=8431 -regtest=1 -addresstype=legacy -datadir=/home/ubuntu/bitcoin/regtest_btc
/home/ubuntu/code/omnicore-0.3.1/bin/omnicored --daemon -server -listen -port=8332 -addnode=127.0.0.1:8331 -connect=127.0.0.1:8331 -rpcuser=btcrpc -rpcpassword=123456 -rpcallowip=0.0.0.0/24 -rpcport=8432 -regtest=1 -addresstype=legacy -datadir=/home/ubuntu/bitcoin/regtest_omni -txindex