Skip to content

Commit 2ca1fca

Browse files
committed
wallet: Construct ExternalSignerSPKM with the new descriptor
Instead of constructing then setting the descriptor with SetupDescriptor, just pass in that descriptor to the constructor.
1 parent 5356339 commit 2ca1fca

4 files changed

+8
-19
lines changed

src/wallet/external_signer_scriptpubkeyman.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include <vector>
1717

1818
namespace wallet {
19-
bool ExternalSignerScriptPubKeyMan::SetupDescriptor(std::unique_ptr<Descriptor> desc)
19+
ExternalSignerScriptPubKeyMan::ExternalSignerScriptPubKeyMan(WalletStorage& storage, int64_t keypool_size, std::unique_ptr<Descriptor> desc)
20+
: DescriptorScriptPubKeyMan(storage, keypool_size)
2021
{
2122
LOCK(cs_desc_man);
2223
assert(m_storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
@@ -38,7 +39,6 @@ bool ExternalSignerScriptPubKeyMan::SetupDescriptor(std::unique_ptr<Descriptor>
3839
TopUp();
3940

4041
m_storage.UnsetBlankWalletFlag(batch);
41-
return true;
4242
}
4343

4444
ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {

src/wallet/external_signer_scriptpubkeyman.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,13 @@
1212
namespace wallet {
1313
class ExternalSignerScriptPubKeyMan : public DescriptorScriptPubKeyMan
1414
{
15-
public:
16-
ExternalSignerScriptPubKeyMan(WalletStorage& storage, const uint256& id, WalletDescriptor& descriptor, int64_t keypool_size, const KeyMap& keys, const CryptedKeyMap& ckeys)
15+
public:
16+
//! Create an ExternalSPKM from existing wallet data
17+
ExternalSignerScriptPubKeyMan(WalletStorage& storage, const uint256& id, WalletDescriptor& descriptor, int64_t keypool_size, const KeyMap& keys, const CryptedKeyMap& ckeys)
1718
: DescriptorScriptPubKeyMan(storage, id, descriptor, keypool_size, keys, ckeys)
1819
{}
19-
ExternalSignerScriptPubKeyMan(WalletStorage& storage, int64_t keypool_size)
20-
: DescriptorScriptPubKeyMan(storage, keypool_size)
21-
{}
22-
23-
/** Provide a descriptor at setup time
24-
* Returns false if already setup or setup fails, true if setup is successful
25-
*/
26-
bool SetupDescriptor(std::unique_ptr<Descriptor>desc);
20+
//! Create a new ExternalSPKM from just a descriptor
21+
ExternalSignerScriptPubKeyMan(WalletStorage& storage, int64_t keypool_size, std::unique_ptr<Descriptor> desc);
2722

2823
static ExternalSigner GetExternalSigner();
2924

src/wallet/scriptpubkeyman.h

-5
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,6 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
621621
//! Setup descriptors based on the given CExtkey
622622
bool SetupDescriptorGeneration(const CExtKey& master_key, OutputType addr_type, bool internal);
623623

624-
/** Provide a descriptor at setup time
625-
* Returns false if already setup or setup fails, true if setup is successful
626-
*/
627-
bool SetupDescriptor(std::unique_ptr<Descriptor>desc);
628-
629624
bool HavePrivateKeys() const override;
630625

631626
std::optional<int64_t> GetOldestKeyPoolTime() const override;

src/wallet/wallet.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3616,8 +3616,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
36163616
continue;
36173617
}
36183618
OutputType t = *desc->GetOutputType();
3619-
auto spk_manager = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, m_keypool_size));
3620-
spk_manager->SetupDescriptor(std::move(desc));
3619+
auto spk_manager = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, m_keypool_size, std::move(desc)));
36213620
uint256 id = spk_manager->GetID();
36223621
AddScriptPubKeyMan(id, std::move(spk_manager));
36233622
AddActiveScriptPubKeyMan(id, t, internal);

0 commit comments

Comments
 (0)