From 845279132b494f03b84d689c666fdcfad37f5a42 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Fri, 26 Aug 2022 02:34:55 +0200 Subject: [PATCH] wallet: support fetching scriptPubKeys with minimum descriptor range index This extra method will be needed for updating the filter set for faster wallet rescans; after an internal top-up has happened, we only want to add the newly created scriptPubKeys. --- src/wallet/scriptpubkeyman.cpp | 9 +++++++-- src/wallet/scriptpubkeyman.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 39afb79600f..c432bfc221c 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2644,13 +2644,18 @@ const WalletDescriptor DescriptorScriptPubKeyMan::GetWalletDescriptor() const } const std::unordered_set DescriptorScriptPubKeyMan::GetScriptPubKeys() const +{ + return GetScriptPubKeys(0); +} + +const std::unordered_set DescriptorScriptPubKeyMan::GetScriptPubKeys(int32_t minimum_index) const { LOCK(cs_desc_man); std::unordered_set script_pub_keys; script_pub_keys.reserve(m_map_script_pub_keys.size()); - for (auto const& script_pub_key: m_map_script_pub_keys) { - script_pub_keys.insert(script_pub_key.first); + for (auto const& [script_pub_key, index] : m_map_script_pub_keys) { + if (index >= minimum_index) script_pub_keys.insert(script_pub_key); } return script_pub_keys; } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 3ab489c3744..4ff7fdb1547 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -643,6 +643,7 @@ public: const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); const std::unordered_set GetScriptPubKeys() const override; + const std::unordered_set GetScriptPubKeys(int32_t minimum_index) const; bool GetDescriptorString(std::string& out, const bool priv) const;