Repository navigation
fix: hold the funding ask while a savings send is unresolved - #2112
Conversation
A savings payment that ends with no answer keeps its transaction as the exit's own payment, as one of unknown result already did, so Progress shows it paid and the own-payment wait brings the ask back if it never lands. Progress says to wait for it while the send journal has not seen it accepted. Verified: SparkExit unit tests, detekt
A failed check now ends the test instead of leaving runTest driving the loop. Verified: SparkExit unit tests, detekt; the kept-payment check fails without the fix
A retry, accepted or not, and a start paid with no answer now update whether a savings send may still land, so Progress shows its note only while it may. A tick that forgets the exit's own payment brings the ask back at once. Verified: none (tests run after this commit)
A retry the send journal rolled back to refused is never kept as the exit's payment. Progress shows the may-still-land note only while the funding is paid from savings, and holds the ask before the first read of the funding address when the record keeps a payment. Verified: SparkExit unit tests and detekt
Verified: SparkExit unit tests and detekt
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryKeeps unresolved savings payments on the exit so Progress does not invite a second payment.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Savings send] --> B{Result}
B -->|Accepted or unknown| C[Keep payment on exit]
B -->|Pending error| D{Journal rolled retry back?}
D -->|Yes| E[Keep retry available]
D -->|No| C
C --> F[Hide funding ask]
F --> G{Payment arrives?}
G -->|Yes| H[Use funding]
G -->|Wait expires| I[Forget payment and restore ask]
Reviews (1) · Last reviewed commit: "test: cover the kept, rolled-back and fo..." · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. A savings payment of the exit's fees that ends with no answer is now kept as the exit's own payment (txid from the error, else from the send journal unless the journal says refused), so Progress holds the funding ask and shows a wait note instead of offering another wallet. Reviewed 544ec02, full tier, static: Bitkit Android PRs are not built on this reviewer's machine, so this rests on the code and CI.
What I checked, and 4 candidates I ruled out
Read in full: payFunding, keepFundingPayment, pendingFundingTxid, noteSavingsSend, savingsSend, retrySavingsPayment and the tick's funding refresh in SparkExitRepo.kt; isAwaitingOwnPayment in SparkExitRecord.kt; isSavingsSendLanding and progressFunding in SparkExitViewModel.kt; the Progress row.
Tests read: the kept, rolled-back and forgotten payment cases in SparkExitRepoTest.kt, and SparkExitViewModelTest.kt.
CI: build-and-test, lint, detekt, compose-ui green.
Ruled out
- A never-sent payment holding the ask forever:
pendingFundingTxiddrops aRejectedjournal entry, and a kept txid that never lands is forgotten by the existing own-payment wait, whose tick now refreshes the funding state whenfundingPaymentTxidchanges. - Retry path losing the cleared refusal flag: the old
isSavingsPaymentRefused = falseis replaced bynoteSavingsSend, which recomputes it from the journal on both outcomes. - Save failure on retry now swallowed: same contract as the start path already had (kept in memory, saved by a later tick), stated in the kdoc.
- Paid shown before any funding read for an exit with no payment:
progressFundingfalls back toPaidonly whenisAwaitingOwnPayment, which needs a kept txid not yet infunding.
Merge confidence: 4/5, no findings, but manual test 1 cannot be run on demand and no device run covers the new note.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer carries the model id only)
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 544ec02.
Low: A failed funding-address read can make Progress ask for the full emergency fee after a short savings payment has already confirmed. The first read calculates the amount still due, and the driver clears the savings payment ID after seeing the short confirmation. That ID change triggers another read at SparkExitRepo.kt:328. If it fails, SparkExitRepo.kt:431 recalculates the amount without the confirmed output. Preserve the verified remainder when the second read fails and the funding requirement is unchanged.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
Confirmed, and left out of this PR so the approval stands: it needs that second read to fail right after the first succeeded, and the next successful read restores the remainder. Tracked in #2123. |
A tick that forgets the exit's own payment reads the funding address again; when that read fails it now goes by the tick's first read, so a short savings payment still counts and only the rest is asked for. Verified: ./gradlew testDevDebugUnitTest --tests '*SparkExit*' (the new test failed before the fix)
A higher fee whose savings payment got no answer may still go out: the exit now keeps it like one of unknown result, with its fee bump, and Progress says it may still land. Verified: ./gradlew testDevDebugUnitTest --tests '*SparkExit*'
Verified: ./gradlew testDevDebugUnitTest --tests '*SparkExit*', ./gradlew detekt
|
Pushed 1eef286:
|
|
QA for 1eef286: Tested on Pixel emulator (Android 16), local regtest. A local debug-only change broadcast the exit's savings payment and then dropped its answer once. 🟢 Savings payment with no answer holds the funding askSavings payment with no answer holds the funding ask Progress shows "Your savings payment hasn't confirmed yet. Wait for it before you pay from another wallet." with no Amount to pay, no funding address and no Cancel.
🟢 The hold survives a relaunchThe hold survives a relaunch After a force-stop and relaunch, Progress shows the same note, still with no ask and no Cancel.
🟢 The payment lands and the exit goes onThe payment lands and the exit goes on Once it confirms, the note goes, no ask comes back, the emergency fees show confirmed and the exit broadcasts its first transaction; the funding address holds exactly one payment.
🟠 A higher fee from savings with no answerA higher fee from savings with no answer Not run: regtest fee estimates stay flat, so Progress never offered a higher fee. Covered by |
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 1eef286.
Low — Progress can ask for the full emergency fee after the driver has seen a confirmed partial Savings payment. If the first address read misses the output, SparkExitDriver.kt:507 can see it on a later read and clear the saved transaction ID. If the final read fails, SparkExitRepo.kt:330 falls back to the first list and asks for the full shortfall. Extend the failed-refresh test so the partial output first appears during the driver's reads, and preserve that observation for the amount shown in Progress.
Low candidate — A failed journal read can make a rolled-back Savings retry appear paid. OnchainSendCoordinator.kt:229 can discard an unsent retry and return a pending error naming that transaction. If the journal read at SparkExitRepo.kt:998 also fails, the exit trusts the discarded ID and hides the retry until its payment wait expires. Extend the rollback test to fail that separate read and check whether Progress still offers the retry once the journal is readable again.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
Both need a failed read on top of a narrow timing, so they're in #2134 for a follow-up, and this PR keeps its approval. |
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at 1eef286: no findings.
Checked and clean:
- No double funding while held. A kept txid makes
fundingStatePaid, so Progress shows no amount or address. Before the first read,progressFundingfalls back toPaidwhenisAwaitingOwnPayment. The 4 h funding reminder needsfundingPaymentTxid == null. If an earlier external payment and the savings send both land, the driver adopts what covers the shortfall and sweeps the rest back to savings (unchanged design). - No dead end after a failed send.
withOwnPaymentLookedforgets the kept txid after 3 blocks unknown or 144 blocks, and the forget tick now re-reads funding, so the ask comes back with a notification. A retry that never dispatched is rolled back andRejectedis never kept, so the retry stays offered. - Only
OnchainSendPendingErrorkeeps a txid (its own, or the journal's when evidence isPending/Unknownand the address matches). I traced every source of that error, and all carry a txid. The note shows only while the send is unresolved and not refused. - Cancel/Back/relaunch while held:
canCancelneeds no txid and no unresolved savings send, re-read undertickMutex. Every exit payment path runsNonCancellable. The txid is saved bykeepFundingPaymentand re-saved by the driver if that save fails. - New string
lightning__spark_exit__savings_unresolvedis in all 16 locales, placed alphabetically, with no placeholders and apostrophes escaped. It renders inBodySwith nomaxLinesinside the scroll column; the longest is fr (117 vs 91 chars). - Parity with synonymdev/bitkit-ios#1457: same key, wording, identifier and note condition.
perf: not relevant (one journal read per exit payment, one extra UTXO read on a tick that changes the funding txid).
Device gate (partial): 1eef286 — not run yet; the note needs a savings send with a dropped answer on the local Spark stack (the body's debug fault). Result to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
|
Device gate (partial): 1eef286 — run on the Android emulator against the local bitkit-docker Spark stack (PR build plus the one-line
Still running: the driver's run of the runbook. |
|
Merging: approved on 1eef286, CI green, and the device run on this head passed (QA above). |
Closes #2059
Closes #2123
Twin: synonymdev/bitkit-ios#1457
Description
Out of Scope
Design
N/A — no design available. One new note on Progress, translated into every locale.
Preview
See the QA comment: #2112 (comment)
QA Notes
Journeys
N/A
Manual Tests
Automated Checks
SparkExitRepoTest.kt; the kept, rolled-back and forgotten payment tests, and the failed re-read test, fail without the fixSparkExitViewModelTest.kt./gradlew testDevDebugUnitTest --tests '*SparkExit*'./gradlew detektModels used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)