-
Notifications
You must be signed in to change notification settings - Fork 1
/
②-1 コマンドラインからのからのBitcoin Core JSON APIの使用
190 lines (172 loc) · 7.67 KB
/
②-1 コマンドラインからのからのBitcoin Core JSON APIの使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#利用できるrpcコマンドを確認
$ bitcoin-cli help
== Blockchain ==
getbestblockhash
getblock "blockhash" ( verbosity )
getblockchaininfo
getblockcount
getblockhash height
getblockheader "hash" ( verbose )
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
verifychain ( checklevel nblocks )
verifytxoutproof "proof"
== Control ==
getinfo
getmemoryinfo ("mode")
help ( "command" )
stop
uptime
== Generating ==
generate nblocks ( maxtries )
generatetoaddress nblocks address (maxtries)
== Mining ==
getblocktemplate ( TemplateRequest )
getmininginfo
getnetworkhashps ( nblocks height )
prioritisetransaction <txid> <dummy value> <fee delta>
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 ==
combinerawtransaction ["hexstring",...]
createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,"data":"hex",...} ( locktime ) ( replaceable )
decoderawtransaction "hexstring"
decodescript "hexstring"
fundrawtransaction "hexstring" ( options )
getrawtransaction "txid" ( verbose )
sendrawtransaction "hexstring" ( allowhighfees )
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
== Util ==
createmultisig nrequired ["key",...]
estimatefee nblocks
estimatesmartfee conf_target ("estimate_mode")
signmessagewithprivkey "privkey" "message"
validateaddress "address"
verifymessage "address" "signature" "message"
== Wallet ==
abandontransaction "txid"
abortrescan
addmultisigaddress nrequired ["key",...] ( "account" )
addwitnessaddress "address"
backupwallet "destination"
bumpfee "txid" ( options )
dumpprivkey "address"
dumpwallet "filename"
encryptwallet "passphrase"
getaccount "address"
getaccountaddress "account"
getaddressesbyaccount "account"
getbalance ( "account" minconf include_watchonly )
getnewaddress ( "account" )
getrawchangeaddress
getreceivedbyaccount "account" ( minconf )
getreceivedbyaddress "address" ( minconf )
gettransaction "txid" ( include_watchonly )
getunconfirmedbalance
getwalletinfo
importaddress "address" ( "label" rescan p2sh )
importmulti "requests" ( "options" )
importprivkey "bitcoinprivkey" ( "label" ) ( rescan )
importprunedfunds
importpubkey "pubkey" ( "label" rescan )
importwallet "filename"
keypoolrefill ( newsize )
listaccounts ( minconf include_watchonly)
listaddressgroupings
listlockunspent
listreceivedbyaccount ( minconf include_empty include_watchonly)
listreceivedbyaddress ( minconf include_empty include_watchonly)
listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed )
listtransactions ( "account" count skip include_watchonly)
listunspent ( minconf maxconf ["addresses",...] [include_unsafe] [query_options])
listwallets
lockunspent unlock ([{"txid":"txid","vout":n},...])
move "fromaccount" "toaccount" amount ( minconf "comment" )
removeprunedfunds "txid"
sendfrom "fromaccount" "toaddress" amount ( minconf "comment" "comment_to" )
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] replaceable conf_target "estimate_mode")
sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode")
setaccount "address" "account"
settxfee amount
signmessage "address" "message"
#bitcoin coreクライアントのステータス取得/マイニングの状態を確認することができる。bitcoinUI上でブロックのダウンロードもできるが、 $bitcoindでもダウンロードできる。
$ bitcoin-cli getinfo
{
"deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",
"version": 150001,
"protocolversion": 70015,
"walletversion": 139900,
"balance": 0.00000000,
"blocks": 377853,
"timeoffset": -14,
"connections": 8,
"proxy": "",
"difficulty": 60813224039.44035,
"testnet": false,
"keypoololdest": 1508618122,
"keypoolsize": 2000,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"errors": ""
}
#warningがでた。使用が変わるらしい。
#ウォレットの暗号化とセットアップ
$ bitcoin-cli encryptwallet [password]
wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet.
The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.
#ウォレットが暗号化されたかどうかはgetinfoで確認できる。実行結果にunlock_untilという項目が追加される。
#暗号化の解除
$ bitcoin-cli walletpassphrase [password] 360
#バックアップウォレットを作成 今回はwallet.backupという名前
$ bitcoin-cli backupwallet wallet.backup
#バックアップウォレットを用いてリストアする。
$ bitcoin-cli importwallet wallet.backup
Error: Please enter the wallet passphrase with walletpassphrase first.
#最初にウォレットのロックを解除しなければいけない。
$ bitcoin-cli walletpassphrase [password] 360
$ bitcoin-cli importwallet wallet.backup
#人間が読める形に変換する為にダンプする。
$ bitcoin-cli dumpwallet wallet.txt
$ more wallet.txt
# Wallet dump created by Bitcoin v0.15.0.1-gfb7b5293844
# * Created on 2017-11-07T18:01:09Z
# * Best block at time of backup was 386438 (00000000000000000e2df9cf8523ac408eb5bf7c6bf1d6a7031ac57b29defd7c),
# mined on 2015-12-02T22:35:04Z
# extended private masterkey: xprv9s21ZrQH143K3LJULz1jneuQtQGqrweRaGtaPNmKvLDpKczWupxN3YX2Dhx56UPX1cZ6wbRWaLURjAATPa88gDs8aNyLPWeBfXs6sxtmpEi
L2HxNCgawbsMg3795AgUxm6gApAuWcKF7DfXDupvEH8Wud96mH71 2017-10-21T20:35:21Z change=1 # addr=113J7V4D9Xf4VnCbduE91n1ikHuWGbQtci hdkeypath=m/0'/0'/175'
L4QxxdwiSRAcHx3efMzeSbRoqrD7umRjw95yCpUqYPpk2b4aNfoF 2017-10-21T20:35:21Z change=1 # addr=115jb6Kzwhf8LkKBVRoK1mgryCuP98Rg6U hdkeypath=m/0'/0'/353'
KzPJEHkyHAD2VtA346wouscXiZgjdLErtu8YgyeDbd89zcmRGFQK 2017-10-21T20:35:21Z change=1 # addr=1166JAVw6yweZ1AgTuA479GkXufUw1fW32 hdkeypath=m/0'/0'/279'
L3JSw8XWfFm9wgguWL9wuKtFZGjoa3GK5Ln5DdBp9kNVUPKPTKWL 2017-10-21T20:35:21Z change=1 # addr=18WMQCfdP4ktfdo1QvhAPtwM2q9zcxieG hdkeypath=m/0'/0'/99'
L2DyM7JhbaenxFK2BUSjdxWTxBxGKJasghsKPnni3ZkhDjSWMmfy 2017-10-21T20:35:21Z change=1 # addr=19WbrEtuSeEAUwFukyHaUEEJk2EsWEmhU hdkeypath=m/0'/0'/157'
KypJvzUpyrLJ8btwpv6KU2DM5Uze5i1nfmBxdmRFqQSic6GQtJzC 2017-10-21T20:35:21Z change=1 # addr=1MVSxxxEWeq5t5gkbwhuNDJBJ2aYUjH4c hdkeypath=m/0'/0'/115'
L4c4xCy821FnDuyGpTgoprFUwgk1Jbp1nLSpskFmFEbbdmidbYbs 2017-10-21T20:35:21Z change=1 # addr=1TuwBJzAyAxm5pFBRJ5uPXfFP6L167hh9 hdkeypath=m/0'/0'/200'
KwdhWTZzmYbRBFcztXPpzx62D71eiCz2qfS6aKzAFsLoRHxv6oQ2 2017-10-21T20:35:21Z change=1 # addr=1U5KafQushuunYLjCbTzuMG5jvCYFhkUG hdkeypath=m/0'/0'/94'
# ウォレットアドレスを作成する
# 他のウォレットからbitcoindウォレットに少額を送る時に、Bitcoinアドレスを使うことができる。今回は以下で作るウォレットに0.050BTCを送る。
$ bitcoin-cli getnewaddress
1A2UqDSpbDC5S1E7wz3QJhgjuNAZ89biGH
#bitcoindクライアントに問い合わせることで、このBitcoinアドレスにbitcoinが届いたか?0.050BTCになるために何回の承認が必要とされてたか?を知ることができる。
# P49