Repository navigation
Conversation
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 based on the code reviewed. SummaryReplaces the Move to Spark screens with an Update Spending Balance modal and lets Lightning payments combine channel and Spark funds after showing the update fee.
No actionable issues found. Tests were not run in this Linux environment. ovitrif explicitly leaves app termination between move settlement and channel closure out of scope; those channels remain available for manual closure. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Review Lightning payment] --> B{Needs combined funds?}
B -- No --> G[Send payment]
B -- Yes --> C[Show update fee]
C --> D[Swipe and refresh quote]
D --> E{New or higher update fee?}
E -- Yes --> C
E -- No --> F[Check allowance and coverage]
F --> H[Move channel funds to Spark]
H --> I[Close emptied channels]
H --> J[Wait for Spark balance]
J --> G
Reviews (1) · Last reviewed commit: "fix: keep the modal artwork 32 above its..." · Reviewed by Greptile |
Replaces the Move to Spark screens with the Update Spending Balance modal: the live routing fee as "Update fee", Later and Update, then Spending Balance Updated with OK. The one-time timed sheet and the Move To Spark buttons on Spending and Lightning Connections open it. States without frames (in flight, partly moved, too large, failed) keep their behaviour inside the modal; their dismiss buttons share the UpdateSpendingBalanceDismiss id. The modal resets the move manager when it closes. Verified: swiftformat --lint on the changed Swift files
Once a move settles, on its first outcome or a late success, every channel it emptied is closed cooperatively with the usual transfer row; a failed close leaves the channel for a manual close. Channels that could send less than the move minimum before it are left alone. This replaces the single-channel Close button after a move. Verified: swiftformat --lint on the changed Swift files
A Lightning payment that only the channels and Spark together can cover runs with one swipe: confirm adds an "Update fee" row and opens its details, the swipe waits for the quote, moves the channel balance to Spark, then pays from Spark. The update fee guard charges nothing the user did not see: the update is quoted again at the swipe and right before the move, and a fee that rose, or none shown, returns to confirm with the new fee and moves nothing. Before moving, the quote and Spark's balance must cover the payment and Spark's fee for it. A request refused by its allowance check moves nothing, and any failed update releases the request. A payment failing after the move leaves the funds in Spark with the usual payment error. An LNURL-pay that needs the update shows its fee before the first swipe. QuickPay never sends such a payment, and Paykit routes are quoted only with what one rail can pay. Verified: swiftformat --lint on the changed Swift files
Send confirm no longer shows the Route row for a Paykit payment over Spark. The Pubky Swaps route row keeps it, so wallet__send_swap_route stays, as on Android. Verified: swiftformat --lint on the changed Swift files
Removes the CJIT receive card, its Receive Lightning Funds button and the liquidity flow behind it: Receive's Transfer Unavailable step, the edit-amount liquidity check and the Spending tab bar shortcut to it. CJIT history stays. Without a Lightning invoice from a usable Spark wallet or channel, the Spending and Auto receive tabs hide. Verified: swiftformat --lint on the changed Swift files
Verified: none (changelog text only)
Adds the update spending balance modal and Update fee strings to every shipped locale and drops the removed move to spark and CJIT receive keys. Verified: node scripts/validate-translations.js
Adds the update spending balance payment journey, rewrites move to spark for the modal, and drops the CJIT receive and route steps from the receive, transfer unavailable and paykit journeys. Verified: xmllint --noout on each journey
A first subscription payment that needs the spending balance update no longer pays by itself behind the progress cover. Send confirm opens the manual confirmation before quoting or moving, and does so again when the fee rises at move time instead of landing on the failure screen. LNURL-pay gets the same rule through a flag its automatic start checks. Verified: swiftformat --lint on the changed files
When the update fee rises at move time, send confirm and LNURL-pay release the request's private payment list and stay on Confirm. They now restore the request as the raised mining fee path does, so the next swipe prepares it again; a send closed or replaced meanwhile is left alone. Verified: swiftformat --lint on the changed files
A fee estimate that needs no update now invalidates an update quote still loading, so that quote can no longer write Spark's fee over the Lightning estimate or bring the Update fee row back. The run counter and the quote holding the swipe move into one value type. Verified: swiftformat --lint on the changed files
A Paykit swap route pays through its swap provider, never from the channels, so send confirm and LNURL-pay neither quote the update for it nor stop its swipe over an update fee, as on Android. Verified: swiftformat --lint on the changed files
The frames bottom-align the modal's content, so on a taller sheet the extra space goes above the artwork, not around it. Verified: swiftformat --lint
Verified: none (file rename only)
f2b60fc to
ea1eb61
Compare
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Replaces the Move to Spark screen with the Update Spending Balance modal, closes the channels a move emptied, lets a Lightning payment that fits only across the channels and Spark together pay in one swipe after showing an update fee, and removes the CJIT receive card and the Route row. Reviewed f2b60fc against its base fix/spark-follow-ups-2 (#1355), oversized tier: 55 files, +1282/-870.
What I checked, and 5 candidates I ruled out
Reviewed in full (the paths that move funds): the diff of MoveToSparkManager.swift, SendConfirmationView.swift, LnurlPayConfirm.swift, SendAmountView.swift, SendSheet.swift, PaymentNavigationHelper.swift, WalletViewModel.swift, AppViewModel.swift, PaykitPaymentProofService.swift, MoveToSparkSheet.swift, MainNavView.swift, LightningConnectionsView.swift, SpendingWalletScreen.swift, plus TransferViewModel.closeChannels, WalletViewModel.sendWithTimeout and performSwapRoutedPayment on the head.
Not reviewed: the CJIT and receive removals (ReceiveQr, ReceiveEdit, ReceiveSheet, TabBar, ReceiveTransferUnavailable), the localisation files, the unit tests and the journeys. That is the oversized tier's limit, not a judgement on them.
Build: not built. iOS does not build on this reviewer's Linux host, so this review is reasoned from the code and from CI.
CI: SwiftFormat green; Run Tests still pending at review time.
Ruled out
- An update fee charged unseen: the swipe re-quotes in
confirmSparkUpdateQuotebefore biometrics, andupdateSpendingBalanceIfNeededquotes again and refuses withupdateFeeUnseenwhen no fee was shown or the fresh one is higher. Both automatic paths (SendConfirmationViewwithisAutomatic,LnurlPayConfirm.startAutomaticPaymentIfNeeded) switch to manual confirmation instead of paying, and QuickPay is skipped by the newneedsUpdateToSendcheck inPaymentNavigationHelper.shouldUseQuickpay. - A failed update reported as a payment that may have gone out: every update failure throws
MoveToSparkErrorbeforeprivatePaymentListOutcome = .uncertainand beforesendWithTimeout, andPaykitPaymentProofServicenow treatsMoveToSparkErroras nothing sent, which matches. - Two moves paying from the same channel balance:
payOverChannelschains onmoveTail, andcheckCoverageprices the payment from Spark's own quote before anything moves. - A double close of one channel: the close runs on exactly one of the settled and
onLateSuccesspaths of a move. A second overlapping move would need the modal and a send sheet open at once. - The swap route quoted against the combined balance:
quoteSwapRouteinSendAmountViewstill passes the uncappedwallet.maxSendLightningSats(which now includes the update), while the hold invoice is paid without an update. The route is behindEnv.isPubkySwapsRouteEnabled(debug regtest withPUBKY_SWAPS_ROUTESonly), and the hold payment fails before anything is committed, so this is below the posting bar.
Merge confidence: 3/5, the oversized tier: the receive and CJIT removals, the tests and the journeys were not reviewed, and the unit tests had not finished in CI.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (the review runner does not report it)
|
Spark replaces Lightning spending in 3.2.0, and this modal is how the Spending balance moves to Spark, so it ships in 3.2.0. This PR now closes #1374, which carries the milestone. |
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews.
worth doing, does not block
- Pubky swap quotes now get a spending figure only an update can fund (Bitkit/Views/Wallets/Send/SendAmountView.swift:521). A Pubky swap can now be quoted and committed for an amount only the spending balance update can fund, and its hold payment then fails.
maxSendLightningSatsnow includesMoveToSparkMath.combinedSendableSats, the amount Spark could send after a move (WalletViewModel.swift:1606).SendAmountView.quoteSwapRoutestill passes that figure toPubkySwapsRouteService.quoteaslightningSpendableSats(SendAmountView.swift:521). The insufficient-funds check at :448 reads the same figure. Swap routes deliberately skip the update:sparkUpdatePaymentSatsreturns nil whenhasSwapRoute.performSwapRoutedPaymentthen commits the quote and pays the hold invoice withLightningService.shared.sendon a single rail (SendConfirmationView.swift:1594-1603). For an amount above both rails but within their sum, the sequence is: bitkit-core quotes, Confirm commits (which spends the quote), and the hold payment fails because neither rail can carry it. The user lands on the failure screen. The PR already clampsrouteContactPaymenttoMoveToSparkMath.singleRailSendableSats()for this reason ("The hold payment goes out over one rail"). The swap quote and its Amount check need the same clamp. Confirmed by reading the code paths only. Not run: the route is behindPUBKY_SWAPS_ROUTES, which is debug and regtest only, so this is non-blocking. - Coverage check and post-move wait apply different Spark fee rules (Bitkit/Managers/MoveToSparkManager.swift:563-579). Before moving,
checkCoverageandwaitForSparkjudge whether Spark can pay using two different rules, so the check can pass for a payment the wait will never accept. -checkCoverage(MoveToSparkManager.swift:563) approves the move whenspark.balanceSats + quote.amountSats >= amountSats + estimateSparkFee. - After the move,waitForSpark(:571) waits forSparkSendState.canSend(amountSats). That usesChannelFreeRailFees.sendableSatsand always reserves the 0.25% service fee. The PR's own test shows the gap.testTheUpdateMustCoverThePaymentAndSparksFeeaccepts 30,000 + 20,000 against a payment of 49,998 with a fee of 2. ButsendableSats(balanceSats: 50000)is 49,875 by the formula in LightningService.swift:42, socanSend(49998)is false. In that case the move happens and the emptied channel starts closing. The swipe then waits 60 s and throwsupdateUnsettled, which the user sees as a failed payment. Whether this happens in production depends on whether Spark's preparedlightningFeeSatsincludes its 0.25% service fee. The Breez SDK bindings don't say, and I couldn't confirm it. The J2 evidence (₿ 202 on 50,000) suggests it may, in which case only the test is misleading. Suggested fix: also requireSparkSendState(balanceSats: have).canSend(amountSats)incoversPayment, so the pre-move check matches the condition the wait andLightningService.shouldPayWithRailuse. - Exact-capacity invoices miss the combined-balance path (Bitkit/Managers/MoveToSparkManager.swift:101-103). An amount equal to channel capacity falls between the direct-send and update checks. This predicate requires the amount to exceed capacity, while
canSendWithChannelsrequires capacity to exceed the amount. An isolated execution with 32,000 sats in channels and 30,000 on Spark rejected 32,000 sats but accepted 32,001 through the update path.
the reviewers disagree, your call
- Contact payments reject amounts that need a spending update (Bitkit/Views/Wallets/Send/SendAmountView.swift:576-579). Objection: Real, but non-blocking rather than blocking: Confirmed. Every contact payment with bitcoin endpoints goes through the router (SendAmountView:423-428, SendConfirmationView:1722-1729), which only gets the single-rail limit, while the amount check at line 448 uses the combined
maxSendLightningSats. A split-balance contact LNURL or request is refused with the amount-exceeded toast and never reaches the update code that the PR says handles requests. The Android twin (#1967) puts this exact// The hold payment goes out over one railcap on the Pubky Swaps quote and gives the Paykit router the full max. So iOS put it on the wrong call and left the swap quote at line 521 uncapped. Non-blocking because base had the same refusal and no funds are at risk. - A refreshed quote can replace the fee approved by the swipe (Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:383-386). Objection: Real, but non-blocking rather than blocking: Confirmed. confirmSparkUpdateQuote runs before requestPinCheck, and that call pushes
.pinonto the stack (SendSheet:907-925). When PIN pops, the view's.taskruns again (the comments at lines 102 and 562 already note PIN cancels it). It reassignssparkUpdateQuotewhile the LNURL callback is still pending, and line 386 reads that reassigned value asshown, so a fee that rose after the swipe passes the guard. SendConfirmationView:2023 does the same through calculateRoutingFee. Non-blocking: it needs PIN without biometrics plus a fee rise within seconds, and the overcharge is a few sats. The fix is to capture the approved quote at the swipe and pass that.
An in-flight payment's HTLC lowers a channel's send limit until it settles, so after a move a channel the move did not empty could look emptied and be closed. The close after a move now skips every channel while the node lists an outbound payment as pending, or can't list its payments. Verified: swiftformat --lint on the changed files; simulator unit tests for MoveToSpark, LnurlPayConfirm, SendConfirmation, ChannelFreeRail, SparkTransferFlow, WalletViewModelSend and QuickPayPaymentCoordinator (294 passed)
An HTLC still counting against the peer's in-flight limit lowers a channel's send limit without emptying it. A channel now closes only when its outbound capacity is under the move minimum too. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (42 passed); swiftformat --lint
…t/update-spending-balance-modal
LDK's outbound capacity leaves out the commitment fee the funder keeps back, so a channel a full move emptied could still read 1 000 sats or more and stay open. The close check now takes that fee off the capacity of a channel we funded, the higher of an anchor and a legacy commitment at its feerate. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (43 passed); swiftformat --lint
A send the user made from another channel while a move ran could empty that channel and settle before the move, and the move then closed it too. Each move now reads the payments when it starts and closes nothing if a payment other than a move's changed since. The commitment fee taken off a funded channel's capacity no longer counts the anchors LDK already took off: an anchor commitment with two HTLCs, as LDK reserves. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (44 passed); swiftformat --lint
The close check took an anchor commitment's fee off every channel we funded, so a legacy channel a move emptied could still read over 1 000 sats and stay open. ldk-node does not expose the channel type, so it is read from the channel before the move: a send limit at least the legacy reserve under the capacity means a legacy commitment, whose fee is one HTLC at twice the feerate. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (45 passed); swiftformat --lint
…t/update-spending-balance-modal
A peer's in-flight cap made an anchor channel read as legacy, so the close took the legacy fee off a channel that could still send 1 332 sats once the move's HTLC cleared. The close no longer estimates any commitment fee: a channel with capacity left whose send limit is under the minimum is read again every 2 s for up to 30 s, and closes only if its limit stays under it. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (43 passed); swiftformat --lint
…t/update-spending-balance-modal
After the 30 s recheck a channel could still close on a send limit the move's HTLC held down, though it could send 1 332 sats once that cleared. A channel with capacity left now closes only when the gap between its capacity and limit is exactly LDK's commitment fee for an anchor or a legacy commitment; otherwise it stays open for a manual close. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (43 passed); swiftformat --lint
…t/update-spending-balance-modal
…t/update-spending-balance-modal
A send limit the peer's in-flight cap held down could match a commitment reserve by chance, so the first read skipped the recheck and closed a channel the move had not emptied. A channel with capacity left now closes only when its reserve explains its limit in two reads 2 s apart with nothing changed between them. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (44 passed); swiftformat --lint
The reserve check used one HTLC for a legacy commitment, so a legacy channel a move emptied (1 400 sats of capacity sending 860 at 253 sat/kW) matched neither reserve and stayed open. It now predicts the limit as LDK 0.2 computes it once HTLCs clear: an above-dust HTLC and the fee spike buffer HTLC, doubled for legacy, and one HTLC less under the dust limit. Verified: m1a MoveToSparkMathTests, MoveToSparkUpdateTests, MoveToSparkQuoteTests, MoveToSparkLateOutcomeTests (44 passed); swiftformat --lint
…t/update-spending-balance-modal
…t/update-spending-balance-modal
Closes #1374
Twin: synonymdev/bitkit-android#1967
Dependency: #1355
Description
TransferViewModel.closeChannels.Out of Scope
DisplayText,BodyMText: the headline and body line heights are the shared components' (about 2 pt under the frame's 44 and 22).Design
Figma page "Bitkit - Progress v64" in the Bitkit Wallet file:
Preview
Figma frame on the left, the app on the right, on
42a656e8f.Screens without a v64 frame
Recordings at 2x: J1 on
42a656e8f, J2 onf2b60fc6c, the others on1ca4159a7.pr4-j12x.mp4
pr4-j22x.mp4
pr4-j32x.mp4
pr4-j42x.mp4
pr4-j52x.mp4
Figma notes
Every note above the v64 frames for these flows, with what this PR does about it.
Modal Update Spending balance (Spark)
Modal Update Spending (Spark) done
Changelog v64
QA Notes
Setup
docs/spark-regtest.md), so the wallet holds an LDK channel to the stack's SSP Lightning node on the same chain as Spark.SPARK_LOCAL_CONFIG_B64from the docs) as the Spark SDK config with fee ladders off, Electrum on the stack, and the stack's chain API as Spark's chain service. This branch has no build setting for a local Spark, so this is a local patch toEnv.swiftandSparkManager.swift, not part of this PR.regtest/wallet0/sparkdirectory with a file), restored after.Journeys
move-to-spark.xml— Update modal with its fee, Later, Update, Updated modal, emptied channel closed — passed on42a656e8fupdate-spending-balance-payment.xml— a payment only channels and Spark together cover: "Update fee" row, no Route row, one swipe — passed onf2b60fc6ctransfer-unavailable-sheet.xml— with Spark down, the funding options and Receive without Lightning tabs — passed on1ca4159a7usdt-receive-swipe-tabs.xml— tabs without the CJIT card — passed on1ca4159a7receive-tabs-wraparound.xml— passed on1ca4159a7, step 10 includedpaykit-spark-route.xml(Route row removed) — not run: needs a paykit stack with a Pubky profileAutomated Checks
MoveToSparkUpdateTests.swift— update-fee guard, coverage before moving, closing only the channels a move emptied, the swipe waiting for the newest quoteMoveToSparkMathTests.swift,MoveToSparkQuoteTests.swift,MoveToSparkLateOutcomeTests.swift— when a payment needs the update, swap routes and Spark legs never doLnurlPayConfirmTests.swift— an automatic payment needing the update waits for a swipe; a refused fee restores only the current sendQuickPayPaymentCoordinatorTests.swiftcase — a payment that needs the update falls back to ConfirmReceiveTabsTests.swift— without Lightning receive the Spending and Auto tabs hideReceiveLiquidityDecisionTests.swift,TabBarReceiveTests.swiftwith the CJIT flowEvidence
On an iPhone 17 Pro simulator (regtest) with the local Spark stack:
1ca4159a7and42a656e8fonly the modal's artwork placement and fix: spark follow-ups #1355's base changes landed; the send, retry and Move to Spark test classes pass on42a656e8f.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)Claude Opus 5.5(reasoning:medium)