You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rehydration parks a coin with no pool row in the first funds account, where it is double-counted by the next replay #5724
Problem. On load, a UTXO whose script matches no core_address_pool row is inserted into the first funds account (BIP44), even when it belongs to another funds account (CoinJoin, BIP32, DashPay receiving). The wallet total is exact after load, but the coin sits in the wrong account: a send selecting it fails ("no derivation path for selected input address"), and when SPV later replays the block that created it, the owning account inserts it again. The wallet balance then counts the coin twice (see dashpay/rust-dashcore#1294).
Reproduction. Use a wallet with CoinJoin coins at indices ≥ 100 (so no stored pool row, see #5723). Close and reopen. Observe those coins in standard_bip44 instead of coinjoin. Run an SPV replay over their creating blocks. The wallet balance exceeds the sum of distinct outpoints by the parked amount.
Cause.packages/rs-platform-wallet-storage/src/sqlite/rehydrate.rs:347-355 routes each UTXO by utxo_accounts.get(&outpoint), which is a script lookup in stored pool rows. route_to_funds_account (:429-450) returns 0 for None. The deep-index probe (extend_pools_for_restored_addresses, :395-405) runs only for the account the UTXO was routed to, so BIP44's xpub can never resolve a CoinJoin address. The docs at :241-254 call this "foreign key routed here … re-warms on next sync". The re-warm is the second insert.
Suggested fix. Before falling back to funding[0], resolve each unrouted UTXO against every funds account that has an xpub in the manifest, reusing the probe walk in extend_pools_for_restored_addresses (seeded per account), and route it to the account that resolves it. A UTXO that resolves nowhere keeps today's fallback. Add a test next to rehydration_routes_utxos_to_their_owning_account: put a CoinJoin UTXO past the stored window, with no pool row, into the load, and assert it lands in CoinJoin and not BIP44. The total cannot change, since the same UTXO set is restored; only account assignment does.
Related: #5723, #5549 (changes the same loop), #5150 / #5210 (stacked on the same file).
dashpay/rust-dashcore#1295 is merged to dev (2ddafdfe3) and adds the key-wallet side of this: ManagedWalletInfo::restore_utxos(&wallet, utxos).
Routing: it puts each stored UTXO into the funds account whose address pools hold its script, and returns the ones no account holds. It never falls back to the first funds account.
Moves: an outpoint already held by another funds account is moved to its owner, so a later replay of the creating block doesn't count it twice (rust-dashcore#1294, closed by that PR).
For rehydrate.rs, that means calling restore_utxos after marking the stored addresses used and before restore_spent_outpoints. That replaces the per-UTXO utxo_accounts lookup and the route_to_funds_account fallback (:347-355, :429-450). Anything it returns matched no account within the gap limit, and only processing its funding transaction will credit it after that. The method's doc comment covers the ordering and the synced_height caveat.
This needs platform's rust-dashcore pin to move to a revision that includes 2ddafdfe3.
🤖 Posted autonomously by Claude on behalf of pasta.
Activity
PastaPastaPasta commentedon Nov 4, 2026
dashpay/rust-dashcore#1295 is merged to
dev(2ddafdfe3) and adds the key-wallet side of this:ManagedWalletInfo::restore_utxos(&wallet, utxos).gap_limitpast its highest used address, and each UTXO's address is marked used. That repeats until no pool grows, so CoinJoin coins at deep indices (SQLite persister never writes gap-extended addresses, so CoinJoin address rows stop at the registration window #5723) are matched without a stored pool row.For
rehydrate.rs, that means callingrestore_utxosafter marking the stored addresses used and beforerestore_spent_outpoints. That replaces the per-UTXOutxo_accountslookup and theroute_to_funds_accountfallback (:347-355,:429-450). Anything it returns matched no account within the gap limit, and only processing its funding transaction will credit it after that. The method's doc comment covers the ordering and thesynced_heightcaveat.This needs platform's rust-dashcore pin to move to a revision that includes 2ddafdfe3.
🤖 Posted autonomously by Claude on behalf of pasta.