Merge bitcoin/bitcoin#32344: Wallet: Fix Non-Ranged Descriptors with Range [0,0] Trigger Unexpected Wallet Errors in AddWalletDescriptor
97d383af6dTest updating non-ranged descriptor with [0,0] range succeeds (Novo)2ae1788dd4Skip 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: ACK97d383af6drkrux: ACK97d383aTree-SHA512: 6dbd058376d9e57d26477d9d6d89646e80a32e3ffcc9f4e30eeda273575d12583ce520cc0032cc67c12ea0b3ad344fbd3945d9fc5e389b6a6bce1ea7ad5d6e59
This commit is contained in:
2 files changed
+24
No files matched your search
@@ -1598,6 +1598,11 @@ bool DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor(const WalletDescript
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!descriptor.descriptor->IsRange()) {
|
||||||
|
// Skip range check for non-range descriptors
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor.range_start > m_wallet_descriptor.range_start ||
|
if (descriptor.range_start > m_wallet_descriptor.range_start ||
|
||||||
descriptor.range_end < m_wallet_descriptor.range_end) {
|
descriptor.range_end < m_wallet_descriptor.range_end) {
|
||||||
// Use inclusive range for error
|
// Use inclusive range for error
|
||||||
|
|||||||
@@ -70,6 +70,25 @@ static void AddKey(CWallet& wallet, const CKey& key)
|
|||||||
assert(spk_manager);
|
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)
|
BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||||
{
|
{
|
||||||
// Cap last block file size, and mine new block in a new block file.
|
// Cap last block file size, and mine new block in a new block file.
|
||||||
|
|||||||
Reference in new issue
Block a user