Skip to content

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

Merged
ovitrif merged 20 commits into
masterfrom
feat/spark-design-v64
Nov 18, 2026
Merged

ovitrif merged 20 commits into
masterfrom
feat/spark-design-v64

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Twin: synonymdev/bitkit-ios#1361, synonymdev/bitkit-ios#1362
Refs: #1840

Description

  • Adds the v64 design of the Spark force transfer (formerly the emergency exit). It has new Intro, Transfer overview, Emergency fees, Please confirm and Progress screens, with a yellow accent throughout. The copy now says "force transfer" everywhere, notifications included.
  • Adds a "Pay to confirm" screen for paying the emergency fees from another wallet. It shows the address and a Copy address button with no QR code, and starts the force transfer by itself once the address holds the fees, also when they were there before it opened; 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".
  • Shows the force transfer's progress as four steps and nothing else under them while it runs, as the frame. The emergency fees step has a block explorer button. A finished transfer says what reached savings, spending balance and unused fees alike, and offers "Wallet Overview".
  • The Transfer overview shows the frame's three rows only.
  • Skips the "Network Fee & Availability" screen when only a Spark balance moves: no channel is open and the node runs. This applies from every Transfer to Savings entry.
  • Removes the piggybank from the Transfer to Savings review and lists Spark after the channels in Advanced. Success now offers "Continue", and the Spark failure toast reads "Could not transfer to savings".
  • Translates the new and changed strings into every shipped locale and drops the removed keys from each.

Out of Scope

  • Spark connection screen and App Status rows (the "Force transfer" button, "Emergency Exit" row): the next v64 PR, feat: spark connection and app status design.
  • Fee bump screen (SparkExitFeeBumpScreen.kt): no v64 frame; only its headline accent changed.

Design

Figma page Bitkit - Progress v64.

Figma notes

Aldert's notes above the v64 frames for these flows; base link https://www.figma.com/design/ltqvnKiejWj0JQiqtDf2JJ/Bitkit-Wallet?node-id=<id>.

Transfer to Savings (51990-155785)

Force transfer to Savings (52050-399437)

Transfer to Savings Balance (Close LN Channel) (51990-154055): channel close states, unchanged by v64

Changelog v64

Preview

Screen Figma App
Force transfer intro
Transfer overview
Emergency fees, paid from savings
Please confirm
Emergency fees, paid from another wallet
Pay to confirm
Progress, in progress
Progress, completed
App Status, force transfer
Transfer to Savings intro
Review
Advanced
Network Fee & Availability
Funds in transfer
Success

Recordings at 2x

J1: force transfer up to the swipe J2: App Status opens the progress
j1-4134.mp4
j2-4134.mp4
1. Spark-only transfer to savings 2. Fees paid from another wallet 4. Pay to confirm with the funds already there
case1-spark-only-transfer-to-savings2x.mp4
c2-4134.mp4
c4-4134.mp4

QA Notes

Setup

  • Dev build (regtest) built with ESPLORA_URL=http://10.0.2.2:3999, with python3 scripts/spark-regtest-esplora.py --port 3999 running on the emulator's host. Without it, Spark and savings sit on different chains: savings cannot pay the emergency fees, and Spark cannot move to savings.
  • New wallet, Spark funded from Lightspark's regtest faucet at the deposit address on the Spark connection screen (SparkDepositAddress).
  • Fund savings by running J2 first: Spark's balance moves to savings on Spark's chain. Fund Spark from the faucet again for J1.

Journeys

  • J1: updated spark-emergency-exit.xml — force transfer up to the swipe, with emergency fees paid from savings — passed on 4134b9aa5
  • J2: updated app-status-emergency-exit.xml — App Status row opens the force transfer progress (needs a started force transfer on a throwaway wallet) — passed on 4134b9aa5

Manual Tests

  • 1. With only a Spark balance, Spending → Transfer to Savings → it opens Review with no Network Fee & Availability screen, and back skips it too; swipe → progress → success shows "Continue" — the journey environment has no step for this yet — passed on aea14d879
  • 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 the shown amount from another wallet starts the force transfer by itself — needs an external wallet on Spark's regtest chain; Lightspark's regtest faucet works as one — passed on 4134b9aa5
  • 4. Pay the emergency fees address from another wallet, then open Pay to confirm → it starts the force transfer on its own, with the button spinning and Cancel disabled while it starts; Pay to confirm has no Continue button — passed on 4134b9aa5

Retired: 3 (Pay to confirm waited for Continue when the fees were already at the address); the v64 frame has no Continue, so 4 replaces it.

