当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Bitcoin listsinceblock用法及代码示例


比特币(Bitcoin) RPC Wallet API中listsinceblock的用法及代码示例。

用法:

listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed )

从块[blockhash]开始获取块中的所有事务,如果省略,则获取所有事务。

如果“blockhash”不再是主链的一部分,则包括从分支点开始的事务。

此外,如果设置了include_removed,则会在“removed”数组中返回影响已删除的钱包的事务。

参数1 - blockhash

类型:字符串,可选

如果设置,则块哈希从此开始列出事务,否则列出所有事务。

参数2 - target_confirmations

类型:数字,可选,默认值= 1

从主链返回第n个区块哈希。例如1表示最佳块哈希。注意:这不用作过滤器,仅影响返回值中的[lastblock]

参数3 - include_watchonly

类型:布尔值,可选,默认= false

包括到watch-only地址的交易(请参阅‘importaddress’)

参数4 - include_removed

类型:布尔值,可选,默认= true

显示由于“removed”数组重组而被删除的交易

(不保证可以在修剪的节点上工作)

返回结果

{
  "transactions": [
    "address":"address",    (string) The bitcoin address of the transaction.
    "category":               (string) The transaction category.
                "send"                  Transactions sent.
                "receive"               Non-coinbase transactions received.
                "generate"              Coinbase transactions received with more than 100 confirmations.
                "immature"              Coinbase transactions received with 100 or fewer confirmations.
                "orphan"                Orphaned coinbase transactions received.
    "amount": x.xxx,          (numeric) The amount in BTC. This is negative for the 'send' category, and is positive
                                         for all other categories
    "vout" : n,               (numeric) the vout value
    "fee": x.xxx,             (numeric) The amount of the fee in BTC. This is negative and only available for the 'send' category of transactions.
    "confirmations": n,       (numeric) The number of confirmations for the transaction.
                                          When it's < 0, it means the transaction conflicted that many blocks ago.
    "blockhash": "hashvalue",     (string) The block hash containing the transaction.
    "blockindex": n,          (numeric) The index of the transaction in the block that includes it.
    "blocktime": xxx,         (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).
    "txid": "transactionid",  (string) The transaction id.
    "time": xxx,              (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).
    "timereceived": xxx,      (numeric) The time received in seconds since epoch (Jan 1 1970 GMT).
    "bip125-replaceable": "yes|no|unknown",  (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);
                                                   may be unknown for unconfirmed transactions not in the mempool
    "abandoned": xxx,         (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the 'send' category of transactions.
    "comment": "...",       (string) If a comment is associated with the transaction.
    "label" : "label"       (string) A comment for the address/transaction, if any
    "to": "...",            (string) If a comment to is associated with the transaction.
  ],
  "removed": [
    <structure is the same as "transactions" above, only present if include_removed=true>
    Note: transactions that were re-added in the active chain will appear as-is in this array, and may thus have a positive confirmation count.
  ],
  "lastblock": "lastblockhash"     (string) The hash of the block (target_confirmations-1) from the best block on the main chain. This is typically used to feed back into listsinceblock the next time you call it. So you would generally use a target_confirmations of say 6, so you will be continually re-notified of transactions until they've reached 6 confirmations plus any new ones
}

示例

bitcoin-cli listsinceblock
bitcoin-cli listsinceblock "000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad" 6
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listsinceblock", "params": ["000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad", 6] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

相关用法


注:本文由纯净天空筛选整理自bitcoin.org大神的英文原创作品 Bitcoin listsinceblock。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。