wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors
This commit is contained in:
1 parent
73926f2d31
commit
85b1fb19dd
2 files changed
+24
No files matched your search
@@ -4486,4 +4486,25 @@ void CWallet::TopUpCallback(const std::set<CScript>& spks, ScriptPubKeyMan* spkm
|
|||||||
// Update scriptPubKey cache
|
// Update scriptPubKey cache
|
||||||
CacheNewScriptPubKeys(spks, spkm);
|
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
|
} // namespace wallet
|
||||||
@@ -1056,6 +1056,9 @@ public:
|
|||||||
void CacheNewScriptPubKeys(const std::set<CScript>& spks, ScriptPubKeyMan* spkm);
|
void CacheNewScriptPubKeys(const std::set<CScript>& spks, ScriptPubKeyMan* spkm);
|
||||||
|
|
||||||
void TopUpCallback(const std::set<CScript>& spks, ScriptPubKeyMan* spkm) override;
|
void TopUpCallback(const std::set<CScript>& spks, ScriptPubKeyMan* spkm) override;
|
||||||
|
|
||||||
|
//! Retrieve the xpubs in use by the active descriptors
|
||||||
|
std::set<CExtPubKey> GetActiveHDPubKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user