Automated Checks

  • added ContentViewTest.kt — Spark-only detection and that Transfer to Savings skips Availability only then
  • updated SparkExitViewModelTest.kt — who pays the emergency fees, the funding address read on entry, and when Pay to confirm starts on its own
  • updated SavingsConfirmScreenTest.kt — removes the piggybank size check
  • updated SavingsProgressScreenTest.kt — new Spark failure copy
  • updated SparkExitFundingTest.kt — drops the funded-steps count the UI no longer shows; splits returned fee funding from the spending balance, across replaced generations too

Evidence

On regtest emulators (Android 16, 896×1994 at 320 dpi) with the local Spark stack, dev builds of cda0b44a1 (manual test 1 and the screens not listed below) and 4134b9aa5 (J1, J2, manual tests 2 and 4, Pay to confirm, the completed screen and the Transfer to Savings intro):

  • J1 passed: Please confirm listed the overview and the emergency fees with the yellow swipe; back from Please confirm left Transfer to Savings enabled.
  • J2 passed: App Status opened the force transfer progress, with no spinner over the title.
  • Manual test 1: the route passed (Review with no Network Fee & Availability), but the transfer itself failed on the local stack, whose operator rejects the leaf swap a Spark withdrawal needs.
  • Manual test 2 passed: the force transfer started when the payment reached the mempool; after one block step 1 showed done with the explorer button.
  • Manual test 4 passed: with the fees paid and mined while on Emergency fees, Pay to confirm opened with the button spinning and Cancel disabled, then moved to the progress with step 1 done, with no tap.
  • Pay to confirm before payment shows Cancel only.
  • Completed: savings received 199 742, shown as a spending balance of ₿ 196 394 and ₿ 3 348 of unused emergency fees, with no transaction ID, small-amounts line or unused-fees note.
  • After 4134b9aa5, e6f8b0eca only keeps the note for a leftover sweep that has not confirmed on the completed screen; the run above confirmed its sweep.

Gaps

  • Manual test 1's transfer did not complete on the local stack (operator rejects the leaf swap); it needs hosted regtest.
  • In the device run the main sweep spent no fee funding, so the returned-funding split ran with 0 there; SparkExitFundingTest.kt covers a sweep that does.
  • The Progress "Amount to pay" row shows only when a started force transfer still needs its fees paid; it was not run on a device.

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), Claude Opus 5.5 (reasoning: medium)

Verified: just compile, just test, just lint (all pass)
Verified: just format, just compile, just test, just lint (all pass)
Verified: just compile, SparkExitViewModelTest, detekt (pass)
@ovitrif ovitrif added this to the 3.2.0 milestone Nov 17, 2026
@ovitrif ovitrif self-assigned this Nov 17, 2026
Verified: none (changelog text only)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T19:52:47.944235Z 3663ad1 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 pwltr and removed request for a team November 17, 2026 19:50
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Critical impact] The PR changes a user-facing path that moves Spark funds into Savings.

The PR appears safe to merge, with non-blocking fixes needed for completed-screen formatting and retrying a failed externally funded start.

Findings

  1. P2 Amounts show formatting tags ▶
  2. P2 Paid users lack a retry ▶

Summary

Updates Spark force transfer screens and adds automatic start after an external fee payment. Spark-only transfers to savings now skip the availability screen.

  • Spark force transfers show their costs, payment choices, and progress to Savings.
  • Spark-only transfers go straight to the Savings review.
  • Savings review puts Spark after channels and drops the piggybank artwork.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Transfer to savings] --> B{Only Spark funds?}
    B -->|Yes| D[Review transfer]
    B -->|No| C[Network fee and availability]
    C --> D
    E[Force transfer overview] --> F[Emergency fees]
    F --> G{Who pays?}
    G -->|Savings| H[Swipe to confirm]
    G -->|Another wallet| I[Pay to confirm]
    I -->|Fees arrive| J[Start force transfer]
    H --> J
    J --> K[Progress]
    K --> L[Wallet overview]
Loading

Reviews (1) · Last reviewed commit: "fix: widen force transfer confirm table ..." · 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: 3663ad1b8e

ℹ️ 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".

Comment thread app/src/main/res/values/strings.xml Resolved
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 8e36808 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

Verified: just format, compile, test, lint
Verified: just format, compile, test, lint

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

1 finding (1 P1). Ports the v64 design of the Spark force transfer (renamed from emergency exit), adds the Pay to confirm screen for external fee funding, and skips Network Fee & Availability when only Spark moves. Reviewed 09a5d85, full tier.

