Repository navigation
Conversation
Verified: just format, just compile, just test, just lint, androidTest compile
…spark-update-spending-balance-v64
Verified: just format, just compile, just test, just lint, androidTest compile
Verified: none (journey text only)
Verified: just compile, just test, just lint
…spark-update-spending-balance-v64-fix # Conflicts: # app/src/main/java/to/bitkit/ui/ContentView.kt
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 changes how wallet balances move and how Lightning payments are sent. Fix the payment coverage check and repeated confirmation resets before merging. FindingsSummaryReplaces the Move to Spark screens with an Update Spending Balance modal and adds payments funded by both channel and Spark balances.
Two issues need attention: the coverage check leaves out the payment’s routing fee, and repeated fee changes can leave confirmation stuck. ovitrif explicitly leaves channel-close recovery after the app is killed out of scope. ovitrif also identifies the receive swipe failure as pre-existing (#1966) and notes that the Pubky journey was not run. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Open Update modal] --> C[Quote channel move]
B[Confirm combined-balance payment] --> D[Quote again and check shown fee]
D --> E[Check request and payment coverage]
E --> F[Move channel funds to Spark]
C --> F
F --> G[Wait for move to settle]
G --> H[Close emptied channels and record transfers]
G --> I[Pay recipient from Spark]
G --> J[Show modal result]
Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/fix..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a2ffa8f2a
ℹ️ 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".
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P1). Replaces the Move to Spark screens with the v64 Update Spending Balance modal, adds a one-swipe channels-to-Spark update before a Lightning payment that neither rail covers alone, auto-closes emptied channels, and removes the CJIT receive flow. Reviewed 1a2ffa8, oversized tier (59 files, about 2,900 changed lines).
What I checked, and 5 candidates I ruled out
Read in depth: MoveToSparkRepo.kt (quote, move, updateToSend, MoveToSparkMath), CloseChannelUseCase.kt, MoveToSparkManager.kt, MoveToSparkViewModel.kt, the AppViewModel.kt hunks (canSendLightning, confirmSparkUpdateQuote, updateSpendingBalanceIfNeeded, estimateSparkUpdateFees, the QuickPay and swap-route guards), SendConfirmScreen.kt, SendSheet.kt, LightningRepo.payInvoice/shouldPayWithSpark/estimateMaxSendFee, SparkRepo.payInvoice/estimateFeeSats/maxSendReserveSats, SparkFees.
Not reviewed: the receive-screen CJIT removal beyond the tab list, the journeys, and the locale files.
Build: not built here. Bitkit Android branches are reviewed from the code and from CI only. CI: build, unit tests, lint, detekt and compose UI tests green; several e2e shards still pending at review time.
Cold reader: not run for the finding below (the review ran out of time). It stands on the traced path and nothing else.
Ruled out
- Two moves paying from the same channel balance:
moveLockinmove()serialises the modal's move and a payment's update. - Allowance-refused request moving funds:
ensurePaymentAllowedruns beforeupdateSpendingBalanceIfNeededwhen an update is needed. - QuickPay sending a payment that needs an update:
handleQuickPayIfApplicablereturns false beforecanApplyQuickPay. - Fee rising between review and swipe:
confirmSparkUpdateQuotere-quotes and resets the confirm screen throughSendEffect.ResetConfirm, whichSendConfirmScreenconsumes. - Proof left behind after a failed update:
clearFailedLightningPaymenttreatsMoveToSparkErrorlike a failed payment.
Merge confidence: 3/5, one P1, and the oversized tier caps it there anyway.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer names no effort setting)
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews.
worth doing, does not block
- LNURL-pay that needs the update always bounces on the first swipe (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7903-7908) [one reviewer only]
- Update coverage check leaves out Spark's routing fee (app/src/main/java/to/bitkit/repositories/MoveToSparkRepo.kt:398) [one reviewer only]
- Spark retry-hold and exit-backup changes are not in the description (app/src/main/java/to/bitkit/repositories/SparkRepo.kt) [one reviewer only]. Commits 244833e, d93f61e, 9e9fe4a and 61730cb change how Spark send outcomes are held and reported. They touch: - the new
takenAttemptsmap -dropExpiredTakenAttempts, which emits late payment events on Synced - which list read activity rows are recorded against -CacheStore.keepSparkSendAttempt- whenBackupRepo.uploadSparkExitBackupmerges the stored exit backup None of this appears in the PR description, QA notes or journeys, which cover only the modal and the combined payment. Someone reviewing or testing #1967 has no reason to look at these payment-state changes. Either move them to the base (#1957), or describe them here with their own QA cases. - Payment coverage ignores the recipient's routing fee (app/src/main/java/to/bitkit/repositories/MoveToSparkRepo.kt:398)
- Unwrapped update failures leave payment requests pending (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7934)
- Repeated fee refreshes leave confirmation loading (app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:328)
nits
- New payment journey has no iOS twin or cross-platform table row (journeys/README.md) [one reviewer only]. CLAUDE.md asks that a journey be ported to iOS, or listed in the cross-platform table in
journeys/README.mdwith a note on what is missing. This PR addssend/update-spending-balance-payment.xmland rewritestransfer/move-to-spark.xml, but it lists no Twin and the table has no row for either.
the reviewers disagree, your call
- Balance changes can bypass migration fee confirmation (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7881)
Verified: just format, just compile, just test, just lint
Verified: just format, just compile, just test, just lint
Verified: just format, just compile, just test, just lint
Those commits (244833e, d93f61e, 9e9fe4a, 61730cb) belong to #1957, this PR's base; they arrived through the base merge and are not in this PR's diff (
The iOS twin opens after synonymdev/bitkit-ios#1355 merges and carries both journeys with the same ids; I'll add its Twin line here then. The other points are answered in their threads. |
coreyphillips
left a comment
There was a problem hiding this comment.
Rechecked after 2 new commits (aff7c0a, 2de3e68). 1 blocking finding the reviewers disagree about.
addressed
- Update coverage check leaves out Spark's routing fee (app/src/main/java/to/bitkit/repositories/MoveToSparkRepo.kt:398). Fixed:
updateToSendnow prices the payment withfeeAfterUpdateOrNull(MoveToSparkRepo.kt:153-157).coversPayment(411-412) requiresbalance + quote.amountSats >= amount + fee, and a fee nothing can price refuses beforemove. I read the new code and the two new tests inMoveToSparkRepoTest.kt, and CI build-and-test passes on 2de3e68. The wait loop still checkscanSendonly, but the pre-move check has already established the balance is enough. Max can now be refused instead of moving funds, which is what the PR promises. The fallback's reach is a separate new finding. - Payment coverage ignores the recipient's routing fee (app/src/main/java/to/bitkit/repositories/MoveToSparkRepo.kt:398). Fixed: Same change as point 2 (MoveToSparkRepo.kt:153-157, 411-412). In your example the check now compares 30,000 + 29,998 = 59,998 against 59,600 plus Spark's quoted fee (449 with a 300-sat route), so it throws
UpdateFallsShortbeforemove. When the fee cannot be priced, nothing moves either.
still open
- LNURL-pay that needs the update always bounces on the first swipe (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7903-7908) [one reviewer only]. Every LNURL-pay that needs a spending balance update takes two swipes, and the first one bounces back with no message. The LNURL invoice is only fetched inside
proceedWithPayment, afterconfirmSparkUpdateQuotehas run.estimateLightningRoutingFeesIfNeededreturns early atcurrentState.decodedInvoice ?: return(line 8614), and the fixed-amount LNURL path goes to Confirm without estimating anything. SosparkUpdateQuoteis always null on the LNURL confirm screen. The result is that the "Update fee" row added toLnurlPayDetailsnever shows before the swipe. On every first swipe,confirmSparkUpdateQuotetakes itsshown == nullbranch and emitsResetConfirm. With PIN for payments on, that also means two PIN prompts. I found this by reading the code. J2 only covers a BOLT11 invoice. One fix: quote the update inestimateLightningRoutingFeesIfNeededwhenlnurl is LnurlPayandneedsUpdateToSend(amount)is true, so the fee shows before the first swipe. Unchanged since the last review, and there is no reply.estimateLightningRoutingFeesIfNeededstill returns atdecodedInvoice ?: return(AppViewModel.kt:8614) before an LNURL invoice exists.confirmSparkUpdateQuote(7903-7908) still emitsResetConfirmwhenshown == null, so an LNURL-pay that needs an update still bounces on the first swipe. - Spark retry-hold and exit-backup changes are not in the description (app/src/main/java/to/bitkit/repositories/SparkRepo.kt) [one reviewer only]. Commits 244833e, d93f61e, 9e9fe4a and 61730cb change how Spark send outcomes are held and reported. They touch: - the new
takenAttemptsmap -dropExpiredTakenAttempts, which emits late payment events on Synced - which list read activity rows are recorded against -CacheStore.keepSparkSendAttempt- whenBackupRepo.uploadSparkExitBackupmerges the stored exit backup None of this appears in the PR description, QA notes or journeys, which cover only the modal and the combined payment. Someone reviewing or testing #1967 has no reason to look at these payment-state changes. Either move them to the base (#1957), or describe them here with their own QA cases. Codex still sees it: The requested diff against origin/fix/spark-follow-ups still includes all three files at the supplied base 037c771. The 02:05 response matches their history through merge parent 61730cb, but remote access failed, so I could not confirm their exclusion from the current PR. - New payment journey has no iOS twin or cross-platform table row (journeys/README.md) [one reviewer only]. CLAUDE.md asks that a journey be ported to iOS, or listed in the cross-platform table in
journeys/README.mdwith a note on what is missing. This PR addssend/update-spending-balance-payment.xmland rewritestransfer/move-to-spark.xml, but it lists no Twin and the table has no row for either. Journeys/README.md's cross-platform table still has no row forsend/update-spending-balance-payment.xmlor the rewrittentransfer/move-to-spark.xml, and there is no Twin line. A Twin promised after bitkit-ios#1355 merges is a plan, not a port. A table row saying the iOS port is pending would close this nit. - Balance changes can bypass migration fee confirmation (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7881). If Spark's balance drops while an LNURL invoice callback is pending, channels can migrate without showing an update fee. The earlier confirmation check passes while Spark can pay alone. This later call then passes a null quote to
updateToSend(), which quotes and moves immediately. I confirmed this using the production repository and extracted confirmation methods: a 60,000-sat payment with 50,000 sats in channels migrated after Spark fell from 70,000 to 20,000 sats, without emittingResetConfirm. AppViewModel.kt:7881 still passes_sendUiState.value.sparkUpdateQuote. That is null whenconfirmSparkUpdateQuotereturned early because no update was needed then, soupdateToSendstill quotes and moves without aResetConfirm. The new coverage check does not stop the 70k to 20k case: 20,000 plus a ~49,900 move covers 60,000 plus its fee. I agree this is non-blocking and fine to track in #1968, but the deferral is not a fix or a rebuttal. - Unwrapped update failures leave payment requests pending (app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:7934). A move refused with
NodeException.InsufficientFundsleaves a payment request pending although its invoice was never sent.move()preserves this error, so it misses theMoveToSparkErrorbranch and the proof layer returns false. I confirmed this with a refused update and the production cleanup method bodies. The pending branch then retains the recipient hash and proof without a recipient payment that can settle them. There is no reply and no change.clearFailedLightningPayment(AppViewModel.kt:7926-7939) still sends errors that are notMoveToSparkErrortofailLightningPayment(paymentHash, error).updateToSendstill lets raw errors through unwrapped, for examplesparkRepo.createInvoice(...).getOrThrow()inquote(MoveToSparkRepo.kt:206) and thepayInvoiceOverLdkerrors rethrown at 267-270. A Paykit request whose invoice was never sent can therefore still be tracked as pending. - Repeated fee refreshes leave confirmation loading (app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:328). A second fee-refresh reset leaves confirmation spinning.
SendConfirmScreenremoves the saved-state key after the first reset, detaching its existingStateFlow. This new in-place reset keeps using that collector. I reproduced two reset events against the shipped saved-state implementation: only the first cleared loading. An LNURL payment with no initial quote followed by a fee increase reaches this sequence. Neither file changed and the Codex thread on SendSheet.kt:332 has no reply. SendSheet.kt:328-331 still setsSEND_CONFIRM_RESET_RESULT_KEYin place. SendConfirmScreen.kt:156-161 still collects it withgetStateFlowand removes the key after the first reset, so a second reset on the same Confirm screen never reaches the collector.
new since the last review
worth doing, does not block
- Update fee fallback cannot price any payment that needs an update (app/src/main/java/to/bitkit/repositories/MoveToSparkRepo.kt:188-191)
Quotes LNURL-pay updates before confirm, releases payment requests on any update failure, keeps repeated confirm resets observable, and stops a send whose update fee was not shown or rose since. Verified: just format, compile, test, lint
Spark's prepare prices any amount whatever its balance, so the LDK routing fallback could never price a payment that needs an update. Also lists the new journeys' pending iOS port. Verified: just format, compile, test, lint
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at ec91454, covering this PR's diff on top of #1957: no HIGH or MEDIUM. Two LOWs are inline, and one docs LOW is below.
LOW (docs): docs/receive-liquidity.md still describes the removed flow. Lines 3-5 and 44 send the user to the Transfer Unavailable screen, and lines 29-30 describe the Spending tab's onboarding view. Both are gone: the Spending and Auto tabs now hide without Lightning receive (ReceiveQrScreen.kt:155-159), and editing calls updateInvoice (EditInvoiceScreen.kt:100-103). Update or delete the doc.
What I checked:
- Nothing moves unconfirmed.
confirmSparkUpdateQuoteandupdateSpendingBalanceIfNeededre-quote and return to confirm when no fee was shown or the fee rose. - No double pay.
moveLockserialises the modal's move and a payment's update.onConfirmPayrefuses a second submission. After process death, the persisted LDK payment settles by itself. - Channel closes.
closeEmptiedByMovecloses only channels that could send 1,000 sats before the move and can't after, only after aMovedoutcome or a settled in-flight success, and only cooperatively. - Balances.
DeriveBalanceStateUseCasechanges onlymaxSendLightningSats; totals are untouched. - Modal lifecycle. Later, Back and swipe-dismiss during a move keep it (
resetreturns whileisMoveInFlight), and reopening shows it. Dismissing while quoting cancels the quote. The one-time sheet's Failed state offers Try again, and the sheet can be reopened from Spending and Lightning Connections. - Journeys and screens map. The six journeys match the head's tags and copy. The screens map drops the removed screens and adds
MoveToSparkSheet.ktwith both frames. - Figma. Update Spending Balance (52052:404808) and Spending Balance Updated (52052:409823) match in copy, accent split, the bold fee tail, buttons and illustrations. The frame breaks "UPDATED" onto its own line, while the app relies on wrapping at 44sp.
- iOS twin. None yet, and
journeys/README.mdrecords the port as pending.
perf: relevant. Every quote() creates a new 1-hour Spark invoice plus up to 4 route estimates. It runs on each modal open, on each fee estimate for an update payment, at swipe and again at send: at least three invoices per combined payment. A swipe can then wait up to 2 min for the move plus 60 s of 2 s polling.
Device gate (partial): ec91454 — not run yet; pending: send/update-spending-balance-payment.xml, transfer/move-to-spark.xml, transfer/transfer-unavailable-sheet.xml, the receive tab journeys and paykit-spark-route.xml on the Spark regtest stack, with swipe → "Bitcoin Sent" timing and quote counts per confirm visit. Device results and the final review type follow in a second review.
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Verified: just format, compile, test, lint
Closes #1982
Stacked on #1957
Refs: #1946
Companion: synonymdev/bitkit-e2e-tests#316
Description
Out of Scope
Design
Figma page "Bitkit - Progress v64" in the Bitkit Wallet file:
Preview
Figma frame on the left, the app on the right.
Screens without a v64 frame
Recordings at 2x
j1.mp4
j2-update-spending-balance-payment2x.mp4
j3.mp4
j4.mp4
j5.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
Renew Instant Payments Connection
Blocktank Sunsetting
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), Electrum on the stack, and the stack's chain shared with Spark; this branch has no build setting for a local Spark, so this is a local patch to the build, not part of this PR.files/regtest/wallet0/sparkwith a file throughrun-as).Journeys
move-to-spark.xml— Update modal with its fee, Later, Update, Updated modal, emptied channel closed — passed on2ada21c75update-spending-balance-payment.xml— a payment only channels and Spark together cover: "Update fee" row, no Route row, one swipe — passed onec9145415; its action 2 (details open on their own) changed in 76b903e and is covered bySendConfirmUpdateFeeTest.kttransfer-unavailable-sheet.xml— with Spark down, the funding options and Receive without Lightning tabs — passed on754638d64, steps 6–9 with Spark failing to startusdt-receive-swipe-tabs.xml— tabs without the CJIT card — passed on754638d64receive-tabs-wraparound.xml— fails at step 10 (a right swipe above the sheet keeps Savings selected); the same on master, tracked in bug: savings swipe released above the receive sheet keeps savings #1966paykit-spark-route.xml(Route row removed) — not run: needs an E2E local-backend build and a paykit stack with a Pubky profileAutomated Checks
MoveToSparkRepoTest.kt— quotes, coverage of a payment, the update falling shortCloseChannelUseCaseTest.kt— closes only the channels a move emptied, after a syncMoveToSparkViewModelTest.kt— modal states and the re-quote at swipeAppViewModelSendFlowTest.kt— combined payment: re-quote at swipe and at send time, LNURL-pay quote, allowance check before moving, failed updates releasing requests, payment failing after the moveSendConfirmResetTest.kt— repeated fee resets each release the swipeAppViewModelSendFlowTest.kt— the swipe waits while the update is quotedSendConfirmUpdateFeeTest.kt— the Update fee shows without opening the detailsPaymentFailureReasonExtTest.kt— a failed update shows the existing payment failure copyReceiveQrScreenTest.kt,WalletRepoTest.kt,SendConfirmLnurlOnchainTest.kt; removedReceiveLiquidityDecisionTest.kt,EditInvoiceVMTest.ktwith the CJIT flowEvidence
On a regtest emulator (Android 15, 896×1994 at 320 dpi) with the local Spark stack:
ec9145415): confirm showed 50 000 with "Update fee ₿ 2", no "up to" and no Route row; after the over-half-balance dialog, one swipe moved 30 458 to Spark and sent 50 000 from Spark, which priced the payment above its 30 000 balance; the emptied channel closed with ↑1 542 / ↓29 458 and savings received 372 sats.754638d64and2ada21c75only the update and payment guards (1f912de0d) and journey text changed; J3 and J4 cover screens those guards do not touch.Gaps
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),Claude Opus 5.5(reasoning:medium)