Skip to content

feat: spark transfer to savings and force transfer design - #1361

Merged
ovitrif merged 17 commits into
masterfrom
feat/spark-transfer-to-savings-design
Nov 18, 2026
Merged

ovitrif merged 17 commits into
masterfrom
feat/spark-transfer-to-savings-design

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Refs: #1270
Twin: synonymdev/bitkit-android#1960

Description

  • Adds the v64 design of the Spark force transfer (formerly the emergency exit): Intro, Transfer overview, Emergency fees, Please confirm and Progress, with a yellow accent throughout. The copy says "force transfer" everywhere, notifications included.
  • Adds a "Pay to confirm" screen for paying the emergency fees from another wallet: the amount, the address and Copy address, with no QR code. It starts the force transfer by itself once a payment covering the fees arrives while it is open; fees already at the address on entry wait for Continue, and a failed start offers Try Again.
  • Shows the emergency fees as one total: "Deducted from your Savings balance*" when savings can pay, otherwise "To be paid with other wallet".
  • The Transfer overview shows the frame's three rows only.
  • Progress shows the four steps and nothing else under them while it runs; the emergency fees step has a block explorer button. A finished transfer says what reached savings: the spending balance, and apart from it the unused emergency fees, those the sweep returned included; it offers "Wallet Overview".
  • Skips "Network Fee & Availability" when only a Spark balance moves (the node runs and no channel is open), from every Transfer to Savings entry.
  • Removes the piggybank from the Transfer to Savings review and lists Spark after the channels in Advanced. Success offers "Continue", and the Spark failure toast reads "Could not transfer to savings".
  • Shows the App Status backup time in the locale's hour cycle ("11:45 PM" in US English).
  • Translates the new and changed strings into every shipped locale and drops the removed keys.

Out of Scope

  • Fee bump screen: no v64 frame; only its headline accent changed.
  • iOS keeps its Background App Refresh, Low Power Mode and notification notes in place of Android's battery notes.

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

Figma App

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

  • Dev build on regtest, Spark funded from Lightspark's regtest faucet at the deposit address on the Spark connection screen (SparkDepositAddress), launched without SPARK_CHAIN_SERVICE_URL so Spark claims it.
  • Savings paying the emergency fees and Spark moving to savings need Spark's chain: launch with SPARK_CHAIN_SERVICE_URL set to the staging Electrum. Without it the fees fall to another wallet and Transfer to Savings fails with "Could not transfer to savings".

Journeys

  • J1: updated transfer/spark-emergency-exit.xml — force transfer up to the swipe, fees from savings and from another wallet — passed on 997913d
  • J2: updated settings/app-status-emergency-exit.xml — the App Status row opens the force transfer progress
    • Not run: it needs a force transfer started, which cannot be cancelled (see Gaps)
  • updated transfer/move-to-spark.xml step 26: Lightning Connections lists only Spark via Breez under Open Connections after the close (wording only)

Manual Tests

  • 1. With only a Spark balance, Spending → Transfer To Savings → Review opens with no Network Fee & Availability screen, no piggybank and no Advanced; swipe → Funds in transfer → "Funds moved to Savings" with "Continue" (passed on ec10de7, recording in Preview)
  • 2. With savings that can't pay the emergency fees, continue past Emergency fees → "Pay to confirm" shows the amount, the address and Copy address; paying that amount from another wallet starts the force transfer by itself
    • Screen checked on 997913d; the payment was not sent, since it starts a force transfer that cannot be cancelled

Automated Checks

  • ran swiftformat --lint, node scripts/validate-translations.js, SparkExitRecordTests, SparkExitMathTests, SparkExitReviewTests, SparkExitDriverTests, SparkExitSweepTests, SparkExitFeeBumpTests, SparkExitBackgroundRunTests, SparkExitBroadcasterTests, SavingsSelectionTests, TransferNavigationTests, AppStatusExitTests (pass)
  • added to SparkExitSweepTests — the completed screen's split: unspent emergency fees the sweep returns count as fees, not spending balance
  • added to SparkExitMathTests — Pay to confirm starts on its own only for a payment that arrives while it is open
  • updated TransferNavigationTests — Spark-only detection, and that Transfer to Savings skips Availability only then
  • updated SparkExitReviewTests — the emergency fees go to another wallet only once savings is priced and can't pay
  • updated SparkExitFeeBumpTests — the quote asks for the whole funding, without the funded-steps count

Evidence

  • J1 on 997913d, iPhone 17 Pro simulator (iOS 27.0), Spark on its regtest with 199 901 sats:
    • Overview: Amount to transfer, Network fees and You receive (estimate) only.
    • Without Spark's chain, Emergency fees reads "To be paid with other wallet" and Continue opens Pay to confirm with the amount, the address and Copy address; Cancel returns, nothing started.
    • With Spark's chain, Emergency fees reads "Deducted from your Savings balance*" with the unused-fees note, and Please confirm lists the overview and fees with the yellow swipe; back leaves Transfer To Savings enabled.
  • Case 1 on ec10de7: Spending → Transfer To Savings landed on Review with no Availability screen; the swipe moved 199 901 sats from Spark, and "Funds moved to Savings" showed "Continue".
  • Progress (staged, see Preview): "TRANSFER IN PROGRESS" with no spinner over the headline, the first step done with its explorer button; completed shows all four steps, the returned spending balance and fees in bold, and "Wallet Overview".

Gaps

  • J2 and a real Progress: a started force transfer runs for weeks and holds the balance. SparkExitDriverTests, SparkExitBackgroundRunTests and AppStatusExitTests cover the states after the swipe.
  • Manual test 2's payment from another wallet was not sent, for the same reason.

Models used

  • Planning/scoping: Claude Opus 5.5 (reasoning: medium)
  • Implementation: Claude Opus 5.5 (reasoning: medium), Claude Sonnet 5.5 (reasoning: high)
  • Review: Claude Sonnet 5.5 (reasoning: high)

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
@ovitrif ovitrif added this to the 3.2.0 milestone Nov 18, 2026
@ovitrif ovitrif self-assigned this Nov 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T03:01:44.414509Z 0e45ad9 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ovitrif
ovitrif requested review from a team, ben-kaufman and coreyphillips and removed request for a team November 18, 2026 02:53
Verified: none (changelog only)
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Cancel leaves force transfer running ▶

Summary

Updates Transfer to Savings and redesigns Spark force transfers, including a new screen for paying emergency fees from another wallet.

  • Spark force transfers show one fee total and offer a separate pay-to-confirm screen.
  • Spark-only transfers to Savings skip the availability screen and show Spark as the balance being moved.
  • App Status shows the backup time in the locale’s usual hour format.

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]
Loading

Reviews (1) · Last reviewed commit: "fix: start pay to confirm only when a pa..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 talosmachina 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.

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 5dced2c the main sweep's funding share sat in received and was added again as returned fees; 4852df5 splits it out in SparkExitMath.returned with tests in SparkExitSweepTests.
  • Pay to confirm starting on funds already at the address: canAutoStartFunding needs 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: isSparkOnly requires .running, non-nil channels and no isChannelReady, covered in TransferNavigationTests.
  • Progress back target: openSparkExitProgress trims the path to .sparkConnectionDetail; entries from App Status, the banner and the wake path push Progress directly, so navigateBack returns 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 ben-kaufman 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.

Manual and automatic force transfer starts can run together.

Reviewer model: gpt-6.1-sol
Reasoning effort: xhigh

@coreyphillips coreyphillips 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.

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_text says "The force transfer starts once the payment confirms on the blockchain." The screen starts it as soon as readFundingAddress sees a covering UTXO, which includes unconfirmed ones (fundingSeenSats is "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 in earlierReceivedSats, 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
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@coreyphillips

Pay to confirm says the transfer starts on confirmation; it starts when seen

The copy is the v64 frame's text, so it stays; the confirmation then shows as Progress's first step, "Confirmation of emergency fees".

Completed totals misclassify fees from earlier recovery generations

Fixed in 40e110b: adopt() keeps each replaced sweep's returned funding (earlierReturnedFundingSats), and the split counts it as fees. Your repro is a test in SparkExitSweepTests: 94 500 spending, 8 000 fees.

App Status funding subtitle still says "Fee funding needed"

Fixed in 2cc94ce: "Emergency fees needed", in every locale.

Pay to confirm Cancel does not stop a force transfer start already running
Auto-start can launch a second exit start while a Continue start runs

Both fixed: one start at a time (2a55017), and Cancel, back, menu and swipe-back locked while it runs (0c39da9, f3bbb3f).

@ben-kaufman

Manual and automatic force transfer starts can run together.

Fixed in 2a55017 and f3bbb3f; details in your thread.

@coreyphillips coreyphillips 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.

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() claims isStarting synchronously and sets SwipeBackState.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: canAutoStartFunding now requires !isStarting (SparkExitFunding.swift:445-447). start() guards on isStarting and claims it before its Task begins (SparkExitViews.swift:466-467), and Continue uses up the visit's start through hasAutoStarted (: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.js passes.
  • 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_text says "The force transfer starts once the payment confirms on the blockchain." The screen starts it as soon as readFundingAddress sees a covering UTXO, which includes unconfirmed ones (fundingSeenSats is "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)

@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Merging: @coreyphillips approved the head and every required check is green (the only Run Tests failure was the UsdtWalletUITests.testReceiveAndInvalidPaymentStaySeparateFromBitcoin hang that also hits master, passing on rerun).

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.

@ovitrif
ovitrif merged commit dc838ac into master Nov 18, 2026
20 of 22 checks passed
@ovitrif
ovitrif deleted the feat/spark-transfer-to-savings-design branch November 18, 2026 05:58
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