What I checked, and 6 candidates I ruled out

Read in full: SparkExitViewModel.kt, SparkExitFundingScreen.kt, SparkExitPayScreen.kt, SparkExitProgressScreen.kt, SparkExitComponents.kt, the sparkExit and transfer graphs in ContentView.kt
Traced: isSparkOnly and navigateToTransferSavings from all three entries, beginSavingsTransfer, refreshFundingAddress, SparkExitRepo.start, the leftover sweep bookkeeping in SparkExitDriver.kt
Strings: every locale's spark_exit__ keys still exist in English with matching placeholders (script over all values-*)
Build: not built, by policy for an unrequested bitkit-android review; reasoned from the code. CI was still running when this was posted (lint, build-and-test, compose-ui pending).

Ruled out

  • Pay screen auto-start firing twice: hasAutoStarted is saveable and start() now returns early while isStarting; the repo's paymentMutex.tryLock is a second guard.
  • Spark-only skip with a running node whose channels are pending: filterOpen keeps only isChannelReady, so a pending channel has nothing to close and the skip is right; the stopped-node case is excluded and tested.
  • Skipping Availability leaves the selection stale: the skip calls beginSavingsTransfer() exactly as Availability's continue does.
  • Continue on the fees screen before the address read: isLoadingFees disables the button until the read and the savings price settle.
  • Returned fees double counted: sweptLeftover holds earlier confirmed sweeps and is cleared into leftoverSweep = null when a late payment is added, so a confirmed current sweep is not in both.
  • Removed fundedSteps / piggybank still referenced: no remaining reference in main, tests or journeys.

Merge confidence: 3/5, the P1 on every completed force transfer.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed

Verified: just format, compile, test, lint
@ovitrif
ovitrif requested a review from ben-kaufman November 17, 2026 20:37
Verified: just format, compile, test, lint
@ovitrif
ovitrif requested a review from ben-kaufman November 17, 2026 21:15
@ovitrif

ovitrif commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed ee6c817: the move to Spark journey's last step now expects Spark via Breez under OPEN CONNECTIONS (no channel left there), matching the Spark connection design; same wording as the iOS twin.

Verified: just compile, just lint
Verified: just compile, just test, just lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed d003628:

  • Translates this PR's new and changed strings into every shipped locale, moved here from chore: translate spark design strings #1961.
  • Progress no longer shows the pull-to-refresh spinner over the title when it opens; only a pull shows it.

Verified: just format, just compile, just test, just lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed ff738a6: Transfer overview shows only its three rows, and Progress only the title, intro, four steps and button (no status line, transaction ids, Spark remainder or battery note), as the v64 frames. Fresh screenshots follow.

Verified: just compile, just lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed cda0b44: the completed force transfer's button reads "Wallet Overview", as the frame.

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: just format, compile, test, lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed bf3ae64:

  • The force transfer completed screen now counts the fee funding the main sweep returns as unused emergency fees, not as spending balance.
  • Pay to confirm starts on its own only when a payment arrives while it is open. Funds already at the address when it opens wait for a tap on Continue, so nothing starts unseen.

Verified: just format, compile, test, lint
Cancel and back wait for a start to end, one start runs at a time and a tap spends the visit's start; App Status reads Emergency fees needed.

Verified: just format, compile, test, lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed d00bc51:

  • While a force transfer starts from Pay to confirm, Cancel is disabled and back and the menu wait, so the start ends on this screen.
  • One start runs at a time, and a tap on Continue spends the visit's one start, so a payment after a failed start waits for a tap too.
  • The App Status row reads "Emergency fees needed" in every locale.

The description's Preview is now a Figma and app table for each screen, with fresh recordings; the completed screen and Pay to confirm with the funds already there come from bf3ae64aa.

Verified: just format, compile, test, lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 49cd43b: while a force transfer starts from Pay to confirm, which can wait minutes for Spark, its Continue button stays and shows a loading spinner, so the locked screen shows progress.

Verified: just format, compile, test, lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 4134b9a, matching the v64 frames:

  • Pay to confirm drops the Continue button, as in Pay to confirm: the force transfer starts on its own once the fees are covered, also when they were already at the address on entry. A failed start shows Try again; while it starts the button spins and Cancel, back and the menu wait.
  • The completed Progress screen drops the transaction ID, the line on small amounts left on Spark and the unused emergency fees note, as in Progress completed. Notes that say where funds stay (dust, a rejected sweep, funding still at its address) remain.
  • The Transfer to Savings intro text lines up with the button, as in Transfer to Savings Intro.

