Skip to content

fix: let send reach spark before the node runs - #1578

Open
jvsena42 wants to merge 22 commits into
masterfrom
fix/send-overlay-recipient
Open

jvsena42 wants to merge 22 commits into
masterfrom
fix/send-overlay-recipient

Conversation

@jvsena42

@jvsena42 jvsena42 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Source: qa, mainnet QA of 3.2.0 RC3 (synonymdev/bitkit-android#2160 (comment); iOS shares the overlay rule)
Twin: synonymdev/bitkit-android#2244

Spark is ready about 0.4 s after launch, but the Send sheet kept its sync overlay up until the node ran. After 20 s in the background, Send was blocked for 24 s, even for invoices Spark could pay (#2032 comment).

Description

  • The sync overlay no longer covers the recipient steps (Options, Contact, Manual). Decoding needs no node. An invoice Spark can pay goes straight to review, and anything else shows the overlay on the next step.
  • On the Amount step, an amountless Lightning invoice takes its amount without the node when Spark can send. LNURL pay still waits for the node.
  • When the node starts late, the deferred validation skips a send that is submitting or already pending or settled, so a Spark payment made before the node ran is not re-validated.
  • For an amountless invoice, the overlay and Confirm decide whether Spark pays from the entered amount, so a Spark-payable amount reaches review without the node.
  • A QuickPay opened while the node starts stays behind the overlay until the late validation has run. When Lightning can't pay a unified invoice, the sheet falls back to on-chain Amount, replacing the QuickPay root, instead of QuickPay attempting Lightning. QuickPay counts as submitted only once its payment has started.
  • While the node's balances are unavailable, the stored Spending limit is the channel limit from the last run plus Spark's current sendable amount, instead of a value from an earlier session.
  • After a payment is submitted (pending, success, failure), the overlay stays off, and channels becoming usable no longer re-validate the send.

Out of Scope

  • AppViewModel.handleLnurlPayInvoice: an LNURL scanned while the node is down shows the existing "Lightning not running" toast. Before, the overlay kept the user from reaching the scanner.
  • Other sync views (transfer to spending, Quick Pay) stay, since those flows need the node.
  • bug: send sheet stays locked while an ldk call stalls bitkit-android#2032's confirm-swipe deadlines: this PR references the issue but does not close it.
  • Not driven on a device: a send Spark already paid, then re-checked when a channel becomes usable. It needs a wallet with a usable channel, and a local channel to the app never left ChannelPending.

Design

N/A — no design available.

Preview

Send options, node down Review, node down Amountless amount entry Failed, node down (30 s)
Send options without overlay Review without overlay Amount entry without overlay Failed screen without overlay

QA Notes

Setup

Debug (regtest) build of this branch on an iPhone with a funded Spark balance. A wallet with a channel shows the Lightning variant of the overlay; without one, the Bitcoin variant.

Journeys

  • J1. On-chain connecting view. Hold node startup, check Recipient, paste an on-chain address and check the overlay on Amount until startup completes.

Manual Tests

  1. Cold start the app (iOS keeps the node running in the background) and open Send right away: the send options show at once, and no sync overlay.

  2. During 1., paste an invoice with an amount Spark can pay: review opens before the node runs, and the payment completes.

  3. During 1., paste an amountless invoice: amount entry shows without the overlay. Enter an amount within the Spark balance, continue, and pay.

  4. During 1., paste an on-chain address: the overlay shows on the Amount step and clears once the node runs.

  5. With the node running and a usable channel, a normal Lightning send still works.

  6. Cold-start a Lightning-only QuickPay that Spark releases before the node is ready. Let the first attempt fail, restore a funded usable channel, and make Spark insufficient before Try Again. Verify the retry uses the ready channel without a connection timeout.

  7. Upgrade a wallet with a legacy Spending limit before its first separate channel snapshot. With node balances unavailable, credit Spark above that limit, then debit Spark. Open an amountless invoice after each refresh and check Available and the amount cap against the greater of the original limit and current Spark capacity.

  8. Let a channel become usable after a Spark payment is submitted. Verify Pending or Success remains visible and the sheet does not revalidate the settled payment.

Evidence

Follow-up at 5ec8c06b. Xcode 27.2 on an iPhone 18 Pro simulator ran the unit suite with 4,717 passes, five skips and zero failures. The QuickPay retry and consecutive Spark refresh regressions passed. SwiftFormat 0.64.6 and J1 XML parsing passed. J1 and the manual cases await candidate device testing.

iPhone 17 Pro simulator (iOS 26.5) on local Spark regtest (bitkit-docker spark profile). Node held down by launching with -E2E_LOCAL_HOST=127.0.0.2. Final build 88fe44eda; invoices went in by deeplink. Unit tests: ChannelFreeRailTests and SendSheetLifecycleTests pass on 88fe44eda.

  • 1. Send options and Enter Manually show without the overlay while the node is down (PASS).
  • 2. An invoice Spark can pay reaches review with no overlay while the node is down (PASS). The payment failed with Tree service error: insufficient funds: the local SSP has no 8,192-sat leaves, so swaps fail.
  • 3. An amountless invoice on a freshly funded wallet opens amount entry (Available 49,672) with no overlay; 1,000 reaches review with no overlay (PASS). A first run failed because it followed a failed send, after which the Spark balance read 0 for minutes; the rerun confirmed the balance first. Amountless review
  • 4. After a Spark send fails with the node down, the Failed screen stays clear of the overlay at 1 s, 3 s and 30 s (PASS). The Pending variant could not be produced locally.
  • On-chain and LNURL flows still show the overlay while the node is down (observed; clearing after Node started not observed because the node was held down).

Gaps: payments made while the node is down are blocked by the local SSP's leaf pool, not by this change. QuickPay stays behind the overlay (88fe44eda), since it pays as soon as it shows; not exercised on device.

Review round (Greptile, ovi-reviewer)

iPhone 17 Pro simulator (iOS 26.5), local regtest. Savings 100,000, Spark 0, no channels, QuickPay on at $5. A unified BIP21 for 1,000 sats was deeplinked on a cold start, so the node starts under the overlay.

  • QuickPay fallback at 384ce626b: 3/3 PASS. The overlay showed, then on-chain Amount (Savings, 1,000 sats) right after Node started, and it stayed ~26 s with no QuickPay or Lightning attempt. Earlier heads ae9bead8a, 8f11931ac and f711daaad showed "Payment Failed" there.
  • Node already running: the deeplink went straight to on-chain Confirm with no overlay stuck.
  • Node held down: the overlay stays, then "Connection issues" at 25 s, with no payment attempt.
  • At d547026bb (Spark releases the hold): unified invoice 2/2 PASS, on-chain Amount held ~55 s. Lightning-only invoice with Spark funded (20,000): the overlay dropped while the node was still starting, and QuickPay paid through Spark (Bitcoin Sent, 1,006 sats).
Fallback to on-chain Amount Node running: Confirm
quickpay-fallback.mp4

Unit tests at d547026bb: ChannelFreeRailTests and SendSheetLifecycleTests pass (168), including the new submission, hold, Spark-release and send-limit tests.

Review round 3 (ovi-reviewer, coreyphillips)

  • Spark payment from Confirm with the node held down (ebe718bf2): Confirm stayed uncovered, the Spark send went out at +3.3 s, and Bitcoin Sent showed at +4.7 s. No "Connecting to network" frame appeared in 40 screenshots.
  • Not device-verified: a retry re-running the skipped node-start validation, which needs a usable channel that the local regtest setup did not provide.
  • Amount holding while channels reconnect (5e67a31d5) was reverted in 6ca0c1a46: it could leave the overlay up for an amountless unified invoice with Spark funds (Greptile P1) and drop a typed amount. While channels reconnect, Available reads Spark's amount until the next balance refresh. Unit tests: ChannelFreeRailTests and SendSheetLifecycleTests pass (170).

🤖 Generated with Claude Code

Models used

  • Planning/scoping and implementation of this follow-up used gpt-6.2-astra (reasoning: high). Earlier implementation model and effort are unrecorded in the PR.
  • Review used gpt-6.2-sol (reasoning: high) and gpt-6.1-sol (reasoning: high). Greptile did not identify its model or effort in the review.

Hide the sync overlay on the recipient steps, so a Lightning invoice
Spark can pay is decoded without waiting for the node, and let Spark
take an amountless invoice's amount.

Refs synonymdev/bitkit-android#2032

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jvsena42 and others added 5 commits December 3, 2026 07:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spark can pay before the node runs, so the deferred validation on node
start skips a send that already reached a pending or result route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Spark payment can be submitted before the node runs, and its balance
then no longer covers it, so the overlay came back over the pending or
result screen. Skip it on the routes after submission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuickPay pays as soon as it shows, so it must still wait for the node
when Spark can't cover the payment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review December 3, 2026 13:49
@jvsena42
jvsena42 requested review from a team, ovitrif and piotr-iohk and removed request for a team December 3, 2026 13:49
@ovitrif ovitrif added this to the 3.2.0 milestone Dec 3, 2026
@ovitrif

ovitrif commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Placed in 3.2.0 for RC4: Send blocking Spark-payable invoices until the node runs (synonymdev/bitkit-android#2032 comment) was agreed into RC4 in the release thread, with its Android twin synonymdev/bitkit-android#2244. This PR closes no issue, so it carries the milestone.

@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge, with no outstanding findings from this review.

Summary

The PR lets users pick recipients and enter Spark-payable amounts before the node starts.

  • Send opens recipient and amount steps before the node is ready.
  • Late node events leave submitted payments on their current screen.
  • QuickPay waits for validation before choosing a payment route.
  • The Spending send limit uses Spark’s current capacity while the node is unavailable.

Reviews (6) · Last reviewed commit: "revert: let amount entry take spark whil..." · Reviewed by Greptile

@jvsena42
jvsena42 marked this pull request as draft December 3, 2026 14:03
jvsena42 and others added 3 commits December 3, 2026 11:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Verdict: ⛔️ Request changes

The PR moved to 2ef665b after this run; these results are for 88fe44e.

Findings:

  • MEDIUM — QuickPay skips Savings fallback before submission — Bitkit/Views/Wallets/Send/SendSheet.swift:631. .quickpay counts as past review while the sync screen still prevents it from submitting. For a unified invoice opened with the node down, no channels, insufficient Spark and enough Savings, startup skips deferred validation and QuickPay attempts the unfunded Lightning leg. Device-confirmed: a 20000-sat invoice failed with RouteNotFound despite 100000 sats in Savings; the same invoice reached Savings Amount with QuickPay disabled. Keep deferred validation until QuickPay actually starts. This adds device evidence to the existing finding.

QA for 88fe44e:

Tested on iPhone 17 Pro simulator, iOS 27.0, using regtest funds. These recordings use 88fe44e plus the startup hold shown below; playback is 2×.

Pay a fixed invoice through Spark before the node starts ✅ Review and Payment Pending stayed clear; settlement before startup was verified in Breez Spark’s stored payment history.

The 1000-sat payment was completed with a 6-sat fee before the hold was released. The recording shows Bitcoin Sent after startup was released; it does not claim that success UI appeared while held.

fixed-node-down-2x.2x.mp4

Pay an amountless invoice through Spark before the node starts ⏭️ Not driven before the head moved.

The run stopped after its current case when the PR moved to 2ef665b.

Clear the on-chain overlay when the node starts ✅ The connection overlay cleared to Savings Amount after explicit startup release.

onchain-node-start-2x.2x.mp4

Send Lightning with the node running ⏭️ Not driven before the head moved.

The run stopped after its current case when the PR moved to 2ef665b.

Fall back from QuickPay to Savings after node startup ❌ QuickPay attempted Lightning and showed Payment Failed instead of Savings Amount.

Both runs used the same unified 20000-sat invoice, no channels, insufficient Spark, and 100000 sats in Savings. The device log records node startup followed by RouteNotFound. The control video ends during startup; its final state was checked in the accessibility snapshot: Amount, SAVINGS (AssetButton-savings), 20 000, available 99 888, and enabled ContinueAmount.

QuickPay enabled: failure QuickPay disabled: startup
quickpay-fallback-failure-2x.2x.mp4
unified-quickpay-off-2x.2x.mp4
Test hook used by the recorded cases

Not pushed. Holds node startup before setup while Breez Spark starts normally, then waits for explicit release. It does not change payment routing or simulate a payment result. Because the hold precedes event-handler setup, fixed-invoice settlement was checked in Breez Spark’s stored history before release.

diff --git a/Bitkit/ViewModels/WalletViewModel.swift b/Bitkit/ViewModels/WalletViewModel.swift
index 723823c93..2ad4854fe 100644
--- a/Bitkit/ViewModels/WalletViewModel.swift
+++ b/Bitkit/ViewModels/WalletViewModel.swift
@@ -311,6 +311,16 @@ class WalletViewModel: ObservableObject {
         syncState()
         // Spark needs no node, so it starts alongside it and keeps running while the node stops.
         Task { await SparkManager.shared.start(walletIndex: walletIndex) }
+        #if DEBUG // test hook
+            let reviewHold = Env.appStorageUrl.appendingPathComponent("revd-hold-node") // test hook
+            if FileManager.default.fileExists(atPath: reviewHold.path) { // test hook
+                Logger.info("REVD: node startup held before setup", context: "ReviewHook") // test hook
+                while FileManager.default.fileExists(atPath: reviewHold.path) { // test hook
+                    try await Task.sleep(nanoseconds: 100_000_000) // test hook
+                } // test hook
+                Logger.info("REVD: node startup explicitly released", context: "ReviewHook") // test hook
+            } // test hook
+        #endif // test hook
         do {
             let electrumServerUrl = electrumConfigService.getCurrentServer().fullUrl
             let rgsServerUrl = rgsConfigService.getCurrentServerUrl()

Deciding observations:

Fixed invoice, before release: payment_type=send status=completed amount=1000 fees=6 method=lightning
QuickPay enabled: node startup held → explicitly released → Node started → Failed to send payment: RouteNotFound
QuickPay disabled: startup release → Savings Amount, 20000 sats

Recipient-screen coverage relies on the author’s exact-head evidence, rather than repeating those cases. Amountless entry/review evidence there does not establish completion; that case remains unrun here.

Coverage: full 63f39dc8..88fe44e, including the send helpers, their callers and tests. The helper tests and changelog received code review; no separate device case applies to those files. This report does not assess the newer 2ef665b head.

Twin: synonymdev/bitkit-android#2244 matches the recipient, amountless and submitted-payment overlay intent; the iOS QuickPay startup path above breaks Savings fallback.


Reviewed by gpt-6.1-sol-high

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Verdict: ⚠️ Not verified — draft PR.

Findings: Not assessed. The delta from 88fe44e to ae9bead was deferred because this PR is a draft; the repository’s reviewer rules require waiting until it is ready for review. The previous finding has not been reverified.

QA for ae9bead: No build, unit tests or device cases ran. No earlier result is presented as validation of this head.

Twin: synonymdev/bitkit-android#2244; parity was not reassessed in this deferred run.


Reviewed by gpt-6.1-sol-high

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Verdict: ⚠️ Not verified — draft PR.

Findings: Not assessed. The delta from ae9bead to 8f11931 was deferred because this PR is still a draft; the repository’s reviewer rules require waiting until it is ready for review. The previous findings have not been reverified.

QA for 8f11931: No build, unit tests or device cases ran. No earlier result is presented as validation of this head.

Twin: synonymdev/bitkit-android#2244; parity was not reassessed in this deferred run.


Reviewed by gpt-6.1-sol-high

@jvsena42
jvsena42 marked this pull request as ready for review December 3, 2026 17:14
@jvsena42
jvsena42 requested a review from a team December 3, 2026 17:14
@jvsena42
jvsena42 marked this pull request as draft December 3, 2026 17:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Verdict: ⚠️ Not verified — draft PR.

Findings: Not assessed. The delta from 384ce62 to d547026 was deferred because this PR is still a draft; the repository’s reviewer rules require waiting until it is ready for review. The previous findings have not been reverified.

QA for d547026: No build, unit tests or device cases ran. Manual cases 1–5 and the prior review’s follow-up cases were not driven because the review was deferred. No earlier result is presented as validation of this head.

Twin: synonymdev/bitkit-android#2244; parity was not reassessed in this deferred run.



Reviewed by gpt-6.1-sol-high

@jvsena42
jvsena42 marked this pull request as ready for review December 3, 2026 18:49

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

QA review

Scope: follow-up on iOS #1578 from 88fe44ed to d547026b. The verified baseline supplies unchanged recipient-step, amountless-invoice predicate, and changelog coverage.

3 actionable findings — resolve or provide an evidence-backed rebuttal.

Focused Swift checks using the pinned helper implementations confirmed that a Quick Pay retry can inherit the original attempt's hold and that a Spark-only refresh can preserve an inflated Spending limit on upgrade. The iOS app suite was unrun locally. The matching unit-test run was still in progress at the final check. The PR description contains earlier fix notes alongside the manual checklist. The checklist informed the runtime plan, and findings were verified against pinned source.

Compared recipient and amount entry, Quick Pay gating, and cancellation at Android #2244, 37f8ec48. Android cancels a typed invoice's node wait when leaving the address step and uses live Spark capacity for amountless entry while the node is down. The Appium source at 9a64fa31 checks the Spark recipient amount and normal Quick Pay success, with no assertion for a cold-start Quick Pay retry.

Device testing was not performed in this review. The runtime plan retains all five author cases.

Suggested additional test cases

  • On iOS with funded Spark and a channel that can reconnect, start a Lightning-only Quick Pay while the node is starting. Let Spark release the hold, make the first attempt fail, then bring the channel online with insufficient Spark balance for the retry. Tap Try Again and verify that the ready channel can be used without a connection timeout.
  • On iOS, upgrade a wallet with no channels and a cached Spending limit. While node balances are unavailable, let a Spark credit raise the limit, then spend part of the balance and open another amountless invoice. Verify that Available and the amount cap fall with the current Spark capacity.

Earlier findings reconciled at this revision: 3 verified fixed.

Findings

  • [MEDIUM] Release Quick Pay retries once the channel is ready — inline at Bitkit/Views/Wallets/Send/SendSheet.swift:514.

  • [MEDIUM] Keep Spark refreshes from inflating the legacy Spending limit — inline at Bitkit/ViewModels/WalletViewModel.swift:1485.

  • [LOW] Move the connecting journey's overlay check to Amount — With the node starting, the iOS on-chain connecting journey still expects the sync overlay immediately after opening Send. The pinned recipient guard would show the recipient screen instead, causing the journey to fail on the intended behavior. Update it to assert that the recipient screen is available, enter a valid on-chain address, then assert that the Bitcoin overlay appears on Amount and clears when the node runs. Source analysis agrees with author cases 1 and 4.

    Source. Summary placement: The obsolete assertion is in an unchanged journey file.

Reviewer model: gpt-6.2-sol
Reasoning effort: high

Comment thread Bitkit/ViewModels/WalletViewModel.swift Resolved
@piotr-iohk

Copy link
Copy Markdown
Collaborator

The connecting journey from the review summary is updated in 5ec8c06b. J1 opens Recipient with startup held, pastes an on-chain address, checks the Bitcoin connecting overlay on Amount, then releases startup and checks that Amount is usable. XML parsing passed. Device execution is pending. The two inline findings have replies in their original threads.

@piotr-iohk

Copy link
Copy Markdown
Collaborator

@greptileai please review the updated head 5ec8c06, including the QuickPay retry and legacy Spending limit fixes.

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

Reviewed 5ec8c06. Three Low defects affect Send during startup and reconnection.

  • Low · A subscription retry can stay on Failure after the channel reconnects. If the first payment fails while resolving the recipient’s list, retrying after the list becomes available can stage Confirm while Failure remains visible. With Spark’s send rail detached during an exit and its payment history still readable, a disconnected LDK peer makes validation wait. When the peer reconnects, the guard treats the old Failure screen as a submitted payment and skips the retry. The user has to tap Retry again. See SendSheet.swift:692–695 and SendSheet.swift:1880–1884.
  • Low · Switching to Savings during startup clears the entered amount. Open a unified invoice with neither leg specifying an amount, enter an amount from Spending, then switch to Savings before the node starts. The connecting screen replaces Amount and discards its draft. When Amount returns, the field is empty. See SendSheet.swift:488, SendSheet.swift:719–733 and SendAmountView.swift:771–784.
  • Low · Manual entry keeps using the balance captured when the invoice was entered. If Enter Manually opens during startup and the initial balance is too low, Continue stays disabled after a refresh makes the invoice payable. This affects a fixed BOLT11 after Spending refreshes and a fixed BIP21 after Savings or its Lightning fallback becomes affordable. Editing the input triggers a fresh check. See SendEnterManuallyView.swift:19–38, SendEnterManuallyView.swift:63–81, AppViewModel.swift:1783–1788 and AppViewModel.swift:1815–1827.
Review details

Quick review: Claude Opus 5.5, high reasoning effort
General review: GPT-6.2 Sol, high reasoning effort
Verification: GPT-6.2 Sol, high reasoning effort

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

Verdict: ⛔️ Request changes

Findings:

  • MEDIUM — Keep the sync overlay off an ordinary send once submission starts — Bitkit/Views/Wallets/Send/SendSheet.swift:467. An ordinary Confirm send is still on .confirm while flow.isSubmittingPayment is true. When Spark debits it, the remaining balance may no longer cover the invoice, so this route-only guard brings Connecting back until Pending. Reproduced on this head with both a 1,000-sat amountless invoice and a 500,000-sat fixed invoice: Spark had completed payment, but Connecting covered the send for about 10 seconds while the node was still starting. Use the existing hasSubmittedPayment predicate here so ordinary in-flight submissions receive the same protection as the late-readiness callbacks.

QA for 5ec8c06:

Built the pinned head with Xcode 27.0. Recorded on iPhone 17 Pro 2x, iOS 27.0, using local regtest funds. Recordings use the test hook below and play at 2×.

Open Recipient and clear the on-chain overlay on Amount ✅ Recipient was usable while startup was held; the on-chain overlay cleared to usable Savings Amount after release.

J1, also covering manual cases 1 and 4. The number pad accepted input, and dragging the header closed Send.

j1-2x.2x.mp4

j1-close-2x.2x.mp4

Pay an amountless invoice through Spark before node startup ❌ Spark completed the payment, but Connecting covered submission for about 10 seconds before Pending.

Manual case 3. Amount entry and Confirm were clear. Before startup release, Spark history showed 1,000 sats completed with a 6-sat fee. Payment Pending appeared after the overlay; startup release then showed Bitcoin Sent.

amountless-2x.2x.mp4

Send Lightning through a usable channel ✅ The usable channel paid a 1,500-sat invoice.

Manual case 5. Spark stayed at 964 sats, below the invoice amount; channel outbound capacity fell by 1,500 sats and Bitcoin Sent appeared.

channel-send-2x.2x.mp4

Retry QuickPay through a channel after Spark releases startup ✅ Try Again paid through the ready channel after Spark released the first attempt.

Manual case 6. A brief provider outage induced the first QuickPay failure while the node was starting. After restoring the provider, a real 20,000-sat Spark debit plus its 82-sat fee left 882 sats. With the channel usable, Try Again paid the 1,000-sat invoice without a connection timeout.

quickpay-retry-2x.2x.mp4

Refresh a legacy Spending limit after Spark credit and debit ✅ Available and the amount cap fell after a real Spark debit.

Manual case 7. The hook seeded a legacy 1,000-sat channel floor and held node setup. A 9,000-sat Spark credit made the send limit 8,977. A real 7,000-sat send with a 30-sat fee reduced the limit to 1,965; Available showed 1,954 after its routing reserve. The pad refused 9,000 before the debit and 2,000 afterward. The original 1,000-sat floor stayed separate.

legacy-limit-2x.2x.mp4

Keep a submitted Spark payment visible when a channel becomes usable ❌ Late channel readiness preserved the paid result, but fixed-invoice submission reproduced the same overlay defect.

Manual case 8, also exercising the fixed-invoice payment in case 2. Spark completed 500,000 sats with a 2,002-sat fee before node startup was released, leaving 98,880 sats. Once Pending appeared, releasing startup made the channel usable and showed Bitcoin Sent. Channel outbound capacity was 391,840 sats, also below the paid amount, so the late guard held despite neither rail being able to pay it again. The earlier submission phase showed Connecting for about 10 seconds, as in case 3.

late-channel-2x.2x.mp4

Test hook and deciding observations

Not pushed. The hook holds node and Spark startup until explicit release, seeds the legacy limit, records state, and stages a real local channel and Spark debits. Payments use the real Spark and Lightning implementations.

diff --git a/Bitkit/ViewModels/WalletViewModel.swift b/Bitkit/ViewModels/WalletViewModel.swift
index 9c7f2bd5..10773d46 100644
--- a/Bitkit/ViewModels/WalletViewModel.swift
+++ b/Bitkit/ViewModels/WalletViewModel.swift
@@ -311,8 +311,40 @@ class WalletViewModel: ObservableObject {
         }
 
         syncState()
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVD_CONTROL"] == "true" { // test hook
+                electrumConfigService.saveServerConfig(ElectrumServer(host: "127.0.0.1", port: 35001, protocolType: .tcp)) // test hook
+                reviewControlStart() // test hook
+                if FileManager.default.fileExists(atPath: Env.appStorageUrl.appendingPathComponent("revd-legacy").path) { // test hook
+                    maxSendChannelSats = -1 // test hook
+                    maxSendLightningSats = 1000 // test hook
+                    try? FileManager.default.removeItem(at: Env.appStorageUrl.appendingPathComponent("revd-legacy")) // test hook
+                } // test hook
+            } // test hook
+        #endif // test hook
         // Spark needs no node, so it starts alongside it and keeps running while the node stops.
-        Task { await SparkManager.shared.start(walletIndex: walletIndex) }
+        Task { // test hook
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVD_CONTROL"] == "true" { // test hook
+                    while FileManager.default.fileExists(atPath: Env.appStorageUrl.appendingPathComponent("revd-hold-spark").path) { // test hook
+                        try? await Task.sleep(nanoseconds: 100_000_000) // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
+            await SparkManager.shared.start(walletIndex: walletIndex) // test hook
+        } // test hook
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVD_CONTROL"] == "true" { // test hook
+                let hold = Env.appStorageUrl.appendingPathComponent("revd-hold-node") // test hook
+                if FileManager.default.fileExists(atPath: hold.path) { // test hook
+                    Logger.info("REVD startup held before setup", context: "ReviewControl") // test hook
+                    while FileManager.default.fileExists(atPath: hold.path) { // test hook
+                        try await Task.sleep(nanoseconds: 100_000_000) // test hook
+                    } // test hook
+                    Logger.info("REVD startup explicitly released", context: "ReviewControl") // test hook
+                } // test hook
+            } // test hook
+        #endif // test hook
         do {
             let electrumServerUrl = electrumConfigService.getCurrentServer().fullUrl
             let rgsServerUrl = rgsConfigService.getCurrentServerUrl()
@@ -2192,3 +2224,54 @@ struct SparkReadinessTransition {
         return isReady && !wasReady
     }
 }
+
+#if DEBUG // test hook
+extension WalletViewModel { // test hook
+    private func reviewControlStart() { // test hook
+        Task { @MainActor [weak self] in // test hook
+            let deadline = Date().addingTimeInterval(10800) // test hook
+            let dir = Env.appStorageUrl // test hook
+            while let self, Date() < deadline, !Task.isCancelled { // test hook
+                let commandURL = dir.appendingPathComponent("revd-command") // test hook
+                if let command = try? String(contentsOf: commandURL).trimmingCharacters(in: .whitespacesAndNewlines) { // test hook
+                    try? FileManager.default.removeItem(at: commandURL) // test hook
+                    do { // test hook
+                        if command.hasPrefix("open:") { // test hook
+                            let peer = try LnPeer(connection: String(command.dropFirst(5))) // test hook
+                            _ = try await lightningService.openChannel(peer: peer, channelAmountSats: 500000, pushToCounterpartySats: 100000) // test hook
+                        } else if command.hasPrefix("spend:") { // test hook
+                            let invoice = String(command.dropFirst(6)) // test hook
+                            _ = try await SparkManager.shared.send(bolt11: invoice, sats: nil, maxFeeSats: nil, // test hook
+                                recheckBeforeSubmission: {}, beforeSubmission: {}) // test hook
+                        } else if command == "refresh" { // test hook
+                            await SparkManager.shared.refreshState() // test hook
+                            await updateBalanceState() // test hook
+                        } // test hook
+                    } catch { // test hook
+                        Logger.error("REVD command error: \(error)", context: "ReviewControl") // test hook
+                    } // test hook
+                } // test hook
+                let spark = SparkManager.shared // test hook
+                let data: [String: Any] = [ // test hook
+                    "node": String(describing: nodeLifecycleState), // test hook
+                    "nodeId": lightningService.nodeId ?? "", // test hook
+                    "savingsAddress": onchainAddress, // test hook
+                    "savings": totalOnchainSats, // test hook
+                    "sparkReady": spark.isReady, // test hook
+                    "sparkBalance": spark.balanceSats, // test hook
+                    "sparkSendable": spark.sendableSats, // test hook
+                    "spendingLimit": maxSendLightningSats, // test hook
+                    "channelLimit": maxSendChannelSats, // test hook
+                    "usable": hasUsableChannels, // test hook
+                    "channels": (channels ?? []).map { ["id": $0.channelId.description, "ready": $0.isChannelReady, // test hook
+                        "usable": $0.isUsable, "outbound": $0.outboundCapacityMsat] as [String: Any] } // test hook
+                ] // test hook
+                if let encoded = try? JSONSerialization.data(withJSONObject: data, options: [.sortedKeys]) { // test hook
+                    try? encoded.write(to: dir.appendingPathComponent("revd-state.json"), options: .atomic) // test hook
+                } // test hook
+                try? await Task.sleep(nanoseconds: 500_000_000) // test hook
+            } // test hook
+        } // test hook
+    } // test hook
+} // test hook
+#endif // test hook
Amountless: Spark completed 1000 sats, fee 6; node still starting; Spark balance 964.
Overlay: true (node starting) -> 9.877 seconds -> false (node starting), then Pending.
QuickPay retry: Spark balance 882; node running; channel usable; Bitcoin Sent 1000 sats.
Fixed invoice: Spark completed 500000 sats, fee 2002; node still starting; Spark balance 98880.
After startup release: channel usable, outbound 391840 sats; Bitcoin Sent 500000 sats.

No planned runtime case was left unrun. The full unit suite was not rerun here; regression-test edits received source review and rely on the author’s exact-head simulator evidence.

Reports relied on:

Coverage: delta d547026..5ec8c06, prior open submission/fallback findings, and previously unverified runtime cases. Changes inherited from the merge of master were separated from the PR-owned patch. The regression-test files and changelog received source review; no separate device case applies to those files.

Twin: synonymdev/bitkit-android#2244, compared at 37f8ec4, matches the recipient and amountless-entry intent. QuickPay retry and late-readiness callbacks use iOS-specific paths.


Reviewed by gpt-6.1-sol-high

@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

  • Amount caps an amountless invoice at Spark while channels reconnect (Bitkit/Views/Wallets/Send/SendSheet.swift:488)
  • Skipped node-start validation is never re-run when the send is retried (Bitkit/Views/Wallets/Send/SendSheet.swift:676)
  • J1 needs node startup held and released, which no capability provides (journeys/send/onchain-connecting-view.xml:9)
  • QuickPay retries can skip the funded on-chain fallback (Bitkit/Views/Wallets/Send/SendSheet.swift:1737-1740)

nits

  • Doc comment for the post-submission routes sits on quickPaySessionID (Bitkit/Views/Wallets/Send/SendSheet.swift:501)

the reviewers disagree, your call

  • PR description disagrees with the code in two places (general). Objection: The code uses max and allows Spark to release held QuickPay, but I could not retrieve the PR description. I cannot confirm the alleged wording mismatches. Answer: I fetched the body at head 5ec8c06 with gh pr view 1578. It says the no-node Spending limit is "the channel limit from the last run plus Spark's current sendable amount", but WalletViewModel.swift:1488 returns max(channelSats, isExiting ? 0 : Int(sparkSendableSats)), and the test at ChannelFreeRailTests.swift:2405 expects 9000 (not 10000) for channels 1000 and Spark 9000. The body's Out of Scope also says the Quick Pay sync view stays because it needs the node, but SendSheet.swift:471-476 (from d547026) releases the QuickPay hold when sparkCanPayScannedInvoice is true, and the body's own Evidence at d547026 reports the overlay dropping and QuickPay paying through Spark before the node started.

hasAnyChannels: (wallet.channels?.isEmpty == false) || wallet.channelCount > 0,
hasUsableChannels: wallet.hasUsableChannels,
sparkCanPay: sparkCanPayScannedInvoice
sparkCanPay: sparkCanPayScannedInvoice || (route == .amount && sparkTakesScannedAmount)

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.

worth doing, does not block: Amount caps an amountless invoice at Spark while channels reconnect

Since sparkTakesScannedAmount (SendSheet.swift:488), Amount for an amountless invoice shows whenever Spark has any balance. That now includes the window after the node runs but before a channel is usable. In that window updateBalanceState takes its success path. calculateMaxSendLightning (BalanceManager.swift:349) counts only usable channels, so maxSendLightningSats becomes Spark's sendable amount and maxSendChannelSats is overwritten with 0 (WalletViewModel.swift:1445). SendAmountView caps input at that value (SendAmountView.swift:115, :169), so an amount the channel could pay a few seconds later gets the "amount exceeded" toast. Before this PR, waitsForNode (hasAnyChannels and no usable channel) held Amount behind the overlay until a channel was usable. A related limit: the new catch path only runs while node == nil. Once setup builds the node, refreshCache queues behind node.start() on the serial ldk-queue (LightningService.swift:630, :2725). A Spark-triggered refresh during start therefore waits instead of applying the new limit. Found by reading the code; I did not reproduce it on a device. Example: a 100k channel and 10k in Spark. Cold start and open an amountless invoice before the peer reconnects. Available reads about 10k, and typing 50k is refused.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 5e67a31. While the node runs but its channels aren't usable yet (isReconnecting), Amount no longer takes the amount from Spark alone, so it waits behind the overlay until a channel is usable, as before this PR. With the node not running, the Spark bypass stays, and the cap is the larger of the channel snapshot and Spark. I haven't changed the refreshCache queueing behind node.start(): with this hold, the Spark-only limit isn't used in that window. Not device-verified, because my local channel never becomes usable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correction: I reverted 5e67a31 in 6ca0c1a. Holding Amount while channels reconnect left the overlay stuck for an amountless unified invoice with Spark funds (the timeout validation succeeded, but the hold kept waiting for channels; Greptile's P1), and it dropped an amount typed when the node started. I'm keeping the behavior you described: while channels reconnect, Available reads Spark's amount, and an amount above it is refused until a channel is usable and the next balance refresh lifts the cap. A cap that lifts within seconds seemed better than an overlay that can stay up. Leaving this open for your call.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Confirmed the behavior described in the correction at 6ca0c1a: during real peer disconnection, Available showed Spark capacity (837 sats); once the channel became usable it rose to 393,969 without losing the 123-sat draft. Leaving the acknowledged cap tradeoff open for the existing discussion. The reconnect recording is in the review.

guard hasScannedInvoice else { return }

// Spark can pay before the node runs, so a send may already be paying or settled when it starts
guard !hasSubmittedPayment else { return }

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.

worth doing, does not block: Skipped node-start validation is never re-run when the send is retried

onChange(of: wallet.nodeLifecycleState) now returns early while hasSubmittedPayment is true (SendSheet.swift:676), and nothing re-arms the validation afterwards. Suppose a Spark payment fails while the node is starting. Try Again from Failure goes back to Confirm through resetNavigationForRetry (SendSheet.swift:1719), with hasValidatedAfterSync still false, and the node state will not change again. A unified invoice that Spark can no longer pay, on a wallet without channels, then retries Lightning instead of falling back to on-chain. A pure Lightning invoice fails again instead of showing the insufficient-spending toast. 5ec8c06 re-validates only a QuickPay that had waited behind the overlay (wasAwaitingValidation). A QuickPay that Spark could pay from the start has the same gap. I traced this through the code and did not run it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in ee5eabd, which also covers the QuickPay retry thread. Every retry (resetNavigationForRetry, Confirm or QuickPay) now runs the node-start validation it skipped, when the node is already running, validation hasn't run, the sheet isn't waiting for the node, and Spark can't pay (revalidatesRetry). If it's still waiting, the node-start or channel callback validates later, since the send no longer counts as submitted. A unified invoice Spark can't pay falls back to Savings, and a Lightning-only one gets the insufficient-spending toast. Test: testARetryRunsTheNodeStartValidationItSkipped.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

At 6ca0c1a, fixed 1,000-sat unified invoices now revalidate on both ordinary and QuickPay retries: after a real Spark debit made them unaffordable and the node was running without channels, Try Again opened Savings Amount. The broader amountless case remains open: the validator still uses the encoded zero instead of the entered amount, as reported in #1578 (comment). Both fixed-amount retry recordings are in the review.

@jvsena42
jvsena42 marked this pull request as draft December 4, 2026 09:32
jvsena42 and others added 5 commits December 4, 2026 06:42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Verdict: ⚠️ Not verified — draft PR.

Findings: Not assessed. The delta from 5ec8c06 to ebe718b is deferred because this PR is a draft; the repository's reviewer rules require waiting until it is ready for review. The previous finding has not been reverified.

QA for ebe718b: No device cases or unit tests ran. The build was stopped before completion. No earlier result is presented as validation of this head.

Twin: synonymdev/bitkit-android#2244; parity was not reassessed in this deferred run.


Reviewed by gpt-6.1-sol-high

@jvsena42
jvsena42 marked this pull request as ready for review December 4, 2026 10:25
@jvsena42
jvsena42 requested review from a team and coreyphillips December 4, 2026 10:25
@jvsena42
jvsena42 marked this pull request as draft December 4, 2026 10:30
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review December 4, 2026 10:33

@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 6 new commits (425fa8f, 5c88784, 5e67a31, and 3 more). Nothing blocking remains.

addressed

  • J1 needs node startup held and released, which no capability provides (journeys/send/onchain-connecting-view.xml:9). Fixed: onchain-connecting-view.xml:10-12 now holds the node with -E2E_LOCAL_HOST=127.0.0.2 and drops the release step. The README row at journeys/README.md:177 names the same mechanism. Env.electrumServerUrl (Env.swift:238-240) uses that host in E2E local-backend builds, which is the standard journey build in journeys/README.md:96-100. The XML parses.
  • Doc comment for the post-submission routes sits on quickPaySessionID (Bitkit/Views/Wallets/Send/SendSheet.swift:501). Fixed: SendSheet.swift:500 now has its own comment on quickPaySessionID. The post-submission text moved to isPastSubmission at :522-523.
  • QuickPay retries can skip the funded on-chain fallback (Bitkit/Views/Wallets/Send/SendSheet.swift:1737-1740). Fixed: The retry no longer depends on wasAwaitingValidation (SendSheet.swift:1736-1749). I traced it: beginQuickPayRetry clears hasValidatedAfterSync and bumps the session, so isAttached is false and hasSubmittedPayment is false. With the node running and no channels the overlay is off, so revalidatesRetry runs validation. For a unified invoice Spark can't pay, it replaces the QuickPay root at :1114-1116 before the new QuickPay view can appear and pay. resetQuickPay does not clear the scanned invoice. I did not run this on a device.

still open

  • Amount caps an amountless invoice at Spark while channels reconnect (Bitkit/Views/Wallets/Send/SendSheet.swift:488). Since sparkTakesScannedAmount (SendSheet.swift:488), Amount for an amountless invoice shows whenever Spark has any balance. That now includes the window after the node runs but before a channel is usable. In that window updateBalanceState takes its success path. calculateMaxSendLightning (BalanceManager.swift:349) counts only usable channels, so maxSendLightningSats becomes Spark's sendable amount and maxSendChannelSats is overwritten with 0 (WalletViewModel.swift:1445). SendAmountView caps input at that value (SendAmountView.swift:115, :169), so an amount the channel could pay a few seconds later gets the "amount exceeded" toast. Before this PR, waitsForNode (hasAnyChannels and no usable channel) held Amount behind the overlay until a channel was usable. A related limit: the new catch path only runs while node == nil. Once setup builds the node, refreshCache queues behind node.start() on the serial ldk-queue (LightningService.swift:630, :2725). A Spark-triggered refresh during start therefore waits instead of applying the new limit. Found by reading the code; I did not reproduce it on a device. Example: a 100k channel and 10k in Spark. Cold start and open an amountless invoice before the peer reconnects. Available reads about 10k, and typing 50k is refused. 5e67a31 was reverted by 6ca0c1a, so SendSheet.swift:487 still lets Spark alone take the amount while channels reconnect. The success path at WalletViewModel.swift:1445 still overwrites maxSendChannelSats with the usable-only 0, so Amount stays capped at Spark until the next balance refresh. The refreshCache-behind-node.start part is unchanged too. The revert reason holds, but the response accepts the behaviour; it does not show it is wrong. To close this, either keep the last channel snapshot while channels exist but none is usable, or defer it with an issue and an Out of Scope bullet.
  • Skipped node-start validation is never re-run when the send is retried (Bitkit/Views/Wallets/Send/SendSheet.swift:676). onChange(of: wallet.nodeLifecycleState) now returns early while hasSubmittedPayment is true (SendSheet.swift:676), and nothing re-arms the validation afterwards. Suppose a Spark payment fails while the node is starting. Try Again from Failure goes back to Confirm through resetNavigationForRetry (SendSheet.swift:1719), with hasValidatedAfterSync still false, and the node state will not change again. A unified invoice that Spark can no longer pay, on a wallet without channels, then retries Lightning instead of falling back to on-chain. A pure Lightning invoice fails again instead of showing the insufficient-spending toast. 5ec8c06 re-validates only a QuickPay that had waited behind the overlay (wasAwaitingValidation). A QuickPay that Spark could pay from the start has the same gap. I traced this through the code and did not run it. Codex still sees it: Retries now call validation at SendSheet.swift:1741-1748, but :1080-1081 still checks an amountless invoice as zero instead of wallet.sendAmountSats. Executing the extracted routing code with 1,000 sats entered, 100 left in Spark, no channels and funded Savings retained Lightning without fallback or the insufficient-spending toast.
  • PR description disagrees with the code in two places. The description says the no-node Spending limit is the last channel limit "plus" Spark's sendable amount. maxSendLightningWithoutNode takes the max, which is the right rule for a one-rail payment. Out of Scope also says the QuickPay sync view stays, but since d547026 Spark releases a held QuickPay without the node. The current description still calls the no-node Spending limit the last channel limit "plus" Spark's sendable amount, but WalletViewModel.swift:1488 takes max. Out of Scope still says the Quick Pay sync view stays because it needs the node, but SendSheet.swift:470-476 releases a held QuickPay when Spark can pay. The body's own evidence shows QuickPay paying through Spark before the node started.

new since the last review

nits

  • J1 cites a PR-scoped QA ID that means nothing once merged (journeys/send/onchain-connecting-view.xml:11)

Precondition: onboarded dev wallet with no Lightning channels. Start on the wallet home screen.
Precondition: onboarded regtest wallet with confirmed Savings and no channels. Copy another
regtest wallet's on-chain address without an amount. Launch with `-E2E_LOCAL_HOST=127.0.0.2`
so the node cannot start (relaunching without it releases startup). Manual test 4 checks that

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.

nit: J1 cites a PR-scoped QA ID that means nothing once merged

The journey description says "Manual test 4 checks that the overlay clears once the node runs" (journeys/send/onchain-connecting-view.xml:11-12). "Manual test 4" is an ID from this PR's QA Notes. After merge, a reader of the journey has no way to find what it refers to. Describe the check itself, or say it is a manual step outside the journey because releasing the hold needs a relaunch.

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

QA review

Scope: full PR diff against its merge base at 6ca0c1a, reassessed as requested for PR #1578.

1 actionable finding — resolve or provide an evidence-backed rebuttal.

Compared recipient entry, amount limits, funding-source selection, QuickPay and result screens with Android #2244 at e5826ce. Android keeps navigation mounted during the overlay and uses current Spark capacity alone for amountless entry while the node is down. The iOS Appium gate covers manual validation, funding-source switches and QuickPay after channel setup. That setup leaves startup transitions untested. Pinned Appium source at 9a64fa3

Swift syntax parsing, journey XML parsing and git diff --check passed locally. A focused Swift probe using the pinned affordability predicates confirmed that a 997-sat Spark limit accepts the encoded zero while rejecting an entered 5,000 sats. The matching iOS unit workflow was still in progress at handoff. The PR description included historical round notes alongside its requirements. Finding evidence comes from the pinned source and the local probe.

Device testing: not performed in this review. The runtime plan retains J1 and all eight author manual cases. J1 checks overlay placement. Manual case 4 needs a startup hold that can be released without relaunching, so it can observe the overlay clearing in the same Send sheet.

Suggested additional test cases

  • iOS, with funded Savings, a cached channel limit above Spark capacity and the peer held offline, enter an amount between the two limits on an amountless unified invoice. Start the node and keep the peer offline through the timeout. Verify the sheet offers Savings and makes no Lightning attempt.
  • iOS, retry a failed initial subscription payment while its Lightning channel reconnects and Spark cannot pay. Restore the channel and verify the retry advances to review without another retry tap or duplicate submission.
  • iOS, with the node held down and Spark funded, type an amount on an amountless unified invoice and switch to Savings. Release startup and verify Amount still shows the draft. With a fixed Lightning invoice, also check that a Spark balance refresh enables Manual's Continue without editing the invoice again.

Earlier findings reconciled at this revision: 2 still present, 10 verified fixed, 1 duplicate.

Three concerns from the earlier review remain on this revision:

  • An embedded subscription retry can remain on the old Failure screen after the channel reconnects.
  • Switching to Savings during startup discards an unsubmitted amount.
  • Manual entry can keep Continue disabled after a balance refresh makes an unchanged invoice payable.

Findings

  • [MEDIUM] Validate the entered amount before releasing the sync wait — inline at Bitkit/Views/Wallets/Send/SendSheet.swift:487.

Existing concerns

  • [LOW] Revalidate manually entered invoices when Spending becomes available — Manual entry can keep Continue disabled after a balance refresh makes an unchanged invoice payable.
  • [LOW] Account for the temporary Spark-only cap during channel reconnect — After the node starts with every channel still disconnected, Amount can appear for an amountless invoice while Spark is funded. Once balance derivation succeeds with no usable channel, the form would refuse an amount above Spark's capacity until a channel reconnects and balances refresh. The author reverted the reconnect hold because it introduced an indefinite wait and draft loss, and explicitly left this trade-off open. The existing discussion records the current behavior. A separate observation in the thread concerns refresh queueing behind node startup, which is present at the merge base.
  • [LOW] Describe J1's manual follow-up in the journey itself — The journey still describes the expected clearing behavior, but a future reader cannot locate the separate manual procedure from its PR-scoped number alone. The prior discussion remains open. State in the journey that clearing is checked manually with startup released in the same Send sheet, or link the manual procedure.

Reviewer model: gpt-6.2-sol
Reasoning effort: high

hasAnyChannels: (wallet.channels?.isEmpty == false) || wallet.channelCount > 0,
hasUsableChannels: wallet.hasUsableChannels,
sparkCanPay: sparkCanPayScannedInvoice
sparkCanPay: sparkCanPayScannedInvoice || (route == .amount && sparkTakesScannedAmount)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[MEDIUM] Validate the entered amount before releasing the sync wait

With a cached channel limit above Spark capacity, enter an amount between the two limits on an amountless unified invoice before the node starts. If the node starts and the channel stays disconnected, the timeout runs deferred validation. The overlay checks the entered amount, but deferred validation checks the BOLT11 invoice's encoded zero. Any positive Spark capacity makes that check succeed and marks validation complete. The sheet would keep showing the sync overlay while the peer stays offline, with no Savings fallback. Use the entered amount for deferred validation once the payer has supplied it. Source analysis and a focused Swift affordability probe. Deferred validation

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Device-confirmed at 6ca0c1a. Entered 200,000 sats while cached channel capacity was 393,469 and Spark sendable was 98,088. After Continue and node startup, the peer stayed disconnected and Connecting remained visible more than 82 seconds later, despite 999,844 sats in Savings. Hook state confirmed a running node, unusable channel and channel limit zero. The amountless-timeout recording is in the review. The encoded-zero validation at line 1080 explains the mismatch with the overlay, which reads the entered amount. This remains open.

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

Verdict: ⛔️ Request changes

Reaudit: diff, 1 file, plus the earlier open submission and retry findings.

Findings:

  • MEDIUM — Entered amount is ignored by deferred validation. Bitkit/Views/Wallets/Send/SendSheet.swift:487 reaches validation at line 1080, which uses the amountless invoice's encoded zero. A 200,000-sat entry stayed behind Connecting more than 82 seconds after node startup, with 98,088 sats sendable through Spark, an unusable channel, and 999,844 sats in Savings. This adds device evidence to the existing finding. The same validator is reached by ordinary and QuickPay retries; those amountless retry variants were checked in source, not driven here.
  • LOW — Switching to Savings loses the unsubmitted amount. Bitkit/Views/Wallets/Send/SendSheet.swift:487 allows early Amount entry, but switching funding source replaces its navigation stack with the sync screen. The locally held 12,345-sat draft returned as zero after startup. This adds device evidence to the earlier review.

QA for 6ca0c1a:

Tested on an iPhone 17 Pro simulator, iOS 27.0, using local regtest and real Breez Spark and LDK payments. The Debug builds included the unpushed startup controls shown below. The local stack was needed to hold startup, interrupt the channel peer, induce a provider outage and stage real balance changes.

Keep a fixed Spark payment visible through startup and channel readiness ✅ Submission stayed uncovered and reached Bitcoin Sent after startup.

Spark completed 500,000 sats with a 2,002-sat fee before node startup was released (SDK history). Confirm and Pending stayed uncovered. After release the channel became usable and Bitcoin Sent remained visible, although Spark had only 98,334 sats and channel outbound was 393,840.

fixed-late-channel-2x.2x.mp4

Used the unpushed node and spark startup control below.

Retry QuickPay through a channel after Spark releases startup ✅ Try Again paid through the usable channel after Spark became insufficient.

QuickPay waited while both starts were held. Spark readiness released it before node startup; the provider outage induced Failure. A real 500-sat Spark send plus 4-sat fee left 336 sats. With the channel ready, Try Again paid the 500-sat invoice: Bitcoin Sent appeared, Spark stayed at 336 and channel outbound fell by 500 sats.

channel-retry-2x.2x.mp4

Used the unpushed node and spark startup control below.

Retry an ordinary unified invoice through Savings after Spark becomes insufficient ✅ Try Again opened Savings Amount for the fixed invoice.

After an induced provider failure while startup was held, a real 19,000-sat Spark send plus 78-sat fee left 922 sats. With the node running and no channels, Try Again opened Savings Amount for 1,000 sats.

ordinary-retry-2x.2x.mp4

Used the unpushed node startup control below.

Retry QuickPay through Savings after Spark becomes insufficient ✅ QuickPay retry opened Savings Amount for the fixed invoice.

QuickPay started automatically with Spark ready and the node held. After its induced failure, a real 20,000-sat send plus 82-sat fee left 840 sats. With the node running and no channels, Try Again opened Savings Amount for 1,000 sats.

quickpay-retry-2x.2x.mp4

Used the unpushed node startup control below.

Keep amountless entry and typed digits while channels reconnect ✅ The draft and number pad stayed usable through peer disconnection.

An amountless unified invoice kept 123 sats through node startup and over a minute of real channel disconnection. Available showed 837, the number pad remained responsive, and reconnecting the channel raised Available to 393,969 without losing the digits. Node and channel states were checked through the hook.

reconnect-amount-2x.2x.mp4

Used the unpushed node startup control below.

Fall back to Savings when an entered amount exceeds Spark during reconnect ❌ Connecting remained visible beyond the timeout instead of offering Savings.

Entered 200,000 sats while cached channel capacity was 393,469 and Spark sendable was 98,088. After node startup and more than 82 seconds with the peer disconnected, Connecting to Network still covered the sheet instead of opening Savings, which held 999,844 sats. Hook state confirmed running node, unusable channel and channel limit zero.

amountless-timeout-2x.2x.mp4

Used the unpushed node and spark startup control below.

Keep an unsubmitted amount when switching to Savings during startup ❌ Switching to Savings reset the 12,345-sat draft to zero.

Typed 12,345 sats on an amountless unified invoice with the node held. Switching from Spending to Savings showed Connecting to Network. After startup and channel readiness, Savings Amount returned as zero, losing the unsubmitted draft.

The recording appends a short final-state continuation showing the unchanged zero amount.

savings-draft-2x.2x.mp4

Used the unpushed node and spark startup control below.

Check: build and focused automated checks ✅ Passed

Built the unmodified head with Xcode 27.0. ChannelFreeRailTests and SendSheetLifecycleTests passed; SwiftFormat 0.64.6, the delta whitespace check and J1 XML parsing passed. The full unit suite was not rerun.

Not driven again:

  • Recipient entry, on-chain send, normal channel send and the legacy-limit case passed in the earlier device report; the paths they exercised are unchanged.
  • The 1,000-sat amountless submission case passed at ebe718b in the author's device report. This delta changes Amount, and the 500,000-sat fixed submission was driven again above.
  • Initial embedded subscription retry and Manual Continue after balance refresh exercise unchanged Failure/Manual guards before the edited Amount predicate. Those concerns from the earlier review remain outside this delta; these results do not claim they are fixed.

The source review covered ebe718b..6ca0c1a and the earlier open findings. The delta changes no documentation, changelog or tests; those earlier changes were checked while verifying the prior findings. The temporary Spark-only cap while channels reconnect is the author's acknowledged tradeoff; the recording confirms the cap rises when the channel reconnects.

Pair PR: synonymdev/bitkit-android#2244 matches the Spark-first and amountless-entry intent. Its implementation differs; the deferred-validation and view-state findings above are in the iOS flow.

Node startup control

Not pushed. Used for ordinary retry, QuickPay Savings retry and reconnect amount retention. Holds startup before node setup, reports wallet and channel state, and stages real channel funding or Spark sends. The holds wait for explicit release. No SDK result, routing decision or payment result is replaced.

diff --git a/Bitkit/ViewModels/WalletViewModel.swift b/Bitkit/ViewModels/WalletViewModel.swift
index 9c7f2bd55..887ed6ed8 100644
--- a/Bitkit/ViewModels/WalletViewModel.swift
+++ b/Bitkit/ViewModels/WalletViewModel.swift
@@ -311,8 +311,26 @@ class WalletViewModel: ObservableObject {
         }
 
         syncState()
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_TEST_CONTROL"] == "true" { // test hook
+                electrumConfigService.saveServerConfig(ElectrumServer(host: "127.0.0.1", port: 35001, protocolType: .tcp)) // test hook
+                reviewControlStart() // test hook
+            } // test hook
+        #endif // test hook
         // Spark needs no node, so it starts alongside it and keeps running while the node stops.
         Task { await SparkManager.shared.start(walletIndex: walletIndex) }
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_TEST_CONTROL"] == "true" { // test hook
+                let hold = Env.appStorageUrl.appendingPathComponent("review-test-hold-node") // test hook
+                if FileManager.default.fileExists(atPath: hold.path) { // test hook
+                    Logger.info("Review test startup held before setup", context: "ReviewControl") // test hook
+                    while FileManager.default.fileExists(atPath: hold.path) { // test hook
+                        try await Task.sleep(nanoseconds: 100_000_000) // test hook
+                    } // test hook
+                    Logger.info("Review test startup explicitly released", context: "ReviewControl") // test hook
+                } // test hook
+            } // test hook
+        #endif // test hook
         do {
             let electrumServerUrl = electrumConfigService.getCurrentServer().fullUrl
             let rgsServerUrl = rgsConfigService.getCurrentServerUrl()
@@ -2192,3 +2210,54 @@ struct SparkReadinessTransition {
         return isReady && !wasReady
     }
 }
+
+#if DEBUG // test hook
+extension WalletViewModel { // test hook
+    private func reviewControlStart() { // test hook
+        Task { @MainActor [weak self] in // test hook
+            let deadline = Date().addingTimeInterval(10800) // test hook
+            let dir = Env.appStorageUrl // test hook
+            while let self, Date() < deadline, !Task.isCancelled { // test hook
+                let commandURL = dir.appendingPathComponent("review-test-command") // test hook
+                if let command = try? String(contentsOf: commandURL).trimmingCharacters(in: .whitespacesAndNewlines) { // test hook
+                    try? FileManager.default.removeItem(at: commandURL) // test hook
+                    do { // test hook
+                        if command.hasPrefix("open:") { // test hook
+                            let peer = try LnPeer(connection: String(command.dropFirst(5))) // test hook
+                            _ = try await lightningService.openChannel(peer: peer, channelAmountSats: 500000, pushToCounterpartySats: 100000) // test hook
+                        } else if command.hasPrefix("spend:") { // test hook
+                            let invoice = String(command.dropFirst(6)) // test hook
+                            _ = try await SparkManager.shared.send(bolt11: invoice, sats: nil, maxFeeSats: nil, // test hook
+                                recheckBeforeSubmission: {}, beforeSubmission: {}) // test hook
+                        } else if command == "refresh" { // test hook
+                            await SparkManager.shared.refreshState() // test hook
+                            await updateBalanceState() // test hook
+                        } // test hook
+                    } catch { // test hook
+                        Logger.error("Review test command error: \(error)", context: "ReviewControl") // test hook
+                    } // test hook
+                } // test hook
+                let spark = SparkManager.shared // test hook
+                let data: [String: Any] = [ // test hook
+                    "node": String(describing: nodeLifecycleState), // test hook
+                    "nodeId": lightningService.nodeId ?? "", // test hook
+                    "savingsAddress": onchainAddress, // test hook
+                    "savings": totalOnchainSats, // test hook
+                    "sparkReady": spark.isReady, // test hook
+                    "sparkBalance": spark.balanceSats, // test hook
+                    "sparkSendable": spark.sendableSats, // test hook
+                    "spendingLimit": maxSendLightningSats, // test hook
+                    "channelLimit": maxSendChannelSats, // test hook
+                    "usable": hasUsableChannels, // test hook
+                    "channels": (channels ?? []).map { ["id": $0.channelId.description, "ready": $0.isChannelReady, // test hook
+                        "usable": $0.isUsable, "outbound": $0.outboundCapacityMsat] as [String: Any] } // test hook
+                ] // test hook
+                if let encoded = try? JSONSerialization.data(withJSONObject: data, options: [.sortedKeys]) { // test hook
+                    try? encoded.write(to: dir.appendingPathComponent("review-test-state.json"), options: .atomic) // test hook
+                } // test hook
+                try? await Task.sleep(nanoseconds: 500_000_000) // test hook
+            } // test hook
+        } // test hook
+    } // test hook
+} // test hook
+#endif // test hook
Node and Spark startup control

Not pushed. Used for channel QuickPay retry, fixed payment, amountless timeout and Savings draft. Adds an independent Spark startup hold to the same controls. The holds wait for explicit release. No SDK result, routing decision or payment result is replaced.

diff --git a/Bitkit/ViewModels/WalletViewModel.swift b/Bitkit/ViewModels/WalletViewModel.swift
index 9c7f2bd55..7b3c95f50 100644
--- a/Bitkit/ViewModels/WalletViewModel.swift
+++ b/Bitkit/ViewModels/WalletViewModel.swift
@@ -311,8 +311,35 @@ class WalletViewModel: ObservableObject {
         }
 
         syncState()
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_TEST_CONTROL"] == "true" { // test hook
+                electrumConfigService.saveServerConfig(ElectrumServer(host: "127.0.0.1", port: 35001, protocolType: .tcp)) // test hook
+                reviewControlStart() // test hook
+            } // test hook
+        #endif // test hook
         // Spark needs no node, so it starts alongside it and keeps running while the node stops.
-        Task { await SparkManager.shared.start(walletIndex: walletIndex) }
+        Task { // test hook
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_TEST_CONTROL"] == "true" { // test hook
+                    while FileManager.default.fileExists(atPath: Env.appStorageUrl.appendingPathComponent("review-test-hold-spark").path) { // test hook
+                        try? await Task.sleep(nanoseconds: 100_000_000) // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
+            await SparkManager.shared.start(walletIndex: walletIndex) // test hook
+        } // test hook
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_TEST_CONTROL"] == "true" { // test hook
+                let hold = Env.appStorageUrl.appendingPathComponent("review-test-hold-node") // test hook
+                if FileManager.default.fileExists(atPath: hold.path) { // test hook
+                    Logger.info("Review test startup held before setup", context: "ReviewControl") // test hook
+                    while FileManager.default.fileExists(atPath: hold.path) { // test hook
+                        try await Task.sleep(nanoseconds: 100_000_000) // test hook
+                    } // test hook
+                    Logger.info("Review test startup explicitly released", context: "ReviewControl") // test hook
+                } // test hook
+            } // test hook
+        #endif // test hook
         do {
             let electrumServerUrl = electrumConfigService.getCurrentServer().fullUrl
             let rgsServerUrl = rgsConfigService.getCurrentServerUrl()
@@ -2192,3 +2219,54 @@ struct SparkReadinessTransition {
         return isReady && !wasReady
     }
 }
+
+#if DEBUG // test hook
+extension WalletViewModel { // test hook
+    private func reviewControlStart() { // test hook
+        Task { @MainActor [weak self] in // test hook
+            let deadline = Date().addingTimeInterval(10800) // test hook
+            let dir = Env.appStorageUrl // test hook
+            while let self, Date() < deadline, !Task.isCancelled { // test hook
+                let commandURL = dir.appendingPathComponent("review-test-command") // test hook
+                if let command = try? String(contentsOf: commandURL).trimmingCharacters(in: .whitespacesAndNewlines) { // test hook
+                    try? FileManager.default.removeItem(at: commandURL) // test hook
+                    do { // test hook
+                        if command.hasPrefix("open:") { // test hook
+                            let peer = try LnPeer(connection: String(command.dropFirst(5))) // test hook
+                            _ = try await lightningService.openChannel(peer: peer, channelAmountSats: 500000, pushToCounterpartySats: 100000) // test hook
+                        } else if command.hasPrefix("spend:") { // test hook
+                            let invoice = String(command.dropFirst(6)) // test hook
+                            _ = try await SparkManager.shared.send(bolt11: invoice, sats: nil, maxFeeSats: nil, // test hook
+                                recheckBeforeSubmission: {}, beforeSubmission: {}) // test hook
+                        } else if command == "refresh" { // test hook
+                            await SparkManager.shared.refreshState() // test hook
+                            await updateBalanceState() // test hook
+                        } // test hook
+                    } catch { // test hook
+                        Logger.error("Review test command error: \(error)", context: "ReviewControl") // test hook
+                    } // test hook
+                } // test hook
+                let spark = SparkManager.shared // test hook
+                let data: [String: Any] = [ // test hook
+                    "node": String(describing: nodeLifecycleState), // test hook
+                    "nodeId": lightningService.nodeId ?? "", // test hook
+                    "savingsAddress": onchainAddress, // test hook
+                    "savings": totalOnchainSats, // test hook
+                    "sparkReady": spark.isReady, // test hook
+                    "sparkBalance": spark.balanceSats, // test hook
+                    "sparkSendable": spark.sendableSats, // test hook
+                    "spendingLimit": maxSendLightningSats, // test hook
+                    "channelLimit": maxSendChannelSats, // test hook
+                    "usable": hasUsableChannels, // test hook
+                    "channels": (channels ?? []).map { ["id": $0.channelId.description, "ready": $0.isChannelReady, // test hook
+                        "usable": $0.isUsable, "outbound": $0.outboundCapacityMsat] as [String: Any] } // test hook
+                ] // test hook
+                if let encoded = try? JSONSerialization.data(withJSONObject: data, options: [.sortedKeys]) { // test hook
+                    try? encoded.write(to: dir.appendingPathComponent("review-test-state.json"), options: .atomic) // test hook
+                } // test hook
+                try? await Task.sleep(nanoseconds: 500_000_000) // test hook
+            } // test hook
+        } // test hook
+    } // test hook
+} // test hook
+#endif // test hook

Reviewed by gpt-6.1-sol-high

hasAnyChannels: (wallet.channels?.isEmpty == false) || wallet.channelCount > 0,
hasUsableChannels: wallet.hasUsableChannels,
sparkCanPay: sparkCanPayScannedInvoice
sparkCanPay: sparkCanPayScannedInvoice || (route == .amount && sparkTakesScannedAmount)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LOW: Keep the typed amount when switching to Savings before startup.

Device-confirmed at 6ca0c1a, adding evidence to the draft-loss item in #1578 (review). Open an amountless unified invoice with Spark ready and node startup held, type 12,345 sats without Continue, then select Savings. The sync screen replaces Amount; after startup, Savings Amount contains zero.

Selecting Savings makes sparkTakesScannedAmount false, so content replaces the NavigationStack. SendAmountView keeps the draft in its local amountViewModel and saves wallet.sendAmountSats only on Continue. Could we retain the draft before changing funding source or keep the Amount view alive under the overlay? The Savings-draft recording in the review shows the full sequence.

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.

5 participants