From e9e5e80b527cfb26b6cae9b5d1875886a379d4dd Mon Sep 17 00:00:00 2001 From: Aleksander Kochetkov Date: Tue, 8 Feb 2022 16:35:15 +0300 Subject: [PATCH] Initial commit --- .gitignore | 1 + blockbook.json | 9 ++++++ blockbook2.json | 9 ++++++ docker-compose.yaml | 74 +++++++++++++++++++++++++++++++++++++++++++++ step1.sh | 11 +++++++ step2.sh | 3 ++ step3.sh | 3 ++ step4.sh | 8 +++++ step5.sh | 15 +++++++++ step6.sh | 4 +++ step7.sh | 8 +++++ 11 files changed, 145 insertions(+) create mode 100644 .gitignore create mode 100644 blockbook.json create mode 100644 blockbook2.json create mode 100644 docker-compose.yaml create mode 100755 step1.sh create mode 100755 step2.sh create mode 100644 step3.sh create mode 100755 step4.sh create mode 100755 step5.sh create mode 100755 step6.sh create mode 100755 step7.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/blockbook.json b/blockbook.json new file mode 100644 index 0000000..428004d --- /dev/null +++ b/blockbook.json @@ -0,0 +1,9 @@ +{ + "coin_name": "Regtest", + "coin_shortcut": "rBTC", + "coin_label": "Bitcoin Regtest", + "rpc_url": "http://bitcoin:18443", + "rpc_user": "btc", + "rpc_pass": "btc", + "message_queue_binding": "tcp://bitcoin-blockbook:48321" +} diff --git a/blockbook2.json b/blockbook2.json new file mode 100644 index 0000000..f33c397 --- /dev/null +++ b/blockbook2.json @@ -0,0 +1,9 @@ +{ + "coin_name": "Regtest", + "coin_shortcut": "rBTC", + "coin_label": "Bitcoin Regtest", + "rpc_url": "http://bitcoin2:18443", + "rpc_user": "btc", + "rpc_pass": "btc", + "message_queue_binding": "tcp://bitcoin-blockbook2:48321" +} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9308c09 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,74 @@ +version: "3" + +services: + + bitcoin: + image: ruimarinho/bitcoin-core:alpine + ports: + - "18443:18443" + command: + -printtoconsole + -regtest + -rpcauth='btc:9cd88b070f00d57a0bdbfbcc31cb0008$$7d80d4fca52cfc293b2311933b8a9d83dbdbc773a228c6dcf0b34743d9efb146' + -fallbackfee=0.00001 + -rpcallowip=0.0.0.0/0 + -rpcbind=0.0.0.0 + + bitcoin2: + image: ruimarinho/bitcoin-core:alpine + ports: + - "28443:18443" + command: + -printtoconsole + -regtest + -rpcauth='btc:9cd88b070f00d57a0bdbfbcc31cb0008$$7d80d4fca52cfc293b2311933b8a9d83dbdbc773a228c6dcf0b34743d9efb146' + -fallbackfee=0.00001 + -rpcallowip=0.0.0.0/0 + -rpcbind=0.0.0.0 + + bitcoin-explorer: + image: getumbrel/btc-rpc-explorer:v3.1.1 + ports: + - "3001:3002" + environment: + - BTCEXP_HOST=0.0.0.0 + - BTCEXP_BITCOIND_HOST=bitcoin + - BTCEXP_BITCOIND_PORT=18443 + - BTCEXP_BITCOIND_USER=btc + - BTCEXP_BITCOIND_PASS=btc + - BTCEXP_BITCOIND_RPC_TIMEOUT=5000 + - BTCEXP_BASIC_AUTH_PASSWORD=btc + + + bitcoin-explorer2: + image: getumbrel/btc-rpc-explorer:v3.1.1 + ports: + - "3002:3002" + environment: + - BTCEXP_HOST=0.0.0.0 + - BTCEXP_BITCOIND_HOST=bitcoin2 + - BTCEXP_BITCOIND_PORT=18443 + - BTCEXP_BITCOIND_USER=btc + - BTCEXP_BITCOIND_PASS=btc + - BTCEXP_BITCOIND_RPC_TIMEOUT=5000 + - BTCEXP_BASIC_AUTH_PASSWORD=btc + + bitcoin-blockbook: + image: kochetkov/blockbook:dev + restart: always + depends_on: + - bitcoin + ports: + - "9130:9130" + volumes: + - ./blockbook.json:/opt/blockbook/blockchaincfg.json + + bitcoin-blockbook2: + image: kochetkov/blockbook:dev + restart: always + depends_on: + - bitcoin + ports: + - "9131:9130" + volumes: + - ./blockbook2.json:/opt/blockbook/blockchaincfg.json diff --git a/step1.sh b/step1.sh new file mode 100755 index 0000000..16188ca --- /dev/null +++ b/step1.sh @@ -0,0 +1,11 @@ +# Init 3 wallets, generate 2 addresses + +curl -d '{"jsonrpc":"2.0","id":"1","method":"createwallet", "params": ["w1"]}' -u btc:btc localhost:18443 +curl -d '{"jsonrpc":"2.0","id":"1","method":"createwallet", "params": ["w2"]}' -u btc:btc localhost:18443 +curl -d '{"jsonrpc":"2.0","id":"1","method":"createwallet", "params": ["w3"]}' -u btc:btc localhost:28443 + +btc=$(curl -d '{"jsonrpc":"2.0","id":"1","method":"getnewaddress", "params": []}' -u btc:btc localhost:18443/wallet/w1 | jq .result) +btc2=$(curl -d '{"jsonrpc":"2.0","id":"1","method":"getnewaddress", "params": []}' -u btc:btc localhost:18443/wallet/w2 | jq .result) + +echo "BTC mining: ${btc}" +echo "BTC second: ${btc2}" diff --git a/step2.sh b/step2.sh new file mode 100755 index 0000000..dbe940e --- /dev/null +++ b/step2.sh @@ -0,0 +1,3 @@ +# Create first 110 blocks + +curl -d '{"jsonrpc":"2.0","id":"1","method":"generatetoaddress", "params":[110, "ADDRESS_HERE"]}' -u btc:btc localhost:18443/wallet/w1 diff --git a/step3.sh b/step3.sh new file mode 100644 index 0000000..872b55f --- /dev/null +++ b/step3.sh @@ -0,0 +1,3 @@ +# sendtoaddress + +curl -d '{"jsonrpc":"2.0","id":"1","method":"sendtoaddress", "params":["ADDRESS2_HERE", 0.123]}' -u btc:btc localhost:18443/wallet/w1 diff --git a/step4.sh b/step4.sh new file mode 100755 index 0000000..a4fbc9c --- /dev/null +++ b/step4.sh @@ -0,0 +1,8 @@ +# connect nodes and sync + +curl -d '{"jsonrpc":"2.0","id":"1","method":"addnode", "params":["bitcoin:18444", "add"]}' -u btc:btc localhost:28443 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getaddednodeinfo", "params":[]}' -u btc:btc localhost:28443 | jq + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getpeerinfo", "params":[]}' -u btc:btc localhost:28443 | jq + diff --git a/step5.sh b/step5.sh new file mode 100755 index 0000000..7d1bdc2 --- /dev/null +++ b/step5.sh @@ -0,0 +1,15 @@ +# disconnect and sendtoaddress (this will be forked in next steps) + +curl -d '{"jsonrpc":"2.0","id":"1","method":"addnode", "params":["bitcoin:18444", "remove"]}' -u btc:btc localhost:28443 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getaddednodeinfo", "params":[]}' -u btc:btc localhost:28443 | jq + +curl -d '{"jsonrpc":"2.0","id":"1","method":"disconnectnode", "params":["bitcoin:18444"]}' -u btc:btc localhost:28443 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getpeerinfo", "params":[]}' -u btc:btc localhost:28443 | jq + +curl -d '{"jsonrpc":"2.0","id":"1","method":"sendtoaddress", "params":["ADDRESS2_HERE", 0.345]}' -u btc:btc localhost:18443/wallet/w1 +curl -d '{"jsonrpc":"2.0","id":"1","method":"sendtoaddress", "params":["ADDRESS2_HERE", 0.245]}' -u btc:btc localhost:18443/wallet/w1 +curl -d '{"jsonrpc":"2.0","id":"1","method":"sendtoaddress", "params":["ADDRESS2_HERE", 0.445]}' -u btc:btc localhost:18443/wallet/w1 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"generatetoaddress", "params":[1, "ADDRESS_HERE"]}' -u btc:btc localhost:18443/wallet/w1 diff --git a/step6.sh b/step6.sh new file mode 100755 index 0000000..a1b2562 --- /dev/null +++ b/step6.sh @@ -0,0 +1,4 @@ +# mine fork on node2 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"generatetoaddress", "params":[10, "ADDRESS_HERE"]}' -u btc:btc localhost:28443/wallet/w1 + diff --git a/step7.sh b/step7.sh new file mode 100755 index 0000000..271baa9 --- /dev/null +++ b/step7.sh @@ -0,0 +1,8 @@ +# and connect again + +curl -d '{"jsonrpc":"2.0","id":"1","method":"addnode", "params":["bitcoin:18444", "add"]}' -u btc:btc localhost:28443 + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getaddednodeinfo", "params":[]}' -u btc:btc localhost:28443 | jq + +curl -d '{"jsonrpc":"2.0","id":"1","method":"getpeerinfo", "params":[]}' -u btc:btc localhost:28443 | jq +