當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。