Repository navigation
Description
platform-wallet: multi-account send persists per-account net_amount (+ null fee, stale pending_inputs, INCOMING-until-confirm) — store-consistency, currently masked on Android
Summary
When a Core (L1) transaction spends inputs owned by more than one account (e.g. a plain BIP44 receive + a DashPay-friendship receive, or pooled BIP44/BIP32 funding), the persisted transactions row does not describe the wallet, only one contributing account. Concretely, on a send:
net_amountis stored as one account'schange - spent, not the wallet total (understated by the other accounts' contribution).feeisNULL.- The just-broadcast send is first persisted as
direction = INCOMING, net_amount = +change(the change output read as a receive), and only corrected to Outgoing when the tx confirms andtxos.isSpent/spendingTxidare written. pending_inputsreservation rows are not cleaned up after confirmation.
None of this is user-visible on Android today — it is fully masked app-side (see below) — but the stored records are wrong until confirmation, and iOS/tooling reading these fields directly will surface the errors.
Root cause (code)
packages/rs-platform-wallet/src/changeset/core_bridge.rs:981-996 documents the mechanism precisely: upstream check_core_transaction emits one TransactionRecord per matched account, so a payment touching a contact produces two records sharing one txid —
| record's account | direction | net_amount |
|---|---|---|
| funding (BIP44/BIP32/…) | Outgoing | change - spent |
| DashpayExternalAccount | Incoming | +paid |
The persisted transactions row is keyed by txid alone, with no per-account dimension (transaction_account_involvements is only written for provider-key accounts), so last-write-wins. The watch-only exclusion (is_contact_watch_only, dashpay/rust-dashcore#926/#952) correctly drops the contact record, but the surviving funding record still reflects only that account's spent/change — not a wallet-total aggregation across every owned account that contributed inputs. fee is not computed in this projection. pending_inputs (Room table; SDK-side reservation set) is written at broadcast but has no confirmation-time cleanup.
Reproduction (Dash testnet, mainnet-equivalent code path)
Wallet holds two owned UTXOs in different accounts: 0.2 DASH in BIP44 (plain receive) + 0.01 DASH in a DashPay-friendship receiving account (received from a contact). Send-max to an address:
- On-chain: correct — one tx spends both, delivers 0.209993, fee ~700 duffs. Recipient credited correctly.
transactionsrow:direction = Outgoing,net_amount = -20000000(-0.2, missing the 0.01 input),fee = NULL.txos: both inputsisSpent = 0until the tx confirmed (~minutes), thenisSpent = 1+spendingTxidlinked.pending_inputs: 2 reservation rows remained after confirmation (isSpent already 1).
(Single-account sends do not exhibit the net_amount error — the funding record then is the wallet total.)
User-visibility & how Android masks it (for the iOS team / to size the SDK fix)
Zero user-facing impact on Android — two app-side layers absorb it:
-
net_amount/feecorrection —SdkTxStoreWalkerrecomputes the true wallet net (and fee) from the transaction's own inputs/outputs and overrides the stored value for display, persisting the correction once confirmed spent-evidence exists (t.spendingTxid = tx.txid). So the UI showed the correct -0.21, not the stored -0.2. -
INCOMING-until-confirm ("lingering receive") correction — the app treats a received output as spent-for-display iff
txos.isSpent = 0 AND txos.spendingTxid IS NULL AND its outpoint ∈ pending_inputs(excluding foreign/watch-only rows). This is display-only (never persisted from a reservation; persisted corrections still require confirmed spent-evidence), and it yields automatically to any SDK authority — the moment the SDK writesisSpent/spendingTxid(at broadcast, confirmation, or via a future API), the app path contributes 0. Stale post-confirmpending_inputsrows are therefore harmless (isSpent=1 wins).
iOS has neither layer today, so it will show the wrong net_amount/fee and a phantom INCOMING row for a just-broadcast multi-account send until confirmation. iOS can either mirror the two Android workarounds or wait on the SDK fix below.
Additional finding: spend reconciliation is block-gated, not islock-gated
On Dash, InstantSend lock (~2s) is finality. The receive side honors this (txos.isConfirmed = 1 on islock). The spend side does not: after an InstantSend-locked send, the input txos.isSpent stayed 0 and the durable net_amount/fee write-back did not fire for 30+ minutes — both wait for block confirmation. Evidence: an islocked send (InstantLocked event logged) whose 5 input UTXOs remained isSpent = 0, isInstantLocked=1-then-cleared, isConfirmed = 1 well past any block interval. This is non-user-facing on Android today (the display uses the islock-independent pending_inputs reservation, so balance/amount are correct immediately), but the durable store state — and therefore any consumer reading it, plus the net_amount/fee correction — lags for no reason on a chain where the spend is already final. Spend reconciliation should trigger on InstantSend lock, consistent with the receive side.
Proposed SDK direction (additive, preserves current invariants)
Priority ordered; each is independently useful:
- Aggregate at persist time: compute
net_amountandfeefor thetransactionsrow across all owned accounts that contributed inputs/outputs (wallet-total), rather than storing one account's view. This removes the need for the app-side recompute entirely. - Clean up
pending_inputswhen the spending tx confirms (or is dropped/re-orged). - Optionally, expose an additive
pendingSpendread (reserved outpoints for in-flight local spends) so clients can render the correct pre-confirm spent state without changingtxos.isSpent's "spent-and-confirmed" invariant and without reading the raw reservation table. This is the clean contract that lets both Android and iOS drop their workarounds.
Note: we deliberately did not propose flipping txos.isSpent at broadcast — that would break its on-chain-truth invariant and is unsafe in the drop/re-org case. (3) is the safe equivalent.
Not blocking
Android ships the masks above; this is store-hardening, not a user-facing defect on Android. Filed for correctness + to unblock iOS parity.
Activity
bfoss765 commentedon Aug 17, 2026
Fix implemented (local branch, held until device-verified per our QA flow):
fold_same_txid_records()merges the per-account records into one wallet-level row at the two seams where siblings co-occur — theBlockProcessedprojection andCoreChangeSet::merge. Net = Σ of the per-account slices (disjoint detail sets ⇒ the wallet's Σreceived − Σspent), details unioned, fee from the funding record, direction recomputed from the merged net. 67/67 changeset tests green including the pre-existing contact-watch-only projections and new coverage for this issue's exact sweep shape.Scope notes against the issue's full list:
net_amount— fixed at batch scope (detection emits the sibling records together). Cross-batch stragglers keep last-write semantics; the Android mirror-heal covers rows persisted before the fix and goes inert on folded rows.feeNULL — the fold carries the funding record's fee onto the persisted row when any sibling knew it.pending_inputs— not addressed here; those are display/confirm-time semantics with their own app-side mitigations (the pending-reservation display correction), and belong to a separate persistence change.fix(tx): heal undersized OUTGOING nets; export asset-lock burns as ex…