Skip to content

Mark Spendable leaves/reapplies Do Not Spend: refresh can overwrite manual choice and UI reports success too early #7077

Open

Description

@antuz123

Release decision — R7 / 2.6.7

22 October 2026 — updated release placement following the owner's latest guidance: assign dust/manual-spendability #7077 to R7 / 2.6.7. Hide-wallet #7075 stays in R6 / 2.6.6 as the higher-priority correction. This supersedes the earlier plan to include both in R6. R5 remains 2.6.5; no intermediate maintenance release is scheduled. The demonstrated spendability race remains a known open defect during R6; deferral is not a fix or a passing acceptance result. Implementation and native/device acceptance remain pending.

Describe the bug

The owner reports: run Dust Report, open a coin marked as dust, choose Mark Spendable, and the Do Not Spend tag does not disappear.

Source investigation established two relevant defects:

  1. An in-flight wallet refresh can overwrite a newer persisted manual spendability choice.
  2. The detail screen announces success immediately after dispatch, even if the local mutation later fails or makes no change.

The exact path that occurred on the owner's phone is not yet established. This report addresses the current coin's stored restriction, live badge and accurate action feedback; a purely cosmetic badge removal is insufficient.

Status: reported incident; source investigation and controlled race reproduction completed; implementation and native/device confirmation pending.

Reproduce and expected behavior

  1. Open wallet → Wallet Settings → Dust Report → Run Report.
  2. Open or navigate to a currently marked coin's details.
  3. Select Mark Spendable.
  4. Check the live detail screen and Manage Coins: badge, opposite action and stored spendability should agree.
  5. Leave/reopen details, refresh the wallet, rerun the report, and cold restart to verify persistence.

Expected: the selected current outpoint is persisted as spendable with isManualOverride: true; the current Do Not Spend restriction/badge clears; ordinary automatic coin-selection eligibility agrees; the choice survives refresh/rescan/restart. Other coins' independent restrictions remain intact.

Existing requirements already require this: #6970 (persistent user overrides), #6972 (spending restrictions and explicit Mark Spendable), #6986 (report). #6971 is a closed duplicate of #6970 and should not be reopened.

Evidence and baseline

Demonstrated failure: older refresh overwrites newer manual choice

The refresh saga takes a persisted spendability snapshot before awaiting Electrum. It later classifies using that earlier snapshot and writes the full refreshed wallet specs without preserving a choice committed during the wait.

Deterministic reproduction:

  1. Begin with a current dust-marked outpoint: doNotSpend, isManualOverride: false.
  2. Start a refresh and hold its Electrum result after the pre-sync snapshot is captured.
  3. Execute the actual manual spendability worker for the same outpoint.
  4. Confirm local persisted state is now spendable, isManualOverride: true.
  5. Release the held refresh. With the old snapshot and a tainted classification, the current code writes doNotSpend, isManualOverride: false.

The reverse also fails: a user can manually mark an initially spendable coin Do Not Spend while refresh is pending, and the older refresh can restore spendable. Fixing both directions is necessary to preserve the user's privacy restriction.

Controlled verification actually executed

Executed source-derived JavaScript for the actual markUTXOSpendabilityWorker and the exact refresh snapshot/classification blocks, with TypeScript annotations removed. Realm, Redux effects, account/session state, backup responses and the network boundary were mocked using synthetic values. This did not execute the entire refresh worker.

Scenario Immediately after manual save After refresh completion
Mark Spendable during ordinary refresh spendable / manual=true doNotSpend / manual=false
Mark Spendable during full dust scan spendable / manual=true doNotSpend / manual=false
Mark Do Not Spend during ordinary refresh doNotSpend / manual=true spendable / manual=false
Control: override completes before refresh starts spendable / manual=true spendable / manual=true

Four deterministic cases executed: three reproduced loss of the latest override; one control preserved it. In all four the manual worker first committed the intended state despite backup returning updated: false.

These are demonstrations of existing behavior, not passing fix tests or a reproduction on the original phone. Native iOS/Android, actual encrypted Realm and live Relay remain untested in this investigation.

Confirmed feedback defect

UTXOLabeling.tsx dispatches Mark Spendable and immediately displays “Coin marked spendable”. The reverse action does the same.

The worker can return early for missing/stale origin, missing wallet/outpoint or failed local commit, and its outer catch only logs the exception. The screen therefore can report success while the restriction remains unchanged.

An ordinary server upload failure should not block the local choice: persistence precedes backup upload. However, shared local recovery-snapshot/account safeguards can fail before/during persistence, so that failure category remains relevant to the phone report and companion #7075. The owner subsequently confirmed that the companion hide attempt also failed locally; do not treat it as a backend-only problem or assume a shared exact root cause without evidence.

