Repository navigation
Description
TL;DR: When the wallet syncs a DashPay contact request it drops the request document's id, so apps fetch the request from the network again whenever they need to point at that document.
User story
As a wallet app developer, I want each contact request the wallet holds to carry the id of its document, so that I can refer to it (in logs, local records or follow-up actions) without querying Platform again.
Scenario
Base flow
- The background DashPay sync fetches the contact requests sent to and by an identity and stores them in the identity's DashPay state.
- The user acts on one of them, for example declines or withdraws it, and the app needs that request's document.
Actual behavior
The stored request has the sender, recipient, key indexes, account reference, payloads and timestamps, but not the document id. The app has to re-query Platform by owner and recipient to find the document.
Expected behavior
The stored request includes its document id, so the app can address the document directly.
Detailed discussion
On v5.1-dev @ 575d961fe0:
ContactRequesthas no document id field (types/dashpay/contact_request.rs#L12-L35).- The sync discards it while parsing:
received_docs.iter().filter_map(|(_doc_id, maybe_doc)| …)and the same forsent_docs(network/contact_requests.rs#L1538, #L1561).sent_contact_requestsat #L3795 discards it too. - Requests are then held per counterparty (
DashPayState::sent_contact_requests/incoming_contact_requests, state/managed_identity/dashpay.rs#L177-L191). A rotated request (a new document with a bumpedaccountReference) replaces the old one, so a document id is also the only way to tell which document a stored entry came from.
Downstream: Dash Evo Tool re-keyed its Accept / Decline / Cancel actions from the document id to the counterparty, and now re-fetches the request document by ($ownerId, toUserId) before each action. It still needs the document id to clear progress records older versions stored per document.
Proposed change
pub struct ContactRequest {
// … existing fields …
/// Id of the `contactRequest` document this entry was parsed from.
/// `None` for entries built locally before the document was confirmed.
pub document_id: Option<Identifier>,
}Fill it in from the (doc_id, doc) pairs at the parse sites above, and carry it through persistence (changeset and SQLite schema), defaulting to None for stored rows. A send path that already knows the id after broadcast can set it there too.
Prior work
- feat(platform)!: dashpay contract v3 declares the checks of its data triggers #4933: makes DashPay contact requests declare their checks. It touches the same document type but not the stored request shape.
Attribution
🤖 Co-authored by Claudius the Magnificent AI Agent
Activity