mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-05 20:50:18 +02:00
wallet: allow to fetch the wallet descriptors for a given Script
We currently expose a method to get the signing providers, which allows to infer a descriptor from the scriptPubKey. But in order to identify "on" what descriptor a coin was received, we need access to the descriptors that were imported to the wallet.
This commit is contained in:
parent
85b601e043
commit
55a82eaf91
@ -3311,6 +3311,18 @@ std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& scri
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<WalletDescriptor> CWallet::GetWalletDescriptors(const CScript& script) const
|
||||
{
|
||||
std::vector<WalletDescriptor> descs;
|
||||
for (const auto spk_man: GetScriptPubKeyMans(script)) {
|
||||
if (const auto desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man)) {
|
||||
LOCK(desc_spk_man->cs_desc_man);
|
||||
descs.push_back(desc_spk_man->GetWalletDescriptor());
|
||||
}
|
||||
}
|
||||
return descs;
|
||||
}
|
||||
|
||||
LegacyScriptPubKeyMan* CWallet::GetLegacyScriptPubKeyMan() const
|
||||
{
|
||||
if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
|
@ -839,6 +839,9 @@ public:
|
||||
std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;
|
||||
std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;
|
||||
|
||||
//! Get the wallet descriptors for a script.
|
||||
std::vector<WalletDescriptor> GetWalletDescriptors(const CScript& script) const;
|
||||
|
||||
//! Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
|
||||
LegacyScriptPubKeyMan* GetLegacyScriptPubKeyMan() const;
|
||||
LegacyScriptPubKeyMan* GetOrCreateLegacyScriptPubKeyMan();
|
||||
|
Loading…
x
Reference in New Issue
Block a user