Skip to content

platform-wallet: a pending shielded spend never resolves once another spend consumes its inputs #6108

Done

Description

@QuantumExplorer

Problem

When the wallet can't confirm a shielded spend's result, the spend's activity row stays Pending. Its notes stay reserved and its signed transition stays saved for re-broadcast.

The row gets stuck when a different transition spends one of its inputs first, for example a spend from a second device restored from the same seed:

  • The note scan's mark_spent clears that note's reservation and drops the saved transition on the first sighting.
  • The competing spend carries none of the row's outputs, so the scan never confirms the row.
  • The anchor-expiry release (release_stranded_spends) only walks reservations, so it never fails the row either.

With a single input, or after a restart, the row stays Pending for good. No funds are held, but the row and its "a sync confirms it" wording are wrong.

Affected spend kinds

Every note-consuming kind: shielded transfer, unshield, withdrawal, identity create and top-up from the pool, private document create, and token purchase from the pool. They all settle through settle_failed_spend.

#6090 makes this more visible for token purchases. Platform's proof for type 28 doesn't bind the purchase, so every accepted purchase stays Pending until the scan finds its change.

Proposed fix

  • A sighting of a spent input stops the re-broadcast but keeps the saved transition until the spend is resolved.
  • Resolve it with Sdk::state_transition_outcome on the saved transition:
    • CannotExecute fails the row and releases its remaining notes.
    • The row's own outputs, once the scan finds them, confirm it.
  • For a token purchase, the token bundle's nullifiers make this decisive even with a single fee input.
  • Ask only the node the spend was broadcast to.
  • Do not infer failure from the scan not having seen the change. feat(swift-example-app): buy a token from the shielded pool (type 28) #6090 tried that across separately proved note ranges, several wallets and restarts, and three review rounds found it unsound.

Tests

  • A single input consumed elsewhere, before and after a restart.
  • Several inputs with one consumed elsewhere.
  • A landed spend whose change arrives a pass later stays Pending, then becomes Confirmed.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions