Repository navigation
fix: hold the funding ask while a savings send is unresolved - #1457
Conversation
Progress no longer shows Amount to pay or the funding address while a savings send of the fees may still land; it says to wait for it. Verified: SparkExitReviewTests, SparkExitFundingTests, OnchainSendAttemptServiceTests on the simulator, swiftformat, validate-translations
…e network A refused send keeps its own retry and never holds the ask. The journal is read on load, before a tick's network calls and after a retry, so Progress never shows the ask first. Verified: SparkExitReviewTests, SparkExitFundingTests, OnchainSendAttemptServiceTests on the simulator, swiftformat --lint
A retry of unknown outcome may still land, so its send keeps holding the funding ask, as on Android. Verified: SparkExitReviewTests, SparkExitFundingTests, OnchainSendAttemptServiceTests on the simulator, swiftformat
A start payment of unknown outcome holds the funding ask at once, as on Android. Verified: SparkExitReviewTests, SparkExitFundingTests, OnchainSendAttemptServiceTests, SparkExitTests on the simulator, swiftformat --lint
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The change affects the Spark emergency-exit Progress funding workflow. The PR appears safe to merge, with a non-blocking gap in regression tests. Findings
SummaryProgress now hides the funding amount and address while a matching Savings send is pending or unknown.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read send journal] --> B{Pending or unknown send?}
B -->|Yes| C{Matches an exit funding address?}
C -->|Yes, fees still missing| D[Hide amount and address; show wait note]
B -->|No| E[Show normal funding state]
C -->|No| E
Reviews (1) · Last reviewed commit: "fix: read the savings send after any sta..." · Reviewed by Greptile |
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 5cef1d8. The hold in Bitkit/Managers/SparkExitManager.swift:371 matches the journal by funding address alone, so it can outlive the payment the exit was waiting for.
- Medium: Restore external funding after an unresolved Savings payment expires. If the payment never arrives,
Bitkit/Services/SparkExit/SparkExitDriver.swift:244clears the tracked txid and the exit asks for funding again. With the journal still unknown,Bitkit/Views/Settings/Advanced/SparkExitViews.swift:868keeps hiding the amount, address, and copy button on subsequent refreshes. The user can be left waiting indefinitely with no way to fund the exit from Progress. - Low candidate: A confirmed short Savings payment can temporarily hide the remainder. If the journal still reads unknown at
Bitkit/Managers/SparkExitManager.swift:619and the next address read sees the confirmed short payment, the funding calculation asks for the remainder while Progress still tells the user to wait. - Low candidate: A retry of a refused Savings payment can leave the external funding instructions visible while the retry may still land. The retry retains the refused status through broadcast at
Bitkit/Services/OnchainSendAttemptService.swift:918andBitkit/Services/OnchainSendAttemptService.swift:943. If the app closes before saving the outcome and the funding host has yet to see the retry, Progress can show the address again on relaunch. A payment from another wallet during that interval could leave excess funds at the exit address and cost an extra mining fee.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P1). Holds Progress's funding ask (Amount to pay and the address) while a savings send of the exit fees is pending or of unknown outcome, reads the send journal before the network on load, each tick and after a start or retry payment, and stops a retry of unknown outcome from ending its send as accepted. Reviewed 5cef1d8, full tier.
What I checked, and 5 candidates I ruled out
Read in full: SparkExitManager.swift (load, reset, retrySavingsPayment, refreshRefusedSavingsPayment, tick, start payment, payFunding), the Progress view in SparkExitViews.swift, OnchainSendAttemptService.swift (status model, record, retrySamePayment, blockingAttempt, resumeAcceptedOrdinarySend, abandonUnbroadcast), SparkExitDriver own-payment expiry, SparkExitFunding.reminders.
Compared with Android: SparkExitRepo.noteSavingsSend on bitkit-android master holds on attempt.isUnresolved for a send to the funding address; same shape as here.
Build: static review, not built (iOS does not build on Linux). node scripts/validate-translations.js passes on the head. CI: SwiftFormat, validate and Greptile green; Run Tests and Integration Tests still pending when this was written.
Ruled out
- Accepted retry never resumed: after an accepted retry
blockingAttemptstill returns the attempt (follow-up not done) with.accepted, solandingSendAddressis nil andresumeAcceptedOrdinarySendruns as before. - Refused send hidden by the hold:
landingSendAddressis nil for.rejected, so the refused note and Pay again stay (covered bytestOnlyAPendingOrUnknownSendMayStillLand). - A send to another address holds the ask:
isSavingsSendLandingmatches the funding address only. - Funded exit still held: the
fundingShortfallSatsguard drops it once running. - Stale hold after reset:
landingSendAddressis cleared with the other per-exit state.
Merge confidence: 3/5, one P1 on the expiry path for an unknown send that never went out.
Reviewer model: claude-opus-5-5, with a cross-check of the finding by xiaomi/mimo-v2.6-pro
Reasoning effort: Not exposed (the run records no named effort for either model)
…or it An unknown savings payment already keeps its txid on the record, so Progress shows it paid and the own-payment wait brings the ask back if it never lands. The journal-keyed hold could outlive that wait and hide the ask for good; it is gone. The note now shows while the exit waits for its own payment and the send journal has not seen it accepted. Verified: SparkExitReviewTests, SparkExitFundingTests, SparkExitTests on the simulator, swiftformat --lint, validate-translations
A retry of unknown outcome may still land: its send stays unresolved, so Progress keeps saying so. A refused send is read from the journal, so its note never shows as one that may still land. Verified: SparkExitReviewTests, SparkExitTests on the simulator, swiftformat --lint
A retry now refreshes whether a savings send may still land, and ends the send only when its own result was accepted. Progress shows the note only while the funding is still paid from savings. Verified: SparkExitReviewTests and SparkExitDriverTests on the simulator, swiftformat
A tick that forgets the exit's own payment brings the ask back at once, and a savings payment of the funding updates the note right away. A refused later attempt no longer hides the note while the kept payment may still land. Verified: none (tests run after this commit)
A funding state read while the exit still awaited its own payment no longer holds the ask after a background run or tick forgot it, and the savings note reads the send journal right at load. Verified: SparkExitReviewTests and SparkExitDriverTests on the simulator, swiftformat
Verified: none (tests run after this commit)
Fixed in 628ccb5: the hold keys on the exit record, so once the own-payment wait clears the txid the amount, address and copy button come back, whatever the journal says. bfff3d4 and eaa1799 bring the ask back on that same tick, and after a background run.
Fixed in 7e8f98b: the note shows only while the funding still counts as paid, so once the address read asks for the remainder, the remainder shows without the note.
The app closing between a broadcast and saving it on the exit is #1459, which covers this window too. |
Verified: none (tests run after this commit)
pwltr
left a comment
There was a problem hiding this comment.
Reviewed eaa1799. Progress treats unavailable funding-address UTXOs as zero received, so a 20,000-sat Savings payment against a 35,000-sat requote can leave a copyable request for the full 35,000 sats. The correct remainder at 2 sat/vB is 15,136 sats.
Low A connected background tick can clear the txid after observing the short confirmation, then publish the record without refreshing funding. Progress drops the cached paid state and shows the full amount until a foreground read completes. Bitkit/Managers/SparkExitManager.swift:62, Bitkit/Managers/SparkExitManager.swift:1475, Bitkit/Views/Settings/Advanced/SparkExitViews.swift:737.
Low A foreground tick can read the correct remainder, clear the txid, then replace that remainder with the full amount if the extra address read fails. Bitkit/Managers/SparkExitManager.swift:632, Bitkit/Managers/SparkExitManager.swift:636, Bitkit/Managers/SparkExitManager.swift:728.
Low If a refused Savings payment is retried, the retry has no known outcome, and neither transaction lands, Progress eventually allows funding from another wallet. That payment can advance the exit while the retained receipt still blocks new on-chain sends. Send Pending offers to retry the same payment to the already funded address. The user needs a safe way to resolve the old attempt while accounting for its potentially live transactions. Bitkit/Managers/SparkExitManager.swift:432, Bitkit/Services/OnchainSendAttemptService.swift:350, Bitkit/Services/OnchainSendAttemptService.swift:1023, Bitkit/Services/OnchainSendAttemptService.swift:1394, Bitkit/Views/Wallets/Send/SendPendingScreen.swift:397.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
A tick that forgets the exit's own payment reads the funding address again; when that read fails it now goes by the tick's first read, so a short savings payment still counts and only the rest is asked for. Twin of synonymdev/bitkit-android#2123. Verified: SparkExitReviewTests, SparkExitDriverTests, SparkExitTests on the iOS simulator
A start whose savings payment fails reads the send journal at once, so cancel reflects a send that may still land; a paid-again retry stays paid in memory when its save fails. Verified: none (tests run after this commit)
…yment Verified: none (tests run after this commit)
Progress re-reads the refused send under the lock before paying it again, and authorizes the retry only while the journal still holds it refused, so a retry from Send Pending since the last tick is never paid a second time. Verified: none (tests run after this commit)
Fixed in cd847b3: a background run that changes the phase or forgets the exit's own payment reads the funding address, as a foreground tick does.
Fixed in ef18c55: a failed re-read keeps the tick's first read, so a short payment still counts and only the rest is asked for (the iOS twin of synonymdev/bitkit-android#2123).
It comes from the retry already on master, so it's tracked in #1512 and fixed in its own PRs: Send Pending stops offering that retry while the exit runs, and offers a release once the exit no longer needs it. |
|
Pushed c8fd11e:
|
pwltr
left a comment
There was a problem hiding this comment.
Reviewed c8fd11e.
Low: Bind the Progress retry to the refused payment the user tapped. If the user resolves payment A through Send Pending, then a different Savings payment B to the same funding address is refused, Progress can still offer the retry for A. The journal refresh in Bitkit/Managers/SparkExitManager.swift:427 picks up B, and the action in Bitkit/Views/Settings/Advanced/SparkExitViews.swift:1076 can dispatch B without the fee confirmation Send Pending would show for that retry. Carry the attempt ID from the button into the retry and require the fresh journal entry to match it.
Low: Preserve the funding outputs the driver sees when it clears a confirmed short Savings payment. In a foreground tick, Bitkit/Managers/SparkExitManager.swift:839 can read an empty address before the driver sees the output, then fall back to that empty response if the final read fails. In a background run, Bitkit/Managers/SparkExitManager.swift:1700 publishes the cleared transaction ID before the reread finishes, and a failed read leaves Progress without the output. Both paths can show the full amount next to the copyable address at Bitkit/Views/Settings/Advanced/SparkExitViews.swift:940. A confirmed 20,000-sat payment against a 35,000-sat requirement at 2 sat/vB can show 35,000 sats due when 15,136 sats remain. Carry the driver's output observation through to the funding state when publishing the updated record.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
|
QA for c8fd11e: Tested on iPhone 17 Pro (iOS 27 simulator), local regtest. A local debug-only change reported the force transfer's savings payment as an unknown outcome once, though it was broadcast, and kept the wallet from seeing it unconfirmed. 🟢 Savings payment with an unknown outcome at the startSavings payment with an unknown outcome at the start Progress showed the unresolved-payment note with no amount to pay, no funding address and no Cancel transfer, and kept it over several ticks (3 min).
🟢 App terminated and relaunchedApp terminated and relaunched After relaunch, Progress showed the same note, still with no ask and no Cancel.
🟢 The payment confirmsThe payment confirms One block later the note went away and no ask came back. The exit broadcast its next step, and the funding address received exactly one payment (7 623 sats).
|
…-funding-ask # Conflicts: # Bitkit/Managers/SparkExitManager.swift
|
Merged master in 3ce2533, resolving the conflicts with #1506 in |
|
QA for 3ce2533: Tested on iPhone 17 Pro (iOS 27 simulator), local regtest. A local debug-only change reported the force transfer's savings payment as an unknown outcome once, though it was broadcast, and kept the wallet from seeing it unconfirmed. 🟢 Savings payment with an unknown outcome at the startSavings payment with an unknown outcome at the start Progress showed the unresolved-payment note with no amount to pay, no funding address and no Cancel transfer, and kept it over several ticks (3 min).
🟢 App terminated and relaunchedApp terminated and relaunched After relaunch, Progress showed the same note, still with no ask and no Cancel.
🟢 The payment confirmsThe payment confirms One block later the note went away and no ask came back. The exit broadcast its next step, and the funding address received exactly one payment (22 754 sats).
|
…-funding-ask # Conflicts: # Bitkit/Managers/SparkExitManager.swift
piotr-iohk
left a comment
There was a problem hiding this comment.
Approved 27ef013. I reran Run Tests. The failure looks like a timing issue in ProfileRecoveryUITests while tapping the transient ProfilePubkyCopiedToast. The same test passed on the master base.
|
QA for 27ef013: Tested on iPhone 17 Pro (iOS 27 simulator), local regtest. A local debug-only change reported the force transfer's savings payment as an unknown outcome once, though it was broadcast, and kept the wallet from seeing it unconfirmed. 🟢 Savings payment with an unknown outcome at the startSavings payment with an unknown outcome at the start Progress showed the unresolved-payment note with no amount to pay, no funding address and no Cancel transfer, and kept it over several ticks (3 min).
🟢 App terminated and relaunchedApp terminated and relaunched After relaunch, Progress showed the same note, still with no ask and no Cancel.
🟢 The payment confirmsThe payment confirms One block later the note went away and no ask came back. The exit broadcast its next step, and the funding address received exactly one payment (7 623 sats).
|
pwltr
left a comment
There was a problem hiding this comment.
Consider separating Spark exit funding progress from Savings send recovery so each can resolve on its own evidence.
Reviewed 27ef013.
Low candidate: If a Savings retry made from Progress has an unknown outcome and another transaction from the same wallet confirms spending one of its inputs, the exit can stop waiting while unrelated Savings sends stay blocked. Bitkit/Managers/SparkExitManager.swift:463 leaves the journal open, Bitkit/Services/SparkExit/SparkExitDriver.swift:244 expires only the exit's wait, and Bitkit/Services/OnchainSendAttemptService.swift:872 still requires the original inputs on retry. The journal ignores the competing transaction at Bitkit/Services/OnchainSendAttemptService.swift:1418, and the ordinary funding payment is ineligible for release at Bitkit/Services/OnchainSendAttemptService.swift:350. Whether an ordinary retry or wallet reconciliation can clear the journal after the competing spend confirms is still open.
Device checks: app-status-emergency-exit.xml passed on an iOS simulator.
Review details
Quick review: Claude Opus 5.5, high reasoning effort
General review: GPT-6.2 Sol, high reasoning effort
Verification: GPT-6.2 Sol, high reasoning effort
Tracked in #1528, starting with whether an ordinary retry or wallet reconciliation already clears the journal once the competing spend confirms. It'll be fixed in the follow-up PR for 3.2.0 if needed, so this head stays as approved. |
|
Merging: approved on 27ef013, device run on this head posted above, all checks green. |
Closes #1451
Twin: synonymdev/bitkit-android#2112
Description
Out of Scope
Design
N/A — no design available. One new note on Progress, translated into every locale.
Preview
N/A — a savings payment with no answer hasn't been reproduced on a device.
QA Notes
Journeys
N/A
Manual Tests
Automated Checks
SparkExitReviewTests.swiftxcodebuild testforSparkExitReviewTests,SparkExitDriverTestsandAppStatusExitTestson an iOS 27 simulatorswiftformat --linton the changed files andnode scripts/validate-translations.jsModels used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)