scantxoutset
scantxoutset "action" ( [scanobjects,...] ) Scans the unspent transaction output set for entries that match certain output descriptors. Examples of output descriptors are: addr(<address>) Outputs whose output script corresponds to the specified address (does not include P2PK) raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes combo(<pubkey>) P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey pkh(<pubkey>) P2PKH outputs for the given pubkey sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys tr(<pubkey>) P2TR tr(<pubkey>,{pk(<pubkey>)}) P2TR with single fallback pubkey in tapscript rawtr(<pubkey>) P2TR with the specified key as output key rather than inner wsh(and_v(v:pk(<pubkey>),after(2))) P2WSH miniscript with mandatory pubkey and a timelock In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one or more path elements separated by "/", and optionally ending in "/*" (unhardened), or "/*'" or "/*h" (hardened) to specify all unhardened or hardened child keys. In the latter case, a range needs to be specified by below if different from 1000. For more information on output descriptors, see the documentation in the doc/descriptors.md file. Arguments: 1. action (string, required) The action to execute "start" for starting a scan "abort" for aborting the current scan (returns true when abort was successful) "status" for progress report (in %) of the current scan 2. scanobjects (json array, optional) Array of scan objects. Required for "start" action Every scan object is either a string descriptor or an object: [ "descriptor", (string) An output descriptor { (json object) An object with output descriptor and metadata "desc": "str", (string, required) An output descriptor "range": n or [n,n], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or [begin,end]) }, ... ] Result (when action=='start'; only returns after scan completes): { (json object) "success" : true|false, (boolean) Whether the scan was completed "txouts" : n, (numeric) The number of unspent transaction outputs scanned "height" : n, (numeric) The block height at which the scan was done "bestblock" : "hex", (string) The hash of the block at the tip of the chain "unspents" : [ (json array) { (json object) "txid" : "hex", (string) The transaction id "vout" : n, (numeric) The vout value "scriptPubKey" : "hex", (string) The output script "desc" : "str", (string) A specialized descriptor for the matched output script "amount" : n, (numeric) The total amount in BTC of the unspent output "coinbase" : true|false, (boolean) Whether this is a coinbase output "height" : n, (numeric) Height of the unspent transaction output "blockhash" : "hex", (string) Blockhash of the unspent transaction output "confirmations" : n (numeric) Number of confirmations of the unspent transaction output when the scan was done }, ... ], "total_amount" : n (numeric) The total amount of all found unspent outputs in BTC } Result (when action=='abort'): true|false (boolean) True if scan will be aborted (not necessarily before this RPC returns), or false if there is no scan to abort Result (when action=='status' and a scan is currently in progress): { (json object) "progress" : n (numeric) Approximate percent complete } Result (when action=='status' and no scan is in progress - possibly already completed): null (json null) Examples: > bitcoin-cli scantxoutset start '["raw(76a91411b366edfc0a8b66feebae5c2e25a7b6a5d1cf3188ac)#fm24fxxy"]' > bitcoin-cli scantxoutset status > bitcoin-cli scantxoutset abort > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "scantxoutset", "params": ["start", ["raw(76a91411b366edfc0a8b66feebae5c2e25a7b6a5d1cf3188ac)#fm24fxxy"]]}' -H 'content-type: application/json' http://127.0.0.1:8332/ > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "scantxoutset", "params": ["status"]}' -H 'content-type: application/json' http://127.0.0.1:8332/ > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "scantxoutset", "params": ["abort"]}' -H 'content-type: application/json' http://127.0.0.1:8332/
Signature
scantxoutset(action: string, scanobjects?: array) → any Code samples
curl --user "$RPC_USER:$RPC_PASS" \
--data-binary '{"jsonrpc":"1.0","id":"docs","method":"scantxoutset","params":["\"<action>\"",[]]}' \
-H 'content-type: text/plain;' \
http://127.0.0.1:8332/ Parameters
| Name | Type | Req. | Description |
|---|---|---|---|
| action | string | yes | The action to execute "start" for starting a scan "abort" for aborting the current scan (returns true when abort was successful) "status" for progress report (in %) of the current scan |
| scanobjects | any[] | — | Array of scan objects. Required for "start" action Every scan object is either a string descriptor or an object: [ "descriptor", (string) An output descriptor { (json object) An object with output descriptor and metadata "desc": "str", (string, required) An output descriptor "range": n or [n,n], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or [begin,end]) }, ... ] |
Result
Type: any
{ (json object) "success" : true|false, (boolean) Whether the scan was completed "txouts" : n, (numeric) The number of unspent transaction outputs scanned "height" : n, (numeric) The block height at which the scan was done "bestblock" : "hex", (string) The hash of the block at the tip of the chain "unspents" : [ (json array) { (json object) "txid" : "hex", (string) The transaction id "vout" : n, (numeric) The vout value "scriptPubKey" : "hex", (string) The output script "desc" : "str", (string) A specialized descriptor for the matched output script "amount" : n, (numeric) The total amount in BTC of the unspent output "coinbase" : true|false, (boolean) Whether this is a coinbase output "height" : n, (numeric) Height of the unspent transaction output "blockhash" : "hex", (string) Blockhash of the unspent transaction output "confirmations" : n (numeric) Number of confirmations of the unspent transaction output when the scan was done }, ... ], "total_amount" : n (numeric) The total amount of all found unspent outputs in BTC } true|false (boolean) True if scan will be aborted (not necessarily before this RPC returns), or false if there is no scan to abort { (json object) "progress" : n (numeric) Approximate percent complete } null (json null)
Source: services/core-node/bcore/src/rpc/blockchain.cpp:2221
C++ symbol: scantxoutset