@@ -2190,7 +2190,7 @@ static RPCHelpMan scantxoutset()
21902190 RPCResult{" when action=='start'; only returns after scan completes" , RPCResult::Type::OBJ, " " , " " , {
21912191 {RPCResult::Type::BOOL, " success" , " Whether the scan was completed" },
21922192 {RPCResult::Type::NUM, " txouts" , " The number of unspent transaction outputs scanned" },
2193- {RPCResult::Type::NUM, " height" , " The current block height (index) " },
2193+ {RPCResult::Type::NUM, " height" , " The block height at which the scan was done " },
21942194 {RPCResult::Type::STR_HEX, " bestblock" , " The hash of the block at the tip of the chain" },
21952195 {RPCResult::Type::ARR, " unspents" , " " ,
21962196 {
@@ -2203,6 +2203,8 @@ static RPCHelpMan scantxoutset()
22032203 {RPCResult::Type::STR_AMOUNT, " amount" , " The total amount in " + CURRENCY_UNIT + " of the unspent output" },
22042204 {RPCResult::Type::BOOL, " coinbase" , " Whether this is a coinbase output" },
22052205 {RPCResult::Type::NUM, " height" , " Height of the unspent transaction output" },
2206+ {RPCResult::Type::STR_HEX, " blockhash" , " Blockhash of the unspent transaction output" },
2207+ {RPCResult::Type::NUM, " confirmations" , " Number of confirmations of the unspent transaction output when the scan was done" },
22062208 }},
22072209 }},
22082210 {RPCResult::Type::STR_AMOUNT, " total_amount" , " The total amount of all found unspent outputs in " + CURRENCY_UNIT},
@@ -2292,17 +2294,20 @@ static RPCHelpMan scantxoutset()
22922294 const COutPoint& outpoint = it.first ;
22932295 const Coin& coin = it.second ;
22942296 const CTxOut& txo = coin.out ;
2297+ const CBlockIndex& coinb_block{*CHECK_NONFATAL (tip->GetAncestor (coin.nHeight ))};
22952298 input_txos.push_back (txo);
22962299 total_in += txo.nValue ;
22972300
22982301 UniValue unspent (UniValue::VOBJ);
22992302 unspent.pushKV (" txid" , outpoint.hash .GetHex ());
2300- unspent.pushKV (" vout" , ( int32_t ) outpoint.n );
2303+ unspent.pushKV (" vout" , outpoint.n );
23012304 unspent.pushKV (" scriptPubKey" , HexStr (txo.scriptPubKey ));
23022305 unspent.pushKV (" desc" , descriptors[txo.scriptPubKey ]);
23032306 unspent.pushKV (" amount" , ValueFromAmount (txo.nValue ));
23042307 unspent.pushKV (" coinbase" , coin.IsCoinBase ());
2305- unspent.pushKV (" height" , (int32_t )coin.nHeight );
2308+ unspent.pushKV (" height" , coin.nHeight );
2309+ unspent.pushKV (" blockhash" , coinb_block.GetBlockHash ().GetHex ());
2310+ unspent.pushKV (" confirmations" , tip->nHeight - coin.nHeight + 1 );
23062311
23072312 unspents.push_back (std::move (unspent));
23082313 }
0 commit comments