spkm: Remove DescriptorSPKM constructor that doesn't take a descriptor

Instead of creating a DescriptorSPKM that doesn't have a descriptor,
only to then generate the descriptor, combine SetupDescriptorGeneration
into the GenerateNewSingleSig factory function, and within that
function, generate the descriptor first before constructing the new
DescriptorSPKM.
This commit is contained in:
Ava Chow
2026-06-02 14:10:54 -07:00
parent 770ff64bd7
commit 9fc7b2618b
4 changed files with 35 additions and 56 deletions

View File

@@ -28,17 +28,16 @@ std::unique_ptr<ExternalSignerScriptPubKeyMan> ExternalSignerScriptPubKeyMan::Lo
std::unique_ptr<ExternalSignerScriptPubKeyMan> ExternalSignerScriptPubKeyMan::CreateNew(WalletStorage& storage, WalletBatch& batch, int64_t keypool_size, std::unique_ptr<Descriptor> desc)
{
auto spkm = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(storage, keypool_size));
LOCK(spkm->cs_desc_man);
assert(storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
assert(storage.IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER));
int64_t creation_time = GetTime();
// Make the descriptor
WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
spkm->m_wallet_descriptor = w_desc;
auto spkm = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(storage, w_desc, keypool_size));
LOCK(spkm->cs_desc_man);
assert(storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
assert(storage.IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER));
// Store the descriptor
if (!batch.WriteDescriptor(spkm->GetID(), spkm->m_wallet_descriptor)) {