想学习比特币的同学,福利来了--创建自己的私有比特币测试链(docker)
发布于 2 年前 作者 codewinguagua 11093 次浏览 来自 新手入门

先说说docker 一个类似于虚拟机的轻量级容器。 官方网址https://www.docker.com 官方有一个在线模拟环境: https://www.docker.com/tryit/ 安装docker: 在Ubuntu 14.04安装和使用Docker参考:http://blog.csdn.net/chszs/article/details/47122005

bitcoin-testnet-box

docker pulls

Create your own private bitcoin testnet

You must have bitcoind and bitcoin-cli installed on your system and in the path unless running this within a Docker container (see below). Starting the testnet-box

This will start up two nodes using the two datadirs 1 and 2. They will only connect to each other in order to remain an isolated private testnet. Two nodes are provided, as one is used to generate blocks and it’s balance will be increased as this occurs (imitating a miner). You may want a second node where this behavior is not observed.

Node 1 will listen on port 19000, allowing node 2 to connect to it.

Node 1 will listen on port 19001 and node 2 will listen on port 19011 for the JSON-RPC server.

github:https://github.com/freewil/bitcoin-testnet-box

使用感受:简直就是比特币测试神器,挖矿,挖多少一个命令解决: make generate BLOCKS=10 bitcoin-cli -datadir=1 generate 10 [ “2a727da492b1b1498f08b98bc8b6c44ff29b47e1ceffb9e103ce7089aa9f487d”, “0a1e11d08d0cd0f90b1003b8cbaed1c8da18870bc6a777812e47b3b22a8a73e8”, “5be157bfd25f1ed36ab6e588a7495a8011f4124ff59437ba2871c9d5ffe24297”, “15b649878b8b5d7f96d0ecece7a280745b8c61ba692ecdbbf40a68c310077b59”, “2ec772b546c4a3bfe266eda3d01266d8c9281813180a798c410c0c1caf3da7b3”, “4bd0d2ad4a0d640387bf88f2b2e157bb43770d8164ef4f73c76cc0463e3299d9”, “1dab30bc73b67130869d68ef313c6ae3f6154b762d0bed2e969cf0c1d1b7236a”, “46bd173eb1e2c42b64eb786672879fde948fc56487b3bbd3e32094160053b8ef”, “5cf4c0107ed6a6940c92451bde58174f9fe39bb18ae42f69d3fb2db9b6dee8de”, “13738bfc8e2626ccc22f5f4b065575f87effe5a28c6d692e5cf366a81797d584” ] 查看详情: tester@0e5cf8a72adc:~/bitcoin-testnet-box$ make getinfo bitcoin-cli -datadir=1 getinfo { “version”: 120100, “protocolversion”: 70012, “walletversion”: 60000, “balance”: 5550.00000000, “blocks”: 211, “timeoffset”: 0, “connections”: 1, “proxy”: “”, “difficulty”: 4.656542373906925e-10, “testnet”: false, “keypoololdest”: 1481096136, “keypoolsize”: 101, “paytxfee”: 0.00000000, “relayfee”: 0.00001000, “errors”: “” } 对,你没看错,“balance”: 5550.00000000,我已经财务自由了

6 回复

能翻译一下就更棒了

lib配置好参数- rpcport=19001 rpcuser=admin1 rpcpassword=123 java版的lib调用结果: @test public static void test() { //bitcoin.sendToAddress(“1EzGDMdqKW5ubTDNHSqCKciPkybGSvWgrj”, 0.0001); System.out.println(bitcoin.getBlockCount()); System.out.println( bitcoin.getBalance(“mvF39ZYwoH59vc1ZwrmG1hwz2X99iosrjn”)); System.out.println(bitcoin.getInfo()); //System.out.println(bitcoin.getNewAddress()); System.out.println(bitcoin.getTransaction(“8fa7d7ff63938f21056c6e2945622c7ef80086731e01326963d51500598bac3e”)); System.out.println(bitcoin.getRawTransaction(“8fa7d7ff63938f21056c6e2945622c7ef80086731e01326963d51500598bac3e”));

	}

