Skip to content

Commit 0233926

Browse files
committed
wallet: populate change label tweak after desc generation
1 parent 9058920 commit 0233926

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,9 +1643,14 @@ bool DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor(const WalletDescript
16431643

16441644
SilentPaymentDescriptorScriptPubKeyMan::SilentPaymentDescriptorScriptPubKeyMan(WalletStorage& storage, WalletDescriptor& descriptor)
16451645
: DescriptorScriptPubKeyMan(storage, descriptor, 0)
1646+
{
1647+
PopulateLabelTweaks();
1648+
}
1649+
1650+
void SilentPaymentDescriptorScriptPubKeyMan::PopulateLabelTweaks()
16461651
{
16471652
LOCK(cs_desc_man);
1648-
if (descriptor.descriptor->GetOutputType() != OutputType::SILENT_PAYMENTS) {
1653+
if (m_wallet_descriptor.descriptor->GetOutputType() != OutputType::SILENT_PAYMENTS) {
16491654
throw std::runtime_error(std::string(__func__) + ": descriptor is not a Silent Payment Descriptor");
16501655
}
16511656
const auto provider{GetSPProvider()};
@@ -1659,6 +1664,13 @@ SilentPaymentDescriptorScriptPubKeyMan::SilentPaymentDescriptorScriptPubKeyMan(W
16591664
}
16601665
}
16611666

1667+
bool SilentPaymentDescriptorScriptPubKeyMan::SetupDescriptorGeneration(WalletBatch& batch, const CExtKey& master_key, OutputType addr_type, bool internal)
1668+
{
1669+
if (!DescriptorScriptPubKeyMan::SetupDescriptorGeneration(batch, master_key, addr_type, internal)) return false;
1670+
PopulateLabelTweaks();
1671+
return true;
1672+
}
1673+
16621674
util::Result<CTxDestination> SilentPaymentDescriptorScriptPubKeyMan::GetNewDestination(const OutputType type)
16631675
{
16641676
LOCK(cs_desc_man);

src/wallet/scriptpubkeyman.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
359359
bool IsHDEnabled() const override;
360360

361361
//! Setup descriptors based on the given CExtkey
362-
bool SetupDescriptorGeneration(WalletBatch& batch, const CExtKey& master_key, OutputType addr_type, bool internal);
362+
virtual bool SetupDescriptorGeneration(WalletBatch& batch, const CExtKey& master_key, OutputType addr_type, bool internal);
363363

364364
bool HavePrivateKeys() const override;
365365
bool HasPrivKey(const CKeyID& keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
@@ -421,6 +421,7 @@ class SilentPaymentDescriptorScriptPubKeyMan : public DescriptorScriptPubKeyMan
421421
TweakMap m_map_spk_tweaks GUARDED_BY(cs_desc_man);
422422
LabelTweakMap m_map_label_tweaks GUARDED_BY(cs_desc_man);
423423

424+
void PopulateLabelTweaks();
424425
FlatSigningProvider GetSPProvider() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
425426
std::unique_ptr<FlatSigningProvider> GetSigningProvider(const CScript& script, bool include_private = false) const override;
426427

@@ -434,6 +435,8 @@ class SilentPaymentDescriptorScriptPubKeyMan : public DescriptorScriptPubKeyMan
434435
: DescriptorScriptPubKeyMan(storage, 0)
435436
{}
436437

438+
bool SetupDescriptorGeneration(WalletBatch& batch, const CExtKey& master_key, OutputType addr_type, bool internal) override;
439+
437440
util::Result<CTxDestination> GetNewDestination(const OutputType type) override;
438441
util::Result<CTxDestination> GetNewLabeledDestination(uint64_t& index);
439442
V0SilentPaymentDestination GetLabeledDestination(uint64_t index) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);

0 commit comments

Comments
 (0)