Repository navigation
fix: release savings payments a force transfer no longer needs - #2142
Conversation
A savings send to a Spark exit's funding address, told apart by that address (the current record's or an earlier exit's), is released through the existing release path once the exit no longer needs it: the exit was cancelled or ended, or it holds all its funding and none of it is the send's. One the exit adopted, or still waits for, is never released. Payment Pending never offers "Retry original payment" for an exit's funding, which Progress owns, and offers the release with its own note once the exit no longer needs it. Progress' Pay from savings retry and Payment Pending's retry read the exit again right before dispatch and refuse once it is funded. Verified: testDevDebugUnitTest (full suite; the new PaykitPaymentProofRepoTest release and pay-again tests fail with the gate stubbed out), detekt, lintDevDebug
Verified: none (changelog only)
A savings send's txid stayed on the exit record after another wallet funded it, so the send was never released. Only a payment the exit still waits for keeps it now. A release already approved also stops for a send that landed as leftover, and paying again refuses once another wallet's funding reached the address. Adds tests for the retry's funding check and Send Pending's exit-funding guard. Verified: gradlew testDevDebugUnitTest PaykitPaymentProofRepoTest, SparkExitRepoTest, AppViewModelSendFlowTest (before the isAdopted line wrap); detekt
Once a release of a savings send to a force transfer's funding address is approved, Send Pending finishes it even after the exit's record is gone, instead of offering Retry. Paying again now ignores the exit's own adopted outputs and their change when it looks for other funding. Verified: gradlew testDevDebugUnitTest PaykitPaymentProofRepoTest, SparkExitRepoTest, AppViewModelSendFlowTest; detekt
Send Pending hid Retry for every savings send to a force transfer's funding address, so an unresolved one Progress could not pay again stayed stuck and blocked new on-chain sends. It offers Retry again unless the release is offered, and the retry checks right before dispatch that the exit still asks for the funding and nothing else reached the address, the same check Progress uses. A send whose release was approved is never paid again. Verified: gradlew testDevDebugUnitTest PaykitPaymentProofRepoTest, SparkExitRepoTest, AppViewModelSendFlowTest, SendPendingViewModelTest; detekt
A savings send whose cancel was approved is refused before the exit-funding check, so it stays refused once the exit's record is gone, and Send Pending hides Retry for it. Verified: gradlew testDevDebugUnitTest PaykitPaymentProofRepoTest, SparkExitRepoTest, AppViewModelSendFlowTest, SendPendingViewModelTest; 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 changes affect recovery for a bounded set of on-chain savings payments tied to Spark exits. The PR appears safe to merge, with a non-blocking issue where Payment Pending can keep Retry hidden after the exit needs funding again. Findings
SummaryLets Payment Pending cancel unresolved savings payments that a force transfer no longer needs.
Explicitly deferred by Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Unresolved savings payment] --> B{Matches an exit address?}
B -->|No| C[Keep ordinary Retry]
B -->|Yes| D{Exit still needs payment?}
D -->|Yes| E[Retry checks exit and address again]
D -->|No| F[Offer cancellation]
F --> G[Check that no candidate reached the network]
G --> H[Approve and save release]
H --> I[Spend coins back to wallet]
Reviews (1) · Last reviewed commit: "fix: never pay an approved exit funding ..." · 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 new findings. Lets Send Pending release an unresolved savings send to a Spark exit's funding address once the exit no longer needs it, and makes Retry check the exit again right before dispatch. Reviewed 2afb912, full tier, static.
What I checked, and 5 candidates I ruled out
Read in full: SparkExitFundingRelease.kt, and the changed parts of OnchainSendAttemptStore.kt, PaykitPaymentProofRepo.kt, SparkExitRepo.kt, SendPendingViewModel.kt, SendPendingScreen.kt, AppViewModel.kt
Call sites traced: canBeAbandoned (store approveRelease, recordRelease, abandonUnbroadcast), onchainRequestHasEnded, abandonUnbroadcastOnchainPayment, finishRelease, retryOriginalOnchainSend's authorize callback, SparkExitMath.fundingState / newFunding, the cancel path that moves a forgotten exit's address into SparkExitEarlierAddressStore
Build: not built here. The sandboxed runner refused the build, so CI is the gate (build-and-test, lint, compose-ui / ui-tests, all still pending at review time)
Ruled out
- Every ordinary send now passes
canBeAbandoned, so the store no longer refuses releasing one: the only path toapproveRelease/abandonUnbroadcastisabandonUnbroadcastOnchainPayment, which first needsonchainRequestHasEnded. FormayFundSparkExitthat isexitNoLongerNeeds, which is true only when the address matches the stored record's funding address or an earlier exit's. An unreadable exit returns false. - Retry pays an address that already got funding from another wallet:
authorizePayAgainreads the address's UTXOs inside the authorize callback before dispatch, andmayPayAgainallows onlyAskwith nothing received, orPaidwhere every new UTXO is one of this attempt's candidates. A failed read refuses. - Release of a payment that landed:
isAdopted/exitNoLongerNeedscheck every candidate against funding, leftover and the awaitedfundingPaymentTxid, andonchainCandidatesNeverReachedNetworkstill runs before approval. - Stale record read off disk while the repo writes it:
SparkExitStore.saveand the earlier-address store write a temp file andATOMIC_MOVEit into place, sostoredExitsees the old file or the new one, never a partial one. - Retry hidden after the exit asks for funding again: this is the open Greptile thread on
SendPendingViewModel.kt:364. I did not repeat it.
Merge confidence: 4/5. No findings, but CI was still running at review time and this was not built here.
Reviewer model: Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: Not exposed (this runtime does not report it)
…ase-unneeded-funding # Conflicts: # app/src/main/java/to/bitkit/repositories/SparkExitRepo.kt
|
Merged master in 40d4816, resolving a conflict in |
jvsena42
left a comment
There was a problem hiding this comment.
One MEDIUM and one LOW, inline.
LOW (PR body, no line to anchor): manual test 1 cannot be performed as written. While the savings send has no answer, noteSavingsSend sets isSavingsSendUnresolved, so canCancel is false (SparkExitRepo.kt:1238-1248), Progress hides Cancel (SparkExitProgressScreen.kt:158) and cancel() throws "The Spark exit can no longer be cancelled". An Unknown outcome also sets fundingPaymentTxid, which fails canCancel too. Please rewrite case 1 to a reachable route: exit funded by another wallet (as in #2136), or exit ended (Done/Failed).
Checked and clean:
- Paid twice: retry re-signs the attempt's
originalInputs(retainPreparedReceiptrequires the same input set and amount), so at most one candidate confirms. - Release and retry both going out:
approveRelease,recordReleaseandabandonUnbroadcastcompare the whole stored attempt to the expected one, so a retry that changed the attempt makes a release started earlier stop.releaseApprovedsurvivesretainPreparedReceiptanddiscardUnsubmittedRetryCandidate, soauthorizePayAgainrefuses a retry after an approved release. The two buttons disable each other. - Release while the broadcast is unresolved still needs a fresh sync showing no candidate, and
releaseOutbidsstill needs an original coin and a higher fee than any candidate. - Ordinary sends reach
approveReleaseonly throughonchainRequestHasEnded, which needs an address match against the exit record or an earlier exit. - Authorization: retry keeps the fee dialog, sanity warnings and PIN/biometrics before anything is retained; the exit check runs after approval and right before dispatch. Release keeps its note, fee and PIN steps.
- Lifecycle: killed after
approveRelease, reopening offers only the cancel and finishes it; killed after the release broadcast, the savedreleaseTxidis found on the next cancel. Attempts from the published release withoutoriginalInputscannot be abandoned, as before. - Persisting
releaseApprovedbefore the fee prompt follows the existing Shop-payment pattern, and Send Pending still offers to finish the release afterwards. - Back/cancel on Send Pending: closing before
approveReleasepersists nothing. Fee-rate, fee-approval and PIN cancels on Retry retain no candidate. wallet__send_pending__abandon_exit_noteis in all 16 locales. The longest (it 217, nl/el/ca 213, de 212 characters) are in the range of the existingwallet__send_pending__abandon_notein the sameAppAlertDialog.
perf: not relevant.
Device gate: not run; held until the MEDIUM is resolved.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating and verifying; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
Pay again while the exit still asks, waits for this payment or holds its own coin: a retry re-signs the same inputs, and what savings pays beyond the ask comes back as leftover. An unreadable list of earlier exit addresses reads as empty, so it never refuses an ordinary send's Retry. Verified: gradlew testDevDebugUnitTest SparkExitRepoTest, PaykitPaymentProofRepoTest, SendPendingViewModelTest (pass; the partial-payment and unreadable-list tests fail on 40d4816 per the reviewer's repro), gradlew detekt
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 378c2e2.
Low: Declining the exact cancellation fee can disable Retry for the original savings payment. PaykitPaymentProofRepo.kt:770 saves releaseApproved before the fee dialog. Dismissing it exits at SendPendingViewModel.kt:277 before a release transaction is recorded. If the externally funded exit later asks for a top-up, Retry stays unavailable even after reopening Payment Pending. Keep the original retry available when the user declines the fee, while preserving recovery for an authorized release.
Low: Payment Pending and Force Transfer Progress use different eligibility checks from retry dispatch. When an unconfirmed payment from another wallet already covers the funding request, SparkExitFundingRelease.kt:66 refuses retry. SendPendingViewModel.kt:364 still offers Retry and takes the user through fee approval, and SparkExitViewModel.kt:508 still offers Pay from Savings even after Progress shows the funding as seen. Use the funding eligibility to decide when to offer both actions and recheck it before dispatch.
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
|
QA for 378c2e2: Tested on Pixel 10 Pro XL (Android 16 emulator), local regtest. A local debug-only change marked the force transfer's first savings payment as sent, then gave it no answer and never broadcast it, so it stayed unresolved. 🟢 1. Another wallet funds the exit fully1. Another wallet funds the exit fully Another wallet paid the full 7 623 sats and the exit moved on. A new on-chain send opened Payment Pending, which offered only Cancel expired payment, with the note that the force transfer no longer needs this payment. The cancel sent the coins back to the wallet (network fee 703 sats), and the next on-chain send (1 000 sats) went through.
🟢 2. Another wallet pays part of the funding2. Another wallet pays part of the funding Another wallet paid 3 000 of the 7 623 sats and the exit kept asking. Payment Pending offered only Retry original payment. After the fee approval it paid once: the funding address got that one savings payment (7 623 sats) besides the partial one, and one block later the exit broadcast its next step.
|
jvsena42
left a comment
There was a problem hiding this comment.
Re-review at 378c2e2: both of my findings are fixed, and the delta adds nothing new.
- MEDIUM (partial funding from another wallet left no way out): fixed.
mayPayAgainnow allows a retry inAskwhateverreceivedSatsis (SparkExitFundingRelease.kt:69). It allows one inPaidonly for this payment's own txid (:71), and inSeenonly while this payment's own coin is unconfirmed, so the retry just bumps it (:73-75). It refuses once other wallets' coins alone cover the funding (:63-66). Covered byan unresolved savings payment keeps a way out once another wallet paid part of the fundingand the extendedSpark exit funding is paid again only while the exit asks or waits for this payment. - LOW (unreadable earlier-addresses file): fixed.
storedExitreads that file with its owngetOrDefault(emptyList())(:84-86). Covered byan ordinary savings send is paid again when the earlier exit addresses cannot be read.
Checked in the delta:
- Every allowed retry is still the same attempt over the same inputs and amount.
retryOriginalneedsoriginalInputs, andretainPreparedReceiptcompares the input set and amount, so it conflicts with every earlier candidate and cannot add a second payment. - If the own coin confirms before dispatch, the replacement is rejected for spent inputs and nothing else leaves.
- A payment with another txid stays refused.
utxos == nulland a funded exit both refuse.- Progress "Pay from savings" and Send Pending Retry still go through the same
mayPayAgain. - In every newly allowed state the record is active with a shortfall, so release and retry are never both offered.
- The 9 000 → 21 000 test changes keep the covered-funding refusal under test, and no assertion was weakened.
perf: not relevant.
Device gate (partial): 378c2e2 — not run yet; Retry after a partial payment from another wallet, and the release once another wallet covers the funding, on the local Spark stack. Result to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating and verifying; Fable 5.2 (claude-fable-5-2) delta review
Reasoning effort: Not exposed
|
Merging: approved on 378c2e2, device run on this head posted above, all checks green. |
Both are valid. They're tracked in #2157, which gets fixed in a follow-up PR for 3.2.0, together with the iOS twin (synonymdev/bitkit-ios#1528). |
Closes #2136
Twin: synonymdev/bitkit-ios#1518
Description
Out of Scope
Tracked in #2157:
Design
N/A — no design available. One new note in the cancel confirmation, translated into every locale.
Preview
N/A — a savings payment the exit no longer needs, with no answer from the node, hasn't been reproduced on a device yet.
QA Notes
Journeys
N/A
Manual Tests
Automated Checks
PaykitPaymentProofRepoTest.kt,SparkExitRepoTest.kt,SendPendingViewModelTest.ktandAppViewModelSendFlowTest.kt./gradlew testDevDebugUnitTestfor those./gradlew detektModels used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Gemini 4 Neon(reasoning:high)