@@ -2074,6 +2074,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2074
2074
" \" txid\" : \" transactionid\" , (string) The transaction id\n "
2075
2075
" \" vout\" : n, (numeric) the vout value\n "
2076
2076
" \" scriptPubKey\" : \" script\" , (string) the script key\n "
2077
+ " \" desc\" : \" descriptor\" , (string) A specialized descriptor for the matched scriptPubKey\n "
2077
2078
" \" amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n "
2078
2079
" \" height\" : n, (numeric) Height of the unspent transaction output\n "
2079
2080
" }\n "
@@ -2108,6 +2109,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2108
2109
throw JSONRPCError (RPC_INVALID_PARAMETER, " Scan already in progress, use action \" abort\" or \" status\" " );
2109
2110
}
2110
2111
std::set<CScript> needles;
2112
+ std::map<CScript, std::string> descriptors;
2111
2113
CAmount total_in = 0 ;
2112
2114
2113
2115
// loop through the scan objects
@@ -2140,7 +2142,11 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2140
2142
if (!desc->Expand (i, provider, scripts, provider)) {
2141
2143
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Cannot derive script without private keys: '%s'" , desc_str));
2142
2144
}
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
+ }
2144
2150
}
2145
2151
}
2146
2152
@@ -2173,6 +2179,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2173
2179
unspent.pushKV (" txid" , outpoint.hash .GetHex ());
2174
2180
unspent.pushKV (" vout" , (int32_t )outpoint.n );
2175
2181
unspent.pushKV (" scriptPubKey" , HexStr (txo.scriptPubKey .begin (), txo.scriptPubKey .end ()));
2182
+ unspent.pushKV (" desc" , descriptors[txo.scriptPubKey ]);
2176
2183
unspent.pushKV (" amount" , ValueFromAmount (txo.nValue ));
2177
2184
unspent.pushKV (" height" , (int32_t )coin.nHeight );
2178
2185
0 commit comments