Skip to content

platform-wallet: keep a contact's DPNS username next to their cached DashPay profile #5598

Open

Description

@Claudius-Maginificent

TL;DR: The wallet caches each contact's DashPay profile but not their username, so every app looks usernames up and stores them on its own to show "@name" in contact lists, especially offline.

User story

As a DashPay user, I want my contacts and pending requests to show each person's username even when I'm offline or just restarted the app.

As a wallet app developer, I want the wallet's contact cache to hold the username it already knows how to look up, so I don't keep a second store of contact names.

Scenario

Base flow

  1. The background DashPay sync refreshes the profiles of the identity's contacts and of everyone who sent it a request, and persists them.
  2. The user opens the contact list, possibly offline after a restart.

Actual behavior

Display name, bio and avatar come from the wallet's cache. The username does not: the cache entry has no field for it. Each app looks usernames up and persists them on its own.

Expected behavior

The cached contact entry also holds the contact's DPNS username, refreshed on the same schedule as the profile and persisted with it.

Detailed discussion

On v5.1-dev @ 575d961fe0:

Downstream: Dash Evo Tool keeps src/wallet_backend/contact_usernames.rs, a per-session lookup plus a persisted k/v store, marked TODO(upstream): carry the DPNS username on ContactProfileEntry.

Proposed change

pub struct ContactProfileEntry {
    pub profile: Option<DashPayProfile>,
    /// The contact's DPNS username (the same deterministic choice
    /// `build_auto_accept_qr` makes when an identity holds several),
    /// `None` when they have none or it has not been resolved yet.
    pub username: Option<String>,
    pub checked_at_ms: u64,
}

Resolve the username in sync_contact_profiles for the ids it already selected, on the same refresh window. Persist it with the entry, defaulting to None for stored rows. Name changes are rare, so reusing the profile's refresh window is enough.

Prior work

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