diff options
author | Ava Chow <github@achow101.com> | 2023-12-21 18:35:29 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-03-20 16:15:43 -0400 |
commit | 85b1fb19dd3a3f3c68da1c5e60a6eb911e1119a6 (patch) | |
tree | 611c00c937e3a100ca92c374bd6dc43b896ddd87 /src/wallet/wallet.cpp | |
parent | 73926f2d31b61ff78d5f0c8f9b5e3130fb1f9620 (diff) | |
download | bitcoin-85b1fb19dd3a3f3c68da1c5e60a6eb911e1119a6.tar.xz |
wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c060127854..0dc3da1738 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4486,4 +4486,25 @@ void CWallet::TopUpCallback(const std::set<CScript>& spks, ScriptPubKeyMan* spkm // Update scriptPubKey cache CacheNewScriptPubKeys(spks, spkm); } + +std::set<CExtPubKey> CWallet::GetActiveHDPubKeys() const +{ + AssertLockHeld(cs_wallet); + + Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)); + + std::set<CExtPubKey> active_xpubs; + for (const auto& spkm : GetActiveScriptPubKeyMans()) { + const DescriptorScriptPubKeyMan* desc_spkm = dynamic_cast<DescriptorScriptPubKeyMan*>(spkm); + assert(desc_spkm); + LOCK(desc_spkm->cs_desc_man); + WalletDescriptor w_desc = desc_spkm->GetWalletDescriptor(); + + std::set<CPubKey> desc_pubkeys; + std::set<CExtPubKey> desc_xpubs; + w_desc.descriptor->GetPubKeys(desc_pubkeys, desc_xpubs); + active_xpubs.merge(std::move(desc_xpubs)); + } + return active_xpubs; +} } // namespace wallet |