mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 08bb4c3156 into merged_master (Bitcoin PR #16285)
This commit is contained in:
commit
f90ae69f01
2 changed files with 24 additions and 8 deletions
|
|
@ -2222,15 +2222,19 @@ UniValue scantxoutset(const JSONRPCRequest& request)
|
|||
},
|
||||
RPCResult{
|
||||
"{\n"
|
||||
" \"success\": true|false, (boolean) Whether the scan was completed\n"
|
||||
" \"txouts\": n, (numeric) The number of unspent transaction outputs scanned\n"
|
||||
" \"height\": n, (numeric) The current block height (index)\n"
|
||||
" \"bestblock\": \"hex\", (string) The hash of the block at the tip of the chain\n"
|
||||
" \"unspents\": [\n"
|
||||
" {\n"
|
||||
" \"txid\" : \"transactionid\", (string) The transaction id\n"
|
||||
" \"vout\": n, (numeric) the vout value\n"
|
||||
" \"scriptPubKey\" : \"script\", (string) the script key\n"
|
||||
" \"desc\" : \"descriptor\", (string) A specialized descriptor for the matched scriptPubKey\n"
|
||||
" \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n"
|
||||
" {\n"
|
||||
" \"txid\": \"hash\", (string) The transaction id\n"
|
||||
" \"vout\": n, (numeric) The vout value\n"
|
||||
" \"scriptPubKey\": \"script\", (string) The script key\n"
|
||||
" \"desc\": \"descriptor\", (string) A specialized descriptor for the matched scriptPubKey\n"
|
||||
" \"amount\": x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n"
|
||||
" \"asset\" : \"asset\", (hex) The asset ID\n"
|
||||
" \"height\" : n, (numeric) Height of the unspent transaction output\n"
|
||||
" \"height\": n, (numeric) Height of the unspent transaction output\n"
|
||||
" }\n"
|
||||
" ,...], \n"
|
||||
" \"total_unblinded_bitcoin_amount\" : x.xxx, (numeric) The total amount of all found unspent unblinded outputs in " + CURRENCY_UNIT + "\n"
|
||||
|
|
@ -2287,15 +2291,20 @@ UniValue scantxoutset(const JSONRPCRequest& request)
|
|||
g_scan_progress = 0;
|
||||
int64_t count = 0;
|
||||
std::unique_ptr<CCoinsViewCursor> pcursor;
|
||||
CBlockIndex* tip;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
::ChainstateActive().ForceFlushStateToDisk();
|
||||
pcursor = std::unique_ptr<CCoinsViewCursor>(::ChainstateActive().CoinsDB().Cursor());
|
||||
assert(pcursor);
|
||||
tip = ::ChainActive().Tip();
|
||||
assert(tip);
|
||||
}
|
||||
bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins);
|
||||
result.pushKV("success", res);
|
||||
result.pushKV("searched_items", count);
|
||||
result.pushKV("txouts", count);
|
||||
result.pushKV("height", tip->nHeight);
|
||||
result.pushKV("bestblock", tip->GetBlockHash().GetHex());
|
||||
|
||||
if (!g_con_elementsmode) {
|
||||
for (const auto& it : coins) {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@ class ScantxoutsetTest(BitcoinTestFramework):
|
|||
self.start_node(0)
|
||||
self.nodes[0].generate(110)
|
||||
|
||||
scan = self.nodes[0].scantxoutset("start", [])
|
||||
info = self.nodes[0].gettxoutsetinfo()
|
||||
assert_equal(scan['success'], True)
|
||||
assert_equal(scan['height'], info['height'])
|
||||
assert_equal(scan['txouts'], info['txouts'])
|
||||
assert_equal(scan['bestblock'], info['bestblock'])
|
||||
|
||||
self.restart_node(0, self.extra_args[0] + ['-nowallet'])
|
||||
self.log.info("Test if we have found the non HD unspent outputs.")
|
||||
assert_equal(self.nodes[0].scantxoutset("start", [ "pkh(" + pubk1 + ")", "pkh(" + pubk2 + ")", "pkh(" + pubk3 + ")"])['total_unblinded_bitcoin_amount'], Decimal("0.002"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue