Repository navigation
Description
Expected Behavior
When a native Rust caller drops a PreparedDashPayPayment without sending or abandoning it, its funding inputs are released and the contact's DIP-15 address is left untouched. When it cancels a send_prepared_payment future, the contact address is settled conservatively: Used if the transaction may have been dispatched, available if it never was.
Current Behavior
PreparedDashPayPaymentowns a signed transaction whose funding inputs are reserved, but it has noDropbehaviour.#[must_use]only warns. A value dropped on an early return or a cancelled confirmation future keeps its inputs reserved until key-wallet's reservation TTL expires.
platform/packages/rs-platform-wallet/src/wallet/identity/network/prepared_payment.rs
Lines 98 to 99 in dfbeb7d
#[must_use = "a prepared payment holds its funding inputs until it is sent or abandoned"] pub struct PreparedDashPayPayment<B: TransactionBroadcaster + ?Sized> { send_prepared_paymentreserves the contact address and stores the reservation before it broadcasts. It settles the address only afterbroadcast_finalized_transactionreturns. If the future is dropped while the broadcast is awaited, the address staysAddressState::Reserved. The reservation sweep covers only Standard accounts, not the DashPay external account, so each such cancellation skips one contact index permanently.
platform/packages/rs-platform-wallet/src/wallet/identity/network/prepared_payment.rs
Lines 388 to 411 in dfbeb7d
// The age guard, the in-broadcast pin and the owner-guarded release // on a definitive rejection all live in the finalized-broadcast path. let broadcast = core.broadcast_finalized_transaction(&signed).await; // Rejected, or refused as stale at dispatch: provably not on the // wire. Anything else went out or may have. On a rejection the // finalized-broadcast path has already released the inputs, so a // build that takes them before the release below sees this address // still reserved and pays the next index; this one becomes available // again, still inside the gap window. let outcome = match &broadcast { Err( PlatformWalletError::TransactionBroadcast(_) | PlatformWalletError::StaleReservation, ) => AddressOutcome::NotSent, _ => AddressOutcome::Sent, }; self.settle_payment_address( generation, &from_identity_id, &to_contact_id, &payment_address, outcome, ) .await;
platform/packages/rs-platform-wallet/src/wallet/identity/network/prepared_payment.rs
Lines 53 to 57 in dfbeb7d
//! Every address change is bound to the wallet generation the payment was //! funded from: a payment that outlives its wallet (removed, or re-created //! under the same id) never touches the new generation's pool. A send //! dropped between reserve and settle leaves the address reserved, one //! skipped index: the reservation sweep covers only Standard accounts.
Hosts that use the FFI are not affected. platform_wallet_prepared_dashpay_payment_free abandons the payment, and the send runs to completion through block_on_worker, so a host cannot cancel it mid-broadcast. The gap applies only to native Rust consumers and future bindings.
Possible Solution
Give the native type an owner guard that releases on drop. A Drop impl cannot await the owner-guarded release, and spawning the release needs Send + 'static bounds that PreparedDashPayPayment<B> does not have. Options:
- add those bounds to the struct and spawn the abandon from
Drop; or - hand callers a guard bound to the wallet's runtime, with explicit
sendandabandonmethods, whoseDropqueues the release.
The cancellation case needs a guard around the broadcast that settles the address as Used, the ambiguous outcome, when it is dropped after dispatch.
Steps to Reproduce
Not reachable from the iOS or Android apps, which go through the FFI. In Rust: call prepare_payment and drop the result, then try to fund another payment from the same inputs before the TTL expires. Or wrap send_prepared_payment in a tokio::time::timeout shorter than the broadcast and read the contact account's address state afterwards.
Context
Follow-up to #5465, raised in its review by a maintainer and by the review bot. The PR's two-step contact payment (prepare → send / abandon) introduced the type.
Your Environment
platform feat/dashpay-payment-prepare @ dfbeb7d (PR #5465), base v5.1-dev.
🤖 Generated with Claude Code
Activity
romchornyi commentedon Oct 29, 2026
Also in scope, from review of #5465: move the prepare lifecycle step out of the FFI wrapper and into
rs-platform-wallet. Todayplatform_wallet_prepare_dashpay_paymenttakes the generation gate itself, checks that the generation is still current, and abandons the payment when it is not:platform/packages/rs-platform-wallet-ffi/src/dashpay.rs
Lines 905 to 937 in dfbeb7d
Add a library operation (in
wallet::coreandprepared_payment) that does that and returns the payment together with a guard for the live generation. The handle registry and the FFI error conversion stay in the wrapper. The guard has to stay held through the registry insertion, so moving only the liveness check intoprepare_paymentis not enough: it would reopen the teardown race. This fits with the release guard above, since both shape how aPreparedDashPayPaymentis owned.