BTC 比特币客户端 命令
飞儿506
post on 2022-12-15 04:23:50
99
0
0
rpcuser=bitcoinrpc
rpcpassword=2XA4DuKNCbtZXsBQRRNDEwEY2nM6M4H9Tx5dFjoAVVbK
写入~/.bitcoin/bitcoin.conf
后台模式运行 bitcoind
bitcoind -daemon
通过命令行使用比特币核心的JSON-RPC API接口
bitcoin-cli help
获得比特币核心客户端状态的信息
bitcoin-cli getinfo
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
钱包设置及加密
加密钱包
bitcoin-cli encryptwallet foo
解锁钱包
bitcoin-cli walletpassphrase foo 360
钱包备份、纯文本导出及恢复
创建钱包的备份文件
bitcoin-cli backupwallet wallet.backup
重新加载备份文件
bitcoin-cli importwallet wallet.backup
将钱包转储为人类可读的文本文件
bitcoin-cli dumpwallet wallet.txt
钱包地址及接收交易
获得其中的一个地址
bitcoin-cli getnewaddress
13Bqx1N77WKSC6ZkFxTmamLNSJDRRL9H51
询问此地址已经接收到的比特币数额
bitcoin-cli getreceivedbyaddress 13Bqx1N77WKSC6ZkFxTmamLNSJDRRL9H51 0
整个钱包接收到的交易
bitcoin-cli listtransactions
列出整个钱包的所有地址
bitcoin-cli getaddressesbyaccount ""
所有经过至少minconf个确认的交易加和后的余额
bitcoin-cli getbalance
探索及解码交易
通过交易哈希值获取一笔交易
bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3
得到整个交易代码并且将之解码
bitcoin-cli getrawtransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3
解码十六进制字符串
bitcoin-cli decoderawtransaction 0100000001d717...388ac00000000
比特币核心默认建立包含仅与用户钱包相关交易的数据库。
若你想使用类似gettransaction的命令访问所有交易,你需要配置比特币核心去建立一个完整的交易索引,这个可以通过txindex选项实现。
在比特币核心配置文件中将txindex赋值为1(通常在安装目录的.bitcoin/bitcoin.conf中可以找到)。
一旦你改变了此参数,你需要重启bitcoind,并等待其重建索引。
探索区块
查询区块
bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31c2a717b true
通过区块高度来检索一个区块/获得“创世区块”的区块哈希值
bitcoin-cli getblockhash 0
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
区块信息
bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
基于UTXO(未花费的交易输出)的建立、签名与提交
查看钱包中所有剩余的从之前交易中已确认的支出
bitcoin-cli listunspent
未花费的输出的详细细节
bitcoin-cli gettxout 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3 0
为交易建立一个新的地址
bitcoin-cli getnewaddress 1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb
建立一笔交易
bitcoin-cli createrawtransaction '[{"txid" : "9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c309acbae2c14ae3", "vout" : 0}]' '{"1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb": 0.025, "1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL": 0.0245}'
签名交易
一个加密的钱包在签名之前必须解密,因为签名需要利用钱包中的秘钥\
bitcoin-cli walletpassphrase foo 360
bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8...518fa2e
提交新交易到比特币网络
bitcoin-cli sendrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8...c17b346
当使用sendrawtransaction命令发布交易到比特币网络时,它会返回交易的哈希值
BitMere.com is Information release platform,just provides information storage space services.
The opinions expressed are solely those of the author,Does not constitute advice, please treat with caution.
The opinions expressed are solely those of the author,Does not constitute advice, please treat with caution.
Write the first review