Skip to content

fix(wallet): resolve sends with an unknown outcome in the UI - #1182

Draft
romchornyi wants to merge 70 commits into
fix/broadcast-off-main-threadfrom
feat/32347-unknown-send-states
Draft

romchornyi wants to merge 70 commits into
fix/broadcast-off-main-threadfrom
feat/32347-unknown-send-states

Conversation

@romchornyi

@romchornyi romchornyi commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

A send whose broadcast gets no answer from the network ("Transaction status unknown") was never resolved in the app. Its history row stayed "Sending", nothing later said whether it went through, and the next payments could be built on the change of a send the network never took. dashpay/platform#5258 adds the SDK side: a probe that asks the network about such a send, and a rule that payments use only confirmed or InstantSend-locked coins (code 59 when the coins a payment needs are still waiting). This PR is the app side.

Stacked on #1178 (wait for the network off the main thread, link and tab refusal). The base is fix/broadcast-off-main-thread; it will be retargeted to develop once #1178 merges. Needs the SDK from dashpay/platform#5258 (the app builds against that branch).

What was done?

What changes for users

  • "Waiting for the network", then "Sent" + toast. A send with an unknown outcome stays in the history with the row "Waiting for the network". Only an InstantSend lock or a block on its stored row turns it into "Sent", with a one-time toast "Payment of … went through". Several sends that settle together get one toast ("2 payments went through, … in total"). The toast belongs to the wallet on screen: only a send of that wallet raises it, publishing a different wallet (switch, network change) or a wipe clears it, and a rebuild of the same wallet keeps it. A send that settles while its wallet is not on screen gets no toast; its row reads "Sent" when that wallet is shown again. The state survives a relaunch. A send that settles within 10 s of its outcome gets no toast on top of the notice below. A send still unconfirmed a week later is no longer followed; its row goes back to "Sending", where "Remove if Not on Network" is offered.

  • Unknown-outcome notice. The paying screen shows "Waiting for the network — The network hasn't confirmed this payment yet. It's in your history as 'Waiting for the network' — don't send it again." and leaves the flow only once the notice is closed. This applies to the Send sheet, the Pay tab, the Coinbase transfer and interactive BIP70.

  • Pending balance. Under the Home balance: "… waiting for confirmation". This is the wallet's own unspent standard-account outputs that are neither mined nor InstantSend-locked; CoinJoin is left out, and the line is hidden when 0 or unknown. After a wallet or network switch it shows the new wallet's amount, also on an idle or offline switch where nothing happens after the wallet is bound.

  • Code-59 copy. A payment refused because its coins still wait for confirmation shows "Payment can't be made yet — Some of your funds are waiting for the network to confirm an earlier payment. Try again in a moment." on the standard, swap, selected-input, contact and BIP70 routes. The SDK's own text goes to the diagnostic only.

  • Repeat payment refused. Paying an address that still has a payment waiting for the network is not possible; there is no "Send anyway". The notice reads:

    Previous payment still in progress
    Your previous payment to this address (amount, date and time) is still being processed by the network. Wait until it is confirmed before paying this address again.
    If it never arrives, you can remove it from your history.

    [OK]

    When the earlier payment's amount is not known, the parentheses hold only the date and time. OK returns to the paying screen; nothing is built or signed and no PIN is asked. The check runs before the PIN prompt and the build for a plain send, and before the confirmation sheet for BIP70. It covers the Send sheet, the Pay tab, the legacy amount screen, the Coinbase transfer, QR / paste / NFC / dash: links, and BIP70. A BIP70 request is checked for every recipient, not only the first, and for the address of the dash: URI it came from (what a plain send falls back to when the request cannot be fetched). In turn, a BIP70 payment with an unknown outcome refuses a later payment to any of those addresses; such a notice gives the time only, since the amount is the whole payment's. Contact payments, swaps (which have their own SwapPendingGate), DashSpend and CrowdNode never had the check. Other addresses are not interrupted. The refusal ends when the earlier payment settles (locked or mined), is removed from the history ("Remove if Not on Network"), its row has been missing for 24 h, or a week has passed.

How it works

  • PendingSendOutcomes follows each send whose broadcast got no answer, by wallet and txid. It settles against the stored rows once at launch, on saves that touch transaction rows (watched only while something waits), and when the SDK probe reports accepted. A verdict is never taken as settled on its own.

    • Wallet and chain scoping: a send is followed under the wallet that signed it and the chain it was signed on (WalletChainScope: wallet id + the persistence scope the running host opened its store for, e.g. mainnet, testnet, devnet-<name>). A seed's wallet id differs between mainnet, testnet and devnet, but every named devnet shares one id while each has its own transaction store, so the id alone is not enough. Reconciliation, the repeat-payment refusal, the "went through" toast and the "no longer refused" log all require the same wallet on the same chain, and rows are read only from that scope's store: a row missing on devnet B cannot drop a send waiting on devnet A, and that send neither refuses nor is told on B. Sends are forgotten after a Delete All that succeeded, dropped for a wallet removed from the device, and kept across a wallet or network switch while within the 7-day window (past it, a send of a wallet or chain that is not bound is let go by age, since it refuses nothing by then).
    • Entries stored by earlier test builds have no chain, and none is made up. On mainnet and testnet the wallet id can only be that chain's, so such an entry is placed on it and follows the ordinary rules. On a devnet it stays without a chain: a row found for it settles it, a missing row never drops it, it ages out after 7 days, and until then it refuses on every devnet of its wallet.
    • A failed read is "no answer", not "the row is gone". A row still missing after 24 h is taken as gone, because on large wallets the persister lags by hours.
  • Every route that knows its txid follows its unknown outcome:

    • plain sends, swap deposits, SendCoinsService, selected-input (CrowdNode), interactive BIP70, and the CTX gift-card payment (awaited, or handed off after the merchant's acknowledgement), through WalletSendService.followUnknownOutcome / unknownOutcomeError;
    • a CoinJoin sweep chunk records itself under the sweeping wallet.

    Every route books the outcome under the wallet and chain that signed the send, read together in the same main-actor hop as the build (buildAndSign* return it; the selected-input send and BIP70's PreparedSend carry it). This holds even when another wallet is active by the time the outcome arrives, as with the detached CTX broadcast. The notice says "it's in your history" only when that wallet is the one on screen; otherwise the outcome is told with the error's own copy.

    The error carries the txid, so callers that book against it keep doing so: an unknown swap deposit blocks the next swap through SwapPendingGate, and an unknown PiggyCards purchase records its order.

  • Dialogs a payment waits on (the unknown-outcome notice, the repeat-payment refusal) report their outcome exactly once from their own host (PaymentController.presentDialog), whether closed, torn down from below, or never presented. A payment is never left hanging.

  • Repeat-payment check. Decided from memory before the PIN prompt; no row is read on the payment's path. PendingSendOutcomes.waitingPayment(toAnyOf:) refuses with the newest followed send to any of the payment's addresses within the 7-day window. A BIP70 payment has one list (Confirmation.repeatCheckAddresses: its recipients, then its URI's address when payable on the network; a URI address longer than any address, 35 characters, is dropped before Base58 decoding, and the shared codec refuses such input for every caller) that the check is asked about and an unknown outcome is followed under, on every route (the four request fetches, the awaited and the handed-off headless broadcast). The followed send stays one entry per transaction (Entry.otherAddresses): one row, one toast, one settlement. When any send to the address is followed, it also starts a background row read (reconcile): one that settled or aged out since the last read is classified from its row and stops refusing on the next try, with its history row leaving "Waiting for the network" at the same moment. A send past 7 days stops refusing at once; its follow ends at the next row read that does not fail (a failed read decides nothing, since the send may have settled).

  • Diagnostics: 💸 TXSEND lines go through DWLogger (new logError:), so they reach "Share application logs". Addresses are always masked (yAbc…wxyz) and wallets are shown as a 4-byte tag. The repeat-payment refusal logs:

    • repeat payment refused — route=… to=<masked> pending=<short txid> age=…s wallet=<tag> reason=still followed: no lock or block seen on its row yet, within the 7-day window; rows re-read in the background, when the notice is shown;
    • repeat payment cancelled on OK — route=… pending=…; no PIN, nothing built, when OK closes it;
    • <txid> settled on chain / removed / row missing for over 24 h / still unconfirmed after 7 days / its wallet was removed / wallet wiped … ; payments to <masked> no longer refused, when an entry stops blocking its address (the clause is left out for sends with no address, such as CoinJoin sweep chunks);
    • nothing when no payment is pending for the address.

New strings ship in English in every locale; translations come from Transifex.

Known limitations

  • An unknown swap deposit shows the swap's failure screen (held until Close, per fix(wallet): wait for the network off the main thread when sending #1178) and is followed in the history and the swap gate, but no SwapOrder is saved for it (follow-up).
  • The broadcast itself resolves the active wallet at broadcast time (pre-existing): a wallet switch between signing and broadcasting submits the signed transaction through the newly active wallet. Its outcome is still booked under the wallet that signed it. Refusing such a broadcast was tried and backed out, because it turned a merchant-acknowledged BIP70 payment into a failure (follow-up: carry the signing wallet with the signed transaction).
  • An unknown outcome that arrives after its wallet was wiped or removed is recorded, and dropped when the next wallet is published.
  • The code-59 copy covers the send routes above, not internal transfers or identity asset locks.
  • A repeat-payment refusal that UIKit cannot present cancels the send (logged) rather than paying without it.
  • The refusal is checked once, before the PIN prompt (or BIP70's confirmation sheet). It is not checked again when the confirmation is tapped.
  • A payment that settled since the last row read is still refused once: the notice's OK starts nothing, the background read clears it, and the next try goes through.
  • While a confirm sheet is on screen the check is not run, for any address (as before this PR).
  • PaymentController keeps weak references to a confirm sheet and a legacy amount screen after they leave; the refusal path forgets an off-screen sheet, the other readers are unchanged (follow-up: clear them where the screens go away).
  • A "no longer refused" log line is written per entry; when two waiting sends go to one address, the first to settle already logs it.
  • A CoinJoin sweep chunk with an unknown outcome counts as moved; CrowdNode signal sends and the CTX awaited payment are followed without a toast.
  • The pending balance is one SwiftData fetch of the wallet's TXOs, after a balance event, a coin save or the active-wallet notification (throttled to 1/s, one read at a time). Each read carries the wallet and chain it was for (the same WalletChainScope the followed sends use) and counts only if that is still what is bound when it lands; while the balance itself is unknown the caption is hidden (PendingBalanceFollower). No SDK API exposes per-UTXO InstantSend flags wallet-wide.
  • The held/unheld send function pairs come from fix(wallet): wait for the network off the main thread when sending #1178 and are left as they are.
  • Follow-up: the app-side waiting store (PendingSendOutcomes) should become an SDK-owned per-row "awaiting network" flag, set where the broadcast verdict comes back and cleared by the same lock/block update that settles the row.

How Has This Been Tested?

  • Live, iOS simulator (2026-10-05), testnet, app @ 998e4465e (fix(wallet): resolve sends with an unknown outcome in the UI #1182 merged with fix(wallet): wait for the network off the main thread when sending #1178) on the SDK from platform#5258 @ f61b2c3f86; P2P blocked and unblocked with a pf rule:

    • H1 healthy send: spinner, IS lock in seconds, "Sent", a second send right after works.
    • H2 P2P blocked: the unknown-outcome notice, row "Waiting for the network", pending balance shown.
    • H3 paying the same address again: repeat warning before the PIN prompt (the earlier two-button warning; the one-OK refusal that replaced it is covered by unit tests).
    • H4 paying another address beyond the confirmed coins: code-59 copy, nothing built.
    • H5 unblock: row turns "Sent", toast, pending balance gone, a new send works.
    • H6 kill while waiting, unblock, relaunch: the row still resolves to "Sent".
    • H7 every send appears exactly once on chain; no orphan built on unconfirmed change.
    • H8 kill during the network wait (before "unknown"): pending row, code 59 until it confirms, then "Sent".
    • H9 kill during the PIN prompt: nothing sent.
    • U1 / U3 (fix(wallet): wait for the network off the main thread when sending #1178's link and tab refusal on top): passed.
    • All passed. The notice regression found after the merge (the Send sheet closed without it) was fixed in 4dbecba89 and its follow-ups; the review rounds after that are covered by unit tests and code reading only.
  • Unit tests: the PR's suites plus the BIP70 protocol, Home balance, CrowdNode ownership and CoinJoin sweep suites (the last two call the address codec and the scoped sweep), 132/132 on two runs (simulator "32347 Tests 2", iOS 26.5, local test scheme). The full suite has no failures in the PR's classes (the failures are pre-existing, in locale-dependent and unrelated suites). Earlier rounds: 92/92 on repeated runs (iOS 26.5 simulator, local test scheme). PendingSendOutcomes' settlement rules are pure functions (settlement, applying, merged, acceptances) and are tested on their own:

    • an accepted verdict with a processing row;
    • a failed read;
    • lock/block settling and notifying once;
    • a send forgotten during the read;
    • wallet mismatch and switching;
    • the 10 s / 24 h / 7 d boundaries;
    • merged notices with a saturating total;
    • another wallet's settlement raising no toast on the wallet shown, a switch dropping the notice while a rebuild keeps it, and merging only within the shown wallet.

    An unknown outcome is booked under the signing wallet: a prepared send's, the detached BIP70 broadcast's, and one arriving with another wallet (or none) active. The tests also cover the unknown-outcome notice shown before the paying screen leaves (and the screen told even when the notice cannot be shown), the exactly-once dialog outcome (choice once, after dismissal; teardown and failed presentation), and an unknown-outcome error carrying its txid. The repeat-payment refusal is tested end to end through the delegate hook: a single OK, the remove hint, no answer while the notice is up, false on OK, the shown and cancelled TXSEND lines (route, short txid, wallet tag, row finding, never the full address), and no log for an address with nothing pending. A failed row read decides nothing, even for a send past 7 days. BIP70 recipients: a request with the pending address in a non-first output is refused; a plain payment to a followed non-first recipient, and to the URI's address, is refused; a several-recipient send is one entry, one notice and one log line; the BIP70 layer hands the same address list out for the awaited and the handed-off broadcast. Chain scope: a missing row on devnet B cannot remove a followed send on devnet A; a send waiting on one chain refuses nothing and raises no toast on another (two devnets; testnet and mainnet pairs as well, though their wallet ids differ in practice); a verdict from another chain's manager is not heard; an entry stored without its chain is never dropped by a missing row, is placed only where its wallet id is one chain's, and ages out; a send of a chain that is not bound again is let go only past the follow window; an unknown outcome is booked under the wallet and chain that signed it on the plain, prepared and handed-off BIP70 routes. An oversized URI address is dropped without decoding and the request still prepares; the codec refuses a string over its bound and still round-trips valid addresses on every network. Pending caption (PendingBalanceFollower): the destination balance event before the active-wallet notification with nothing after it still brings the caption up; another wallet's or network's value is never shown; nothing is read while the balance is unknown; events during a slow read start exactly one more. They also include fix(wallet): wait for the network off the main thread when sending #1178's routing, exit-hold, sweep, legacy-amount and swap-gate suites.

  • dashpay scheme builds against platform#5258 (arm64 simulator). Local /code-review high passes until the findings were low-severity polish.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…aiting for confirmation

Turn on the SDK's broadcast probe once the manager is configured, so a send
whose broadcast outcome was unknown gets a verdict instead of staying
"Sending".

A build the SDK refuses because the coins that would fund it are not
confirmed yet (code 59, coreFundsAwaitingNetwork — the change of an earlier
send the network has not taken, or a fresh incoming payment) now reads
"Payment can't be made yet — Some of your funds are waiting for the network
to confirm an earlier payment. Try again in a moment." on every send route
(standard send, swap deposit, selected-input send, contact payment). The
SDK's own text (duffs, internal wording) goes to the error's diagnostic only.

New keys ship in English in every locale; translations come from Transifex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e59f6205-c0d9-40ed-98b7-02c6a8735bfe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

The change records payment broadcasts with unknown outcomes and tracks them until wallet data reports a verdict or the record expires. Payment flows show network-waiting notices and same-address prompts. The home screen displays pending amounts and confirmation notices.

Changes: Pending payment tracking

Layer / File(s) Summary
Outcome tracking
DashWallet/Sources/Models/Transactions/PendingSendOutcomes.swift, DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKHost.swift, DashWallet/Sources/Infrastructure/SwiftDashSDK/UnconfirmedTransactionRemover.swift, DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m, DashWallet.xcodeproj/project.pbxproj
A shared tracker persists unknown-outcome sends, observes wallet saves and broadcast verdicts, and reconciles records against transaction rows. Removed transactions and successful wallet wipes clear related records.
Broadcast outcome capture
DashWallet/Sources/Models/Transactions/WalletSendService.swift, DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKTransactionSender.swift, DashWallet/Sources/Models/Transactions/SendCoinsService.swift, DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift, DashWallet/Sources/Infrastructure/SwiftDashSDK/BIP70PaymentService+App.swift, DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKWalletSending.swift, DashWallet/Sources/Infrastructure/DWLogger.*
Send paths attach transaction IDs to unknown-outcome errors and record eligible sends. BIP70 and CoinJoin flows handle unknown outcomes. Build errors for funds awaiting network confirmation receive a specific mapping.
Payment prompts and unknown-outcome handling
DashWallet/Sources/UI/Payment Controller/PaymentController.swift, DashWallet/Sources/UI/Payments/PaymentModels/*, DashWallet/Sources/UI/Payments/Pay/*, DashWallet/Sources/UI/Payments/PaymentsViewController.swift, DashWallet/Sources/UI/Coinbase/Transfer Amount/TransferAmountHostingController.swift, DashWallet/Sources/UI/Explore Dash/Views/DashSpend/DashSpendPayViewModel.swift, DashWalletTests/PaymentLinkRoutingTests.swift, DashWalletTests/PaymentProtocolTests.swift
Address payments check for an existing pending payment and ask whether to wait or send anyway. Payment delegates report unknown outcomes, and related integrations retain the transaction ID. Tests cover notice timing, dialog outcomes, and pending-record cleanup.
Pending and confirmed payment surfaces
DashWallet/Sources/Models/Transactions/Model/Transaction.swift, DashWallet/Sources/UI/Home/Views/Home Balance View/*, DashWallet/Sources/UI/Home/Views/HomeView.swift, DashWallet/Sources/UI/Home/Views/HomeViewModel.swift, DashWallet/*.lproj/Localizable.strings
Transaction rows show a waiting status when applicable. The home screen displays amounts awaiting confirmation and confirmation notices. Localization tables add payment status, warning, and confirmation messages.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant PaymentController
  participant DWPaymentProcessor
  participant WalletSendService
  participant PendingSendOutcomes
  participant PlatformWalletManager
  participant HomeView
  User->>PaymentController: Choose whether to send to an address with a pending payment
  PaymentController->>DWPaymentProcessor: Request payment authorization
  DWPaymentProcessor->>WalletSendService: Prepare and broadcast payment
  WalletSendService->>PendingSendOutcomes: Record unknown outcome with transaction ID
  DWPaymentProcessor-->>PaymentController: Report followed unknown outcome
  PaymentController-->>User: Present waiting-for-network notice
  PlatformWalletManager->>PendingSendOutcomes: Deliver broadcast verdict
  PendingSendOutcomes-->>HomeView: Publish reconciled outcome notice
Loading
Merge Risk: 🔵 Low · up to bcd7d

Users with non-English locales will see the new pending-payment messages in English, including the warning not to resend. This does not affect payment behavior, so the change can merge with a localization follow-up.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 105 functions across 24 files. (48 skippe… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resolving wallet sends with unknown broadcast outcomes in the UI.
Full details: Docstring Coverage

Explanation

Docstring coverage is 48.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 105 functions across 24 files. (48 skipped: 48 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Final review complete — no blockers (commit f1f9150) · triage: critical

jeanpierreroma and others added 27 commits October 3, 2026 23:39
A send whose broadcast got no answer ended on a "Transaction status
unknown" alert, and its row read "Sending" for good — an invitation to
pay again. It now goes back to the history: the row reads "Waiting for
the network" until the SDK's broadcast probe hears the network has it,
or the row is InstantSend-locked or mined. Either moves it to "Sent"
and shows "Payment of … went through" once; an unresolved verdict keeps
it waiting. The record is persisted, so a relaunch keeps it waiting, and
"Remove if Not on Network" is not offered once the network has it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Payments now spend only confirmed or InstantSend-locked coins, so part
of the balance on screen can be unusable for a while — an incoming
payment not locked yet, or the change of a send the network has not
taken. The home balance says how much: "… waiting for confirmation",
shown only when there is some. Computed as the unconfirmed bucket plus
the trusted own change the funding pool leaves out; the CoinJoin
account, which the pool excludes for another reason, is taken off
first, and nothing is shown while the pooled figure is unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While an earlier payment to an address is still waiting for the
network, paying the same address again asks first: "Your previous
payment to this address (amount, time) hasn't been confirmed by the
network yet. If you send again, the recipient may get both." Wait backs
out of the send; Send anyway goes on to the confirmation. Asked once,
before the confirm sheet; payments to other addresses are not
interrupted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The send path (WalletSendService, SwiftDashSDKTransactionSender) logged
its 💸 TXSEND lines through os.Logger, which the "Share application
logs" export does not carry — a report of a send that failed or ended
with no answer arrived without the send's own trace. Route both
loggers through DWLogger, which writes the exported files and still
mirrors to the console; the level travels as a text tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…send-states

# Conflicts:
#	DashWallet/Sources/UI/Payments/PaymentModels/DWPaymentProcessor.m
A probe's accepted verdict means a node took the bytes, not that the
payment settles; it no longer flips the row to "Sent", is no longer
persisted, and no longer hides "Remove if Not on Network". It only
prompts a re-read of the stored rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ps it

The prepared standard send (plain sends, swap deposits, SendCoinsService)
and the selected-input send now record the waiting send at the point
they map the broadcast to broadcastUnknown; the payment processor no
longer records it on its own. A send without a known address is still
followed by its txid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he coins

The figure was balance minus the pooled spendable read, combined from
three publishers that update at different moments. It is now the sum of
the wallet's own unspent standard-account outputs (every index) that are
neither mined nor InstantSend-locked, read in one SwiftData fetch;
CoinJoin is left out. HomeViewModel's feed-row save filter is internal so
the read follows the same saves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no active wallet the unknown outcome cannot be recorded, so the
send keeps the plain "Transaction status unknown" error instead of the
copy that says it waits in the history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… build

The payment processor asks its delegate before it authorizes and builds a
plain send; PaymentController shows the repeat warning there instead of
after the transaction was already signed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n rows

The waiting-send check ran on every SwiftData save; it now uses the home
feed's save filter, and runs once when the wallet runtime comes up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Remove if Not on Network" and the bulk drop clear the send from
PendingSendOutcomes right away instead of after the missing-row grace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two payments of the same amount settling one after the other were one
Equatable notice, so the second never showed. Each notice now has an id;
payments that settle while one is up are told together ("2 payments went
through, … in total"), and the toast clears only the notice it showed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the SendLog facade: TXSEND lines call DWLogger directly, with new
logWarning:/logError: class methods over DDLogWarn/DDLogError instead of
a text tag. The CoinJoin sweep destination address no longer reaches the
shareable log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dialogs

Both now use the SwiftUI ModalDialog (showModalDialog) instead of new
UIAlertController code; the repeat warning resumes only after the dialog
is gone, so the PIN prompt after "Send anyway" presents cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto feat/32347-unknown-send-states

Brings #1178 (head 2468bef) in: the router refusal rule, send-boundary
routing holds, routing-owning ExitHold, tab-bar refusal, notices and the
Coinbase keypad lock.

Conflicts:
- Localizable.strings (43): both sides' new keys kept.
- SwiftDashSDKTransactionSender: #1178's sweepChunks / runningWallet
  structure with #1182's DWLogger TXSEND logs; the selected-input send keeps
  #1182's unknown-outcome txid mapping and runs unheld (CrowdNode).
- WalletSendService: #1178's recordCoinJoinSweepChunks, logs via DWLogger.
- DWPaymentProcessor: #1182's followed unknown outcome inside #1178's
  reportBroadcastOutcome, so the routing hold lasts through the report.

Combined flow: the Coinbase transfer screen implements
paymentControllerDidSubmitWithUnknownOutcome, ending its in-flight state and
keeping the keypad off until the "Waiting for the network" notice is closed
(shared PaymentController.showUnknownOutcomeNotice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto feat/32347-unknown-send-states

Brings #1178's refusal notices as the app's standard toast (a72353d).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a send

A send whose broadcast got no answer was followed in the history, but a
paying screen that implements paymentControllerDidSubmitWithUnknownOutcome
(DWBasePayViewController: the SwiftUI Send sheet and the other base pay
screens) left at once via finishSendFlow, and PaymentController presented the
notice only for delegates without that callback — so the Send sheet closed
to Home with no notice.

PaymentController now presents the notice for every delegate and tells the
delegate only once it has been closed and its dismissal has finished (the
async modal dialog), so the sheet's own dismissal is not dropped. The notice
is a presented modal, so the router refuses links until it is read. The
Coinbase transfer screen no longer shows a notice of its own; its keypad
comes back when that callback arrives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d a send on its notice

- PaymentController tells its delegate at once (new optional
  paymentControllerDidReceiveUnknownOutcome) before the "Waiting for the
  network" notice; the Coinbase transfer screen tags its history row there,
  so a kill while the notice is up no longer loses the label. Only the
  screen's continuation (paymentControllerDidSubmitWithUnknownOutcome) waits
  for the notice.
- The notice reports its close exactly once from its own host: after OK and
  the dismissal, after any other teardown, or right away when UIKit does not
  present it. A paying screen is never left waiting for a notice that is not
  there, OK dismisses the notice itself (not its presenter), and the closure
  holds the controller and delegate weakly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto feat/32347-unknown-send-states

Brings #1178's legacy amount-field lock during a pending broadcast and the
SwapPendingGate tests (59d9632). Conflict: PaymentLinkRoutingTests.swift,
where both sides appended test types at the end; both kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nging

- An unknown-outcome error now carries its txid (unknownTxidWireKey,
  WalletSendService.unknownOutcomeTxidWire), so callers that book a send
  against it keep doing so:
  - a swap deposit with an unknown outcome registers with SwapPendingGate,
    blocking the next swap until it settles like a confirmed one;
  - a PiggyCards purchase with an unknown outcome records its order, as
    the CTX branch does.
- Interactive BIP70: an unknown broadcast outcome is followed as "Waiting
  for the network" and shown like a plain send's, not as "Couldn't make
  payment".
- CoinJoin sweep: a chunk with an unknown outcome counts as sent (grouped
  with the sweep) and its row waits for the network.
- PendingSendOutcomes.forgetAll() on wallet wipe and network switch.
- The repeat-payment warning uses the same exactly-once dialog host as the
  unknown-outcome notice (PaymentController.presentDialog): a dialog torn
  down or never shown does not send and never strands the payment.
- The selected-input send honours holdingRouting.

The held/unheld send pairs (#1178's) are left as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A send forgotten while its rows were being read no longer settles or
  raises "went through".
- A network switch keeps waiting sends (entries are per wallet); only a
  wipe forgets them.
- Entries that are not payments (a CoinJoin sweep chunk, a CTX payment whose
  amount is unknown here) settle without the notice.
- The CTX headless BIP70 payment with an unknown outcome is followed too.
- BIP70 builds refused for coins awaiting the network show the code-59 copy
  and title like every other route.
- One unknown-outcome path for every paying screen: the notice, then the
  legacy amount step is left (as after a sent payment), then the delegate;
  the amount screen keeps its input off under the notice.
- Home no longer re-renders on every waiting-list change.
- PiggyCards binds the unknown txid once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A waiting send's row reads "Waiting for the network" whatever titles it
  otherwise (Coinbase, gift card, swap, internal transfer).
- After the unknown-outcome notice, a paying screen that leaves the flow
  does the only navigation; others leave the legacy amount step.
- A sweep chunk is followed under the sweeping wallet, not the active one.
- Waiting sends of a wallet removed from the device are dropped.
- Saves are watched only while a send is waiting.
- The "went through" toast gets its full window when home shows it.
- A pending-balance read that fails keeps the last value instead of 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A CTX gift-card payment whose broadcast, handed off after the merchant's
  acknowledgement, gets no answer is followed (BIP70PaymentService reports
  it; the app records it).
- Waiting sends of a removed wallet are dropped when a wallet's host is
  published, only with the keychain readable and a non-empty list — not on
  every save, and never because a locked device listed no wallets.
- A failed transaction read is no answer, not "the rows are gone".
- A "went through" notice not yet dismissed absorbs later settlements.
- DWLogger.logWarning: (unused) removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Delete All (beginWipeWallet) forgets waiting sends too.
- An interactive BIP70 payment asks before repeating a payment to an
  address that still waits, before its confirmation sheet.
- A dialog torn down from below still reports its close (deinit).
- Reconcile fetches only the active wallet's waiting sends.
- WalletSendService.followUnknownOutcome follows without building an
  error; unknownOutcomeError composes it.
- Doc fixes (delegate contract, misplaced comments).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Delete All forgets waiting sends only once the wipe succeeded; after a
  partial wipe the surviving wallets keep theirs.
- The host publishes its wallet and store before PendingSendOutcomes
  observes the manager, so the reconcile at bind time settles sends that
  went through while the app was closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A send that settles while its unknown-outcome notice is still being read
  (within 10 s) gets no "went through" toast on top of it.
- A missing row is taken as gone after 24 h, not 1 h: on large wallets the
  persister can lag by hours.
- The waiting-txid mirror is seeded from the stored entries, so a row
  titled before PendingSendOutcomes.shared exists still reads waiting.
- BIP70 unknown outcomes are followed on the main actor without blocking
  a concurrency thread.
- The pending balance is cleared on a wallet or network switch.
- Doc fix on BIP70PaymentService.onDetachedBroadcastUnknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeanpierreroma and others added 3 commits October 6, 2026 22:38
The off-main row read on the payment path (pass 3) needed a generation
counter, an off-main hop, a wallet-switch retry and a silent drop, and
each review pass found a new race in them. The refusal is decided
synchronously from the followed sends again, as before the row read;
any followed send to the address starts a background reconcile, so one
that settled or aged out since the last read stops refusing on the
next try. The delegate's completion is called exactly once again.

An expiry decided without a row read is logged as such.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A confirm sheet on screen skips the check again, whatever the
  address: refusing a new input over it left the sheet up on a reset
  processor. Off-screen sheets are still forgotten first.
- A failed row read decides nothing again, even past 7 days: the send
  may have settled, and expiring it lost its notice. The refusal still
  lifts by age.
- Log the follow window from maxFollowAge; list each distinct address
  even when two mask alike; one filter in waitingPayment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Forget a confirm sheet that is being dismissed, too.
- Leave empty addresses out of "no longer refused" lines.
- maxFollowDays is a constant; the refusal log line is split.
- The refusal test checks the window in the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the supplied findings against head 49c555f. All four prior findings are fixed, but two in-scope blockers remain: multi-recipient BIP70 payments bypass the repeat-payment refusal, and post-bind wallet notifications can suppress the pending-balance caption until another balance event. This was static verification only; the supplied exact-head CI snapshot contains passing checks but no build, test, or end-to-end payment result.

🔴 2 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate, cross-route change directly alters funds-movement control in WalletSendService and SwiftDashSDKTransactionSender.sweepCoinJoin, including pre-signing repeat-payment refusal and handling unknown broadcast outcomes during sweeps.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `DashWallet/Sources/UI/Payments/PaymentModels/DWPaymentProcessor.m`:
- [BLOCKING] DashWallet/Sources/UI/Payments/PaymentModels/DWPaymentProcessor.m:281-283: Apply the BIP70 repeat-payment refusal to every recipient
  This checks only paymentOutput.address, which BIP70PaymentOutputFactory obtains from confirmation.primaryAddress (recipients.first). BIP70PaymentService.confirmAndSend builds every recipient, and testMultiOutputPassthrough confirms that multi-output requests are supported. With an unknown-outcome payment to A still followed, a request with recipients [B, A] passes the check and can pay A again using other confirmed funds. The reverse direction also fails: BIP70InteractiveCoordinator records an unknown multi-output payment using only primaryAddress, so a later plain payment to its second recipient is not refused. Check every recipient before presenting confirmation and retain every paid recipient address when following an unknown BIP70 outcome, without counting the transaction multiple times in settlement notices. Add regressions with the pending address in a non-first output and with a plain payment to a previously followed non-first recipient.

In `DashWallet/Sources/UI/Home/Views/Home Balance View/BalanceModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Home/Views/Home Balance View/BalanceModel.swift:88-91: Refresh the pending balance after the destination wallet is published
  The merged handler treats activeWalletDidChangeNotification as a pre-switch signal, but SwiftDashSDKWalletRuntime.switchWallet posts it after the destination refresh completes. That refresh already publishes the destination balance through SwiftDashSDKSPVCoordinator.refreshBalanceBridge. When the balance event is delivered before this notification, the handler invalidates its read generation, sets awaitingNewWalletBalance back to true, and clears the caption through walletChanges.map { nil }. The notification starts no replacement read, and reads triggered while the flag remains true are tagged -1 and discarded. This can leave a wallet with saved pending outputs showing no caption on an idle or offline switch; there is no unconditional timer in BalanceModel to recover it. Handle the pre-switch network notification separately from the post-bind active-wallet notification, and let the latter enable and schedule a destination-scoped read. Add a regression where the destination balance event precedes the active-wallet notification and no further balance event arrives.

Comment on lines +281 to +283
[self.delegate paymentProcessor:self
shouldPayAddress:paymentOutput.address
isBIP70:YES

@thepastaclaw thepastaclaw Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 25a48771; see the replies below.

🔴 Blocking: Apply the BIP70 repeat-payment refusal to every recipient

This checks only paymentOutput.address, which BIP70PaymentOutputFactory obtains from confirmation.primaryAddress (recipients.first). BIP70PaymentService.confirmAndSend builds every recipient, and testMultiOutputPassthrough confirms that multi-output requests are supported. With an unknown-outcome payment to A still followed, a request with recipients [B, A] passes the check and can pay A again using other confirmed funds. The reverse direction also fails: BIP70InteractiveCoordinator records an unknown multi-output payment using only primaryAddress, so a later plain payment to its second recipient is not refused. Check every recipient before presenting confirmation and retain every paid recipient address when following an unknown BIP70 outcome, without counting the transaction multiple times in settlement notices. Add regressions with the pending address in a non-first output and with a plain payment to a previously followed non-first recipient.

source: gpt-6.1-sol (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 25a4877 (008bfa0 and its follow-ups).

  • The delegate is now asked with every recipient of the request (shouldPayAddresses:), so a request paying [B, A] is refused while a payment to A is followed.
  • An unknown BIP70 outcome keeps every address: the interactive route, the awaited headless one (the error carries the list) and the handed-off broadcast (the hook carries it) all follow the payment under Confirmation.repeatCheckAddresses.
  • That list also holds the address of the dash: URI the request came from, when it is payable on the network. A failed re-fetch falls back to a plain send to that address, and that send is now refused as well. All four request fetches pass it in.
  • It is still one entry per transaction (Entry.otherAddresses next to the primary address): one row, one toast, one settlement, and one "no longer refused" line listing each address once. The pending balance is computed from saved outputs and does not use these entries.
  • A notice for a several-address entry gives the time only, because the amount is the whole payment's.

Regressions: testARequestWithThePendingAddressInANonFirstOutputIsRefused, testAPlainPaymentToAFollowedNonFirstRecipientIsRefused, testARequestIsRefusedForAPendingRecipientThatIsNotItsFirst (through the delegate hook), testASeveralRecipientSendCountsOnce, testABIP70UnknownOutcomeCarriesEveryRecipientAndTheURIsAddress, testAFallbackPlainSendToTheURIsAddressIsRefused.

Not fixed here: followed sends are keyed by wallet id without a network (older than this change). It is listed in the PR description as a follow-up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 25a48771): Your delegate check and all three unknown-outcome routes now use the full repeatCheckAddresses list, including the payable URI fallback, and retain it within one transaction entry. The non-first-recipient, fallback-refusal, and single-count regressions address both directions of the original defect; the separately documented network-key limitation does not invalidate this fix.

Comment on lines +88 to +91
.handleEvents(receiveOutput: { [weak self] _ in
self?.walletGeneration += 1
self?.awaitingNewWalletBalance = true
})

@thepastaclaw thepastaclaw Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 25a48771; see the replies below.

🔴 Blocking: Refresh the pending balance after the destination wallet is published

The merged handler treats activeWalletDidChangeNotification as a pre-switch signal, but SwiftDashSDKWalletRuntime.switchWallet posts it after the destination refresh completes. That refresh already publishes the destination balance through SwiftDashSDKSPVCoordinator.refreshBalanceBridge. When the balance event is delivered before this notification, the handler invalidates its read generation, sets awaitingNewWalletBalance back to true, and clears the caption through walletChanges.map { nil }. The notification starts no replacement read, and reads triggered while the flag remains true are tagged -1 and discarded. This can leave a wallet with saved pending outputs showing no caption on an idle or offline switch; there is no unconditional timer in BalanceModel to recover it. Handle the pre-switch network notification separately from the post-bind active-wallet notification, and let the latter enable and schedule a destination-scoped read. Add a regression where the destination balance event precedes the active-wallet notification and no further balance event arrives.

source: gpt-6.1-sol (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 25a4877 (008bfa0, reworked in aaac22c).

I checked the order first: switchWallet posts activeWalletDidChangeNotification after the awaited refresh and the bind guard, and refresh posts it after SwiftDashSDKSPVCoordinator.startAsync has seeded the balance. So the notification does come after the destination balance, as described.

The caption no longer depends on the order of the two notifications. PendingBalanceFollower (extracted from BalanceModel) works like this:

  • Every read carries the wallet and network it was for, and counts only if that is still what the host has bound when it lands.
  • While the balance itself is unknown (a teardown clears it), the caption is cleared and nothing is read.
  • The active-wallet notification clears a value that is not the bound wallet's and starts a read. On an idle or offline switch this is the read that brings the caption up.
  • The pre-switch network notification is no longer used for the caption.
  • One read runs at a time, with one re-run for events that arrive during it.

Regression: testTheWalletNotificationReadsWhenTheBalanceEventCameFirstAndNothingFollows. The read started by the balance event finds nothing, then the notification arrives with no further event, and the caption still appears from exactly one read. Also covered: a caption read before the notification survives it; another wallet's or network's value is never shown; a restart that posts no notification.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 25a48771): Your extracted PendingBalanceFollower now starts a read from the post-bind wallet notification and rejects results for a different bound wallet or network, without reinstating the old balance-event gate. I verified that the named regression covers the balance event arriving first and no event following the notification.

jeanpierreroma and others added 6 commits October 7, 2026 14:36
…ng caption after a wallet switch

BIP70 repeat-payment refusal covered only the first recipient:
- The delegate is asked with every recipient of the request
  (shouldPayAddresses:), so a request paying [B, A] is refused while a
  payment to A is followed.
- An unknown BIP70 outcome keeps every address it paid (interactive,
  headless and handed-off broadcasts): the error and the detached hook
  carry the recipients, and the followed send stores the others next to
  its primary address. It is still one entry per transaction: one
  notice, one settlement, one "no longer refused" line listing each
  address once.

Home pending caption lost on a wallet switch:
- The runtime posts the active-wallet notification after the
  destination wallet is bound and its balance published. Treating it
  as a pre-switch signal invalidated the destination's read and
  started none, so an idle or offline switch showed no caption.
- PendingBalanceFollower handles the pre-switch network notification
  (clear, no read counts) apart from the post-bind wallet notification
  (clear, then schedule a read for the bound wallet).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eview pass 1

Pending caption:
- A read comes back with the wallet and store it read, and counts only
  if that is still what the host has bound when it lands. This replaces
  the generation counter fed by the order of two notifications, which a
  Home rebuilt after the network notification never saw.
- While the balance is not known the caption is not either: cleared,
  nothing read.
- The active-wallet notification clears a value that is not the bound
  wallet's and starts a read, the one an idle switch depends on. The
  regression test makes the earlier read fail so that only this one can
  bring the caption up.

BIP70 recipients:
- recipientAddresses on the unknown-outcome error is nil when the
  wallet adapter raised it (not known), not an empty list.
- A several-recipient payment refuses with the time only: its amount is
  the whole payment's, not what the address was paid.
- Callers pass the recipient list as it is; one helper for the followed
  entries of an address set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ption

- A BIP72 URI's own address is checked, and followed, with the
  request's recipients: it is what a plain send falls back to when the
  request cannot be fetched. The interactive and headless routes use
  the same list (recipients first, then the fallback).
- The pending caption reads one at a time; events during a read start
  one more when it lands, instead of superseding it every second.
- A read's scope is the network and wallet id, not the identity of a
  store it does not keep alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew pass 3

- The URI's own address is an input of the request fetch and is kept on
  the Confirmation, whose repeatCheckAddresses (recipients, then that
  address, each once) is the one list the repeat-payment check is asked
  about and an unknown outcome is followed under. The QR-scan and
  input-builder fetches and the handed-off headless broadcast now carry
  it too; before, only the processor's own fetch set it.
- The pending caption's single-flight read uses PooledReadSlot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion

- A URI address is kept as the fallback only when it is payable on the
  request's network: nothing else can be fallen back to.
- The pending-balance scope names the network by its persistence
  scope, so two devnets are two scopes.
- The read takes its handles on the main queue before it is handed
  off; the worker no longer hops back to main for them.
- Comments say what otherAddresses holds since it carries the URI's
  address too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…URI address is kept

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the supplied reviewer claims against head 25a4877 and independently confirmed that all six prior findings are fixed. One blocking issue remains: the newly added URI fallback validation exposes an unbounded, quadratic-time address decoder to untrusted input. Validation was static only; the supplied exact-head CI snapshot has title and accessibility checks queued, contains no application build/test result, and the reported runtime smoke predates this head.

🔴 1 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate, cross-route change directly alters funds-movement gating in WalletSendService.swift and broadcast outcome handling for CoinJoin sweeps and selected-input sends in SwiftDashSDKTransactionSender.swift.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:282-284: Bound the URI fallback address before Base58 decoding
  The new fallback validation passes the unvalidated, percent-decoded URI address into ScriptAddressCodec.scriptPubKey. ParsedPaymentURI accepts a payment intent with a request URL even when its address is invalid, and the interactive fetch callers still forward that address. ScriptAddressCodec.base58Decode allocates a buffer proportional to the encoded input length and traverses that buffer for each input byte, so oversized alphabet-valid input causes quadratic CPU work before rejection. The transport's response-size cap does not constrain the address in the original URI. This newly reachable work occurs during preparation, before interactive confirmation or authentication, and can occupy payment preparation for an input-controlled duration. Reject oversized fallback addresses before decoding, enforce the same address-length bound in the shared codec, and add a regression for oversized fallback input.
Out-of-scope follow-up suggestions (2)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Reject out-of-range BIP70 amounts before arithmetic — BIP70 output amounts are UInt64 values without monetary bounds, while prepareForConfirmation sums them with unchecked addition and Confirmation.estimatedTotal adds the fee unchecked. Out-of-range request amounts can therefore trap during preparation. Both operations are present in base 59d9632, so this is a concrete pre-existing issue rather than a blocker introduced by this PR.
    • Follow-up: Track separately: validate individual and aggregate amounts against Dash monetary bounds, use checked amount-and-fee arithmetic, and add boundary and invalid-input regressions.
  • Bind broadcast execution to the signing wallet and network — SwiftDashSDKTransactionSender.broadcast still selects SwiftDashSDKHost.shared.wallet at broadcast time. A wallet or network switch between signing and submission can therefore send the prepared transaction through a different SDK wallet context. The same lookup exists in the exact base; this PR correctly fixes outcome attribution but does not change broadcast ownership.
    • Follow-up: Track separately: retain the signing wallet and network through broadcast, with lifecycle handling and regression coverage for merchant-acknowledged and detached broadcasts.

Comment on lines +282 to +284
fallbackAddress: fallbackAddress.flatMap {
ScriptAddressCodec.scriptPubKey(forAddress: $0, network: network) != nil ? $0 : nil
})

@thepastaclaw thepastaclaw Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 02fd0d6e; see the replies below.

🔴 Blocking: Bound the URI fallback address before Base58 decoding

The new fallback validation passes the unvalidated, percent-decoded URI address into ScriptAddressCodec.scriptPubKey. ParsedPaymentURI accepts a payment intent with a request URL even when its address is invalid, and the interactive fetch callers still forward that address. ScriptAddressCodec.base58Decode allocates a buffer proportional to the encoded input length and traverses that buffer for each input byte, so oversized alphabet-valid input causes quadratic CPU work before rejection. The transport's response-size cap does not constrain the address in the original URI. This newly reachable work occurs during preparation, before interactive confirmation or authentication, and can occupy payment preparation for an input-controlled duration. Reject oversized fallback addresses before decoding, enforce the same address-length bound in the shared codec, and add a regression for oversized fallback input.

Suggested change
fallbackAddress: fallbackAddress.flatMap {
ScriptAddressCodec.scriptPubKey(forAddress: $0, network: network) != nil ? $0 : nil
})
fallbackAddress: fallbackAddress.flatMap {
guard $0.utf8.count <= 35 else { return nil }
return ScriptAddressCodec.scriptPubKey(forAddress: $0, network: network) != nil ? $0 : nil
})

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 02fd0d6 (2421bf9 and its follow-up).

  • Bound: ScriptAddressCodec.maxAddressLength = 35. An address encodes 25 bytes (version, 20-byte hash, 4-byte checksum), and Base58 of 25 bytes is at most 35 characters (25 × log 256 / log 58 = 34.14, rounded up). With Dash's version bytes (76, 16, 140, 19) every valid address is 34 characters on mainnet, testnet and devnet, so 35 matches the suggestion and refuses nothing valid.
  • In the codec: the bound sits on the decoder itself. base58CheckDecode takes a required maxLength and refuses a longer string before decoding, and scriptPubKey(forAddress:) passes maxAddressLength. base58Decode is private and reachable only through it, so every caller is covered. The other callers (SwiftDashSDKTransactionSender twice, CrowdNodeModel, the refund output in BIP70PaymentService) pass wallet- or transaction-derived addresses and behave as before.
  • At the call site: prepareForConfirmation drops an oversized fallback address before calling the codec, as suggested. The request still prepares.
  • Other routes: all four request fetches and the headless route hand the URI address to this one prepareForConfirmation call, so there was no second unbounded path into this codec. The headless route's last-resort use of the raw URI address is bounded by the same constant. The validity flag computed at URI parse time uses the SDK's Address.validate, not this codec, and is unchanged by this PR.

Regressions: testAnOversizedURIAddressIsDroppedWithoutDecoding (200 000 Base58 characters; the confirmation has no fallback address and the same recipients) and testTheAddressCodecRefusesAnOversizedStringAndTakesValidAddresses (a valid address decodes at a bound of its own length and is refused one below it; an oversized string returns nil; both address kinds round-trip within the bound on every network).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 02fd0d6e): Your fallback validation now rejects addresses over 35 UTF-8 bytes before calling the codec, and scriptPubKey passes that bound to base58CheckDecode before its private decoder allocates or loops. I verified the oversized-input and valid-address round-trip regressions in the current source; I did not execute them in this static lane.

jeanpierreroma and others added 2 commits October 7, 2026 16:18
The URI fallback address reaches ScriptAddressCodec.scriptPubKey
unvalidated and of any length, and base58Decode costs time quadratic in
its input, during payment preparation.

- ScriptAddressCodec.maxAddressLength (35: the longest Base58 encoding
  of an address's 25 bytes) is enforced in scriptPubKey(forAddress:),
  for every caller.
- prepareForConfirmation drops an oversized fallback address before
  calling the codec; the request still prepares.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- base58CheckDecode takes a required maxLength and refuses a longer
  string before decoding, so a future caller cannot skip the bound;
  scriptPubKey(forAddress:) passes maxAddressLength.
- The test pins the bound itself (a valid address at its own length
  and one below), not only the time an oversized input takes.
- The headless route's last-resort URI address is bounded too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static verification of the complete base-to-head range at 02fd0d6 confirms that all seven prior findings are fixed, but the new pending-send store can permanently discard an unresolved payment when switching between named devnets. Chain scope must accompany signing-wallet identity to preserve reconciliation and repeat-payment protection. No builds or tests were run; the supplied exact-head CI snapshot has title and accessibility checks queued and provides no build or runtime validation.

🔴 1 blocking

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate, cross-route change directly alters funds-movement behavior in WalletSendService.swift and SwiftDashSDKTransactionSender.swift, including repeat-payment refusal and handling unknown broadcast outcomes for selected-input sends and CoinJoin sweeps.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `DashWallet/Sources/Models/Transactions/PendingSendOutcomes.swift`:
- [BLOCKING] DashWallet/Sources/Models/Transactions/PendingSendOutcomes.swift:367-372: Scope reconciliation by the signing chain, not only wallet ID
  Different named devnets share the same seed's devnet wallet ID: SwiftDashSDKStoredWalletNetworkResolver derives one ID for .devnet, while Network.persistenceScope and SwiftDashSDKHost open a separate transaction store for each devnet name. After switching from devnet A to B, this wallet-ID-only filter therefore includes A's followed sends, and fetch(txids:) reads B's store. For an A send older than 24 hours, a successful read with no matching row satisfies settlement's missingRowGrace rule and permanently removes A's entry. Returning to A then loses its waiting status and repeat-payment protection even though its payment remains unresolved within the seven-day window; before removal, the same identity collision can also refuse unrelated payments on B and retain A's settlement notice. This is introduced by the new store, despite being documented as a follow-up. Capture the immutable chain persistence scope alongside the signing wallet, propagate it through unknown outcomes, and require scope equality for reconciliation, refusal, and notices. Add a regression proving that a missing row on devnet B cannot remove a followed send on devnet A.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Reject overflowing totals in merchant payment requests — BIP70PaymentService.swift:267 sums merchant-controlled output amounts with unchecked UInt64 addition. PaymentOutput decoding retains raw UInt64 amounts, and resolveOutputs checks only that each amount exists and its script is standard. An allowed unsigned request containing valid outputs with amounts UInt64.max - 1 and 2 therefore traps during interactive preparation, before authentication or confirmation. The same decoder, unsigned-request policy, and unchecked sum exist at base 59d9632; this PR does not introduce or worsen the crash path.
    • Follow-up: Track separately: enforce Dash monetary bounds on individual and aggregate amounts, reject overflow using checked arithmetic, and add malformed-request boundary regressions.

Comment on lines +367 to +372
let activeWalletId = SwiftDashSDKHost.shared.wallet?.walletId
let pending = entries.filter { $0.value.walletId == activeWalletId }
guard !pending.isEmpty else { return }
reconcileInFlight = true
Task.detached(priority: .utility) { [weak self] in
let snapshot = SwiftDashSDKWalletSource.fetch(txids: Set(pending.keys))

@thepastaclaw thepastaclaw Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 665a0a92; see the replies below.

🔴 Blocking: Scope reconciliation by the signing chain, not only wallet ID

Different named devnets share the same seed's devnet wallet ID: SwiftDashSDKStoredWalletNetworkResolver derives one ID for .devnet, while Network.persistenceScope and SwiftDashSDKHost open a separate transaction store for each devnet name. After switching from devnet A to B, this wallet-ID-only filter therefore includes A's followed sends, and fetch(txids:) reads B's store. For an A send older than 24 hours, a successful read with no matching row satisfies settlement's missingRowGrace rule and permanently removes A's entry. Returning to A then loses its waiting status and repeat-payment protection even though its payment remains unresolved within the seven-day window; before removal, the same identity collision can also refuse unrelated payments on B and retain A's settlement notice. This is introduced by the new store, despite being documented as a follow-up. Capture the immutable chain persistence scope alongside the signing wallet, propagate it through unknown outcomes, and require scope equality for reconciliation, refusal, and notices. Add a regression proving that a missing row on devnet B cannot remove a followed send on devnet A.

source: gpt-6.1-sol (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 665a0a9 (a65c27b and three follow-ups).

  • Scope: a followed send is kept under WalletChainScope: the wallet id plus the persistence scope the running host opened its store for. SwiftDashSDKHost now publishes and clears that scope together with its modelContainer (runningPersistenceScope), so it is a stored fact of the bound store and not the devnet configuration of the moment.
  • Captured at build: every route reads it in the same main-actor hop as the build: plain send, swap deposit, selected-input (CrowdNode), BIP70 (interactive, awaited headless, handed-off broadcast) and the CoinJoin sweep. The sweep takes it in the hop that reads its destination, and starts, continues and is joined only on that chain.
  • Carried through: it replaces the bare wallet id in PreparedStandardSend, PreparedSend, SendError.transactionStatusUnknown, BIP70Error.broadcastOutcomeUnknown, the detached hook and the stored entry, so a route cannot name a wallet without its chain.
  • Required everywhere: reconciliation, the refusal, the notice, the "no longer refused" log and probe verdicts all require the same wallet on the same chain. Rows are read with fetch(txids:from:), which returns nothing unless that scope is bound in the hop that takes the store. A send of another chain is not settled, not expired by a missing row, not used to refuse and not told.
  • Entries stored before this have no chain; none is made up. A seed's wallet id differs between mainnet, testnet and devnet, and only named devnets share one. On mainnet and testnet such an entry can only be that chain's, so it is placed on it. On a devnet it stays without a chain: a row found for it settles it, a missing row never drops it, it ages out after the 7-day window, and until then it refuses on every devnet of its wallet.
  • Retired chains: a send of a wallet or chain that is not bound is let go once it is past the 7-day window, by age and never by a missing row. Otherwise a send on a retired devnet would be kept for good.
  • Pending caption: it now uses the same scope type.

Regressions: testAMissingRowOnAnotherDevnetCannotRemoveAFollowedSend (the one asked for), testASendWaitingOnOneChainRefusesAndTellsNothingOnAnother, testAnEntryStoredWithoutItsChainIsNeverDroppedByAMissingRow, testAnUnchainedEntryIsPlacedOnlyWhereItsWalletIdIsOfOneChain, testASendOfAChainNotBoundAgainIsLetGoOnlyPastTheFollowWindow, testAVerdictFromAnotherChainsManagerIsNotHeard, testAnOutcomeIsFollowedUnderTheChainThatSignedIt.

Not changed: broadcast(_:) still submits through whatever wallet is bound at broadcast time. That is the known limitation already listed in the PR description; the outcome is booked under the scope that signed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 665a0a92): Your runningPersistenceScope records the scope of the opened store, and WalletChainScope now accompanies signing ownership through prepared sends, unknown-outcome errors, detached callbacks, and sweep admission. Reconciliation uses a scope-checked store read, refusal and notices require matching wallet/chain ownership, and testAMissingRowOnAnotherDevnetCannotRemoveAFollowedSend covers the reported removal path; the explicitly unchanged broadcast-time wallet lookup is separate from this finding.

jeanpierreroma and others added 4 commits October 7, 2026 17:05
…ts wallet id

The same seed has one wallet id on every chain, every named devnet
included, while each chain has its own transaction store. Followed
sends were kept by wallet id alone, so after a switch from devnet A to
devnet B a read of B's store dropped A's send as "row missing" after
24 h, A's send refused payments on B, and its settlement could be told
on B.

- WalletChainScope (wallet id + Network.persistenceScope) is read in
  the same main-actor hop as the build on every route: plain send,
  swap deposit, selected-input send, BIP70 (interactive, awaited
  headless, handed-off), CoinJoin sweep. It replaces the bare wallet id
  in the prepared sends, the unknown-outcome errors and the hook, so a
  route cannot name a wallet without its chain.
- An entry stores its chain. Reconciliation, the repeat-payment
  refusal, the "went through" notice and the "no longer refused" log
  all require the same wallet on the same chain; the rows are read only
  from the store of that scope.
- Entries stored before this have no chain, and none is made up: a row
  found settles them, a missing row never drops them as gone, they age
  out after the follow window, and until then they refuse on every
  chain of their wallet.
- The Home pending caption uses the same scope type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he chain scope

- The host publishes the persistence scope its store was opened for
  (runningPersistenceScope), and WalletChainScope.bound reads that
  stored fact instead of recomputing it from the devnet configuration.
- Every route reads the scope inside its main-actor hop: the swap
  deposit and the selected-input send computed the chain string after
  it, and the CoinJoin sweep at outcome time. The sweep now takes the
  scope it starts on and lets a chunk through only while that scope is
  bound (two devnets share the wallet id and the Network).
- A seed's wallet id differs between mainnet, testnet and devnet; only
  named devnets share one. So an entry stored without its chain is
  placed on the bound chain on mainnet and testnet, where the id can be
  no other chain's, and keeps the conservative rule only on a devnet.
- A probe verdict is heard only from the manager of the send's own
  chain.
- Docs: the type doc says which networks share a wallet id; the class
  doc is back on the class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A send of a wallet or chain that is not bound is let go once it is
  past the follow window (it refuses nothing by then): otherwise a send
  on a retired devnet was kept, and watched for, for good. By age only,
  never by a row missing on another chain.
- The CoinJoin sweep's scope is read in the hop that reads its
  destination address, and the sweep starts and continues only while
  that scope is bound.
- A settlement is told only if the store that was read is still the
  one on screen.
- Legacy placement runs only while an entry without a chain exists;
  "one chain per wallet id" is an allowlist (mainnet, testnet).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The sweep's single-flight key and its "still selected" check include
  the chain: a call on another devnet no longer joins a sweep running
  on the first one.
- Comments and one test narration brought in line with the rule that a
  send of a non-bound chain is let go past the follow window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static inspection of the complete base-to-head diff at 665a0a9 found no confirmed in-scope defects, and all eight prior findings are fixed. Signing wallet/chain ownership is preserved through unknown outcomes, settlement requires persisted-row evidence, and focused regression sources cover reconciliation, recipient refusal, notices, and pending balances. The supplied exact-head CI snapshot shows passing title, accessibility, and CodeRabbit checks but no build or XCTest results; SDK binary compatibility and exact-head runtime behavior remain unverified, and the reported live smoke used an earlier revision.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate cross-route change directly alters funds-movement gating in WalletSendService.swift and BIP70PaymentService.swift and CoinJoin sweep broadcast handling in SwiftDashSDKTransactionSender.sweepCoinJoin, including wallet-and-chain scoping of uncertain sends.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Reject overflowing BIP70 output totals — BIP70PaymentService.prepareForConfirmation sums merchant-controlled output amounts with unchecked UInt64 addition. The decoder and output resolver do not impose monetary bounds, so a malformed unsigned request can terminate preparation through an arithmetic-overflow trap before interactive confirmation or authentication. The identical aggregation exists at base 59d9632, making this a concrete pre-existing denial-of-service issue rather than a defect introduced by this PR.
    • Follow-up: Track separately and enforce monetary bounds on individual outputs and their aggregate, use checked arithmetic, and add malformed-request regression coverage.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I read the whole non-localization diff at 665a0a9 (about 2k lines across 30 files), concentrating on the money path and the wallet/chain scoping.

What I checked:

  • Every route that knows its txid books an unknown outcome under the wallet and chain that signed it. Each route reads that origin in the same main-actor hop as its build: buildAndSign*, the selected-input send, PreparedSend.origin and the detached BIP70 broadcast. I grepped every pattern match on SendError.transactionStatusUnknown and BIP70Error.broadcastOutcomeUnknown, and all of them are updated.
  • A send settles only when its stored row shows a lock or a block. A failed read (a nil snapshot) decides nothing. fetch(txids:from:) returns nil when the bound scope changes between the snapshot and the read, so a missing row on another devnet cannot drop a send.
  • The repeat-payment check runs on main. For a plain send it runs before the PIN prompt and the build; for BIP70, before the confirm sheet. A refusal goes through the existing paymentProcessorDidCancelTransactionSigning path, the same one an auth cancel takes, so the paying screen stays. If the notice can't be presented, the send is refused rather than made.
  • PaymentController is the only DWPaymentProcessorDelegate, so the two new required ObjC methods can't hit an unrecognized selector.
  • The notice's "you can remove it from your history" hint works while the row reads "Waiting for the network": TxDetailModel.supportsUnconfirmedRemoval is gated on state == .processing.
  • The wiper's defer (@MainActor deleteLogicalWallet) and UnconfirmedTransactionRemover both drop entries on the main actor.

Two non-blocking notes, inline: the PaymentProtocol layer now depends on an app type, and the plural toast string should go through Localizable.stringsdict.

Before merging (these are not code issues):

  • #1178 has to land first.
  • dashpay/platform#5258 is still open. coreFundsAwaitingNetwork, setBroadcastProbeEnabled and outgoingTransactionVerdicts exist only on that branch, not on v5.0-dev.
  • The branch conflicts with its updated base only in the 43 Localizable.strings files, where both sides appended at the end. git merge-tree shows no Swift or ObjC conflicts.

Design note: a repeat payment is refused outright, with no override, for up to 7 days. That's reasonable: the send can be removed, and an unknown send normally settles within seconds once the network is reachable. Still, it's worth watching support feedback about exchange deposit addresses and static merchant addresses that people pay repeatedly.

/// `repeatCheckAddresses` is `Confirmation.repeatCheckAddresses` of the
/// payment; nil as raised by the wallet adapter, which does not know it,
/// and filled in by `BIP70PaymentService.confirmAndSend`.
case broadcastOutcomeUnknown(txHashDisplay: Data, origin: WalletChainScope?, reason: String, repeatCheckAddresses: [String]? = nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (coupling): the PaymentProtocol layer now names WalletChainScope, both here and in PreparedSend.origin. That type is defined in PendingSendOutcomes.swift, which imports UIKit and SwiftDashSDK. The doc comment on PreparedSend.sdkTransaction still says the module is kept Foundation-only, and the origin is described as "opaque to this layer", but the type is concrete.

In practice this adds a second break to scripts/bip70_manual_test/run.sh, which compiles these sources on their own: BIP70Error.swift:57: cannot find type 'WalletChainScope' in scope. To be fair, base was already broken by DWLogger in BIP70PaymentService.swift, so this PR didn't break it first.

A cheap fix would be to move the plain struct WalletChainScope (just walletId and chain) into its own Foundation-only file, keep the @MainActor bound and boundWalletIdIsOfOneChain accessors as an extension in PendingSendOutcomes.swift, and add the new file to the harness's source list. This is fine as a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 49c95d8: the plain struct WalletChainScope (walletId, chain) now lives in Models/Transactions/WalletChainScope.swift, which imports only Foundation. The @MainActor bound and boundWalletIdIsOfOneChain accessors stay in PendingSendOutcomes.swift as an extension, the doc comment on PreparedSend.origin no longer calls the type opaque, and scripts/bip70_manual_test/run.sh lists the new file. I did not run the harness: as you noted, it was already broken on base by DWLogger in BIP70PaymentService.swift, so this removes the second break, not the first.

notice.total.formattedDashAmount)
}
return String(
format: NSLocalizedString("%1$ld payments went through, %2$@ in total", comment: "Several payments that had been waiting for the network were confirmed; %1$ld is how many, %2$@ their total amount"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (l10n): count == 1 is handled separately, so English reads correctly. But %1$ld payments went through as a flat .strings entry can't be translated properly in pl, ru, uk, cs, sk, hr, sr and other locales, where 2–4 and 5+ take different noun forms. We already ship Localizable.stringsdict, so moving this key there (NSStringPluralRuleType) before Transifex picks it up would save a retranslation later.

@romchornyi romchornyi Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and left for a follow-up rather than done here. The gain is in the locales with several plural forms, and each of those needs its own categories written in its Localizable.stringsdict; an English-only entry would change nothing, since count == 1 is already handled separately. It should go in together with the Transifex resource, so translators get the plural form from the start.

jeanpierreroma and others added 2 commits October 10, 2026 22:15
…send-states

Conflicts only in the 43 Localizable.strings catalogs, where both sides
appended new keys at the end of the file; resolved by keeping both sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The payment-protocol layer names the type in PreparedSend.origin and in
BIP70Error, and that layer is compiled on its own by the BIP70 manual
test. The plain struct moves out of PendingSendOutcomes.swift (UIKit and
SwiftDashSDK); the host-bound accessors stay there as an extension, and
the harness lists the new file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The complete base-to-head diff addresses all eight prior findings, with focused regression coverage present in the source. One blocking issue remains: the new repeat-payment refusal compares full Swift recipient strings while native validation and signing can interpret a truncated address, allowing the safeguard to miss the same on-chain recipient. Verification was static only; the exact-head CI snapshot shows successful accessibility, PR-title, and CodeRabbit checks, but no application build, XCTest, or runtime evidence.

🔴 1 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate diff changes funds-movement behavior in WalletSendService and SwiftDashSDKTransactionSender.sweepCoinJoin, including repeat-payment refusal, wallet/chain binding, and handling unknown broadcast outcomes.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `DashWallet/Sources/Models/Transactions/PendingSendOutcomes.swift`:
- [BLOCKING] DashWallet/Sources/Models/Transactions/PendingSendOutcomes.swift:306-307: Reject embedded NULs before using recipient strings as refusal keys
  The refusal keys do not necessarily identify the recipient that native signing pays. BIP70URI percent-decodes the address, and ParsedPaymentURI and PaymentIntent preserve the resulting full string. WalletEnvironment delegates validation to the SDK's Address.validate, which uses withCString; at the required SDK revision f61b2c3f86, validation ultimately reads a Rust CStr. CoreTransactionBuilder.addOutput similarly uses strdup followed by CStr::from_ptr. These native operations stop at an embedded NUL, whereas this Set comparison and unknown-outcome recording retain the entire Swift string. Consequently, differently represented strings for the same native recipient can miss the new refusal in either direction. With an unresolved earlier payment and additional confirmed funds, another user-authorized payment to that recipient can proceed despite the promised safeguard. The strict ScriptAddressCodec validation protects BIP70 fallback preparation, but the plain-send route does not use it. Reject embedded NULs and other full-string-invalid addresses at a shared boundary before the refusal check, authentication, and signing; do not merely omit invalid addresses from the check. Add regression coverage establishing that refusal identity and signed-recipient identity cannot diverge.
Out-of-scope follow-up suggestions (2)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Preserve the signing wallet generation through deferred broadcast — SwiftDashSDKTransactionSender.broadcast resolves the active wallet at submission time, and this behavior is unchanged from the PR base. At SDK f61b2c3f86, Rust consumes the finalized handle and rejects a different wallet generation before network submission. A switch between signing and deferred submission can therefore prevent the app's broadcast after a merchant has acknowledged the signed bytes; it does not establish that Rust broadcasts on the wrong chain. The new origin metadata correctly fixes outcome attribution without resolving this pre-existing execution limitation.
    • Follow-up: Track a separate maintainer-requested change that preserves the originating wallet generation through submission and defines lifecycle handling for merchant-acknowledged payments.
  • Reject overflowing BIP70 payment amounts before confirmation — PaymentOutput accepts UInt64 amounts, ScriptAddressCodec.resolveOutputs checks their presence but not monetary bounds, and BIP70PaymentService aggregates them with unchecked addition. Confirmation.estimatedTotal also adds the estimated fee without an overflow check. Out-of-range merchant amounts can therefore terminate preparation before interactive confirmation. Both arithmetic paths are unchanged from the PR base, so this is a concrete pre-existing input-validation issue rather than an in-scope blocker.
    • Follow-up: Track separate monetary-bound validation and checked amount/fee arithmetic, with malformed-request regression coverage.

Comment on lines +306 to +307
let wanted = Set(addresses)
return entries.values.filter { $0.isFollowed(on: scope) && !wanted.isDisjoint(with: $0.addresses) }

@thepastaclaw thepastaclaw Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at f1f91507; see the replies below.

🔴 Blocking: Reject embedded NULs before using recipient strings as refusal keys

The refusal keys do not necessarily identify the recipient that native signing pays. BIP70URI percent-decodes the address, and ParsedPaymentURI and PaymentIntent preserve the resulting full string. WalletEnvironment delegates validation to the SDK's Address.validate, which uses withCString; at the required SDK revision f61b2c3f86, validation ultimately reads a Rust CStr. CoreTransactionBuilder.addOutput similarly uses strdup followed by CStr::from_ptr. These native operations stop at an embedded NUL, whereas this Set comparison and unknown-outcome recording retain the entire Swift string. Consequently, differently represented strings for the same native recipient can miss the new refusal in either direction. With an unresolved earlier payment and additional confirmed funds, another user-authorized payment to that recipient can proceed despite the promised safeguard. The strict ScriptAddressCodec validation protects BIP70 fallback preparation, but the plain-send route does not use it. Reject embedded NULs and other full-string-invalid addresses at a shared boundary before the refusal check, authentication, and signing; do not merely omit invalid addresses from the check. Add regression coverage establishing that refusal identity and signed-recipient identity cannot diverge.

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f1f9150.

Confirmed first: BIP70URI percent-decodes the address, and the SDK's Address.validate takes <address>\0<anything> for <address> (measured in a test against the SDK this branch builds with).

  • One rule for "is an address". ScriptAddressCodec.isWellFormedAddress: the whole string is a Base58Check address (35 bytes at most, a valid checksum, a version byte and a 20-byte hash). String.isValidDashAddressForCurrentNetwork, the app's one address check, requires it before it asks the SDK.
  • The send boundary. WalletSendService refuses such a recipient before it asks for authorisation (standard, selected-input and swap-deposit sends). SwiftDashSDKTransactionSender refuses it again at the start of buildAndSign, buildAndSignSwapDeposit, buildAndSignFromAddress and sweepCoinJoin, so a recipient that does not come through the UI check (a swap vault, a gift-card merchant) is held to the same rule. The refusal is an error, not an omission from the repeat check.
  • A second way the keys could differ. dash:<address>%20 was payable by the classifier, which trims, while the intent kept the untrimmed string. BIP70URI now keeps the address trimmed, for the interactive and the headless route.
  • The headless unknown-outcome fallback records the URI's address only when it is well formed.

Tests (UnknownOutcomeWalletTests, run on a simulator: 14 pass):

  • testNoSendIsBuiltForARecipientThatIsNotAWholeAddress: all four build entry points refuse with the address reason, before a wallet is looked for;
  • testTheAppsAddressCheckRefusesAnAddressWithAnEmbeddedNul: the app's check and ParsedPaymentURI.parse for dash:<address>%00x;
  • testAnAddressWithAnEmbeddedNulIsNotAnAddress, testOnlyAWholeBase58CheckAddressIsWellFormed, testAPaymentURIKeepsItsAddressTrimmed.

Not done here:

  • The SDK wrappers still read a C string (Address.validate, CoreTransactionBuilder.addOutput). That is a change in the SDK; the app no longer hands them such a string.
  • No test drives a signed transaction and compares its output with the recorded recipient; the tests show that a string which is not a whole address cannot reach the build.

A behaviour change: an address followed by a trailing NUL was paid before and is now refused as not an address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at f1f91507): Your whole-string Base58Check guard now runs before SDK address validation, before WalletSendService authorization, and at every recipient-building entry point; BIP70URI also retains the trimmed address. The regression cases establish rejection before wallet lookup or construction, so the remaining SDK C-string behavior does not leave this app-side finding open.

The SDK validates and pays an address as a C string, which ends at the
first NUL, while the app keeps the whole Swift string: a payment URI
with `<address>%00<anything>` validated as `<address>` and was paid to
it, but was compared, recorded and shown as another string. The
repeat-payment refusal compares those strings, so it missed the same
recipient.

- `ScriptAddressCodec.isWellFormedAddress`: the whole string is a
  Base58Check address (35 bytes at most, a valid checksum, a version
  byte and a 20-byte hash).
- The app's one address check requires it before asking the SDK.
- `WalletSendService` refuses such a recipient before it asks for
  authorisation, and every sender function that adds an output for an
  address it is given refuses it too, so a recipient from a server (a
  swap vault, a merchant) is held to the same rule.
- A payment URI's address is kept trimmed, so `dash:<address>%20` is the
  address and not a different key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The complete base-to-head diff has no confirmed in-scope findings, and all nine prior findings are fixed in the current source. Whole-string recipient validation, signing-wallet/chain attribution, multi-recipient refusal, settlement notices, and pending-balance handling address the reported defects. Verification was static only: the supplied exact-head CI snapshot has title and accessibility checks queued and provides no app-build or test result; the documented live smoke testing used an earlier head.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate diff changes funds-movement behavior in WalletSendService.swift and SwiftDashSDKTransactionSender.swift, including repeat-payment refusal before signing, wallet/chain binding of sends, and handling unknown broadcast outcomes for CoinJoin sweep chunks.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.
Out-of-scope follow-up suggestions (2)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Reject overflowing amounts in untrusted BIP70 requests — BIP70PaymentService.swift:267 sums merchant-controlled UInt64 amounts using trapping addition. An unsigned, unexpired request containing two standard outputs with amounts UInt64.max and 1 passes the unsigned-request policy and output-shape checks, then terminates the app during preparation, before confirmation or authentication. The aggregation, missing amount bounds, and reachable preparation route already exist at base 1071173, so this is a concrete pre-existing availability defect, not a blocker for this PR.
    • Follow-up: Track separately: enforce Dash monetary bounds and overflow-checked output-total and fee arithmetic, with malformed unsigned-request regressions.
  • Reject embedded NULs in reusable SDK address APIs — At SDK revision f61b2c3f86, Address.validate uses withCString, and CoreTransactionBuilder.addOutput and setChangeAddress use strdup; native transaction-builder entry points read CStr::from_ptr. These APIs therefore interpret a Swift address containing an embedded NUL as its prefix. The current app routes reject such strings before native validation or construction, resolving this PR's recipient/refusal-key defect, but the reusable SDK boundary retains the mismatch for direct consumers.
    • Follow-up: Track separately in dashpay/platform: reject embedded NULs in the shared address wrappers or use length-delimited native inputs, with validation, recipient-output, and change-address regressions.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed what changed since my approval at 665a0a9: the base merge (80eabd6), 49c95d8 (WalletChainScope move) and f1f9150 (whole-string address check). Still approving. The merge brings in one non-blocking interaction, described below.

What I checked

  • 49c95d8 resolves my coupling note. WalletChainScope.swift imports only Foundation and has the same four target memberships as PendingSendOutcomes.swift. The PaymentProtocol codec, BIP70Error.swift and WalletChainScope.swift compile on their own with swiftc.
  • f1f9150 puts isWellFormedAddress in front of Address.validate in the app's one address check. It also runs at every sender entry that adds an output for an address it is given: buildAndSign(recipients:), the swap deposit, the selected-input send and the CoinJoin sweep. In WalletSendService it runs before authorizeSend on all three routes.
  • I ran the codec in a small harness. P2PKH and P2SH addresses on mainnet and testnet pass (all are 34 characters). These are refused: a NUL before or after the address, trailing whitespace, a full-width digit, a combining mark, and an oversized string.
  • Every caller of isValidDashAddressForCurrentNetwork (Send sheet, paste, URI parse, masternode withdrawal and unban) expects a Base58 Core address, so nothing legitimate is newly refused.
  • Merge: --remerge-diff shows no hand-resolved Swift or ObjC hunks. modelContainer and runningPersistenceScope are still set and cleared together, in publish and clearRuntimeReferences.

Non-blocking: the merge meets the local-store reset from #1195

Base added resetLocalStoresAndRetry, which deletes every scope's DashModel.sqlite and rescans. It leaves PendingSendOutcomes alone. When the host republishes, observeVerdicts calls reconcile, which reads the new, empty store. That read succeeds, so settlement treats rows[txid] == nil as gone once now − sentAt > missingRowGrace (PendingSendOutcomes.swift:592).

As a result, every followed send older than 24 h is dropped right after the reset, before the rescan can bring its row back. Its repeat-payment refusal is lifted even though the send may still confirm, which is the double payment this PR exists to prevent. The log line also gives the wrong cause ("removed, swept or replaced").

This path is rare (a store that fails to open, plus a send with an unknown outcome) and is no worse than develop today. It is still cheap to close. For example, dropLocalStoreDerivedState() could stamp a reset time on PendingSendOutcomes, and the missing-row grace could run from max(sentAt, storesResetAt). Listing it under Known limitations would also do. Either way, for a send whose row never comes back, the refusal's "you can remove it from your history" has no row to remove.

Nits

  • ScriptAddressCodec.swift:172 says "Required, so every decode is bounded". Since the merge, base58Decode is internal so the voting-key screen can call it. That caller limits input to 52 bytes itself, so nothing is unbounded, but the comment's claim is no longer true.
  • No test covers the ordering in WalletSendService (refused before the PIN prompt), because sendAuthorizer is a private let. The new tests only exercise the sender's static entry points.

Before merging (unchanged)

  • #1178 and dashpay/platform#5258 are both still open.
  • The live simulator run was on 998e446 (Oct 5). Everything after it is covered only by unit tests and static review: the refusal's final one-OK form, the BIP70 recipient lists, the chain scope and the whole-address check. CI on this PR builds nothing and runs no tests. One more simulator pass of H2, H3 and H5 on the final head, after the SDK branch lands, would close that gap.

This branch was previously deployed

1 inactive (outdated) deployment
testflight — 665a0a92 Deployed Oct 7, 2026 by romchornyi via Build and upload dashpay #103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants