1 minor finding · 3 suggestions
Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.
Findings
[minor] · The upgrade changes below-range_start ownership without recovery guidance
Active, derivable descriptors with range_start > range_end - range_start can lose below-start IsMine recognition after upgrade; no affected production wallet was identified.
Location: src/wallet/scriptpubkeyman.cpp:1152 (head).
Details and suggested fix
Base Load() leaves m_max_cached_index at range_end - range_start - 1, and startup then calls TopUpKeyPool() for active descriptors. For a stored range of [600000, 601000), base resumes derivation at 1000 and restores recognition of indexes 1000 through 599999 on every reopening. Head records the absolute cached endpoint and no longer watches that band. The PR description's statement that reopening already drops below-start ownership overlooks this startup top-up.
Keep the corrected range semantics, but explain this existing-wallet effect in a release note and correct the description. Document that re-importing the same descriptor with a lower start restores recognition, provided the requested end also includes the current stored end. No keys or descriptor data are removed.
Optional improvements
[suggestion] · Reload assertions miss a regression in Load()'s cached index
The functional test's load-time top-up repairs an incorrect m_max_cached_index before check() runs, so reverting only the Load() assignment leaves the new assertions unchanged.
Location: test/functional/wallet_importdescriptors.py:226 (head).
Details and suggested fix
Node 0 uses the default keypool of 1000. Importing the descriptor and rescanning the payment at index 1000 leaves its stored range at [1000, 2001). If only Load() reverted to m_max_cached_index++, the counter would be 1000 after loading. Startup top-up would re-derive indexes 1001 through 2000 and restore the correct endpoint before checking ownership, balance, range, or metadata-derived keypoolsize. Those assertions cannot detect the redundant work. Add a wallet unit test that reloads a descriptor with a nonzero start through LoadFromStorage() and asserts GetEndRange() == GetWalletDescriptor().GetEnd() before any top-up. This directly guards the endpoint invariant while retaining the functional ownership checks.
[suggestion] · Lower-start re-import coverage does not check recovered ownership
The existing range-lowering test checks keypoolsize, not whether newly included scripts become IsMine; the new funded fixture can directly cover that recovery path.
Location: test/functional/wallet_importdescriptors.py:193 (head).
Details and suggested fix
UpdateWalletDescriptor() clears the script maps, resets m_max_cached_index, applies the new start, and calls TopUpWithDB(). The current range-extension test checks only GetEnd() - GetNext(), so its assertions do not establish that the maps were rebuilt. Before the new test's final unload, read the current inclusive end from listdescriptors and re-import with "range": [999, current_end] and "timestamp": 0. Using [999, 1009] would fail because updates cannot shrink the already extended range. Assert that below_start becomes mine, first_in_range remains mine, and trusted balance becomes 3, then repeat those checks after reloading.
[suggestion] · The description's example range is rejected before expansion
Source inspection shows that importdescriptors rejects the description's [2146483648, 2147483647]; the commit message's [2146483647, 2147483646] passes the bounds and demonstrates the base expansion.
Location: src/wallet/scriptpubkeyman.cpp:1152 (head).
Details and suggested fix
ProcessDescriptorImport() converts the inclusive end to range_end = high + 1. For the description's example, that becomes 2147483648 and fails the int32_t bound with "End of range is too high" before constructing a WalletDescriptor. Use [2146483647, 2147483646], as in the commit message. Its exclusive end is 2147483647, so it passes this check and base TopUpWithDB() would derive [0, 2147483647).
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Check the cached-index cursor after reload and during a later top-up
- [suggestion]: Prevent top-up endpoint overflow for accepted near-limit ranges
- [suggestion]: Check the loaded cache end before descriptor top-up