Compare commits

...

3 commits

Author SHA1 Message Date
Oghenovo Usiwoma
cb1e04c871
Merge fa0993462b into 3a29ba33dc 2025-04-28 20:49:08 +05:30
Novo
fa0993462b Test updating non-ranged descriptor with [0,0] range succeeds 2025-04-25 05:54:26 +01:00
Novo
2ae1788dd4 Skip range verification for non-ranged desc
Non-range desc  are always added to the wallet with the range [0,0]. After the descriptor is added, the wallet will  TopUp the keypool. For non-range descriptors, this process updates the desc range to [0,1].

Any attempts to update this non-range descriptor with a [0,0] range will result in an error because the range checks rejects new ranges not included in the old range.

Since  this is a non-range desc, the range information should be disregarded and AddWalletDescriptor should always succeed regardless of provided range information
2025-04-25 05:54:25 +01:00
2 changed files with 26 additions and 0 deletions

View file

@ -2852,6 +2852,11 @@ bool DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor(const WalletDescript
return false;
}
if (!descriptor.descriptor->IsRange()) {
// Skip range check for non-range descriptors
return true;
}
if (descriptor.range_start > m_wallet_descriptor.range_start ||
descriptor.range_end < m_wallet_descriptor.range_end) {
// Use inclusive range for error

View file

@ -73,6 +73,27 @@ static void AddKey(CWallet& wallet, const CKey& key)
assert(spk_manager);
}
BOOST_FIXTURE_TEST_CASE(update_non_range_descriptor, TestingSetup)
{
CWallet wallet(m_node.chain.get(), "", CreateMockableWalletDatabase());
{
LOCK(wallet.cs_wallet);
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
auto key{GenerateRandomKey()};
auto desc_str{"combo(" + EncodeSecret(key) + ")"};
for (size_t i = 0; i < 2; i++)
{
FlatSigningProvider provider;
std::string error;
auto descs{Parse(desc_str, provider, error, /* require_checksum=*/ false)};
auto& desc{descs.at(0)};
WalletDescriptor w_desc{std::move(desc), 0, 0, 0, 0};
auto spk_manager{*Assert(wallet.AddWalletDescriptor(w_desc, provider, "", false))};
assert(spk_manager);
}
}
}
BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
{
// Cap last block file size, and mine new block in a new block file.