@@ -2074,6 +2074,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
20742074 " \" txid\" : \" transactionid\" , (string) The transaction id\n "
20752075 " \" vout\" : n, (numeric) the vout value\n "
20762076 " \" scriptPubKey\" : \" script\" , (string) the script key\n "
2077+ " \" desc\" : \" descriptor\" , (string) A specialized descriptor for the matched scriptPubKey\n "
20772078 " \" amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n "
20782079 " \" height\" : n, (numeric) Height of the unspent transaction output\n "
20792080 " }\n "
@@ -2108,6 +2109,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21082109 throw JSONRPCError (RPC_INVALID_PARAMETER, " Scan already in progress, use action \" abort\" or \" status\" " );
21092110 }
21102111 std::set<CScript> needles;
2112+ std::map<CScript, std::string> descriptors;
21112113 CAmount total_in = 0 ;
21122114
21132115 // loop through the scan objects
@@ -2140,7 +2142,11 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21402142 if (!desc->Expand (i, provider, scripts, provider)) {
21412143 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Cannot derive script without private keys: '%s'" , desc_str));
21422144 }
2143- needles.insert (scripts.begin (), scripts.end ());
2145+ for (const auto & script : scripts) {
2146+ std::string inferred = InferDescriptor (script, provider)->ToString ();
2147+ needles.emplace (script);
2148+ descriptors.emplace (std::move (script), std::move (inferred));
2149+ }
21442150 }
21452151 }
21462152
@@ -2173,6 +2179,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21732179 unspent.pushKV (" txid" , outpoint.hash .GetHex ());
21742180 unspent.pushKV (" vout" , (int32_t )outpoint.n );
21752181 unspent.pushKV (" scriptPubKey" , HexStr (txo.scriptPubKey .begin (), txo.scriptPubKey .end ()));
2182+ unspent.pushKV (" desc" , descriptors[txo.scriptPubKey ]);
21762183 unspent.pushKV (" amount" , ValueFromAmount (txo.nValue ));
21772184 unspent.pushKV (" height" , (int32_t )coin.nHeight );
21782185
0 commit comments