Repository navigation
fix(cutover): migrate CoinJoin funds through bounded consolidation - #1607
Merged
HashEngineering merged 40 commits intoOct 24, 2026
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses D-069: CoinJoin funds are included in the wallet header after SDK cutover but excluded from ordinary sends. Restore the migration prompt and provide a working route to either the shielded balance or the wallet's BIP44 balance.
For shielding, accounts with more than 100 outputs first consolidate within CoinJoin account 0. Select an unused external address from the SDK's persisted CoinJoin address pool. Build ordinary transactions with at most 500 inputs, keeping both the payment and any change on that address, until the account has at most 100 outputs. Smaller accounts proceed directly to the dedicated CoinJoin asset-lock API. No BIP44 funds participate in shielding.
The regular-balance option also uses 500-input consolidation batches. Accounts above 500 outputs consolidate within CoinJoin first, then the remaining outputs drain to the wallet's saved BIP44 destination. The final transfer is checkpointed before broadcast and must settle before the migration completes. Both options support retrying the persisted migration without replacing an uncertain transaction.
Migration requires completed blockchain sync and agreement between the persisted CoinJoin UTXOs and the engine's confirmed balance. Each consolidation must become InstantSend-locked or confirmed and its resulting outputs must reach persistence before the next step. Inspect the signed consolidation's input count, input ownership, and output destinations before broadcast.
Persist the destination, stage, wallet identity, and transaction ID before broadcasting consolidation. Resume observation after app locking or restart; uncertain submissions are not rebuilt. Existing pending asset locks block new funding and are resumed through the SDK recovery API. The activity-scoped migration presentation survives auto-lock, with Later, a Tools entry, retry, and explicit completion states.
A shield migration completes only when the SDK records its own asset lock as Consumed. Platform's
AssetLockAlreadyConsumedanswer is not authenticated, so it never completes, clears, or releases a migration's own record. It only stops retrying a lock whose inputs are already final on L1 (InstantSend-locked, ChainLocked, or recovered). Such a lock no longer blocks a new drain or another migration's proof. Adopted records and invalid stages held only by such locks return to the choice without recording success. When a shield record can no longer be proven, either because its own lock is in that state or because it is a legacy record with no saved inputs over an empty, synced CoinJoin account, the "could not confirm" sheet offers a confirmed "Close this migration". Closing drops the record without recording success.Consolidation publicly links the inputs it combines.
Validation
*CoinJoin*,*MixedFundsMigration*,*ShieldedBalanceService*,*SdkL1Send*,*SeamOutputLock*,*MainViewModel*) passed 423 tests with one skipped. Mutation checks cover the Consumed-only proof, retry suppression, the release paths, and each "Close this migration" condition.Remaining Recovery Limitation
This change does not discard previously persisted rejected asset locks. A process death between saving a consolidation transaction ID and submitting it can leave an uncertain checkpoint: recovery observes that transaction and will not silently construct a replacement. The pinned SDK does not expose a durable raw-transaction rebroadcast API through this path.