Skip to content

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

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

jvsena42 wants to merge 16 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.

🤖 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; no new blocking issue was found.

Summary

Lets users choose recipients and review Spark-payable invoices before the Lightning node runs.

  • Send reaches recipient steps and Spark-payable invoices before the node starts.
  • Late node startup leaves submitted payments and waiting QuickPay on the right screen.
  • The Spending limit uses current Spark capacity while node balances are unavailable.

No new actionable issues found. The earlier submitted-payment finding is fixed. Device journeys and iOS tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Choose recipient] --> B{Spark can pay?}
  B -->|Yes| C[Review or QuickPay]
  B -->|No| D[Wait for node and check funds]
  D -->|Lightning can pay| C
  D -->|Unified invoice needs Savings| E[Replace QuickPay with Amount]
  C --> F[Submit payment]
  F --> G[Keep payment result unchanged]
Loading

Reviews (4) · Last reviewed commit: "fix: refresh QuickPay retry readiness an..." · Reviewed by Greptile

Comment on lines +629 to +631
// Spark can pay before the node runs, so a send may already be paying or settled when it starts
guard !flow.didFinish, !flow.isSubmittingPayment, !PaykitPaymentActivity.shared.isActive,
!Self.isPastReview(flow.navigationPath.last ?? currentRoot) else { return }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Paid send loses its result

The new guard protects only the node-start callback. The hasUsableChannels callback still calls validatePaymentAfterSync() during or after submission. If Spark pays before startup and a small channel reconnects afterward, hasValidatedAfterSync can still be false while the remaining Spark balance no longer covers the invoice. Validation then dismisses the paid send as insufficient, or moves a unified invoice back to .amount.

Apply these guards to both callbacks, or put them in the shared validation entry point.

Knowledge Base Used:

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 0083a2c. The hasUsableChannels callback now uses the same hasSubmittedPayment guard as the node-start callback (didFinish, isSubmittingPayment, Paykit activity, or a route past submission, with QuickPay counted only once it started), so channels becoming usable after a Spark payment no longer revalidate it.

Not device-verified: it needs a wallet with a channel and Spark funds, and the local regtest stack has no channel set up for this run. Leaving this thread open. Not twinned: Android has no usable-channels revalidation after submission.

@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 8f11931 to f711daa 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 f711daa: 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

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 f711daa to 384ce62 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 384ce62: 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

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.

@piotr-iohk
piotr-iohk self-requested a review December 4, 2026 08:20
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.

3 participants