This is functional state, not just a text label

The detail screen reads current spendability through the spendability hook. Automatic selection excludes doNotSpend coins.

Check persisted state and selection eligibility as well as rendering. Do not remove the warning while leaving the coin restricted, or falsely clear the restriction while retaining a stale warning.

The detail screen currently reads isManualOverride and dustReason from its original route UTXO while using live spendability. When touching this view, read all three from the same current outpoint so the reason text does not remain stale.

Preserve static Dust Report semantics

The existing report specification explicitly describes a static scan result with Last scanned. A retained historical report row alone is not proof that the current coin remains restricted.

Keep historical dust findings and historical transaction labels. Distinguish them from current UTXO state and current actionable eligibility. No live-report/dashboard redesign, dust-threshold change, or classifier-policy expansion belongs in this fix.

Narrow correction requested

  • Preserve the latest persisted manual choice at the refresh's final merge/write boundary, keyed by wallet identity and txId:vout. Make that boundary consistent so a user mutation cannot be lost between reading current overrides and committing refreshed specs.
  • Cover both Mark Spendable and Mark Do Not Spend, confirmed/unconfirmed transitions, and normal/hard refresh plus full dust scans.
  • Show success only after confirmed local persistence. Correctly report rejected/stale/failed/no-target outcomes; avoid premature success or optimistic removal of a real restriction.
  • Keep local success independent of remote upload availability and retain accurate pending-backup state.
  • Keep current account/session/network isolation, backup consent and protected-backup safety guards.
  • Do not weaken the coin-selection restriction, indiscriminately clear other coins, change donation behavior or rewrite synchronization architecture.

Acceptance required before closure

  • Failing-before/passing-after tests using the actual workers and controlled delayed network completion for both manual directions.
  • Run report → open current coin → Mark Spendable: persisted state, live badge, opposite action and automatic-selection eligibility agree.
  • The latest override survives refresh, hard refresh, full rescan, leaving/reopening the screen and cold restart.
  • Cover confirmed/unconfirmed coins and both normal wallets and vault-backed wallets.
  • Backup disabled, offline and failed upload preserve a valid locally saved choice.
  • Actual local-write failure and stale account/session produce no success toast; no mutation leaks across accounts, including A → B → A.
  • Other outpoints retain their restrictions; historical report/transaction findings remain historical.
  • Targeted native iOS/Android acceptance on the final PR SHA, followed by non-destructive affected-phone confirmation on an approved build. No transaction broadcast or real-funds test is necessary to verify the state/selection bug.

Release placement and Codex Cloud handoff

Target: R7 / 2.6.7 — explicitly deferred from R6 with the owner's agreement. Keep the refresh/manual-spendability race and truthful action feedback together in one focused PR. Use the verified completed R6 baseline, inspect any shared local-operation corrections from hide-wallet #7075, and implement only the remaining work. Include this fix in the R7 integration candidate and iOS/Android acceptance. Preserve already-running work. New R7 implementation follows the existing roadmap sequence after R6 closes; this scheduling update does not launch a Codex task.

The later scheduling does not classify this as cosmetic: the demonstrated race can also undo Mark Do Not Spend, affecting coin-selection/privacy controls. Retain the known failure and its explicit deferral in R6 evidence; do not mark it passed or imply the manual override is reliable under the reproduced race. Correct and verify both directions and persistence across refresh/relaunch as part of R7 acceptance before Assisted Multisig production readiness. The existing handling of critical or release-blocking findings still applies.

Provisional remaining estimate for this issue in R7: 3k–6k changed code/test tokens, re-estimated after adopting any relevant R6/shared fixes. Hide-wallet's separate 2k–5k estimate belongs to R6. At R7 kickoff, reconcile completed work and estimate the whole remaining R7 scope, including Assisted Multisig security/production work and this fix. Apply the existing ~20k / more-than-two-substantial-features advisory to the combined release scope; keep any further allocation changes within numbered releases.

At handoff use the Bitcoin Keeper Codex Cloud environment, not base. Re-read current AGENTS.md and applicable repository instructions, inspect current PR heads/comments, select the verified compatible source baseline and use a separate task branch/focused PR. Reuse completed upstream work without cross-editing active producer branches. Supply actual test outcomes and the exact-head Codex local handoff / NEEDS_LOCAL, required IOS and ANDROID acceptance, and explicit original-phone confirmation gap. No merge, signing, deployment or publication authorization is granted.

Related: #7075, #6970, #6972, #6974, #6986, #7066.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: to-do 📋Items not yet picked upType: bug🐛severity:S2Major: core flow blocked or degraded; provisional until reproduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions