Repository navigation
Conversation
Hide the sync overlay on the recipient steps, so a Lightning invoice Spark can pay is decoded without waiting for the node. Let Spark take an amountless invoice's amount, and check the entered amount when deciding whether the review can skip the node. Refs #2032 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A scanned payment Spark can't cover still waits for the node from the recipient steps, so show the sync overlay there while that wait runs. While the node is down, cap amount entry for an amountless invoice at Spark's sendable balance, since the cached limit is not refreshed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a cold start the own-invoice check waits for the node id, so count that wait like the channel wait and show the overlay meanwhile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
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>
Confidence Score: 5/5
[Critical impact] The PR appears safe to merge; no new actionable issues remain. SummarySend can reach Spark before the Lightning node runs.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Choose or enter recipient] --> B{Can Spark pay?}
B -->|Yes| C[Review payment]
B -->|Amountless invoice| D[Enter amount within Spark balance]
D --> C
B -->|No| E[Wait for node and channels]
E --> F[Check capacity]
F --> C
C --> G[Submit payment]
G --> H[Show result without sync overlay]
Reviews (4) · Last reviewed commit: "fix: keep typed invoices pending through..." · Reviewed by Greptile |
|
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 iOS twin synonymdev/bitkit-ios#1578. This PR closes no issue, so it carries the milestone. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict:
Findings:
MEDIUM — Apply Spark capacity throughout amount entry (app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:532). The new balance override is not forwarded by SendAmountScreen to SendAmountContent. With a 10,000-sat explicit limit and a 100,000-sat ambient cache, the real amount-screen wrapper accepts 20,000 sats. The ViewModel also retains the cached limit: with cached zero and Spark able to send 500 sats, entering 500 leaves Continue disabled. Forward the balance through the wrapper and use live Spark capacity in amount validation while the node is down.
These reproduce the existing reports, with focused failing-test evidence:
MEDIUM — Wait for node capacity during manual invoice validation (app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:173). Manual entry is now reachable while the node restarts, but validateLightningInvoice calls syncState and canSend without waiting for usable channels. A fixed invoice beyond Spark's balance is rejected as insufficient spending balance even when a channel can cover it after startup. Apply the scan/paste path's node wait to manual validation, then revalidate against loaded capacity.
QA for 1064562:
Check: sync overlay policy ✅ The exact-head build and SendSheetSyncOverlayTest passed.
Built the reviewed commit in both standard dev and local Spark configurations. The overlay checks executed without failures or skips.
Check: amount entry uses Spark capacity ❌ Focused regressions reproduced the dropped screen cap and cached-limit rejection.
Temporary JVM tests exercised the actual screen wrapper and AppViewModel. The wrapper accepted 20,000 with a supplied maximum of 10,000; a separate 500-sat input stayed invalid with cached zero despite Spark being able to pay. Reproduction tests were not pushed.
Check: manual invoice validation during restart ❌ Manual validation checked insufficient capacity without awaiting the restarting node.
A focused AppViewModel test entered a foreign fixed invoice with a known own-node ID, a Starting node and insufficient Spark capacity. It called syncState and canSend, but never waitForUsableChannels. Reproduction test was not pushed.
Pay a fixed invoice through Spark while the node is stopped ⏭️ Manual case 2 was not driven after the PR returned to draft.
The existing report reaches review but does not prove payment completion with the node down.
Pay an amountless invoice through Spark while the node is stopped ⏭️ Manual case 3 was not driven after the PR returned to draft.
The existing report proves amount entry and review, but not payment completion with the node down.
Send Lightning with the node and channel running ⏭️ Manual case 5 was not driven after the PR returned to draft.
The existing successful Spark send does not establish a channel-funded send.
Show the recipient overlay during a node-dependent scan ⏭️ This gap in the existing evidence was not driven after the PR returned to draft.
Manual cases 1 and 4 were not repeated: the PR's evidence covers recipient access and the on-chain overlay clearing at this head plus the companion logging change. No device journey ran in this review.
Full review: fc82f5c..1064562, including recipient routes, node waits, amount validation, QuickPay and submitted-payment routes. Device behavior remains unverified for the four cases above.
Twin: synonymdev/bitkit-ios#1578 implements the same recipient, amountless-entry and submitted-payment overlay exemptions; payment parity was not exercised.
Reviewed by gpt-6.1-sol-high
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict: ⛔️ Request changes — two MEDIUM regressions reproduced at 90fddb0.
The PR moved to 652c67b after this run; these results are for 90fddb0.
Findings:
- MEDIUM — Cancel manual validation when leaving Send (
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:3696). The new node wait survives dismissal becausehideSheetdoes not canceladdressValidationJob. A held-wait regression leavesisSendWaitingForNodetrue after closing Send; releasing the wait then marks the dismissed invoice valid. System Back from manual entry also leaves the wait active on Recipient. - MEDIUM — Preserve the routing-fee reserve for Spark amounts (
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:5579). The new Spark branch bypassesestimatedRoutingFee, including with a fresh cached limit. With 10,000 sendable and a 100-sat routing reserve, entering 9,950 remains valid although Available is 9,900. An existing amount can survive a Savings-to-Spending switch above that limit.
QA for 90fddb0:
Check: overlay policy and earlier regressions ✅ The exact-head build and focused checks pass.
Built standard dev and local Spark configurations. SendSheetSyncOverlayTest and AppViewModelSendFlowTest pass, including the stale spending-limit and manual node-wait regressions. The temporary test of the actual amount-screen wrapper now enforces the explicit Spark cap over a larger ambient cache.
Check: cancel manual validation when Send closes ❌ A dismissed validation retains its wait and publishes a late result.
Temporary JVM regressions suspend the real ViewModel's manual channel wait, close Send, then release it. The wait flag stays true after dismissal and the late result sets isAddressInputValid to true. Both assertions fail; the tests were not pushed.
Check: reserve routing fees for Spark amounts ❌ The Spark branch accepts an amount above capacity after the routing reserve.
A temporary JVM regression sets a 10,000-sat spending limit, a 100-sat routing reserve and Spark coverage of 9,950 sats. AmountChange(9,950) remains valid. The assertion fails; the test was not pushed.
Pay a fixed invoice through Spark while the node is stopped ⏭️ Payment completion was not driven.
Manual case 2 remains unverified: the earlier report proves reaching review, but its payment did not complete.
Pay an amountless invoice through Spark while the node is stopped ⏭️ Payment completion was not driven.
Manual case 3 remains unverified: the earlier report proves amount entry and review, but not payment completion.
Send Lightning with the node and channel running ⏭️ The channel-funded send was not driven.
Manual case 5 remains unverified: the earlier successful send used Spark.
Show the recipient overlay during a node-dependent scan ⏭️ The recipient wait was not driven.
The earlier report used deeplinks, which skip the recipient step.
Cap amountless entry at Spark capacity during restart ⏭️ The device case was not driven.
The wrapper cap passes its focused JVM regression; its live restart behavior was not driven.
Validate a manual invoice while the node restarts ⏭️ The device case was not driven.
The initial channel-wait ordering passes its focused regression; restarting-node behavior was not driven.
The six device cases above were left unrun when the head advanced to 652c67b before payment QA began. No device journey ran in this review. Manual cases 1 and 4 rely on the PR's earlier evidence: recipient access and the on-chain overlay clearing were proved at 1064562 plus the companion logging change, and this delta leaves those paths unchanged.
Reviewed the contiguous delta from 1064562 to 90fddb0, all three changed files and the earlier open findings. The newer head 652c67b was not reviewed here.
Twin: synonymdev/bitkit-ios#1578 has the same recipient, amountless-entry and submitted-payment overlay exemptions, with platform-specific validation; device parity was not exercised.
Reviewed by gpt-6.1-sol-high
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full Android PR diff against its merge base, at 7c9ab365.
3 actionable findings — resolve or provide an evidence-backed rebuttal.
The five earlier threads are marked resolved. Pinned source and CI confirm the balance forwarding, stale-limit acceptance, fee-reserve application, manual wait ordering, and dismissal fixes. The amount and manual-wait findings identify remaining triggers outside those regression tests. The initial PR description included prior-review notes. Review threads and comments were fetched after source findings were recorded. The automated review’s signed retrigger action was ignored.
CI for the pinned head and base passed the build, JVM tests and Compose UI suite. The JVM report recorded 7,041 cases, including two skips and zero failures. Focused Kotlin probes checked the relevant fee and lifecycle branches with test doubles. The matching Appium run was still in progress at the final check. Build and test run · Appium run
Compared recipient and fallback navigation, amountless entry, manual validation and submitted-payment loading in the iOS twin at f711daaa. Appium coverage was checked at 9a64fa31 with the f5d81748 fixture. The Spark nightly asserts recipient settlement and fees in its normal setup. It does not assert these node-restart cases.
Device testing was not performed in this review. The author’s combined builds leave payment completion with the node down open in manual cases 2 and 3. The reported success in case 5 used Spark, so a channel-funded send remains open. Author QA evidence
Suggested additional test cases
- Android regtest with Spark funded, the node held down and a zero cached Spending limit. Open a fee-bearing amountless invoice and tap Available. Verify the filled amount leaves room for the quoted fees and review preserves that amount.
- Android regtest with a usable channel and less Spark capacity than the invoice requires. Foreground during an in-progress background node stop and enter the fixed invoice manually. Release the stop and verify Continue enables after the channel is available without editing the invoice or showing an insufficient-balance error.
- Android with Enable Paykit UI off and the node still starting. Tap Contact from Send and verify Coming Soon and its Back control are immediately visible.
Findings
- [MEDIUM] Quote the fee reserve from the live Spark limit — inline at
app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:536. - [MEDIUM] Keep typed invoices pending across a queued node restart — inline at
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:3702. - [LOW] Keep the Contact fallback visible during node startup — inline at
app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt:175.
Reviewer model: gpt-6.2-sol
Reasoning effort: high
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None.
QA for 7c9ab36:
Dev regtest build on Android API 35 for Spark sends and API 30 for channel and restart checks.
Pay a fixed invoice through Spark while the node is stopped ✅ Pasted a 1,000-sat invoice with the node stopped; uncovered review reached Bitcoin Sent, the recipient confirmed success, and node logs showed no successful restart.
Manual case 2, tested on 7c9ab36.
case2-fixed2x.2x.mp4
Pay an amountless invoice through Spark while the node is stopped ✅ With the node stopped, a variable-amount invoice opened uncovered amount entry and review, and a 1,000-sat payment completed through Spark, confirmed by app and recipient state.
Manual case 3, tested on 7c9ab36.
The recording preserves amount entry and review; payment completion was checked in the app’s PaymentSuccessful event and the recipient’s SUCCEEDED state.
case3-amountless-valid2x.2x.mp4
Send Lightning through a usable channel ✅ A 1,000-sat payment completed through the active LDK channel with the node running; Bitkit showed Bitcoin Sent and LND confirmed SETTLED.
Manual case 5, tested on 7c9ab36.
case5-channel2x.2x.mp4
Show the recipient overlay during a node-dependent scan ✅ On 7c9ab36 plus the node-start hold, pasting a channel-covered 200,000-sat invoice showed the recipient overlay; release started the node and opened uncovered review.
Tested on 7c9ab36 plus the following debug-only test hook. It waits for an explicit file release before native node start; the Send decision code is unchanged. Not pushed.
Test hook
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index aa4408f4f..46a5fbdf7 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -544,6 +544,15 @@ class LightningRepo @Inject constructor(
return@withLock adoptRunningNode()
}
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(walletIndex), "review-node-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding native node start for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released native node start for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
+
lightningService.start(timeout, ::onEvent)
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Running) }17:47:06 Holding native node start for review test
17:47:07 Waiting for node to load channels before sending payment
17:47:11 Released native node start for review test
17:47:11 Node started
case6-held2x.2x.mp4
Validate a manual invoice while the node restarts ✅ On 7c9ab36 plus the node-start hold, a manually pasted 200,000-sat invoice waited with the overlay; after explicit release and channel recovery, Continue opened uncovered review.
Tested on 7c9ab36 plus the following debug-only test hook. It waits for an explicit file release before native node start; the Send decision code is unchanged. Not pushed.
Test hook
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index aa4408f4f..46a5fbdf7 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -544,6 +544,15 @@ class LightningRepo @Inject constructor(
return@withLock adoptRunningNode()
}
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(walletIndex), "review-node-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding native node start for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released native node start for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
+
lightningService.start(timeout, ::onEvent)
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Running) }17:50:19 Waiting for node to load channels before sending payment
17:50:19 Holding native node start for review test
17:50:21 Released native node start for review test
17:50:22 Node started
case10-manual-held2x.2x.mp4
Check: Preserve routing fees in Spark amount validation ✅ The focused AppViewModel regression rejects 9,950 sats against 10,000 sendable with a 100-sat routing reserve and accepts 9,900.
Check: overlay and send-flow regressions ✅ Exact-head local Spark dev build and focused overlay and AppViewModel checks passed, including dismissal cancellation and routing reserve.
Manual cases 1 and 4 were not repeated: the earlier PR evidence covers recipient access and the on-chain overlay clearing, and this delta leaves those paths unchanged.
Dismissal and system Back were not repeated: the current-head device report proves cancellation and no late overlay or toast after node recovery on 7c9ab36 plus the companion logging change.
The stale-cache amount pad relies on the 90fddb0 device report and the explicit-cap verification. The pad and balance forwarding are unchanged; the routing-reserve change was checked at 7c9ab36.
Reviewed the contiguous delta from 652c67b to 7c9ab36, all three changed files and the earlier open findings.
Twin: synonymdev/bitkit-ios#1578 matches the recipient and amountless overlay exemptions, with platform-specific validation. iOS device parity was not exercised in this run.
Reviewed by gpt-6.1-sol-high
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>
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None.
QA for 37f8ec4:
Dev regtest build on Android API 30. Additional cases 11–13 cover the three fixes in this delta.
Quote the routing reserve from live Spark capacity ✅ Cached capacity 0 and live Spark 49,875 produced a 77-sat reserve; Available and Max showed 49,798, and Continue reached uncovered Confirm before the node started.
Rechecks the fee-reserve finding. Additional case 11, on 37f8ec4 plus the disclosed hold/log hook. The zero cached limit was staged while the app was stopped. The recording shows the amount and Confirm; the log verifies the quote's inputs and reserve.
case11-2x.2x.mp4
Test hook
Not pushed. Debug/E2E-only file holds pause native node start or stop until explicit release. Two log lines expose the actual fee ceiling and returned reserve. No SDK result or Send decision is changed.
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index b2ec8575c..618ccef5f 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -544,6 +544,15 @@ class LightningRepo @Inject constructor(
return@withLock adoptRunningNode()
}
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(walletIndex), "review-node-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding native node start for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released native node start for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
+
lightningService.start(timeout, ::onEvent)
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Running) }
@@ -896,6 +905,14 @@ class LightningRepo @Inject constructor(
// so it is dropped before the state change that ends its review.
reviewedPreparedSend.getAndSet(null)?.release()
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Stopping) }
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(0), "review-stop-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding stopping node for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released stopping node for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
lightningService.stop()
clearProbeOutcomes()
_lightningState.update {
diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
index 9bbdb5ca9..e9d4a1a2a 100644
--- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
+++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
@@ -9237,12 +9237,14 @@ class AppViewModel @Inject constructor(
// The cached limit is re-derived only once the node runs, so Spark's live amount is quoted while it trails
val cachedMax = walletRepo.balanceState.value.maxSendLightningSats
val maxSendLightning = maxOf(cachedMax, lightningRepo.sparkSendableSats())
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee ceiling cached=$cachedMax live=${lightningRepo.sparkSendableSats()} max=$maxSendLightning", context = TAG) // test hook
if (maxSendLightning == 0uL) {
_sendUiState.update { it.copy(estimatedRoutingFee = 0uL) }
return
}
lightningRepo.estimateMaxSendFee(bolt11, maxSendLightning).onSuccess { fee ->
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee reserve=$fee", context = TAG) // test hook
_sendUiState.update { it.copy(estimatedRoutingFee = fee) }
}.onFailure { e ->
Logger.error("Failed to estimate routing fee for max amount", e, context = TAG)19:05:40.787 Holding native node start for review test
19:06:06.255 Review fee ceiling cached=0 live=49875 max=49875
19:06:06.880 Review fee reserve=77
Keep a typed invoice pending through a queued restart ✅ A 200,000-sat invoice beyond Spark stayed behind the overlay during the held stop, then became valid and reached uncovered Confirm after restart and channel recovery.
Rechecks the queued-restart finding. Additional case 12, on 37f8ec4 plus the disclosed stop hold. Returned to the foreground while the background stop held the lifecycle lock, then pasted into Enter Manually. Validation stayed pending beyond the old early-return window. Releasing the stop let the queued start run and restored the real usable channel; no invoice edit was needed.
case12-2x.2x.mp4
Test hook
Not pushed. Debug/E2E-only file holds pause native node start or stop until explicit release. Two log lines expose the actual fee ceiling and returned reserve. No SDK result or Send decision is changed.
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index b2ec8575c..618ccef5f 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -544,6 +544,15 @@ class LightningRepo @Inject constructor(
return@withLock adoptRunningNode()
}
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(walletIndex), "review-node-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding native node start for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released native node start for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
+
lightningService.start(timeout, ::onEvent)
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Running) }
@@ -896,6 +905,14 @@ class LightningRepo @Inject constructor(
// so it is dropped before the state change that ends its review.
reviewedPreparedSend.getAndSet(null)?.release()
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Stopping) }
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(0), "review-stop-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding stopping node for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released stopping node for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
lightningService.stop()
clearProbeOutcomes()
_lightningState.update {
diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
index 9bbdb5ca9..e9d4a1a2a 100644
--- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
+++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
@@ -9237,12 +9237,14 @@ class AppViewModel @Inject constructor(
// The cached limit is re-derived only once the node runs, so Spark's live amount is quoted while it trails
val cachedMax = walletRepo.balanceState.value.maxSendLightningSats
val maxSendLightning = maxOf(cachedMax, lightningRepo.sparkSendableSats())
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee ceiling cached=$cachedMax live=${lightningRepo.sparkSendableSats()} max=$maxSendLightning", context = TAG) // test hook
if (maxSendLightning == 0uL) {
_sendUiState.update { it.copy(estimatedRoutingFee = 0uL) }
return
}
lightningRepo.estimateMaxSendFee(bolt11, maxSendLightning).onSuccess { fee ->
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee reserve=$fee", context = TAG) // test hook
_sendUiState.update { it.copy(estimatedRoutingFee = fee) }
}.onFailure { e ->
Logger.error("Failed to estimate routing fee for max amount", e, context = TAG)19:14:29.986 Holding stopping node for review test
19:16:07.379 Released stopping node for review test
19:16:07.865 Node stopped
19:16:08.226 Waiting for node to load channels before sending payment
19:16:13.356 Node started
19:16:13.372 Waiting for usable channels before sending payment
Show Contact fallback during node startup ✅ With Enable Paykit UI off, Contact showed Coming Soon and Back returned to Recipient without an overlay while native startup remained held.
Rechecks the Contact fallback finding. Additional case 13, on 37f8ec4 plus the disclosed native-start hold. The hold file was still present after Back; the log contains no node start until its later explicit release.
case13-2x.2x.mp4
Test hook
Not pushed. Debug/E2E-only file holds pause native node start or stop until explicit release. Two log lines expose the actual fee ceiling and returned reserve. No SDK result or Send decision is changed.
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index b2ec8575c..618ccef5f 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -544,6 +544,15 @@ class LightningRepo @Inject constructor(
return@withLock adoptRunningNode()
}
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(walletIndex), "review-node-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding native node start for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released native node start for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
+
lightningService.start(timeout, ::onEvent)
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Running) }
@@ -896,6 +905,14 @@ class LightningRepo @Inject constructor(
// so it is dropped before the state change that ends its review.
reviewedPreparedSend.getAndSet(null)?.release()
_lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Stopping) }
+ if (Env.isDebug && Env.isE2eTest) { // test hook
+ val hold = File(Env.ldkStoragePath(0), "review-stop-hold") // test hook
+ if (hold.exists()) { // test hook
+ Logger.info("Holding stopping node for review test", context = TAG) // test hook
+ while (hold.exists()) delay(100.milliseconds) // test hook
+ Logger.info("Released stopping node for review test", context = TAG) // test hook
+ } // test hook
+ } // test hook
lightningService.stop()
clearProbeOutcomes()
_lightningState.update {
diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
index 9bbdb5ca9..e9d4a1a2a 100644
--- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
+++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
@@ -9237,12 +9237,14 @@ class AppViewModel @Inject constructor(
// The cached limit is re-derived only once the node runs, so Spark's live amount is quoted while it trails
val cachedMax = walletRepo.balanceState.value.maxSendLightningSats
val maxSendLightning = maxOf(cachedMax, lightningRepo.sparkSendableSats())
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee ceiling cached=$cachedMax live=${lightningRepo.sparkSendableSats()} max=$maxSendLightning", context = TAG) // test hook
if (maxSendLightning == 0uL) {
_sendUiState.update { it.copy(estimatedRoutingFee = 0uL) }
return
}
lightningRepo.estimateMaxSendFee(bolt11, maxSendLightning).onSuccess { fee ->
+ if (Env.isDebug && Env.isE2eTest) Logger.info("Review fee reserve=$fee", context = TAG) // test hook
_sendUiState.update { it.copy(estimatedRoutingFee = fee) }
}.onFailure { e ->
Logger.error("Failed to estimate routing fee for max amount", e, context = TAG)19:05:40.787 Holding native node start for review test
19:12:56.541 Released native node start for review test
19:12:57.349 Node started
Check: send-flow and node-wait regressions ✅ The exact-head build and focused regression checks passed without failures or skips.
Built 37f8ec4 before adding any hook. Ran SendSheetSyncOverlayTest, AppViewModelSendFlowTest and LightningRepoTest, including the live-Spark quote, pending start behind a stop, stopped-with-no-start, Spark bypass, routing reserve and dismissal checks.
No planned case was left unrun. Earlier behavior was not driven again where the delta leaves it untouched:
- Manual cases 2, 3 and 5, plus recipient/manual channel-wait recovery: the prior 7c9ab36 review proves fixed and amountless Spark payments with the node down and a real channel-funded send. Case 11 above checks the changed amountless fee ceiling; case 12 checks the new queued-stop window.
- Manual cases 1 and 4: the PR's recorded evidence covers recipient access and the on-chain overlay clearing at 1064562 plus the logging companion. Case 13 above checks the newly included Contact fallback.
- Dismissal and system Back: the 7c9ab36 device report covers the unchanged cancellation/disposal path; focused regressions also pass at 37f8ec4.
Reviewed all six files in the contiguous 7c9ab36..37f8ec4 delta, their callers and the three open review findings. Every changed behavior was driven above; the stopped/no-start and Spark-bypass branches also have focused checks.
Twin: synonymdev/bitkit-ios#1578 already includes Coming Soon among recipient steps and refreshes the stored Spark limit while node balances are unavailable; its manual-entry validation differs. No iOS device run in this delta review.
Reviewed by gpt-6.1-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: Follow-up through 37f8ec486, covering changes since 7c9ab365, their affected paths, and unchanged coverage inherited from the baseline review.
3 actionable findings — resolve or provide an evidence-backed rebuttal.
Focused Kotlin probes exercised the pinned fee and amount-validation methods with simulated wallet and quote responses. The Android app suite was unexecuted locally, and CI for the pinned head was in progress at the final check. The existing on-chain connecting journey still expects the overlay on Recipient. Move its overlay assertion to Amount to match manual case 4.
The iOS twin at d547026b was checked for Contact fallback navigation, manual-entry cancellation, amount entry, and post-submission loading. Its amount screen uses the combined Spending limit. Android caps amount entry at Spark’s balance while the node is down. The payment trace used Breez SDK 0.28.3 source. The companion Appium Spark spec checks settlement of a fixed invoice and leaves the stopped-node amountless Max path uncovered.
Device testing: not performed in this review.
Suggested additional test cases
- Android, funded Spark and a cached channel limit above Spark’s sendable balance. Hold the node down, open an external amountless invoice, and tap Available. Verify the amount leaves Spark’s routing reserve and can settle.
- Android, with a controllable fee quote. Tap Available before the quote returns and verify Continue disables if the resulting limit falls below the entered amount. Repeat with invoice A’s quote held, open invoice B, return B’s quote, then release A’s quote. Verify B retains its own Available amount.
Earlier findings reconciled at this revision: 8 verified fixed.
Findings
-
[MEDIUM] Quote the Spark limit when only Spark can pay — inline at
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:9239. -
[MEDIUM] Discard Max fee quotes from a previous Send session — With a zero Spending cache and funded Spark, close amountless invoice A while its Max quote is in flight, then open invoice B. The quote runs in the view model scope, and its completion writes the reserve into whichever Send state is current. If A returns last, B would show A’s Available limit and could reject an amount B can pay. Tie the quote to the Send session and invoice, and ignore late success and failure results after either changes. A focused Kotlin probe returned B’s 10-sat reserve first and confirmed A’s delayed 76-sat result overwrote it.
Source. Summary placement: The unguarded completion write sits outside the PR diff. The new live Spark balance makes it reachable with a zero cache.
-
[MEDIUM] Revalidate the entered amount when the Spark fee arrives — inline at
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:5592.
Reviewer model: gpt-6.2-sol
Reasoning effort: high
| val maxSendLightning = walletRepo.balanceState.value.maxSendLightningSats | ||
| // The cached limit is re-derived only once the node runs, so Spark's live amount is quoted while it trails | ||
| val cachedMax = walletRepo.balanceState.value.maxSendLightningSats | ||
| val maxSendLightning = maxOf(cachedMax, lightningRepo.sparkSendableSats()) |
There was a problem hiding this comment.
[MEDIUM] Quote the Spark limit when only Spark can pay
With the node stopped, open an amountless invoice when the cached Spending limit exceeds Spark’s live sendable balance. The keypad uses the Spark limit, but the Max quote takes the larger cached limit. That amount cannot route through Spark, so the estimate falls through to the stopped node and leaves a zero reserve. Available would then offer an amount the wallet cannot fund whenever the route fee exceeds the remaining fee headroom. Use the same live limit for the quote and the keypad while Spark is the only available rail. The route selection and a focused Kotlin probe confirmed the quote and validation behavior.
| when (val lnurl = _sendUiState.value.lnurl) { | ||
| null -> amount <= maxSendable && lightningRepo.canSend(amount) | ||
| // The cached limit is re-derived only once the node runs, so it can trail Spark's balance | ||
| null -> (amount <= maxSendable || lightningRepo.canSendWithSpark(sparkDebit)) && |
There was a problem hiding this comment.
[MEDIUM] Revalidate the entered amount when the Spark fee arrives
With the node down and a zero cache, tap Available while the Spark Max quote is still in flight. The amount passes validation with a zero reserve. A later quote can lower Available below the entered amount, but the fee update leaves the validity flag true and Continue uses that flag. The user could advance to review with an amount the updated limit rejects. Revalidate the entered amount when the quote arrives and enforce the updated limit on Continue. A focused Kotlin probe confirmed that fresh validation rejects the amount while the stored validity remains true.
Source: qa, mainnet QA of 3.2.0 RC3 (#2160 (comment))
Twin: synonymdev/bitkit-ios#1578
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
AppViewModel.isSendWaitingForNodecounts these waits, and the overlay shows on the recipient step only while one runs.SendAmountScreenpasses the Spark-capped balances to the pad. The max routing fee is quoted from Spark's live sendable amount when the cached limit trails it.Out of Scope
LightningRepo.earlierNodeSend: before each Spark send, the duplicate-send check lists node payments onServiceQueue.LDK. While a node exists and that queue is busy with start or an Electrum sync, the swipe waits behind it. That is payment-safety code, so it is left for a separate change.SpendingAmountScreen,SendQuickPayScreen,LightningConnectionsScreen: their sync views stay, since those flows need the node.ChannelPendingin LDK for over 6 minutes. The unit tests cover the wait and the check.Design
N/A — no design available.
Preview
QA Notes
Setup
Dev (regtest) build of this branch on a phone with a funded Spark balance. A wallet with a channel shows the Lightning variant of the overlay; without one, the Bitcoin variant.
Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
Evidence
Emulator (API 37.1) and local Spark regtest (
bitkit-dockerspark profile), node held down by blocking Electrum. Build0ad84e6e9(#2244 at272067dfa+ #2245) and rerun4fad15073(#2244 at106456253+ #2245). Clipboard paste does not work on the emulator, so invoices went in by deeplink.Tree service error: insufficient funds: the local SSP has no 8,192-sat leaves, so swaps fail. After that "Payment pending" result, the first build covered the Pending screen with the overlay;106456253fixed it and the rerun shows Pending uncovered at 1 s and 30 s (PASS).Node started(PASS).spark-send.mp4
Gaps: payments made while the node is down are blocked by the local SSP's leaf pool, not by this change. The recipient-step overlay during a node wait was not observed, since deeplinks skip that step.
Review round (Greptile, ovi-reviewer)
Device runs on the emulator (API 37.1), local Spark regtest, node held down by blocking Electrum. Builds
02e8b79(#2244 at90fddb07c+ #2245) anda6f2e7dbd(#2244 at7c9ab3653+ #2245).Node started16:04:57.1, toast ~16:05:00 (PASS).Node started(PASS).Typed invoice while the node starts:
typed-invoice-node-start.mp4
Closing Send during the wait:
close-during-wait.mp4
Unit tests: 7,034 pass, and detekt is clean. Each new test failed before its fix.
Review round 2 (piotr-iohk)
Device runs at
37f8ec486on the emulator (API 37), local Spark regtest, node held down.Unit tests: 7,038 pass, detekt is clean and androidTest compiles.
🤖 Generated with Claude Code