Repository navigation
Description
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
- The background DashPay sync refreshes the profiles of the identity's contacts and of everyone who sent it a request, and persists them.
- 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:
ContactProfileEntry { profile: Option<DashPayProfile>, checked_at_ms }(types/dashpay/profile.rs#L58-L64), held inDashPayState::contact_profiles(state/managed_identity/dashpay.rs#L127). It is persisted through the changeset and SQLite.sync_contact_profiles(network/profile.rs#L419) already batches the contact ids and runs one$ownerId In [...]query per chunk. The same id set could drive a batched DPNS lookup.- The wallet already resolves DPNS names elsewhere:
build_auto_accept_qrresolves the owner's name on-chain viaget_dpns_usernames_by_identity(rs-sdk platform/dpns_usernames/queries.rs#L44).
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
- feat(platform-wallet): wallet-level DPNS username marketplace with FFI and Swift wrappers #4348: the DPNS username marketplace (wallet-level DPNS sync). It covers the identity's own names, not its contacts'.
- feat(sdk): move DashPay profile create, update and fetch into rs-sdk #5470: moved DashPay profile create, update and fetch into rs-sdk. It is where a batched profile-plus-username fetch could live if preferred.
Attribution
🤖 Co-authored by Claudius the Magnificent AI Agent
Activity