diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 475627c76c7..18ca6303122 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3311,6 +3311,18 @@ std::unique_ptr CWallet::GetSolvingProvider(const CScript& scri return nullptr; } +std::vector CWallet::GetWalletDescriptors(const CScript& script) const +{ + std::vector descs; + for (const auto spk_man: GetScriptPubKeyMans(script)) { + if (const auto desc_spk_man = dynamic_cast(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)) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e2c3d76438f..b08b491ef1a 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -839,6 +839,9 @@ public: std::unique_ptr GetSolvingProvider(const CScript& script) const; std::unique_ptr GetSolvingProvider(const CScript& script, SignatureData& sigdata) const; + //! Get the wallet descriptors for a script. + std::vector GetWalletDescriptors(const CScript& script) const; + //! Get the LegacyScriptPubKeyMan which is used for all types, internal, and external. LegacyScriptPubKeyMan* GetLegacyScriptPubKeyMan() const; LegacyScriptPubKeyMan* GetOrCreateLegacyScriptPubKeyMan();