Skip to content

platform-wallet: a swept and reinstated asset lock loses its recorded shielded recipient #5778

Open

Description

@llbartekll

Problem

#5762 (closes #5603) records the Orchard recipient of a Core → Shielded funding on the tracked asset lock, so a resume after an app kill pays the recorded recipient and refuses another one. That binding does not survive a sweep followed by a reinstatement of the same funding transaction.

  1. A shielded funding to recipient A is tracked with shielded_recipient = Some(A).
  2. The funding transaction is swept, for example after a conflict. remove_tracked_asset_locks_for_swept (packages/rs-platform-wallet/src/wallet/asset_lock/sync/reconstruction.rs) removes the whole live entry and emits a persistence removal.
  3. The same transaction returns. Reconstruction in the same file rebuilds the entry with operation_id: None and shielded_recipient: None, and apply_record inserts it into the live map.
  4. A generic resume reaches resume_recipient(None, requested) and accepts any recipient B.

preserve_recovery_metadata cannot help, because it only protects an entry that still exists. When the sweep and the reinstatement are folded into one persistence round, storage may keep A through its keep-on-nil rule while the live map holds None, so the protection differs before and after a reload.

The operation UUID has the same shape of gap for locks outside the retention added for drains (see #5528). A lock without a UUID, such as a typed-amount shielded funding, is not covered by that work.

Impact

Rare, since it needs a sweep and a return of the same transaction, but when it happens the destination check from #5762 is bypassed: the lock is treated as a legacy row and the caller's recipient is accepted.

Suggested direction

Retain non-actionable recovery metadata (recipient and operation UUID) across a removal and a restart, and reattach it when the same outpoint is recovered. If it cannot be reattached, fail closed and refuse the resume. One design should cover both fields.

Acceptance

  • A recipient-bearing lock without a UUID keeps its recipient through sweep and reinstatement, both in memory and after a reload, including when both events share a persistence round.
  • A resume to a different recipient is refused with AssetLockRecipientMismatch after reinstatement.
  • The existing sweep and reinstatement regression test is extended with a recipient-bearing lock.

Raised in review on #5762 (#5762 (comment)) and deferred there as out of scope.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions