From bbe4a36152fb8d9c8c3682ca2380f1c88cca61cb Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 4 May 2020 18:49:38 -0400 Subject: [PATCH] wallet: Add GetDescriptorString to DescriptorScriptPubKeyMan GetDescriptorString returns a normalized descriptor for a DescriptorScriptPubKeyMan. --- src/wallet/scriptpubkeyman.cpp | 13 +++++++++++++ src/wallet/scriptpubkeyman.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 51715462c52..d725f868354 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2254,3 +2254,16 @@ const std::vector DescriptorScriptPubKeyMan::GetScriptPubKeys() const } return script_pub_keys; } + +bool DescriptorScriptPubKeyMan::GetDescriptorString(std::string& out, bool priv) const +{ + LOCK(cs_desc_man); + if (m_storage.IsLocked()) { + return false; + } + + FlatSigningProvider provider; + provider.keys = GetKeys(); + + return m_wallet_descriptor.descriptor->ToNormalizedString(provider, out, priv); +} diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index a96d971734b..4750f769dfa 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -615,6 +615,8 @@ public: const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); const std::vector GetScriptPubKeys() const; + + bool GetDescriptorString(std::string& out, bool priv) const; }; #endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H