比特币RPC命令简介

比特币测试时可以通过bitcoin-cli发送RPC命令,以下是bitcoin RPC命令的简单介绍:

== Blockchain ==
getbestblockhash # 获取最佳块哈希
getblock “hash” ( verbose ) # 获取指定区块信息
getblockchaininfo # 获取区块链信息
getblockcount # 获取当前的区块数
getblockhash index # 获取指定区块哈希
getblockheader “hash” ( verbose ) # 获取指定区块头信息
getchaintips # 获取区块链尖信息
getdifficulty # 获取当前挖矿难度
getmempoolinfo # 获取交易内存池信息
getrawmempool ( verbose ) # 获取内存池原始交易
gettxout “txid” n ( includemempool ) # 获取交易输出细节
gettxoutproof [“txid”,…] ( blockhash ) # 获取交易证明
gettxoutsetinfo # 获取交易输出集合信息
verifychain ( checklevel numblocks ) # 验证链
verifytxoutproof “proof” # 验证交易证明

== Control ==
getinfo # 获取比特币核心信息
help ( “command” ) # 获取命令帮助信息
stop # 远程终止比特币核心服务

== Generating ==
generate numblocks # 生成区块
getgenerate # 获取挖矿状态
setgenerate generate ( genproclimit ) # 挖矿开关

== Mining ==
getblocktemplate ( “jsonrequestobject” ) # 获取区块模板
getmininginfo # 获取挖矿信息
getnetworkhashps ( blocks height ) # 获取网络算力
prioritisetransaction  # 改变交易优先级
submitblock “hexdata” ( “jsonparametersobject” ) # 提交区块

== Network ==
addnode “node” “add|remove|onetry” # 添加节点并执行操作
clearbanned # 清空黑名单
disconnectnode “node” # 断开与指定节点的连接
getaddednodeinfo dns ( “node” ) # 获取添加的节点信息
getconnectioncount # 获取连接数
getnettotals # 获取网络总流量
getnetworkinfo # 获取网络信息
getpeerinfo # 获取对端信息
listbanned # 列出黑名单
ping # ping 连接的节点
setban “ip(/netmask)” “add|remove” (bantime) (absolute) # 设置黑名单

== Rawtransactions ==
createrawtransaction [{“txid”:”id”,”vout”:n},…] {“address”:amount,”data”:”hex”,…} ( locktime ) # 创建原始交易
decoderawtransaction “hexstring” # 解码原始交易
decodescript “hex” # 解码脚本
fundrawtransaction “hexstring” includeWatching # 资助原始交易
getrawtransaction “txid” ( verbose ) # 获取原始交易信息
sendrawtransaction “hexstring” ( allowhighfees ) # 发送原始交易
signrawtransaction “hexstring” ( [{“txid”:”id”,”vout”:n,”scriptPubKey”:”hex”,”redeemScript”:”hex”},…] [“privatekey1”,…] sighashtype ) # 签名原始交易

== Util ==
createmultisig nrequired [“key”,…] # 创建多重签名
estimatefee nblocks # 估算交易费
estimatepriority nblocks # 估算交易优先级
estimatesmartfee nblocks # 智能估计交易费
estimatesmartpriority nblocks # 智能估计交易优先级
validateaddress “bitcoinaddress” # 验证地址
verifymessage “bitcoinaddress” “signature” “message” # 验证消息

== Hidden ==
invalidateblock # 无效化区块
reconsiderblock # 再考虑区块
setmocktime # 设置 mocktime
resendwallettransactions # 再次发送钱包交易

== Wallet ==
abandontransaction “txid” # 放弃交易
addmultisigaddress nrequired [“key”,…] ( “account” ) # 添加多签地址
backupwallet “destination” # 备份钱包
dumpprivkey “bitcoinaddress” # 导出私钥
dumpwallet “filename” # 导出钱包
encryptwallet “passphrase” # 加密钱包
getaccount “bitcoinaddress” # (已过时)获取地址所属账户
getaccountaddress “account” # (已过时)获取账户收款地址
getaddressesbyaccount “account” # 获取某账户下所有地址
getbalance ( “account” minconf includeWatchonly ) # 获取余额
getnewaddress ( “account” ) # 获取新的地址
getrawchangeaddress # 获取原始交易找零地址
getreceivedbyaccount “account” ( minconf ) # (已过时)获取指定账户接收到的金额
getreceivedbyaddress “bitcoinaddress” ( minconf ) # 获取指定地址接收到的金额
gettransaction “txid” ( includeWatchonly ) # 获取交易信息
getunconfirmedbalance # 获取未确认的余额
getwalletinfo # 获取钱包信息
importaddress “address” ( “label” rescan p2sh ) # 导入地址或脚本
importprivkey “bitcoinprivkey” ( “label” rescan ) # 导入私钥
importpubkey “pubkey” ( “label” rescan ) # 导入公钥
importwallet “filename” # 导入钱包
keypoolrefill ( newsize ) # 再填充钥匙池
listaccounts ( minconf includeWatchonly) # (已过时)列出账户及其余额
listaddressgroupings # 列出地址分组
listlockunspent # 列出锁定的未花费交易输出
listreceivedbyaccount ( minconf includeempty includeWatchonly) # (已过时)列出账户接收金额
listreceivedbyaddress ( minconf includeempty includeWatchonly) # 列出地址接收金额
listsinceblock ( “blockhash” target-confirmations includeWatchonly) # 列从某区块开始的全部交易
listtransactions ( “account” count from includeWatchonly) # 列出交易
listunspent ( minconf maxconf [“address”,…] ) # 列出未花费交易输出
lockunspent unlock [{“txid”:”txid”,”vout”:n},…] # 加解锁未花费交易输出
move “fromaccount” “toaccount” amount ( minconf “comment” ) # (已过时)转账
sendfrom “fromaccount” “tobitcoinaddress” amount ( minconf “comment” “comment-to” ) # (已过时)从指定账户发送
sendmany “fromaccount” {“address”:amount,…} ( minconf “comment” [“address”,…] ) # 发送到多个地址
sendtoaddress “bitcoinaddress” amount ( “comment” “comment-to” subtractfeefromamount ) # 发送到指定地址
setaccount “bitcoinaddress” “account” # (已过时)设置地址关联账户
settxfee amount # 设置交易费
signmessage “bitcoinaddress” “message” # 签名消息
walletlock # 锁定钱包
walletpassphrase “passphrase” timeout # 解锁钱包数秒
walletpassphrasechange “oldpassphrase” “newpassphrase” # 更改钱包密码

你可能感兴趣的:(区块链)