The description's media for these screens follows with a fresh capture.

Verified: just format, compile, test, lint
@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed e6f8b0e: the completed screen hides only leftover sweeps that confirmed, and only when the returned note counts them as unused fees. A sweep that is still unconfirmed or was refused keeps its note, so its amount no longer drops out of both notes.

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code scan at e6f8b0e: one MEDIUM and one LOW, both inline.

What I checked:

  • Fund safety. SparkExitRepo.kt is untouched. Savings pays min(fresh, confirmed quote) with the approved fee. start() returns early while isStarting, and also holds paymentMutex.tryLock. Pay starts with fundFromSavings=false, so the external path never spends savings. The fee bump logic is unchanged.
  • Total debit. Please confirm shows the funding plus the savings payment's own fee as one row (savingsTotalSats). That's more than the frame's figure, and it's the true debit.
  • States. Progress keeps needs-funding, savings-refused retry, fee low or rose, pay a higher fee, cancel, rejection, lost or left-behind leaves, and leftover notes. A second exit is still refused while one runs (startLocked).
  • Journeys and tags. Removed testTags have no consumers left in the app, journeys or bitkit-e2e-tests. spark-emergency-exit.xml and app-status-emergency-exit.xml match the head. The screens map has rows for all seven exit screens.
  • Figma. Confirm (52050:403921), Pay to confirm (52050:404135), Progress (52050:404411) and Completed (52050:404632) match in layout, copy, the yellow accent, the four steps with the explorer button, the Cancel-only Pay screen and the Done buttons.

Out of scope, pre-existing: after process death on Pay, the graph-scoped VM is gone and Pay shows ₿ 0 with no address until the user backs out to Quote. Master's Funding screen has the same gap.

perf: not beyond master. Pay polls Esplora every 15 s while composed, background included (4 chain.utxos calls per minute).

⚠️ Device gate: not run — the code scan has a MEDIUM.

Comment thread app/src/main/res/values/strings.xml Resolved
Pay to confirm restarts its watch on each resume: a cancelled predictive back swipe composes Funding underneath, which stopped it, so a payment from another wallet never started the force transfer.

Verified: just format, compile, test, lint; SparkExitPredictiveBackTest fails without the fix

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving at 8e36808: nothing above LOW from the code scan or the device gate. 8e36808 fixes the MEDIUM, and I confirmed it on a device. You kept the funding copy because it is the frame's text, so that LOW is resolved.

Device gate: 8e36808 — Pixel_9 emulator (Android 17, gesture navigation), local Spark stack (bitkit-docker spark profile).

  • journeys: transfer/spark-emergency-exit.xml 12/12 and settings/app-status-emergency-exit.xml 5/5. The quote waited about 2 min on "Waiting for Spark to finish moving your balance", then showed ₿ 196 608 to exit, ₿ 4 572 network and ₿ 192 036 received, with ₿ 8 602 in fees deducted from Savings. Going back from Please confirm starts nothing.
  • Pay from savings: the swipe starts the exit and Progress shows.
  • Cancelled back swipe, the MEDIUM's path: a wallet with only Spark (199 865), fees ₿ 10 109 "To be paid with other wallet", then Pay to confirm. I started a back swipe from the edge with the predictive preview showing, then cancelled it. Pay to confirm stayed with the same address. I paid the address with ./spark send and mined 1 block, and the exit started on its own: the notification prompt appeared, then Broadcast Spark exit 'FAN_OUT' … 'accepted', and Progress shows the fees step checked.
  • Figma: Confirm (52050:403921), Pay to confirm (52050:404135) and Progress (52050:404411) match on the device. Completed (52050:404632) wasn't reachable, because it needs the exit timelock to mature.
  • l10n: de and pt-BR on the progress screen, no truncation.
  • perf: not relevant beyond master.

⚠️ Not run: transfer/move-to-spark.xml, which needs a channel to move and wasn't set up in time. Its change here is only the wording of the Lightning Connections check, and this PR doesn't touch the move code. Also not run: l10n on the other exit screens.
Skipped — covered by CI at 8e36808: unit tests, compose UI tests, detekt, lint, e2e.

@ovitrif

ovitrif commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Merging: approved at 8e36808, required checks pass and every review thread is resolved.

@ovitrif
ovitrif merged commit 847d6de into master Nov 18, 2026
23 checks passed
@ovitrif
ovitrif deleted the feat/spark-design-v64 branch November 18, 2026 12:48
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