Skip to content

fix(account): "Generate new user" keeps the previous identity's trades and chats #273

Description

@Catrya

Generating a new user rotates the identity but never deletes the data derived
from the old one. delete_identity() (rust/src/api/identity.rs:287) clears
the in-memory identity, the persisted identity row, the trade-key mappings and
the logs — but the trades table (full My Trades history) and the
messages table (chat history) survive
, and the in-memory sessions are not
emptied either. The new identity starts with fresh keys yet inherits the
previous user's entire trade list and conversations.

This is a privacy issue, not just cosmetic: the point of "Generate new user"
is a clean start. The code's own comment shows the intent ("a new mnemonic
must start counting from zero instead of inheriting") but it was only applied
to keys, not data. The leftover rows are also functionally dead — their trade
keys were cleared, so nothing can operate on those orders anymore.

Reproduce

Account → Generate new user → My Trades still lists every order (and chat)
from the previous identity.

Proposed fix

  • Add clear_trades / clear_messages to the DB trait (+ SQLite and
    IndexedDB backends), mirroring the existing clear_trade_keys.
  • Call them from delete_identity(), and empty the in-memory
    session_manager there too.
  • Dart: invalidate rawTradesProvider after IdentityService.regenerate()
    so the UI reflects the clean slate immediately.

Related: the configurable retention setting (#131) will need the same bulk
DB operations.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority: highHigh priority

Type

No type

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions