GetTransaction/查询指定交易
gettransaction
调用获取指定钱包内交易的详细信息。该调用需要节点
启用钱包功能。
参数
- TXID:要查看详情的交易ID
- WatchOnlyIncl:是否包含watch-only地址
返回值
gettransaction
返回指定ID的交易的详细信息,结构如下:
- amount:交易金额,正数表示该交易增加钱包余额,负数表示该交易减少钱包余额
- fee:交易手续费,仅针对转出交易
- confirmations:交易确认数,0表示未确认,-1表示存在冲突
- generated:币基交易则该值为true
- blockhash:交易所在区块的哈希
- blockindex:交易所在区块的编号
- blocktime:交易所在区块的unix时间
- txid:交易ID
- walletconflicts:冲突交易数组,成员为冲突交易的ID
- timereceived:节点收到交易的unix时间
- bip125-replacable:是否可替换交易
- comment: 保存在钱包中的交易备注,
- to:保存在钱包中的交易目标备注
- details:输入输出详情数组,成员结构如下:
- involvesWatchonly:是否包含watch-only地址
- account:交易影响的账户名称
- address:对端地址
- category:交易类别,可以是:
- send:发送交易
- receive:接收交易
- generate:成熟币基交易
- immature:未成熟币基交易
- orphan:孤儿块中的币基交易
- send:发送交易
- amount
- vout
- fee
- abandoned
- involvesWatchonly:是否包含watch-only地址
- hex:串行序列化字符串
示例代码
下面的命令提取指定钱包内的详细信息:
~$ bitcoin-cli -testnet gettransaction \
5a7d24cd665108c66b2d56146f244932edae4e2376b561b3d396d5ae017b9589
输出结果如下:
{
"amount" : 0.00000000,
"fee" : 0.00000000,
"confirmations" : 106670,
"blockhash" : "000000008b630b3aae99b6fe215548168bed92167c47a2f7ad4df41e571bcb51",
"blockindex" : 1,
"blocktime" : 1396321351,
"txid" : "5a7d24cd665108c66b2d56146f244932edae4e2376b561b3d396d5ae017b9589",
"walletconflicts" : [
],
"time" : 1396321351,
"timereceived" : 1418924711,
"bip125-replaceable" : "no",
"details" : [
{
"account" : "",
"address" : "mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN",
"category" : "send",
"amount" : -0.10000000,
"vout" : 0,
"fee" : 0.00000000
},
{
"account" : "doc test",
"address" : "mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN",
"category" : "receive",
"amount" : 0.10000000,
"vout" : 0
}
],
"hex" : "0100000001cde58f2e37d000eabbb60d9cf0b79ddf67cede6dba58732539983fa341dd5e6c010000006a47304402201feaf12908260f666ab369bb8753cdc12f78d0c8bdfdef997da17acff502d321022049ba0b80945a7192e631c03bafd5c6dc3c7cb35ac5c1c0ffb9e22fec86dd311c01210321eeeb46fd878ce8e62d5e0f408a0eab41d7c3a7872dc836ce360439536e423dffffffff0180969800000000001976a9142b14950b8d31620c6cc923c5408a701b1ec0a02088ac00000000"
}