比特币RPC命令简介

mac2025-07-30  2

比特币测试时可以通过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 <txid> <priority delta> <fee delta> # 改变交易优先级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 # 设置 mocktimeresendwallettransactions # 再次发送钱包交易

== 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” # 更改钱包密码

最新回复(0)