Skip to content

platform-wallet: one-time funding key used by an external asset lock can be offered again after restart #5789

Open

Description

@Claudius-Maginificent

TL;DR

A wallet may hand out an identity funding key a second time after a restart, if that key was already used by an asset lock that the wallet did not build itself.

User story

As a wallet user, I want every one-time funding key to be used only once, to keep my identity funding private and avoid failed or linked registrations.

Scenario

Expected behavior

When any asset lock that the wallet sees pays Platform credits to one of its own one-time funding keys (identity registration, top-up or invitation), that key is stored as used. After a restart it is not offered again.

Actual behavior

Found by reading the code during review of #5787; not reproduced at runtime.

  • An asset lock built outside this wallet (for example, signed with the same seed in another app) can pay credits to a funding key that this wallet still holds as unused.
  • The SQLite store saves such a key only when it has no row yet (ON CONFLICT DO NOTHING, needed so a live snapshot never overwrites a newer stored reservation). An existing row stays unused.
  • After a restart the restored pool still offers the key as available, so the next identity registration, top-up or invitation can reuse it.

The wallet's own asset-lock builder marks its credit key used before broadcast, so this needs an externally built lock.

Detailed discussion

  • Where: credit-key evidence written in platform-wallet-storage sqlite/schema/core_pool.rs (PoolWrite::Evidence, insert-only) and emitted from platform-wallet changeset/core_bridge.rs (credit_ownership). Introduced alongside fix(platform-wallet): classify asset locks funding foreign credits as outgoing #5787, which records credit keys so the history repair can classify asset-lock direction. Before fix(platform-wallet): classify asset locks funding foreign credits as outgoing #5787 such keys got no evidence row at all.
  • Open question: does key-wallet mark an address used when it appears only in an asset-lock payload's credit_outputs (not an ordinary output)? If not, the in-memory pool keeps the key Available too, and the gap exists independently of SQLite.
  • Possible fix: when a credit output of a seen asset lock matches an owned one-time funding key, mark that key used in both the in-memory pool and the store. Only move it toward used, never back to available, so a newer reservation is never lost. Add a restart regression with an externally built lock.
  • Impact: privacy (address reuse) and possibly a failed or linked identity operation. No loss of funds identified; no consensus change.

🤖 Co-authored by Claudius the Magnificent AI Agent

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions