a.下载
wget https://bitcoin.org/bin/bitcoin-core-0.17.0/bitcoin-0.17.0-x86_64-linux-gnu.tar.gz
b.解压
tar -zvxf bitcoin-0.17.0-x86_64-linux-gnu.tar.gz
c.安装(就是放到BIN目录)
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.17.0/bin/*
d.基础配置
mkdir /etc/bitcoin
touch /etc/bitcoin/bitcoin.conf
chmod 600 /etc/bitcoin/bitcoin.conf
echo rpcuser=bitcoinrpc >> /etc/bitcoin/bitcoin.conf
echo rpcpassword=XXXXXX >> /etc/bitcoin/bitcoin.conf
注意:XXXXXX是你的密码,是什么都无所谓,访问RPC用的。
e.后台运行
bitcoind -daemon
f.测试是否成功
bitcoin-cli getdifficulty
bitcoin-cli listtransactions
bitcoin-cli stop
备注:返回一串难度数据就是正确的:1
bitcoin-cli getinfo
查看当前核心状态
curl测试
curl --user bitcoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
如果需要远程访问,需要修改核心的配置。允许远程访问。
备注:
默认同步端口:8333
默认RPC端口:8332
# 测试网络
8 #testnet=1
9
10 maxconnections=1
11
12 # 私连模式
13 regtest=1
将testnet注释掉,添加regtest=1,启用私有链模式
[root@localhost data]# bitcoind -conf=/etc/bitcoin/bitcoin.conf
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblockchaininfo
{
"chain": "regtest",
"blocks": 0,
"headers": 0,
"bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
"difficulty": 4.656542373906925e-10,
"mediantime": 1296688602,
"verificationprogress": 1,
"initialblockdownload": true,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000002",
"size_on_disk": 293,
"pruned": false,
"softforks": [
{
"id": "bip34",
"version": 2,
"reject": {
"status": false
}
},
{
"id": "bip66",
"version": 3,
"reject": {
"status": false
}
},
{
"id": "bip65",
"version": 4,
"reject": {
"status": false
}
}
],
"bip9_softforks": {
"csv": {
"status": "defined",
"startTime": 0,
"timeout": 9223372036854775807,
"since": 0
},
"segwit": {
"status": "active",
"startTime": -1,
"timeout": 9223372036854775807,
"since": 0
}
},
"warnings": ""
}
[root@localhost testnet3]#
显示"chain": “regtest”,回归测试链 “blocks”: 0,区块为0
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getbestblockhash
0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblock 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
{
"hash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
"confirmations": 1,
"strippedsize": 285,
"size": 285,
"weight": 1140,
"height": 0,
"version": 1,
"versionHex": "00000001",
"merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
"tx": [
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
],
"time": 1296688602,
"mediantime": 1296688602,
"nonce": 2,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000002",
"nTx": 1
}
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblockcount
0
当前区块高度为0
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf createwallet testwallet_99
{
"name": "testwallet_99",
"warning": ""
}
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getwalletinfo
{
"wallettestwallet_99: "testwallet_99",
"walletversion": 169900,
"balance": 0.00000000,
"unconfirmed_balance": 0.00000000,
"immature_balance": 0.00000000,
"txcount": 0,
"keypoololdest": 1575427556,
"keypoolsize": 1000,
"keypoolsize_hd_internal": 1000,
"paytxfee": 0.00000000,
"hdseedid": "d7556bedb6783119590c9f4e94412feedfb71165",
"hdmasterkeyid": "d7556bedb6783119590c9f4e94412feedfb71165",
"private_keys_enabled": true
}
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getnewaddress testwallet_99
2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getaccountaddress sky_testwallet_99 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getaddressesbyaccount testwallet_99
[
2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d,
"2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM"
]
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getbalance testwallet_99
0.00000000
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getaddressinfo 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
{
"address": "2N874CtqJjNZS46gPB9S69G7ScovfDX5qg8",
"scriptPubKey": "a914a2fe649a3a175447bb45fcb3ab9b373f70be918287",
"ismine": true,
"iswatchonly": false,
"isscript": true,
"iswitness": false,
"script": "witness_v0_keyhash",
"hex": "001447927b6359e837eb15a9aacafd34814dc8dc5d9e",
"pubkey": "03b4672461350c3fec2cb5f9508fa678e1a58baf2f72ad50c905d760cac1d3293b",
"embedded": {
"isscript": false,
"iswitness": true,
"witness_version": 0,
"witness_program": "47927b6359e837eb15a9aacafd34814dc8dc5d9e",
"pubkey": "03b4672461350c3fec2cb5f9508fa678e1a58baf2f72ad50c905d760cac1d3293b",
"address": "bcrt1qg7f8kc6eaqm7k9df4t906dypfhydchv76z8z7j",
"scriptPubKey": "001447927b6359e837eb15a9aacafd34814dc8dc5d9e"
},
"label": "testwallet_99",
"account": "testwallet_99",
"timestamp": 1575427555,
"hdkeypath": "m/0'/0'/0'",
"hdseedid": "d7556bedb6783119590c9f4e94412feedfb71165",
"hdmasterkeyid": "d7556bedb6783119590c9f4e94412feedfb71165",
"labels": [
{
"name": "testwallet_99",
"purpose": "receive"
}
]
}
包含地址公钥的信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 listaccounts
{
"testwallet_99": 0.00000000
}
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf listwallets
[
"",
"testwallet_99"
]
[root@localhost testnet3]#
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getmininginfo
{
"blocks": 0,
"currentblockweight": 0,
"currentblocktx": 0,
"difficulty": 4.656542373906925e-10,
"networkhashps": 0,
"pooledtx": 0,
"chain": "regtest",
"warnings": ""
}
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getnetworkinfo
{
"version": 170000,
"subversion": "/Satoshi:0.17.0/",
"protocolversion": 70015,
"localservices": "000000000000040d",
"localrelay": true,
"timeoffset": 0,
"networkactive": true,
"connections": 0,
"networks": [
{
"name": "ipv4",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "ipv6",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "onion",
"limited": true,
"reachable": false,
"proxy": "",
"proxy_randomize_credentials": false
}
],
"relayfee": 0.00001000,
"incrementalfee": 0.00001000,
"localaddresses": [
],
"warnings": ""
}
当前只有这一个节点所以connections为0
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 generate 1
[
"4f8e6797b93e3fcc75391932f99321587111c2729d52695c4ac95207a3982d6b"
]
查询区块信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblock 4f8e6797b93e3fcc75391932f99321587111c2729d52695c4ac95207a3982d6b
{
"hash": "7c39d0779a4da634a94060a1e1d09cbd58e33610776605e4e6b0c2031e95d41e",
"confirmations": 1,
"strippedsize": 226,
"size": 262,
"weight": 940,
"height": 1,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "ec553edd6ada64b1e0209e1b9310c568156654841873bf39f8c8548ea7fe696b",
"tx": [
"ec553edd6ada64b1e0209e1b9310c568156654841873bf39f8c8548ea7fe696b"
],
"time": 1575429707,
"mediantime": 1575429707,
"nonce": 0,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"chainwork": "0000000000000000000000000000000000000000000000000000000000000004",
"nTx": 1,
"previousblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
}
可以看到previousblockhash的值正好是我们前面区块的HASH值
在测试链里面,前100个区块是没有BTC奖励的,所以查询账户余额是0
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getbalance
0.00000000
再继续创建99个区块
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 generate 99
[
"43a6a93e1e7de23315c7c7107cb635323f0a82779a9380a8d6c49e3f1b413d6f",
"6ef5a1153e0eaf3caecbd093410c70020cb6dfc1de327777ba193b026b65942a",
"1318133764ea6c9d5b07498b5a0083d6d9dce30aecfd3fbe650ec6a1207da21f",
"53614aab3566ad038bdb5d3f99e19dbefbb98da5977ce8843730528965726129",
"07c80a1c62ec845199669813f499899e609a656d8b8fae8019a06eb4bfc9b998",
"3a132d75e8f199e938b345d5e23d2df90e2d565202b1ee354a5529136cf132ed",
"50ad926929bc8bc216705032fb90c3ee474d4e50eec5079348def9b914085bab",
"6df370c4fd6f5d9f4a0ce1c00b529ff64e0a86a2683631a67f55104070f05411",
"657e92c8ea93983fc4585c3e82fecc0d02126daa144b1c468cf52f253b864ecf",
"01a22ab940f0a2cb927ec50e77a70e1963a30569d49b194b31f0d391371526bb",
"3a155c7ed00ec16014749511db7fdbf189c0cad9cf730491ac39df41f5122b97",
"3f973c7c927931c15aa0fa65a3d4a84a5f2acc23502fcdb1039175c9db42347f",
"7465d0b112057a431131d55cf9d5fea5f1e17b37fc5c083cdc885563cec1fb42",
"5fd4b0870bbaf6af8add9fe1bcf4137cb45da729712792eff023b0a51e713e36",
"41a9d9fed6e061707e5035c91ba9cd895f5724b460e93280246a01a5278bbd21",
"4d7d3f32e056ca4928cc79873a4995b3b055b2c155d9caad17c43b23f5a39f3d",
"1a7be0e4a6fa221d1c21cfe6a9e6e9ea0584fe48c6a305d0655cbb00999ae9c4",
"182a731807fbcd84b458e0d04936a177180c41944151aeee29b0cb34ba7e0e91",
"530e75e283fcaace15af75ee391cbb4d62a11b1a033973a29799579163c493fe",
"4b1531d03c724dce7262b9cb373f5168d127a5622f30584f5567e61fcdef1de5",
"515924ceb1be0bfa948fcd9d1cdc07f2fe77eec3ea50aeec030db364dba11c3d",
"7bad141a1044107fdcd47d515f3b60bafd1e9a83946e782705da1f73aa9e1917",
"0814b243daf0d2288022ffdb3d2ec6a07bb95f7eb34f2854b33e0018a4c85a66",
"21eda368c927dade01ff5d51948e62bdfb8fc3505a0ec0b766fabd877015c2c3",
"189a2fba3f03eca19dac0c35a82214155b43cb5ba0f3445a18485a882d0f0056",
"5a5b3c144afe40df077243d8f22f4ec06d277937b790584b9567ca68de03281b",
"4d4ee48c9c91542d61d7248c0e7441bc097753f96c1cf769c7a320be5204b483",
"3dc9e1cc7b23a95e2207d58199773b9e36a928803c75f1f79e7438555bb3547e",
"39fc5e3fc50aaf57601e624302d514aec799d1539dea661c401d11a7bf766eff",
"03ea167daf1284f6d4ee5f72bb8b4dc2804997854057a62e36203ab6a18ff20e",
"6d4d8a62ce14afbaa7f58056770fe378977c1de0bd0f1a49f2a007b763b75846",
"3c756fb53194158ace0bb4433ecc9d923624808e853c2b02af132a37f7da0cbf",
"591f6260e8ee7ae1d8ca31bf273852201d3c8b9ae62dbdbe06683865899a4392",
"122383b82b9fb7c94c57a849be96989bf207c0fe150b3231bc9944f9ea17609e",
"29c555d0e11e7715d8b77e46e710031ff01b252fab9f0e27533dcda197cc42ea",
"47c85e8b7fe95cf71eb8124337515713486bf775d217027b54d981c04e6060f4",
"7c5b43676ff03c0aa9214f6f8bf1f7f186753bc505f340a8845e069692d2685e",
"75097a79590c79c7eb25bf55989fb4c73c9225d7b89d69b401903723b147e8a8",
"41888205cf5c69047b585b83703884da805870d208352e6585159fe29d0fb9a4",
"5fd308324f0d55bf0ae3fbe8ab52fadcf13193914c516ad5c97f4aa61c81a138",
"28bc70370cd2b9544dc7c7fa89b2bd37e2bfed733a0057bad3a13e63e7eef4a3",
"59bd9e8c840dd0e3e050da0586cdc8f18d7b85565b1110cbadd792a470cf6be5",
"270a3f142a4b5e8f1af481da834e8bd0375fb10e3a5892ba47266eb1581b89f7",
"6641c2400396950b5e737905f92675c0cdf807eee202448d0ec838463cdff6dd",
"52ec075a6f6289c42b3a5d25e8f03af7f881d46c494d005174ec6052d495b7b3",
"47669524a3aa3924ea115a55cacd9554393a09e4dcfbc9cd43d259e063b45fd4",
"0dc3b852e8e6f16db4e1f909cec7cccd074f4888a59510100ee42a7963cbb393",
"5c8ca62302f7e88d7c07dd4e8bacac393c8364af1800940a94df3cc7de46ad70",
"4cf9288b5733efdf112efe0c520bb846738aa6ce837ea15cc0f0eeccb8abab39",
"7091e882c7ed45f8128ea8ed4c86e0fdc0089b84780178bfb45ff85fd92c2303",
"7a54554f2063b1bb3e92102e5af6e4f9c59be4c49458d85641367ef668107165",
"03572fb9ef712bd04f1cff1423f4e3738583774b0b4f8bd6c4ed2a7be171fc8e",
"0351965c37d49a1964ea1659bfe6cc3c34461cbdaf6c09f2bdc72308472faa4f",
"056ad64fec6632b8911cf0f7a2b36fb89a91c2c4c60420a8416144e67721c1a5",
"5005b1381fa3e46fc195d3502fd39bf23613a7ff241235979134e1d4704ac670",
"45c83208a7cf8d32fc2f81c32e8541518deff2a4a390cee7d862a2640d3ee400",
"2f332278b68d6221a916b1ebab9e6ff2f66975930c99ba9c37c300e8763bb555",
"2eb31f2adaa822696eb416b5bd7ec658f9171cdd32c09ff7aa3d2593492e84f8",
"6cc8e1fdcad871933b55912df1f086d7abbe463c767dcdf824718d61702a74da",
"03f6829195bc827e65c25bef783d4f6242975a5318c718b17fd024c8970c06a5",
"32167335e2799f2565dfd1fe59c3b4570e12072624d86c52b60479465f9caf86",
"0e30303a580d134b51d908cbc9dc5caa06301a21d8f156fb4db28625cadbe438",
"13ee9e668537124f7863272535afecd127a3804fc9a55e8c5d48548fac1f5253",
"4606260c218768c7333d6f33f1b7145aaace100938336fe61577cc782a6b3f64",
"6b1107c693510c580acfc0d6e35f69e19372019ecf091daada5023ffac369e61",
"47fdf88be1e206c28b1c8a0d3b2530543c89e4ca3d5698823862731d62d03e63",
"475587c82bc166b3b25608fcb41f9fd3fa85b63f1a366e17ff2103d50cd17a06",
"77827236004d2aa7915f74c676ff94e42adfa5e37beeabb3413e1b6e33856bf1",
"18c50369837139427c07512460454107e83fb69dfd14ad0cdd5902974ae5e5b9",
"623922bbb44f05b0520215e63b23ef6c690dc879028fe623c09fad092f12de61",
"7c39c5c96d73fcc4f9c6a5c11f70f1a68ba0fdcfba8583bcfc9968c9d081bd5b",
"7da66f222f43f9bf7156877627a94c392207026f777605417a447f50ebfc8c91",
"472b119da8a075582e32b51a096f2794525e4c20a50cc23ed41eddb979f611d1",
"73918a3e41e1362a97a10f22ffcde4f09d750c1346077984dbe144639c7f88b8",
"27e1c8a1137eced3b0ceb552e726423f2e7f091a7215728e580b2b80c473123d",
"40c41b99ba7798b51dd32f4dad90484266b6b2ff0314916c604d494dfe07285f",
"07d734942f6a3b020822826c1aed6854b4271140e8a26682a5eadb691ef44ba3",
"2dc7aebf5c62104a04ca432e9fd0b80362e067f293ce35488aed1ea55ed4d5d7",
"7fd6dd39a3684fa607563e69d2a8be639a5f1dc321c4f8f041d2fc0f15cb64e5",
"7e09657dc7d4746acd26fcee6a6805acb6ef0407a87d219dee1278bead57f837",
"40f5d18202e9234a1180bf8dbd97b1ef3df081a8cfc55033526f63188584f8e2",
"3f177203d6d060dff70d48030379f7983e1489ad6bdd646784eea76ef275b3cd",
"07aef4e3a255e3c1c942f1f9cc201d7c20345c6cfa4f69041b5a6fde6c9d1c62",
"6e10dcc8c5366c61ee2a132c699b9642b88bb36bc5adf41ebee9bc50cc5722d3",
"50d5a88808216e1b628b240655c8ae5e30cf4f49f736803d2b7c4dfd0d1f0c2c",
"37d4d1fd5d936f77ef6f235740d936008b1fe99642c2a20d178b9aaccde88c61",
"4df75f4e622569936f7a876d030c2240713b4518a7ad43b6560f7407bbb603f2",
"6d39cf6192ee2e43d7132d5360dab74b437b5d671853c7199db30fd1830ee442",
"29727355a9205b0a06b18dcf98e482574f65367e92e499ce9d02df00f9cf90f3",
"2ee68013b79a812c8863f5213d2a0f43dff7f1f49a393d1ed5b3ec73935fb54b",
"5ff1d1ad75ffef8e36585414fab4e5c3e33bfed59cd6ba42b0b7cf4b6f4f6c60",
"238057cfc78cbc477151f51bcc92a05b736a88744f28cd88acb51524e15cf5ae",
"08562742cc6624ff601452b1fdd1a00a1b464a1de1bd61419ed4d3ac29cbd0ee",
"32c3e98cb3a3e2d96e6caab5c610c2c375eb99ae4a00dafba5d2bf4199920ca9",
"4f7480b5228df48809b2ebbf423adb3458adf04b44ac99f9813f7e4982a28cb7",
"727ddd08a7aa23015c42bbee31b9895d401021201f7600b7474c4d8b078347ef",
"5a0c32a6a35d525fcaee939b33f7ad06735f12309a1c1c197ba9308937f4d428",
"2e135c58f3eccae64305b44c1c5a4142e6507cfc8cfdfed02f714e7ec720ba22",
"2e76b2d7846bdfc75703c6c18edf11ceb38581e494e8319faea49b1a45d1f785"
]
查询余额
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getbalance
0.00000000
还是0,再创建一个区块,并指定接收出块奖励的地址
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 generatetoaddress 1 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
[
"7321e4ef85636580c289c94bc63a798e9348ef473fed7dd5d85b6d9a4787c51e"
]
查看区块信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getblock 4dd1973e691d8b716119f34af5cea53d9cdaea686759c4e672859ab7015ecc4e
{
"hash": "4dd1973e691d8b716119f34af5cea53d9cdaea686759c4e672859ab7015ecc4e",
"confirmations": 1,
"strippedsize": 215,
"size": 251,
"weight": 896,
"height": 102,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "7f80bbb65a9d23224fb78392e3a599a3921a09a56a6193d698dffd78ab4befb9",
"tx": [
"7f80bbb65a9d23224fb78392e3a599a3921a09a56a6193d698dffd78ab4befb9"
],
"time": 1575438630,
"mediantime": 1575430247,
"nonce": 0,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"chainwork": "00000000000000000000000000000000000000000000000000000000000000ce",
"nTx": 1,
"previousblockhash": "47c10c21548a452a290263077939b40beefc53239703dced5e52b623c876e764"
}
查看交易信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 gettransaction 1b620cbeccc9b71d674f54cb2a22e08676341714dac0d0519c103f5be8306e6f
{
"amount": 0.00000000,
"confirmations": 1,
"generated": true,
"blockhash": "4dd1973e691d8b716119f34af5cea53d9cdaea686759c4e672859ab7015ecc4e",
"blockindex": 0,
"blocktime": 1575438630,
"txid": "7f80bbb65a9d23224fb78392e3a599a3921a09a56a6193d698dffd78ab4befb9",
"walletconflicts": [
],
"time": 1575438630,
"timereceived": 1575438630,
"bip125-replaceable": "no",
"details": [
{
"account": "testwallet_99",
"address": "2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM",
"category": "immature",
"amount": 50.00000000,
"label": "testwallet_99",
"vout": 0
}
],
"hex": "020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff0401660101ffffffff0200f2052a0100000017a914b9c3acd130868ef67af6b46c2253c217a6e146ef870000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000"
"generated": true 铸币交易
查询余额
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getbalance
50.00000000
账户里有50个BTC了。
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 sendfrom "" 2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM 10
a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc
从默认的账户中转账到指定地址
查看交易信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 gettransaction a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc
{
"amount": 0.00000000,
"fee": -0.00003740,
"confirmations": 0,
"trusted": true,
"txid": "a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc",
"walletconflicts": [
],
"time": 1575440457,
"timereceived": 1575440457,
"bip125-replaceable": "no",
"details": [
{
"account": "",
"address": "2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM",
"category": "send",
"amount": -10.00000000,
"label": "testwallet_99",
"vout": 1,
"fee": -0.00003740,
"abandoned": false
},
{
"account": "testwallet_99",
"address": "2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM",
"category": "receive",
"amount": 10.00000000,
"label": "testwallet_99",
"vout": 1
}
],
"hex": "02000000016b69fea78e54c8f839bf73188454661568c510931b9e20e0b164da6add3e55ec000000004847304402202d1b82fcd41fe903c6afda32e4814007e9e958e5f5d6152d47f23cfc85e9a97e02207f6af48f53309481b827ddb217b5cd51320411c69291096eece1dc3d24d2d3bf01feffffff0264196bee0000000017a9140ccd27e0103153fa564ef6de568b0a365ae3ae118700ca9a3b0000000017a914b9c3acd130868ef67af6b46c2253c217a6e146ef8766000000"
}
显示未确认交易,我们再挖一个区块
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 generatetoaddress 1 2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM
[
"59ad7dd984642c8dcbc4148cd0e028add28e8f862c970a291a78d3e5406997ae"
]
查看区块信息
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getblock 59ad7dd984642c8dcbc4148cd0e028add28e8f862c970a291a78d3e5406997ae
{
"hash": "59ad7dd984642c8dcbc4148cd0e028add28e8f862c970a291a78d3e5406997ae",
"confirmations": 1,
"strippedsize": 589,
"size": 625,
"weight": 2392,
"height": 103,
"version": 536870912,
"versionHex": "20000000",
"merkleroot": "98312b71b67fcbbd4523123f90cc9defef9d20dce0ef7bbc6b85f17fc065800f",
"tx": [
"f074f30a25161c9d7b949795f271e2062a1f8010c848c1f87ef5b295056557a2",
"ba5ad4082b1c3df0399b38ac00d2b86958a53be350f35049131229e8703ac1bb",
"a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc"
],
"time": 1575441665,
"mediantime": 1575430248,
"nonce": 1,
"bits": "207fffff",
"difficulty": 4.656542373906925e-10,
"chainwork": "00000000000000000000000000000000000000000000000000000000000000d0",
"nTx": 3,
"previousblockhash": "4dd1973e691d8b716119f34af5cea53d9cdaea686759c4e672859ab7015ecc4e"
}
此时发现交易列表里有3条上链的交易记录,一笔铸币交易,两笔转账交易,再继续出5个区块,使这3笔交易满足默认的6次确认
[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 generatetoaddress 5 2NABTQWoJyyvuAQbhjLKfVmvqBqW1zA17aM
[
"3fd66ac921b9363e481706d31f4176ae9be5ca38da12a12a893ae36be9d3fe32",
"35debf3dde488dddca3e209d81055efe90ad9806c9ec86557f2a6542dbb91c68",
"3e66ab2c7955baa7f9833c95cb347ec1d80f36dc9f7404104747e9959b247b91",
"762f41973e75e5b10463462b97e950e52c477769691a9313759f821597493c7e",
"008ce83f0051fa25cfa30930391621008efc4bb76e95d53c079564afc43a1ef4"
]
== Blockchain ==
#查看当前链最新区块HASH
getbestblockhash
#查询指定区块HASH的区块信息
#getblock 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
getblock "blockhash" ( verbosity )
#查看链信息
getblockchaininfo
#获取区块高度
getblockcount
getblockhash height
getblockheader "hash" ( verbose )
getblockstats hash_or_height ( stats )
getchaintips
getchaintxstats ( nblocks blockhash )
getdifficulty
getmempoolancestors txid (verbose)
getmempooldescendants txid (verbose)
getmempoolentry txid
getmempoolinfo
getrawmempool ( verbose )
gettxout "txid" n ( include_mempool )
gettxoutproof ["txid",...] ( blockhash )
gettxoutsetinfo
preciousblock "blockhash"
pruneblockchain
savemempool
scantxoutset ( )
verifychain ( checklevel nblocks )
verifytxoutproof "proof"
== Control ==
getmemoryinfo ("mode")
help ( "command" )
logging ( )
stop
uptime
== Generating ==
#创建区块
#-rpcwallet=testwallet_99 generate 1
generate nblocks ( maxtries )
#创建区块,指定接收出块奖励的地址
#-rpcwallet=testwallet_99 generatetoaddress 1 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
generatetoaddress nblocks address (maxtries)
== Mining ==
getblocktemplate ( TemplateRequest )
#查看挖矿信息
getmininginfo
getnetworkhashps ( nblocks height )
prioritisetransaction
submitblock "hexdata" ( "dummy" )
== Network ==
addnode "node" "add|remove|onetry"
clearbanned
disconnectnode "[address]" [nodeid]
getaddednodeinfo ( "node" )
getconnectioncount
getnettotals
#查看网络信息
getnetworkinfo
getpeerinfo
listbanned
ping
setban "subnet" "add|remove" (bantime) (absolute)
setnetworkactive true|false
== Rawtransactions ==
combinepsbt ["psbt",...]
combinerawtransaction ["hexstring",...]
converttopsbt "hexstring" ( permitsigdata iswitness )
createpsbt [{"txid":"id","vout":n},...] [{"address":amount},{"data":"hex"},...] ( locktime ) ( replaceable )
createrawtransaction [{"txid":"id","vout":n},...] [{"address":amount},{"data":"hex"},...] ( locktime ) ( replaceable )
decodepsbt "psbt"
decoderawtransaction "hexstring" ( iswitness )
decodescript "hexstring"
finalizepsbt "psbt" ( extract )
fundrawtransaction "hexstring" ( options iswitness )
getrawtransaction "txid" ( verbose "blockhash" )
sendrawtransaction "hexstring" ( allowhighfees )
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1"
,...] sighashtype )signrawtransactionwithkey "hexstring" ["privatekey1",...] ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript"
:"hex"},...] sighashtype )testmempoolaccept ["rawtxs"] ( allowhighfees )
== Util ==
createmultisig nrequired ["key",...] ( "address_type" )
estimatesmartfee conf_target ("estimate_mode")
signmessagewithprivkey "privkey" "message"
validateaddress "address"
verifymessage "address" "signature" "message"
== Wallet ==
abandontransaction "txid"
abortrescan
addmultisigaddress nrequired ["key",...] ( "label" "address_type" )
backupwallet "destination"
bumpfee "txid" ( options )
#创建一个钱包
createwallet "wallet_name" ( disable_private_keys )
dumpprivkey "address"
dumpwallet "filename"
encryptwallet "passphrase"
getaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
#查询指定账号地址信息
#-rpcwallet=testwallet_99 getaccountaddress testwallet_99
getaccountaddress (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accou
nts)getaddressbyaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=acc
ounts)getaddressesbylabel "label"
#查询指定账户地址的详细信息
#-rpcwallet=testwallet_99 getaddressinfo 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d
getaddressinfo "address"
#查询余额
#-rpcwallet=testwallet_99 getbalance testwallet_99
getbalance ( "(dummy)" minconf include_watchonly )
#给指定钱包创建一个账号
#-rpcwallet=testwallet_99 getnewaddress testwallet_99
getnewaddress ( "label" "address_type" )
getrawchangeaddress ( "address_type" )
getreceivedbyaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=ac
counts)getreceivedbyaddress "address" ( minconf )
#查看交易信息
#-rpcwallet=testwallet_99 gettransaction 1b620cbeccc9b71d674f54cb2a22e08676341714dac0d0519c103f5be8306e6f
gettransaction "txid" ( include_watchonly )
getunconfirmedbalance
#查询钱包信息
#bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf -rpcwallet=testwallet_99 getwalletinfo
getwalletinfo
importaddress "address" ( "label" rescan p2sh )
importmulti "requests" ( "options" )
importprivkey "privkey" ( "label" ) ( rescan )
importprunedfunds
importpubkey "pubkey" ( "label" rescan )
importwallet "filename"
keypoolrefill ( newsize )
#显示指定钱包的账户列表
#-rpcwallet=testwallet_99 listaccounts
listaccounts (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
listaddressgroupings
listlabels ( "purpose" )
listlockunspent
listreceivedbyaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=a
ccounts)listreceivedbyaddress ( minconf include_empty include_watchonly address_filter )
listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed )
listtransactions (label count skip include_watchonly)
#查找未花费的交易输出
listunspent ( minconf maxconf ["addresses",...] [include_unsafe] [query_options])
listwallets
loadwallet "filename"
lockunspent unlock ([{"txid":"txid","vout":n},...])
move (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
removeprunedfunds "txid"
rescanblockchain ("start_height") ("stop_height")
#从默认的账户中转账到指定地址
#-rpcwallet=testwallet_99 sendfrom "" 2MuepUnhhEmvhkLPVXzCiW662uPrXwhSH8d 10 a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc
a04de4a803ec6ca0aa611ab8273df2a9b4d71b89cba635ef481e262a090d16bc
sendfrom (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
sendmany "" {"address":amount,...} ( minconf "comment" ["address",...] replaceable conf_target "estimate_mode")
sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode")
setaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
sethdseed ( "newkeypool" "seed" )
settxfee amount
signmessage "address" "message"
signrawtransactionwithwallet "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] sigh
ashtype )unloadwallet ( "wallet_name" )
walletcreatefundedpsbt [{"txid":"id","vout":n},...] [{"address":amount},{"data":"hex"},...] ( locktime ) ( replaceable
) ( options bip32derivs )walletlock
walletpassphrase "passphrase" timeout
walletpassphrasechange "oldpassphrase" "newpassphrase"
walletprocesspsbt "psbt" ( sign "sighashtype" bip32derivs )
== Zmq ==
getzmqnotifications
…} ( minconf “comment” [“address”,…] replaceable conf_target “estimate_mode”)
sendtoaddress “address” amount ( “comment” “comment_to” subtractfeefromamount replaceable conf_target “estimate_mode”)
setaccount (Deprecated, will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts)
sethdseed ( “newkeypool” “seed” )
settxfee amount
signmessage “address” “message”
signrawtransactionwithwallet “hexstring” ( [{“txid”:“id”,“vout”:n,“scriptPubKey”:“hex”,“redeemScript”:“hex”},…] sigh
ashtype )unloadwallet ( “wallet_name” )
walletcreatefundedpsbt [{“txid”:“id”,“vout”:n},…] [{“address”:amount},{“data”:“hex”},…] ( locktime ) ( replaceable
) ( options bip32derivs )walletlock
walletpassphrase “passphrase” timeout
walletpassphrasechange “oldpassphrase” “newpassphrase”
walletprocesspsbt “psbt” ( sign “sighashtype” bip32derivs )
== Zmq ==
getzmqnotifications