Skip to content

fix(platform-wallet): keep stored acceptedAccounts when set_contact_info_with_external_signer replaces a contactInfo document #5657

Open

Description

@Claudius-Maginificent

TL;DR: Saving a contact's nickname, note or hidden flag through set_contact_info_with_external_signer always writes an empty acceptedAccounts list, so the accounts stored in the existing DIP-15 contactInfo document are silently erased.

User story

As a wallet app developer, I want to update a contact's nickname, note or hidden flag without losing the accepted accounts already saved for that contact, to achieve a metadata edit that changes only what the user edited.

Scenario

Base flow

A contact already has a contactInfo document on Platform whose private data lists one or more accepted accounts (written by another app or an older version of this one). The user edits the contact's note and saves.

Actual behavior

The wallet builds the new private data with accepted_accounts: Vec::new() and publishes it as the replacement document. The previously stored accepted accounts are gone after the save.

Expected behavior

The stored accepted accounts survive a metadata edit. Callers that do want to change them can say so explicitly.

Detailed discussion

At the revision Dash Evo Tool pins (575d961), packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs, set_contact_info_with_external_signer (~line 504) builds:

let metadata = ContactInfoPrivateData {
    alias_name: alias,
    note,
    display_hidden,
    // Multi-account acceptance isn't populated yet; a metadata
    // update carries an empty `acceptedAccounts`.
    accepted_accounts: Vec::new(),   // ~line 531
};

The method has no parameter for accepted accounts and does not read the existing document's value before encoding, so the field cannot be kept or set by the caller. The same struct is used both for the local contact copy and for the encrypted payload that replaces the document.

Dash Evo Tool's earlier in-house writer avoided this with an explicit choice per field (AcceptedAccounts::Preserve / Replace, see src/backend_task/dashpay/contact_info.rs on v1.0-dev): it decrypted the existing document and carried accepted_accounts over unless told otherwise. Moving to the platform-wallet writer loses that behaviour. This blocks dashpay/dash-evo-tool#1102.

Proposed approach (either is fine):

  1. Default to preserving: when a previous contactInfo is available (it is already fetched/decrypted for the document slot), reuse its accepted_accounts.
  2. Or add an accepted_accounts: Option<Vec<u32>> parameter (None = keep stored, Some = replace).

Option 1 is the smaller API change; option 2 is more explicit and lets callers clear the list. Either way a test should cover "edit note, accepted accounts unchanged".

Prior work

None of these covers dropping acceptedAccounts on replace.

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

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