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


Bitcoin listunspent用法及代碼示例

比特幣(Bitcoin) RPC Wallet API中listunspent的用法及代碼示例。

用法:

listunspent ( minconf maxconf ["address",...] include_unsafe query_options )

返回帶有minconf和maxconf(含)確認的未花費交易輸出的數組。

(可選)過濾以僅包括支付給指定地址的txout。

參數1 - minconf

類型:數字,可選,默認值= 1

要過濾的最小確認

參數2 - maxconf

類型:數字,可選,默認值= 9999999

要過濾的最大確認

參數3 - addresses

類型:json數組,可選,默認=空數組

一個要過濾的比特幣地址的json數組

[
  "address",                     (string) bitcoin address
  ...
]

參數4 - include_unsafe

類型:布爾值,可選,默認= true

包括不安全使用的輸出

請參閱下麵的“safe”屬性說明。

參數5 - query_options

類型:json對象,可選

帶有查詢選項的JSON

{
  "minimumAmount": amount,       (numeric or string, optional, default=0) Minimum value of each UTXO in BTC
  "maximumAmount": amount,       (numeric or string, optional, default=unlimited) Maximum value of each UTXO in BTC
  "maximumCount": n,             (numeric, optional, default=unlimited) Maximum number of UTXOs
  "minimumSumAmount": amount,    (numeric or string, optional, default=unlimited) Minimum sum value of all UTXOs in BTC
}

返回結果

[                   (array of json object)
  {
    "txid" : "txid",          (string) the transaction id
    "vout" : n,               (numeric) the vout value
    "address" : "address",    (string) the bitcoin address
    "label" : "label",        (string) The associated label, or "" for the default label
    "scriptPubKey" : "key",   (string) the script key
    "amount" : x.xxx,         (numeric) the transaction output amount in BTC
    "confirmations" : n,      (numeric) The number of confirmations
    "redeemScript" : "script" (string) The redeemScript if scriptPubKey is P2SH
    "witnessScript" : "script" (string) witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH
    "spendable" : xxx,        (bool) Whether we have the private keys to spend this output
    "solvable" : xxx,         (bool) Whether we know how to spend this output, ignoring the lack of keys
    "desc" : xxx,             (string, only when solvable) A descriptor for spending this output
    "safe" : xxx              (bool) Whether this output is considered safe to spend. Unconfirmed transactions
                              from outside keys and unconfirmed replacement transactions are considered unsafe
                              and are not eligible for spending by fundrawtransaction and sendtoaddress.
  }
  ,...
]

示例

bitcoin-cli listunspent
bitcoin-cli listunspent 6 9999999 "[\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\",\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\"]"
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listunspent", "params": [6, 9999999 "[\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\",\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\"]"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
bitcoin-cli listunspent 6 9999999 '[]' true '{ "minimumAmount": 0.005 }'
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listunspent", "params": [6, 9999999, [] , true, { "minimumAmount": 0.005 } ] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

相關用法


注:本文由純淨天空篩選整理自bitcoin.org大神的英文原創作品 Bitcoin listunspent。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。