mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-18 03:19:18 +00:00
Merge bitcoin/bitcoin#32344: Wallet: Fix Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
97d383af6d54b463da64f45680a146d7e93eb146 Test updating non-ranged descriptor with [0,0] range succeeds (Novo) 2ae1788dd46a71cb47ec25e149ea11fa8689c64f Skip range verification for non-ranged desc (Novo) Pull request description: Closes https://github.com/bitcoin/bitcoin/issues/31728 This PR updates the `DescriptorScriptPubKeyMan` to skip range checks for non-ranged descriptors, which previously caused errors when updating a non-ranged descriptor with the range [0,0] #### Testing A unit test was added to test the new behaviour ACKs for top commit: achow101: ACK 97d383af6d54b463da64f45680a146d7e93eb146 rkrux: ACK 97d383a Tree-SHA512: 6dbd058376d9e57d26477d9d6d89646e80a32e3ffcc9f4e30eeda273575d12583ce520cc0032cc67c12ea0b3ad344fbd3945d9fc5e389b6a6bce1ea7ad5d6e59
This commit is contained in:
commit
9a887baade
@ -1598,6 +1598,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
|
||||
|
||||
@ -70,6 +70,25 @@ 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) + ")"};
|
||||
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};
|
||||
BOOST_CHECK(wallet.AddWalletDescriptor(w_desc, provider, "", false));
|
||||
// Wallet should update the non-range descriptor successfully
|
||||
BOOST_CHECK(wallet.AddWalletDescriptor(w_desc, provider, "", false));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||
{
|
||||
// Cap last block file size, and mine new block in a new block file.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user