比特币RPC API中文手册

区块链API
GetBestBlockHash GetBlock GetBlockChainInfo GetBlockCount GetBlockHash GetBlockHeader GetChainTips GetDifficulty GetMemPoolAncestors GetMemPoolDescendants GetMemPoolEntry GetMemPoolInfo GetRawMemPool GetTxOut GetTxOutProof GetTxOutSetInfo PreciousBlock PruneBlockChain VerifyChain VerifyTxOutProof
节点控制API
GetInfo Help Stop
区块构造与挖矿API
Generate GenerateToAddress GetBlockTemplate GetMiningInfo GetNetworkHashPS PrioritiseTransaction SubmitBlock
P2P网络通信API
AddNode ClearBanned DisconnectNode GetAddedNodeInfo GetConnectionCount GetNetTotals GetNetworkInfo GetPeerInfo ListBanned Ping SetBan SetNetworkActive
裸交易相关API
CreateRawTransaction FundRawTransaction DecodeRawTransaction DecodeScript GetRawTransaction SendRawTransaction SignRawTransaction
工具类
CreateMultiSig EstimateFee EstimatePriority GetMemoryInfo ValidateAddress VerifyMessage
钱包相关
AbandonTransaction AddWitnessAddress AddMultiSigAddress BackupWallet BumpFee DumpPrivKey DumpWallet EncryptWallet GetAccountAddress GetAccount GetAddressesByAccount GetBalance GetNewAddress GetRawChangeAddress GetReceivedByAccount GetReceivedByAddress GetTransaction GetUnconfirmedBalance GetWalletInfo ImportAddress ImportMulti ImportPrunedFunds ImportPrivKey ImportWallet KeyPoolRefill ListAccounts ListAddressGroupings ListLockUnspent ListReceivedByAccount ListReceivedByAddress ListSinceBlock ListTransactions ListUnspent LockUnspent Move RemovePrunedFunds SendFrom SendMany SendToAddress SetAccount SetTxFee SignMessage SignMessageWithPrivKey WalletLock WalletPassphrase WalletPassphraseChange

GetTxOut

gettxout调用返回一个UTXO的详细信息。

参数

  • TXID: UTXO所在的交易id
  • Vout:UTXO在交易输出中的序号
  • Unconfirmed:是否显示在内存交易池中的未确认交易,默认值:false

返回值

gettxout调用返回交易输出的描述信息,结构如下:

  • bestblock:本地最优链上该区块的哈希
  • confirmations:所在交易的确认数
  • value:该UTXO的面值
  • scriptPubKey
    • asm:助记符表示的公钥脚本
    • hex:16进制表示的公钥脚本
  • reqSigs:消费该UTXO需要的最少签名数量
  • type:脚本类型:
    • pubkey:P2PK脚本
      • pubkeyhash:P2PKH脚本
      • scripthash:P2SH脚本
      • multisig:多重签名脚本
      • nulldata:空数据脚本
      • nonstandard:非标脚本
  • addresses:交易中使用的地址数组
  • version:包含公钥脚本的交易的版本号
  • coinbase:如果utxo所在交易是coinbase交易,则为true,否则为false

示例代码

下面的命令返回指定交易第0个输出的详情:

~$ bitcoin-cli -testnet gettxout \
  d77aee99e8bdc11f40b8a9354956f0346fec5535b82c77c8b5c06047e3bca86a \
  0 true

输出结果如下:

{
    "bestblock" : "00000000c92356f7030b1deeab54b3b02885711320b4c48523be9daa3e0ace5d",
    "confirmations" : 0,
    "value" : 0.00100000,
    "scriptPubKey" : {
        "asm" : "OP_DUP OP_HASH160 a11418d3c144876258ba02909514d90e71ad8443 OP_EQUALVERIFY OP_CHECKSIG",
        "hex" : "76a914a11418d3c144876258ba02909514d90e71ad844388ac",
        "reqSigs" : 1,
        "type" : "pubkeyhash",
        "addresses" : [
            "mvCfAJSKaoFXoJEvv8ssW7wxaqRPphQuSv"
        ]
    },
    "version" : 1,
    "coinbase" : false
}