current position:Home>Bitcoin series - using docker to build BTC private chain

Bitcoin series - using docker to build BTC private chain

2022-02-03 05:27:43 Brick moving leader

Reference resources : https://www.2cto.com/kf/201707/659271.html

adopt docker function BTC Private chain

 start-up Docker.
$ service docker start 
or
$ systemctl start docker

 Download bitcoin test network (bitcoin-testnet) Of Docker Mirror image .
docker pull freewil/bitcoin-testnet-box

 function Docker Mirror image .
$ docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box

 Get into Docker After operating environment , Enter the following command to start the bitcoin test network :
$ make start

 View the status information of test network nodes ( Be careful : If you install a newer version bitcoind, Get into docker After environment , We need to arrive first. Makefile Internal modification getinfo command , Change to -getinfo)
$ make getinfo

 Simulate the new generation 200 Block records ( At least you need to generate 100 Block , The account balance of the first wallet node will increase )
$ make generate BLOCKS=200

################# Transfer money to the test wallet address as an example 10 individual BTC##############
 For the first time 2 A wallet generates an address 
$ make address2
 Echoed address  2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ

 Transfer accounts 
$ make sendfrom1 ADDRESS=[ Generated address ] AMOUNT=10
[ for example ] make sendfrom1 ADDRESS=2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ AMOUNT=10
 The echo 
bitcoin-cli -datadir=1  sendtoaddress 2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ 10
9a768b7e1377444c8d32fb44d9583ac9cad7646dc5d5a2d83edcf48af8df4136

 Simulate the new generation 10 Block records , So that the above transfer transaction can be effectively confirmed 
$ make generate BLOCKS=10
##################################################

 Stop bitcoin test network 
$ make stop

 close Docker
$ service docker stop

Run your own modified docker( Adaptation new edition bitcoind The order of )

$ systemctl start docker
$ docker run -t -i -p 19001:19001 -p 19011:19011 my/bitcoin-testnet-box
$ make start
$ make getinfo
$ make generate BLOCKS=10
$ make address1
$ make stop

rpc Your account and password are bitcoin.conf File configuration 


 Remember to save the modified image content before exiting 
 Seems to have to stop first bitcoin (docker Internal execution )
make stop
 Then save the image , Get the container through the command id(docker External execution )
docker container ls
 Save again 
docker commit  Containers ID  New image name  (docker External execution )
[ for example ]	docker commit 5814f80288ac my/bitcoin-testnet-box

 List all addresses of the whole wallet  
bitcoin-cli -datadir=1 getaddressesbyaccount ""

 List all addresses and balances of the whole wallet 
bitcoin-cli -datadir=1 listaddressgroupings

 Displays the total balance of all addresses currently managed by the wallet  
bitcoin-cli -datadir=1 getbalance
 List all transaction information 
bitcoin-cli -datadir=1 listtransactions
 View single transaction information 
bitcoin-cli -datadir=1 gettransaction 980be3d6694e905679b45d568829cfd1b73387b920b3d6e302a6b78c699bbb07
 View single raw data 
bitcoin-cli -datadir=1 getrawtransaction 935fc327ed8d36d971ba3147c0b7aaba695a8ba312f471c9a96706d1bb3aaa2a
 Decode the original data of the transaction 
bitcoin-cli -datadir=1 decoderawtransaction  The original data found in the previous article 

** Query the private key of the address **
bitcoin-cli -datadir=1 dumpprivkey 2MvSvdJBGSZVfdMGYXFpnDofv3ADQBeXPq4

(4) adopt docker function    Reference resources :https://www.2cto.com/kf/201707/659271.html
 start-up Docker.
$ service docker start 
or
$ systemctl start docker

 Download bitcoin test network (bitcoin-testnet) Of Docker Mirror image .
docker pull freewil/bitcoin-testnet-box

 function Docker Mirror image .
$ docker run -t -i -p 19001:19001 -p 19011:19011 freewil/bitcoin-testnet-box

 Get into Docker After operating environment , Enter the following command to start the bitcoin test network :
$ make start

 View the status information of test network nodes ( Be careful : If you install a newer version bitcoind, Get into docker After environment , We need to arrive first. Makefile Internal modification getinfo command , Change to -getinfo)
$ make getinfo

 Simulate the new generation 200 Block records ( At least you need to generate 100 Block , The account balance of the first wallet node will increase )
$ make generate BLOCKS=200

################# Transfer money to the test wallet address as an example 10 individual BTC##############
 For the first time 2 A wallet generates an address 
$ make address2
 Echoed address  2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ

 Transfer accounts 
$ make sendfrom1 ADDRESS=[ Generated address ] AMOUNT=10
[ for example ] make sendfrom1 ADDRESS=2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ AMOUNT=10
 The echo 
bitcoin-cli -datadir=1  sendtoaddress 2N8nax4iYqNivqVosJE5pMZUHJus3N896YJ 10
9a768b7e1377444c8d32fb44d9583ac9cad7646dc5d5a2d83edcf48af8df4136

 Simulate the new generation 10 Block records , So that the above transfer transaction can be effectively confirmed 
$ make generate BLOCKS=10
##################################################

 Stop bitcoin test network 
$ make stop

 close Docker
$ service docker stop

Past highlights :
Blockchain Knowledge Series
Cryptography series
Zero knowledge proof series
Consensus series
Public chain research series
Bitcoin series
Ethereum series
EOS series
Filecoin series
Alliance chain series
Fabric series
Smart contract series
Token series

copyright notice
author[Brick moving leader],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202030527407874.html

Random recommended