From 66632e5c24c1b59afef1e89b562fbd0117ab6ef5 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Thu, 21 Dec 2023 17:33:19 -0500 Subject: wallet: Add IsActiveScriptPubKeyMan Given a ScriptPubKeyMan, it's useful to ask the wallet whether it is currently active. --- src/wallet/wallet.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 8b0ee22276..305d359a64 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -942,6 +942,7 @@ public: //! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers std::set GetActiveScriptPubKeyMans() const; + bool IsActiveScriptPubKeyMan(const ScriptPubKeyMan& spkm) const; //! Returns all unique ScriptPubKeyMans std::set GetAllScriptPubKeyMans() const; -- cgit v1.2.3 From 54e74f46ea10e479be682750c1279165f29bb2f4 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 19 Dec 2022 16:59:25 -0500 Subject: wallet: Refactor function for single DescSPKM setup We will need access to a function that sets up a singular DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM setup function. --- src/wallet/wallet.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 305d359a64..8586c09b59 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1018,6 +1018,8 @@ public: //! @param[in] internal Whether this ScriptPubKeyMan provides change addresses void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal); + //! Create new DescriptorScriptPubKeyMan and add it to the wallet + DescriptorScriptPubKeyMan& SetupDescriptorScriptPubKeyMan(WalletBatch& batch, const CExtKey& master_key, const OutputType& output_type, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Create new DescriptorScriptPubKeyMans and add them to the wallet void SetupDescriptorScriptPubKeyMans(const CExtKey& master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); -- cgit v1.2.3 From 85b1fb19dd3a3f3c68da1c5e60a6eb911e1119a6 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Thu, 21 Dec 2023 18:35:29 -0500 Subject: wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors --- src/wallet/wallet.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 8586c09b59..83425fca6b 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1056,6 +1056,9 @@ public: void CacheNewScriptPubKeys(const std::set& spks, ScriptPubKeyMan* spkm); void TopUpCallback(const std::set& spks, ScriptPubKeyMan* spkm) override; + + //! Retrieve the xpubs in use by the active descriptors + std::set GetActiveHDPubKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); }; /** -- cgit v1.2.3 From 8e1a475062e62321e58a0624385cc3fa0885aa12 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Thu, 21 Dec 2023 18:39:23 -0500 Subject: wallet: Be able to retrieve single key from descriptors Adds CWallet::GetKey which retrieves a single key from the descriptors stored in the wallet. --- src/wallet/wallet.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 83425fca6b..f07db175b4 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1059,6 +1059,10 @@ public: //! Retrieve the xpubs in use by the active descriptors std::set GetActiveHDPubKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + + //! Find the private key for the given key id from the wallet's descriptors, if available + //! Returns nullopt when no descriptor has the key or if the wallet is locked. + std::optional GetKey(const CKeyID& keyid) const; }; /** -- cgit v1.2.3