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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。