Repository navigation
feat: spark transfer to savings and force transfer design - #1361
Conversation
Brings the Spark force transfer (formerly emergency exit) to the v64 frames, as synonymdev/bitkit-android#1960 does: - Intro, Transfer overview, Emergency fees, Please confirm and Progress in the v64 copy with a yellow accent; the fee bump headline too. - Emergency fees shows one total: deducted from savings when savings can pay, else to be paid with another wallet. The screen reads the funding address once on entry: a payment there means another wallet pays. - New Pay to confirm screen: the amount, the address with Copy address and no QR. It starts the force transfer once the address holds the fees, and offers Try Again after a failed start. - Progress shows four steps under Progress overview, with a block explorer button on the emergency fees step, an amount to pay while fees are missing, and what returned to savings once completed. It has no back button; Continue Using Bitkit returns to the screen below it, Wallet overview to home. A start opens it above the Spark screen. - Amount rows always show bitcoin, as the amount may have to be sent. - English copy says force transfer everywhere, notifications included. - Journeys follow Android's prose with iOS ids and button names. Verified: Debug simulator build on m1a, swiftformat --lint, node scripts/validate-translations.js
- Skips Network Fee & Availability when only a Spark balance moves (the node runs, its channels are loaded and none is open), from every Transfer to Savings entry: Spending, the Spark screen and the intro. - Removes the piggybank from the review and puts the Spark fee 32 pt under the balance, as in the frame. - Advanced keeps Spark after the channels, 24 pt under its text. - Success offers Continue; the Spark failure toast reads "Could not transfer to savings" (English copy in the previous commit). - move-to-spark journey checks Spark via Breez is the only connection. Verified: Debug simulator build on m1a, swiftformat --lint
Every string the v64 force transfer and transfer to savings add or change, in all 14 locales: synonymdev/bitkit-android#1960's translations where the keys match, the iOS-only Background App Refresh, Low Power Mode and notification lines by hand, and Dutch in the formal "u". Adds the cancel and earlier address strings the locales lacked, and drops the removed keys from every locale. Verified: node scripts/validate-translations.js
Puts "Nil where Spark is unsupported." back above sparkStatus(network:) and names the App Status subtitle keys each ExitStatusStep picks. Verified: swiftformat --lint
The App Status backup date template uses j instead of HH, so US English shows "11:45 PM" as in the frame and 24-hour locales keep their clock. Verified: swiftformat --lint
The v64 completed frame reads "Wallet Overview", like other Bitkit buttons. Verified: none (string casing only)
Headlines sit 16 pt under the nav bar as in the v64 frames, and the completed screen's amounts are accented once, since its strings already carry the accent tags. Verified: none yet (build and tests follow)
The overview shows only its three rows, as the v64 frame and Android, and Progress leaves 32 pt between its intro and the overview header. Verified: swiftformat --lint, validate-translations
Progress drops the waiting-for-confirmation lines, the sweep transaction id and the Spark remainder note, as the v64 frame and Android. Verified: swiftformat --lint, validate-translations
Funds already at the address on entry wait for a Continue tap, so the force transfer never starts without the user seeing the address. Drops the now unused unexitable-balance math with the overview note it fed. Verified: 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. |
Verified: none (changelog only)
[Critical impact] The changes reach wallet flows that move Bitcoin between balances and start a long-running Spark force transfer. Fix the payment page’s Cancel behavior before merging. Findings
SummaryUpdates Transfer to Savings and redesigns Spark force transfers, including a new screen for paying emergency fees from another wallet.
The new payment screen still lets users cancel while a force transfer is starting, without stopping that work. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Transfer overview] --> B{Emergency fees needed?}
B -->|No| C[Swipe to confirm]
B -->|Yes| D{Savings can pay?}
D -->|Yes| C
D -->|No| E[Pay from another wallet]
E --> F[Payment arrives or user continues]
C --> G[Start force transfer]
F --> G
G --> H[Progress]
H --> I[Funds reach savings]
Reviews (1) · Last reviewed commit: "fix: start pay to confirm only when a pa..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e45ad9907
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The force transfer done screen counts the fee funding the main sweep returns as unused fees, not spending balance. Pay to confirm starts on its own only for a payment that arrives while it is open; funds already there wait for Continue. Verified: swiftformat --lint, build and SparkExitSweepTests, SparkExitReviewTests, SparkExitDriverTests, SparkExitRecordTests, SparkExitMathTests, SparkExitBackgroundRunTests, SparkExitBroadcasterTests on the iOS simulator
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Moves the Spark force transfer to the v64 design, adds Pay to confirm for paying the emergency fees from another wallet, and skips Network Fee & Availability when only a Spark balance moves. Reviewed 4852df5, full tier, static.
What I checked, and 5 candidates I ruled out
Read in full: the diff of SparkExitViews.swift, NavigationViewModel.swift, SparkExitManager.swift, SparkExitFunding.swift, the transfer views and the tests; traced startSparkExit, openSparkExitProgress, navigateToTransferSavings, readFundingAddress/watchFundingAddress, SparkExitMath.returned.
Build: skipped. talos-pr-run could not confirm the author's permission and fails closed, and iOS does not build on Linux here, so this is reasoned from the code and CI.
CI at review time: SwiftFormat green on rerun (the first run segfaulted in swiftformat_linux, not a lint error), translations validate green; Run Tests and Run Integration Tests still pending.
Ruled out
- Done screen counting the unspent fee funding twice: at
5dced2cthe main sweep's funding share sat inreceivedand was added again as returned fees;4852df5splits it out inSparkExitMath.returnedwith tests inSparkExitSweepTests. - Pay to confirm starting on funds already at the address:
canAutoStartFundingneeds a payment counted after the first successful read, so pre-existing funds wait for Continue. - Removed string keys still referenced: none of the 17 removed
lightning__spark_exit__*keys is used in Swift, none survives in any locale, and every new key is present in all 15 locales. - Spark-only skip firing with a channel or before channels load:
isSparkOnlyrequires.running, non-nil channels and noisChannelReady, covered inTransferNavigationTests. - Progress back target:
openSparkExitProgresstrims the path to.sparkConnectionDetail; entries from App Status, the banner and the wake path push Progress directly, sonavigateBackreturns to the opener.
Merge confidence: 4/5, unit and integration tests were still running and the branch was not built here.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer does not report it)
ben-kaufman
left a comment
There was a problem hiding this comment.
Manual and automatic force transfer starts can run together.
Reviewer model: gpt-6.1-sol
Reasoning effort: xhigh
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews.
worth doing, does not block
- Pay to confirm says the transfer starts on confirmation; it starts when seen (Bitkit/Resources/Localization/en.lproj/Localizable.strings:481).
lightning__spark_exit__pay_textsays "The force transfer starts once the payment confirms on the blockchain." The screen starts it as soon asreadFundingAddresssees a covering UTXO, which includes unconfirmed ones (fundingSeenSatsis "Confirmed or not"). The confirmation is then the first Progress step. Either the copy or a note on the Progress step could say so. - Completed totals misclassify fees from earlier recovery generations (Bitkit/Services/SparkExit/SparkExitFunding.swift:389-390). A recovery retry can report returned emergency fees as spending balance.
SparkExitRecord.adopt()retains earlier sweep payouts inearlierReceivedSats, but this helper examines only the replacement recovery. I reproduced this with a 96,500-sat sweep containing 7,000 sats of funding, followed by a 5,000-sat cooperative retry. With 1,000 sats returned separately, the result reported 101,500 sats spending and 1,000 sats fees. The correct split is 94,500 sats spending and 8,000 sats fees.
nits
- App Status funding subtitle still says "Fee funding needed" (Bitkit/Resources/Localization/en.lproj/Localizable.strings:1068). The App Status row for a force transfer waiting on its fees reads "Fee funding needed" (
settings__status__exit__funding). Every other screen and notification in this PR now says "emergency fees" (for example "Your force transfer needs more emergency fees"). It is the only leftover of the old vocabulary in the English strings.
the reviewers disagree, your call
- Pay to confirm Cancel does not stop a force transfer start already running (Bitkit/Views/Settings/Advanced/SparkExitViews.swift:434-456). Objection: Real, but blocking rather than non-blocking: Cancel remains enabled and only navigates back, leaving the start task running. That task can commit an uncancellable funded exit and reopen Progress after the user leaves.
- Auto-start can launch a second exit start while a Continue start runs (Bitkit/Views/Settings/Advanced/SparkExitViews.swift:426-460). Objection: Real, but blocking rather than non-blocking: Continue leaves hasAutoStarted false, and the automatic start bypasses the isStarting guard. If both calls enter before the first record exists, neither the spend hold nor writeStart prevents duplicate transfers and an overwritten transferId.
The automatic start no longer claims a start while one is running, such as one Continue began, and the start claims itself before its task begins, so the isClaimed bypass is gone. Verified: swiftformat --lint on changed files
Once a start begins, Cancel is disabled, the back button hides and swipe-back is blocked until it ends: success opens Progress, a failure gives them back. Verified: swiftformat --lint on changed files
A retry replaced the recovery whose confirmed sweep returned unspent fee funding, and the done split then counted that funding as spending balance. Adopting a new generation now keeps what the outgoing sweep returned in earlierReturnedFundingSats, and the split adds it to the fees. Verified: swiftformat --lint on changed files
The App Status row for a force transfer waiting on its fees read "Fee funding needed", the only leftover of the old wording. It now reads "Emergency fees needed", translated in every locale with the wording its force transfer screens use, and the journey names the new text. Verified: node scripts/validate-translations.js
A Continue tap spends the visit's start too, so a payment arriving after a failed start never starts one by itself, and the menu hides while a start runs, as the back button does. Verified: swiftformat --lint
The copy is the v64 frame's text, so it stays; the confirmation then shows as Progress's first step, "Confirmation of emergency fees".
Fixed in 40e110b:
Fixed in 2cc94ce: "Emergency fees needed", in every locale.
Both fixed: one start at a time (2a55017), and Cancel, back, menu and swipe-back locked while it runs (0c39da9, f3bbb3f).
|
coreyphillips
left a comment
There was a problem hiding this comment.
Rechecked after 5 new commits (2a55017, 0c39da9, 40e110b, and 2 more). Nothing blocking remains.
addressed
- Pay to confirm Cancel does not stop a force transfer start already running (Bitkit/Views/Settings/Advanced/SparkExitViews.swift:434-456). Fixed:
start()claimsisStartingsynchronously and setsSwipeBackState.allowSwipeBack = false(SparkExitViews.swift:465-481). Cancel is disabled at :439, and back and menu are hidden at :406 while it runs. I checked that the pop gesture reads that flag when it begins (UINavigationController+SwipeBack.swift:20-24) and that CustomButton drops taps while disabled (Button.swift:233). Progress's.allowSwipeBack(false)(:1002) restores the gesture when it disappears, and the catch at :477 restores it on failure. - Auto-start can launch a second exit start while a Continue start runs (Bitkit/Views/Settings/Advanced/SparkExitViews.swift:426-460). Fixed:
canAutoStartFundingnow requires!isStarting(SparkExitFunding.swift:445-447).start()guards onisStartingand claims it before its Task begins (SparkExitViews.swift:466-467), and Continue uses up the visit's start throughhasAutoStarted(:432). All of it runs on the main actor, so no payment can land between the check and the claim. The new asserts at SparkExitTests.swift:3331-3333 cover the rule. I traced this by reading the code. I could not run XCTest here because only Command Line Tools are installed, not Xcode. - App Status funding subtitle still says "Fee funding needed" (Bitkit/Resources/Localization/en.lproj/Localizable.strings:1068). Fixed: en.lproj/Localizable.strings:1068 now reads "Emergency fees needed" and all 15 locales changed with it. The journey description matches, and
node scripts/validate-translations.jspasses. - Completed totals misclassify fees from earlier recovery generations (Bitkit/Services/SparkExit/SparkExitFunding.swift:389-390). Fixed:
adopt()now stores the confirmed sweep's returned funding by txid (SparkExitRecord.swift:426-431), and the coder keeps it (:759, :786, :814).returned()adds it to the fees unless that sweep is still in the current recovery (SparkExitFunding.swift:433-439). I traced the new test of the earlier repro (SparkExitSweepTests.swift:389-426) by hand. 4,000 of funding plus 3,000 of CPFP change gives 7,000 returned, and 101,500 received, so the split is 94,500 spending and 8,000 fees. I could not run XCTest here because Xcode is not installed.
still open
- Pay to confirm says the transfer starts on confirmation; it starts when seen (Bitkit/Resources/Localization/en.lproj/Localizable.strings:481).
lightning__spark_exit__pay_textsays "The force transfer starts once the payment confirms on the blockchain." The screen starts it as soon asreadFundingAddresssees a covering UTXO, which includes unconfirmed ones (fundingSeenSatsis "Confirmed or not"). The confirmation is then the first Progress step. Either the copy or a note on the Progress step could say so. The code is unchanged. Once an unconfirmed payment covers the fees, Pay to confirm writes the record, holds the balance and loses Cancel, but the copy says the transfer starts once the payment confirms. Matching the v64 frame and showing the confirmation as Progress's first step does not make the sentence accurate: only the build waits for confirmed funding (SparkExitFunding.swift:514). This is non-blocking. A wording change, or the designer confirming this reading is intended, would close it.
new since the last review
worth doing, does not block
- Pay to confirm locks every way out during a start but shows no progress (Bitkit/Views/Settings/Advanced/SparkExitViews.swift:429-442)
|
Merging: @coreyphillips approved the head and every required check is green (the only Run Tests failure was the The open spinner point (thread) is resolved with this merge and moves to a follow-up PR, which brings Pay to confirm and the completed screen fully in line with the frames: the force transfer starts on its own once the fees are covered, the button spins while it starts, and Try again shows only after a failed start. |
Refs: #1270
Twin: synonymdev/bitkit-android#1960
Description
Out of Scope
Design
Figma page "Bitkit - Progress v64" in the Bitkit Wallet file.
Figma notes
Aldert's notes above the v64 frames for these flows.
Transfer to Savings (51990-155785)
Force transfer to Savings (52050-399437)
Preview
The two Progress states were captured on a local build that stages a running and a finished force transfer, since a real one runs for weeks and cannot be cancelled.
J1, force transfer up to the swipe, both fee payers (2x):
j1.mp4
Case 1, Transfer to Savings with only a Spark balance (2x):
j2.mp4
QA Notes
Setup
SparkDepositAddress), launched withoutSPARK_CHAIN_SERVICE_URLso Spark claims it.SPARK_CHAIN_SERVICE_URLset to the staging Electrum. Without it the fees fall to another wallet and Transfer to Savings fails with "Could not transfer to savings".Journeys
transfer/spark-emergency-exit.xml— force transfer up to the swipe, fees from savings and from another wallet — passed on 997913dsettings/app-status-emergency-exit.xml— the App Status row opens the force transfer progresstransfer/move-to-spark.xmlstep 26: Lightning Connections lists only Spark via Breez under Open Connections after the close (wording only)Manual Tests
Automated Checks
swiftformat --lint,node scripts/validate-translations.js,SparkExitRecordTests,SparkExitMathTests,SparkExitReviewTests,SparkExitDriverTests,SparkExitSweepTests,SparkExitFeeBumpTests,SparkExitBackgroundRunTests,SparkExitBroadcasterTests,SavingsSelectionTests,TransferNavigationTests,AppStatusExitTests(pass)SparkExitSweepTests— the completed screen's split: unspent emergency fees the sweep returns count as fees, not spending balanceSparkExitMathTests— Pay to confirm starts on its own only for a payment that arrives while it is openTransferNavigationTests— Spark-only detection, and that Transfer to Savings skips Availability only thenSparkExitReviewTests— the emergency fees go to another wallet only once savings is priced and can't paySparkExitFeeBumpTests— the quote asks for the whole funding, without the funded-steps countEvidence
Gaps
SparkExitDriverTests,SparkExitBackgroundRunTestsandAppStatusExitTestscover the states after the swipe.Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)Claude Sonnet 5.5(reasoning:high)