Repository navigation
fix: release savings payments a force transfer no longer needs - #1518
Conversation
A savings send to a Spark exit's funding address, told apart by that address (the current record's or an earlier exit's), is released through the existing release path once the exit no longer needs it: the exit was cancelled or ended, or it holds all its funding and none of it is the send's. One the exit adopted, or still waits for, is never released. Send Pending never offers "Retry original payment" for an exit's funding, which Progress owns, and offers the release with its own note once the exit no longer needs it. Progress' Pay from savings retry and Send Pending's retry read the exit again right before dispatch and refuse once it is funded. Verified: xcodebuild test of the BitkitTests unit suite (CI selection); the new release, hidden-retry and pay-again tests fail with the gate stubbed out; swiftformat --lint; validate-translations.js
Verified: none (changelog only)
A savings send's txid stayed on the exit record after another wallet funded it, so the send was never released. Only a payment the exit still waits for keeps it now. A release already approved also stops for a send that landed as leftover, and paying again refuses once another wallet's funding reached the address. Verified: xcodebuild test SparkExitFundingReleaseTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests
Once a release of a savings send to a force transfer's funding address is approved, Send Pending finishes it even after the exit's record is gone, instead of offering Retry. Paying again now ignores the exit's own adopted outputs and their change when it looks for other funding. Verified: xcodebuild test SparkExitFundingReleaseServiceTests, SparkExitFundingReleaseTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests
Send Pending hid Retry for every savings send to a force transfer's funding address, so an unresolved one Progress could not pay again stayed stuck and blocked new on-chain sends. It offers Retry again unless the release is offered, and the retry checks right before dispatch that the exit still asks for the funding and nothing else reached the address, the same check Progress uses. A send whose release was approved is never paid again. Verified: xcodebuild test SparkExitFundingReleaseTests, SparkExitFundingReleaseServiceTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests; swiftformat --lint on the changed files
A savings send whose cancel was approved is refused before the exit-funding check, so it stays refused once the exit's record is gone, and Send Pending hides Retry for it. Verified: xcodebuild test SparkExitFundingReleaseTests, SparkExitFundingReleaseServiceTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests; 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. |
[Critical impact] The PR appears safe to merge; no actionable issues were found. SummaryLets users cancel unresolved savings payments that a force transfer no longer needs.
No actionable issues found. Tests were not run during this review. Native iOS visual checks were unavailable in this Linux environment. Acknowledged scope from
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Unresolved savings payment] --> B{Matches an exit address?}
B -->|No| C[Keep ordinary send behavior]
B -->|Yes| D{Exit still needs payment?}
D -->|Yes| E[Offer Retry]
E --> F[Recheck exit and funding address]
F --> G[Retry only when allowed]
D -->|No| H[Offer Cancel]
H --> I[Check network for original transactions]
I --> J[Spend original coins back to wallet]
J --> K[Remove pending send after release succeeds]
Reviews (1) · Last reviewed commit: "fix: never pay an approved exit funding ..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. iOS twin of synonymdev/bitkit-android#2142: Send Pending releases an unresolved savings send to a Spark exit's funding address once the exit no longer needs it, and Retry checks the exit again right before dispatch. Reviewed 895d096, full tier, static.
What I checked, and 5 candidates I ruled out
Read in full: SparkExitFundingRelease.swift, and the changed parts of OnchainSendAttemptService.swift, PaykitPaymentProofService.swift, SparkExitManager.swift, SendPendingScreen.swift
Call sites traced: canBeAbandoned (approveRelease, recordRelease, abandonUnbroadcast in OnchainSendAttemptService), onchainRequestHasEnded, abandonUnbroadcastOnchainPayment, finishRelease, loadAbandonableAttempt, both retrySamePayment authorize closures, the cancel path that adds the forgotten address to earlierAddressStore
Build: not built. iOS does not build on Linux, so CI is the gate (Run Tests, Run Integration Tests, both still pending at review time; SwiftFormat and validate passed)
Ruled out
mayFundSparkExitmakes every ordinary send passcanBeAbandoned(the rewrittenOnchainSendAttemptServiceTestscase drops the store-level refusal): release still needsonchainRequestHasEnded, and for these sends that isexitNoLongerNeeds, true only when the address is the stored exit's or an earlier exit's.storedExitreturns nil for another wallet's attempt or an unreadable store, and then nothing is released.- Spark deposit funding treated as exit funding:
mayFundSparkExitexcludessparkFunding == true, and the test asserts it. - Retry pays over another wallet's funding: the Send Pending closure and
SparkExitManager's refused-payment retry both callauthorizePayAgainbefore dispatch. A nilutxosread refuses, and.paidpasses only when every new UTXO is one of this attempt's candidates. - Behaviour differs from Android:
isExitFunding,exitNoLongerNeeds,isAdoptedandmayPayAgainmatch the Kotlin twin case for case, including the approved-release refusal. - Release shown alongside Retry:
offersRetryhides Retry for exit funding once a release is offered or approved, the same rule as Android'scanRetry.
Merge confidence: 4/5. No findings, but the unit and integration suites were still running at review time and nothing here builds iOS.
Reviewer model: Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: Not exposed (this runtime does not report it)
…ase-unneeded-funding # Conflicts: # Bitkit/Managers/SparkExitManager.swift
The manager takes its send journal, the shared one by default, so a test can drive retrySavingsPayment over its own journal. Verified: xcodebuild test SparkExitFundingReleaseTests, SparkExitFundingReleaseServiceTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests, SparkExitReviewTests (pass; the new test fails with the read guard removed), swiftformat --lint
|
Added in 56b4444: a test that Pay from savings throws and pays nothing when the funding address can't be read, as @piotr-iohk suggested on #1519 (#1519 (review)). It fails with that read check removed. |
Pay again while the exit still asks, waits for this payment or holds its own coin: a retry re-signs the same inputs, and what savings pays beyond the ask comes back as leftover. An unreadable list of earlier exit addresses reads as empty, so it never refuses an ordinary send's Retry. Verified: xcodebuild test SparkExitFundingReleaseTests, SparkExitFundingReleaseServiceTests, PaykitPaymentProofServiceTests, OnchainSendAttemptServiceTests, SparkExitReviewTests (pass; the partial-payment and unreadable-list tests fail on 56b4444), swiftformat --lint
|
Pushed 4e64a12, the twin of @jvsena42's review on synonymdev/bitkit-android#2142 (synonymdev/bitkit-android#2142 (review)):
A device run on this head follows. |
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 4e64a12.
Medium candidate: BitkitTests/SparkExitFundingReleaseTests.swift:38 and BitkitTests/SparkExitFundingReleaseTests.swift:80 call helpers on the SwiftUI view from synchronous tests without @MainActor. If Xcode 26.6 diagnoses the inferred actor isolation under the project's build settings, BitkitTests cannot compile.
A force transfer can ask for more funding at the same address after it first qualifies for Cancel. The screen caches that eligibility, and the service can persist the release decision before the user approves the fee.
Low: Bitkit/Views/Wallets/Send/SendPendingScreen.swift:341 stops checking eligibility once Cancel appears. If the exit asks for a top-up while the sheet stays open, Cancel fails and Retry stays hidden until the user reopens the sheet.
Low: Bitkit/Services/PaykitPaymentProofService.swift:809 saves releaseApproved before the fee and PIN prompts. If the user declines and the exit subsequently asks for a top-up, the saved flag still blocks Retry after reopening Send Pending. Persist the approval once the user has approved the fee and completed any required authentication.
Low: BitkitTests/SparkExitFundingReleaseTests.swift:104 overwrites and deletes the active wallet's earlier-address file. A rerun in a simulator that already has saved exit history can erase it. Use a temporary store for the corrupt-file fixture.
Low: BitkitTests/SparkExitFundingReleaseTests.swift:82 repeats the foreign-payment case at line 69 with a different dummy txid. The Retry assertion in BitkitTests/PaykitPaymentProofServiceTests.swift:4412 also repeats the two visibility cases at BitkitTests/SparkExitFundingReleaseTests.swift:38. Keep the ownership assertions in the service test.
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
|
QA for 4e64a12: Tested on iPhone 17 Pro (iOS 27 simulator), local regtest. A local debug-only change made the force transfer's savings payment get no answer once: it was never broadcast and was kept as an unknown outcome. 🟢 Another wallet funds the force transfer in fullAnother wallet funds the force transfer in full After another wallet paid the whole funding (7 700 of 7 623 sats), the force transfer moved on with it. Send Pending showed the savings payment with Cancel expired payment and the force transfer's own note, and no Retry. Cancelling sent its coins back to savings (703 sats fee), and a new 20 000 sats on-chain send went through right after.
🟢 Another wallet pays only part of the fundingAnother wallet pays only part of the funding After another wallet paid 3 000 of the 7 623 sats, Send Pending offered Retry original payment and no cancel. Retry paid the funding address once (7 623 sats, one transaction). One block later the force transfer confirmed its emergency fees and published its next transaction.
|
All four are valid. They're tracked in #1528, which goes in a follow-up PR for 3.2.0 together with the Android twin. That keeps this head and its device run as they are. |
…ase-unneeded-funding # Conflicts: # Bitkit/Managers/SparkExitManager.swift Verified: SparkExitFundingReleaseTests, SparkExitReviewTests and PaykitPaymentProofServiceTests pass on an iOS simulator
|
Merged master in 7585390 to resolve the conflict with #1457 in The Spark exit, payment proof and funding release tests pass on the merge. A device run on this head follows. |
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 7585390. No actionable findings. The merge preserves the rejected-attempt guard and the funding check before retry dispatch, and keeps the earlier funding read as a fallback when the reread fails.
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
|
QA for 7585390: Tested on iPhone 17 Pro (iOS 27 simulator), local regtest. A local debug-only change made the force transfer's savings payment get no answer once: it was never broadcast and was kept as an unknown outcome. 🟢 Another wallet funds the force transfer in fullAnother wallet funds the force transfer in full After another wallet paid the whole funding (7 700 of 7 623 sats), the force transfer moved on with it. Send Pending showed the savings payment with Cancel expired payment and the force transfer's own note, and no Retry. Cancelling sent its coins back to savings (703 sats fee), and a new 20 000 sats on-chain send went through right after.
🟢 Another wallet pays only part of the fundingAnother wallet pays only part of the funding After another wallet paid 3 000 of the 7 623 sats, Send Pending offered Retry original payment and no cancel. Retry paid the funding address once (7 623 sats, one transaction). One block later the force transfer confirmed its emergency fees and published its next transaction.
|
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at 7585390: no code findings. Both of the Android fixes from synonymdev/bitkit-android#2142 are here in the same shape:
mayPayAgain(SparkExitFundingRelease.swift:44-70) is a case-for-case port. It allows a retry in.askwhatever was received, in.paidonly for this payment's own txid, and in.seenonly while this payment's own coin is unconfirmed. It refuses when other wallets' coins alone cover the funding.- The earlier-addresses file is read with
(try? …load()) ?? [](:79-82).
LOW (PR body, no line to anchor): manual test 1 cannot be performed as written. While the savings send has no answer, its address is unresolved and payFunding has set fundingPaymentTxid, so canCancel (SparkExitManager.swift:681-685) is false. Progress hides Cancel (SparkExitViews.swift:1106), and cancel() returns .notCancellable (:763). The "was cancelled" release branch therefore has no UI route at this head. Please reword case 1 to a reachable route (exit funded by another wallet, or exit ended), and drop "or was cancelled" from the description or mark that branch as defensive. Android's QA case was reworded the same way.
Checked and clean:
- A retry prepares
original.address,original.amountSatsandrecovery.inputs, so every candidate spends the same inputs and at most one confirms. With partial outside funding the excess returns as leftover. approveRelease,recordReleaseandabandonUnbroadcastneednativeDispatchInProgress == niland the expected attempt, so a release cannot run around a retry.releaseApprovedis saved before the fee prompt, andmayPayAgainrefuses on it from both Send Pending and Progress.- Release still needs a fresh sync showing no candidate. Ordinary sends reach the store mutators only through
sparkExitFundingHasEnded, which needs an exit address match. - Retry: fee approval, then PIN or biometrics, then the exit check, then broadcast. Release: fee, PIN,
recordRelease, broadcast. Cancelling a prompt or closing the sheet discards the unsubmitted candidate. - An attempt from a non-current wallet is neither retried nor released (
:74-75), which is the safe direction. wallet__onchain_abandon_exit_noteis in all 15 locales and rendered in a wrapping system alert. The longest (it/ca/de ~218 characters) are in the range of the existing transfer note.- v3.1.1 has no Spark exit code, so there is no upgrade path.
perf: Send Pending's 30 s poll now does two small file reads for an unresolved ordinary send, and an exit-funding Retry adds one Esplora round trip between PIN and broadcast.
Device gate (partial): 7585390 — not run yet; partial and full funding from another wallet on the local Spark stack. Result to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating and verifying; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
Fixed in the PR body. Case 1 now funds the exit from another wallet, as on Android. The description keeps the cancelled exit, marked as a branch Progress can't reach while the payment is unanswered. |
|
Merging: approved on 7585390, device run on this head posted above, all checks green. |
Closes #1512
Twin: synonymdev/bitkit-android#2142
Description
Out of Scope
Tracked in #1528:
Design
N/A — no design available. One new note in the cancel confirmation, translated into every locale.
Preview
N/A — a savings payment the exit no longer needs, with no answer from the node, hasn't been reproduced on a device yet.
QA Notes
Journeys
N/A
Manual Tests
Automated Checks
SparkExitFundingReleaseTests.swiftandSparkExitFundingReleaseServiceTestsPaykitPaymentProofServiceTests.swiftandOnchainSendAttemptServiceTests.swiftxcodebuild testfor those on an iOS 27 simulatorswiftformat --linton the changed filesModels used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)