212 0.0 {version=120100, protocolversion=70012, walletversion=60000, balance=5584.9999618, blocks=212, timeoffset=0, connections=1, proxy=, difficulty=4.656542373906925E-10, testnet=false, keypoololdest=1481096136, keypoolsize=101, paytxfee=0.0, relayfee=1.0E-5, errors=} {amount=-15.0, fee=-3.82E-5, confirmations=1, blockhash=2a79d25e3945f9a12ca45b8d8fb7435b6dd8f71255029609178b158f8cf1c2c2, blockindex=1, blocktime=1481096471, txid=8fa7d7ff63938f21056c6e2945622c7ef80086731e01326963d51500598bac3e, walletconflicts=[], time=1481096354, timereceived=1481096354, bip125-replaceable=no, details=[{account=, address=mvF39ZYwoH59vc1ZwrmG1hwz2X99iosrjn, category=send, amount=-15.0, vout=0, fee=-3.82E-5, abandoned=false}], hex=01000000012b609d15cbb66832dbfc06ee9a9a6506c7f06b42884bfba3023d68e1a3d1f4dd0000000048473044022000fd3e491820e41bb5240214a3fec57af38e4ff494413a85269e70db8bca0aa10220117e2de51196bd3d4dec736972c0846f44f8cafb9678ecbe43c13dccad39894701feffffff02002f6859000000001976a914a187486e9fd68a981e6914d7d323155aa5bd842b88ac14b49dd0000000001976a91456e769f69fe18ba3135e4c7d102f1a448bf95b6688acd3000000} {hex=01000000012b609d15cbb66832dbfc06ee9a9a6506c7f06b42884bfba3023d68e1a3d1f4dd0000000048473044022000fd3e491820e41bb5240214a3fec57af38e4ff494413a85269e70db8bca0aa10220117e2de51196bd3d4dec736972c0846f44f8cafb9678ecbe43c13dccad39894701feffffff02002f6859000000001976a914a187486e9fd68a981e6914d7d323155aa5bd842b88ac14b49dd0000000001976a91456e769f69fe18ba3135e4c7d102f1a448bf95b6688acd3000000, txid=8fa7d7ff63938f21056c6e2945622c7ef80086731e01326963d51500598bac3e, size=191, version=1, locktime=211, vin=[{txid=ddf4d1a3e1683d02a3fb4b88426bf0c706659a9aee06fcdb3268b6cb159d602b, vout=0, scriptSig={asm=3044022000fd3e491820e41bb5240214a3fec57af38e4ff494413a85269e70db8bca0aa10220117e2de51196bd3d4dec736972c0846f44f8cafb9678ecbe43c13dccad398947[ALL], hex=473044022000fd3e491820e41bb5240214a3fec57af38e4ff494413a85269e70db8bca0aa10220117e2de51196bd3d4dec736972c0846f44f8cafb9678ecbe43c13dccad39894701}, sequence=4294967294}], vout=[{value=15.0, n=0, scriptPubKey={asm=OP_DUP OP_HASH160 a187486e9fd68a981e6914d7d323155aa5bd842b OP_EQUALVERIFY OP_CHECKSIG, hex=76a914a187486e9fd68a981e6914d7d323155aa5bd842b88ac, reqSigs=1, type=pubkeyhash, addresses=[mvF39ZYwoH59vc1ZwrmG1hwz2X99iosrjn]}}, {value=34.9999618, n=1, scriptPubKey={asm=OP_DUP OP_HASH160 56e769f69fe18ba3135e4c7d102f1a448bf95b66 OP_EQUALVERIFY OP_CHECKSIG, hex=76a91456e769f69fe18ba3135e4c7d102f1a448bf95b6688ac, reqSigs=1, type=pubkeyhash, addresses=[moSTdUMYqFRGcJu13iZadMBxsmW7YY3UmF]}}], blockhash=2a79d25e3945f9a12ca45b8d8fb7435b6dd8f71255029609178b158f8cf1c2c2, confirmations=1, time=1481096471, blocktime=1481096471}

感觉看着有点蒙圈

建议楼主用markdown 把帖子重新排版一下

回到顶部