Repository navigation
Conversation
A late failure event of an earlier attempt no longer ends the hold of an uncertain retry of the same invoice. After a waiting early claim, the Instant claim poll stops quoting and only watches for the claim. Also rewords the spark send liveness comment.
Stub the now-suspending move check in the send flow tests, drop translations of two keys English marks untranslatable, wrap long lines, and add the Activity row to the move-to-spark journey. Verified: detekt, lintDevDebug, MoveToSparkRepoTest, BackupRepoTest, AppViewModelSendFlowTest, MoveToSparkViewModelTest
A closed Move to Spark screen's late cleanup no longer clears the quote of a screen opened after it. Skipping unimportable stored exit data drops a staged restore only when it holds that same data. Verified: detekt, BackupRepoTest, MoveToSparkViewModelTest, SparkRepoTest, MoveToSparkRepoTest
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. |
[High impact] The PR reaches payment tracking, wallet activity, Spark claiming, and exit-backup workflows. Clear the move manager during wallet wipe before merging. FindingsSummaryThis PR keeps Move to Spark running after its screen closes and remembers move hashes across restarts.
Acknowledged behavior: ovitrif explicitly describes the missing restored send time and the decision to let failure events end that hold after restart. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Screen[Move screen] --> Manager[App-scoped move manager]
Manager --> Repo[Move repository]
Repo --> Cache[Persist move hash]
Repo --> LDK[Send over Lightning]
LDK --> Outcome[Wait for payment outcome]
Outcome --> Manager
Cache --> Activity[Move title and icon in Activity]
Wipe[Wallet wipe] --> Stores[Clear wallet stores and node]
Wipe -. Missing reset .-> Manager
Reviews (1) · Last reviewed commit: "fix: keep staged exit data and a reopene..." · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
Back up move to Spark hashes in the metadata envelope as bitkit-ios does (lowercase, sorted, left out when empty, read leniently) and merge them on restore. Set unimportable exit data aside under SPARK_EXIT_REJECTED, keeping the first copy and a different one under its digest. List moves under Other, not Sent, and keep a pending or failed move's row with its status. Verified: just test, just lint
|
Pushed
|
An earlier attempt's late failure now returns before it is recorded, so the uncertain retry's Activity row stays pending, as on bitkit-ios. The move-to-spark journey takes the iOS wording for its last steps. Verified: just test, just lint
|
Pushed |
talosmachina
left a comment
There was a problem hiding this comment.
No findings in the paths I read. Spark follow-ups: moves to Spark are kept in the cache and backup so Activity shows each as one move, the move screen's state now lives in a singleton MoveToSparkManager, unimportable Spark exit backups are set aside, an older failure no longer settles an uncertain retry, and QuickPay re-checks its limits at dispatch. Reviewed 114f3a8, static: per the Bitkit track rules this branch was not built here.
What I checked, and 4 candidates I ruled out
Read: MoveToSparkRepo, MoveToSparkManager, MoveToSparkViewModel, CacheStore.addMoveToSparkHash, BackupPayloads (LenientStringListSerializer), the BackupRepo exit-backup and restore hunks, the SparkRepo hunks (uncertain sends, early claim wait, mergeRemoteExitBackup), ActivityListViewModel, ActivityRow / ActivityIcon / ActivityDetailScreen.
Not read in full: the middle of the QuickPayRepo diff (LNURL admission and the dispatch path), and the tests.
Ruled out
- Hash case mismatch: every write and read of
moveToSparkHasheslowercases, including restore merge andisMoveToSpark. - A move lost on process death before payment: the hash is persisted before
payAndWait, so a restart still hides both legs. - Rejected exit backup overwritten:
setAsideRejectedExitBackupnever replaces an existing copy and suffixes a different one with its SHA-256 prefix. - Screen reset cancelling a running move:
resetreturns whileisMoveInFlight, and a newer screen token blocks an older screen's reset.
Merge confidence: 3/5, part of the diff (QuickPay dispatch, tests) was not read, so this is the ceiling whatever the reviewed paths showed.
Verified: just compile, just test, just lint
|
Pushed f7184ed: three changes, each to match synonymdev/bitkit-ios#1355.
New cases in |
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at f7184ed: no findings.
f7184ed already closes the one candidate that survived verification, the late-failure compare with no clock-skew margin. isEarlierFailureOfUncertainSend now allows RAIL_CLOCK_SKEW_SECONDS = 10 (SparkRepo.kt:1787), as iOS does. I reproduced the old behaviour with a unit test before the push: a phone clock 3 s ahead of Spark dropped the send's own PaymentFailed, leaving the send screen pending and the invoice refused until it expired. The 10 s margin makes it pass, and the older-failure cases still hold.
What I checked:
- Double pay.
reset()is skipped whileisMoveInFlight, andstart()doesn't quote while it keeps an outcome. Done(InFlight) offers only OK, so no path from the UI quotes over a running move. A restart mid-move re-quotes with a new invoice, and the pending HTLC lowersmovableSats. The fee cap is stillfeeCapMsat(quote.feeSats), now tested. - Backup. Spark and Move to Spark aren't in v3.1.1, so there's no installed format. The new field is read as null from old envelopes and ignored by old apps (
ignoreUnknownKeys).LenientStringListSerializerreturns empty for malformed values. Restore takes the union of lowercased hashes. Wipe resetsCacheStore(WipeWalletUseCase.kt:122). - Exit set-aside (
f7184ed). Rejected staged exit data is copied aside under a digest-keyedSPARK_EXIT_REJECTED_*key beforediscardStagedExitStatedeletes it. The delete happens only when the file still holds the same data, so a failed set-aside keeps the staged file for the next upload. A transient import failure staysPending. - Cancellation. It propagates through the move and the exit paths.
quoteJobis touched only from the main thread, and generation checks guard the state writes. - iOS twin. synonymdev/bitkit-ios#1355 already had the skew margin and a synchronous move-hash read.
perf: mildly relevant. After Spark reports Waiting, the claim poll does one listUnclaimedDeposits per 5 s tick instead of a list plus a quote. Each Activity row now runs its own moveToSparkHashes collector.
Device gate (partial): f7184ed — not run yet; pending: transfer/move-to-spark.xml with Back during a move and reopen, Activity rows and details for a done, pending and failed move, and Activity scroll frame timing with 100+ rows. Device results and the final review type follow in a second review.
Verified: just compile, just test, just lint
|
Pushed ab895d2: two changes, each to match synonymdev/bitkit-ios#1355.
New cases in |
A sync that runs as a send returns no longer takes back its saved hold before the result clears it, as when Spark refuses it for its balance. Verified: just format, just compile, just test, just lint
A sync takes back saved holds under the same lock a send leaves flight with, so it never restores a hold a refused send just cleared. Verified: just format, just compile, just test, just lint
Settling a send takes its hold and clears the saved copy under the lock a sync restores holds with, so its failure is reported once. Verified: just format, just compile, just test, just lint
The poll and Spark payment event claim the payment id before reporting, so a failure the poll settled first is not reported again. Verified: just format, just compile, just test, just lint
The poll builds the event from the payment it read and claims its id only for the send own final outcome, so a retry read as pending keeps its success and an expiry past an earlier failure is still reported. Verified: just format, just compile, just test, just lint
Verified: just format, just compile, just test, just lint
Verified: just format, just compile, just test, just lint
Verified: just format, just compile, just test, just lint
|
cc0cc6c: a failure event no longer drops a retry's hold. The event checked the hold, then read Spark's list and wrote the row before ending the hold and the saved send for the invoice, so a retry that entered Spark's send call in between lost both. The event now checks again under the restore lock right before ending them, as the poll does since 5f79ba2. |
Verified: just format, just compile, just test, just lint
The sync that records Spark's list now settles each held send from that same list, so a send whose own failure Spark lists frees its invoice at launch even when the next read of Spark's list fails. Verified: just format, just compile, just test, just lint
pwltr
left a comment
There was a problem hiding this comment.
Reviewed d20d1c7. Spark's ten-second clock allowance in SparkRepo.kt:1535 can match a previous attempt's failure to a different attempt on the same invoice. For example, the first attempt fails, the user retries five seconds later, and the retry loses its response while history still shows only the first failure.
Medium: The poll and the delayed failure callback can both release the live retry's hold and saved send (SparkRepo.kt:688, SparkRepo.kt:741, SparkRepo.kt:1990, SparkRepo.kt:2009). That allows another submission, including over a Lightning channel, while Spark may still finish the retry.
Medium: The pending-screen lookup can independently use that first failure before the hold is cleared (SparkRepo.kt:1518, AppViewModel.kt:7991, AppViewModel.kt:8022). It reports the retry as failed, clears its pending contact context and stops tracking it on the Pending screen. Bind failure to the attempt before releasing the invoice or resolving the screen.
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
A retry's saved start is floored 11 s past every failure Spark dated for its invoice, or past now when Spark's list can't be read, so an earlier attempt's failure inside the clock margin never reads as the retry's own. A failure only fails an existing send row in place, so at expiry the retry's row keeps its own amount and fee. Verified: just format, just compile, just test, just lint
|
@pwltr the clock-margin case from your review of synonymdev/bitkit-ios#1355 applies here too, as this PR uses the same date rule. Fixed in 8573baf:
The remaining gap is a retry starting before the app knows the earlier attempt's failure. It can't happen:
Also in 2372752: the launch sync now settles a held send from the list it just read, so a send whose own failure Spark lists frees its invoice even when the next read of the list fails. Covered by new cases in |
@pwltr addressed in 8573baf, which this comment explains. A retry's saved start is now at least 11 s past the earlier attempt's failure, so in your five-second case that failure reads as the earlier attempt's on every path that reads it: the poll, the failure event, and the pending-screen lookup. The retry stays held and pending until its own outcome or its invoice's expiry. |
The sync settles only the holds taken before it read Spark's list, so a send held while it writes activity is never settled from that older list. A send whose start can't be dated because Spark can't list its payments is refused before anything goes out, instead of saving a start past now that made its own failure read as an earlier attempt's. Verified: just format, just compile, just test, just lint
After a restore, before Spark syncs, its list can't date an earlier attempt the operators show failed, and a send must start past that failure, so a Spark send of such an invoice is refused until Spark syncs. An invoice the operators show no send of still sends. Verified: just format, just compile, just test, just lint
|
Pushed ff2687e: after a restore, before Spark syncs, a Spark send of a pre-restore invoice that the Spark operators show failed is now refused until Spark syncs. Spark's list can't yet date that earlier failure, and a send must start past it so the failure never reads as its own. An invoice the operators show no send of still sends, and the node's rail is unchanged. This matches bitkit-ios. |
Closes #1802
Closes #1819
Closes #1840
Closes #1848
Closes #1919
Closes #1976
Closes #1983
Closes #1982
Closes #1984
Closes #1986
Twin: synonymdev/bitkit-ios#1355
This PR closes the remaining Spark follow-ups from bitkit-android#1946. It also carries the Android side of three iOS issues:
Description
MoveToSparkManagerholds the move and its outcome. Pressing Back during a move no longer cancels the wait. Opening the screen again shows the same move. When a closed screen's cleanup runs late, it leaves a reopened screen's quote alone. A wallet wipe drops the move, so the next wallet starts on a new quote. A move waiting on its payment reads the node's stored payment again while it waits, so a missed outcome still ends it. Spending and Lightning Connections keep offering Move to Spark while a move is kept for its result, also once too little is left to move again.CacheStore, so after a restart the move is still recognised: no received notice, and it stays a Move to Spark row. The metadata backup carries the hashes asmoveToSparkPaymentHashes, as bitkit-ios does: lowercase hex, sorted, left out when there are none, and read as none when the value is not a list of strings. A restore adds them to the device's own.MoveToSparkRepo.move(). They cover:payInvoiceOverLdkand the fee reported backSPARK_EXIT_REJECTED_plus the first 16 hex digits of its SHA-256, as bitkit-ios does in the same VSS store, and the fresh export is uploaded. Each copy has its own key, so none replaces another, and a copy already kept is not uploaded again. A staged restore is dropped only when it holds that same data. Restored data that Spark rejects as invalid input is set aside the same way before the upload: the stored backup when it still holds that data, otherwise a new backup envelope around it. Then it is dropped instead of being retried on every start, and the stored backup is merged into Spark before the upload, so exit data another device stored is never replaced. Dropping a rejected staged copy asks for the stored backup to be merged again, and every upload merges it until one merge succeeds, also after a failed attempt. Stored data Spark can't import is replaced only when it is still the stored one after it was set aside. A staged restore is compared and dropped under the same lock that stages and imports it, so a restore retried meanwhile keeps its new copy. A restore that finds stored exit data it can't read sets it aside the same way and reports the exit data as not restored. Any other error still blocks the upload. The restore's cache log leaves out the move hashes. This is the Android side of bitkit-ios#1268.lightning__setting_up__step_seen,lightning__setting_up__step_sentandlightning__spending_confirm__up_toare not in English, so they are not added.LightningRepo.ktis reworded (bitkit-android#1919).release.ymlalready fails early on a blank key, andrelease-internal.ymlleaves the key optional on purpose.Out of Scope
Design
N/A — no design available. The row reuses the existing Lightning-era Transfer activity row (component, icon, layout), titled "Move to Spark"; a later design can restyle it.
Preview
Activity shows a move as one outgoing Move to Spark row, and its detail shows the moved amount, the routing fee and the transfer icon:
row2x.mp4
QA Notes
Setup
sparkprofile of bitkit-docker, plus a dev build pointed at it, with one channel to the SSP.Journeys
move-to-spark.xml— after the move, Activity lists a "Move to Spark" transfer row with the moved amount plus the routing fee, and its detail is titled "Move to Spark"Manual Tests
N/A
Automated Checks
MoveToSparkRepoTest.kt— the move pays capped at the quoted fee and reports the fee paid, matches a failure by payment id, reports a payment with no outcome in time as in flight, and keeps a move's hash after a restart, and a move whose outcome was missed while the node was down reads it once the node is backMoveToSparkViewModelTest.ktcases — leaving during a move keeps it and shows it again, leaving while it's in flight keeps waiting, leaving after it settled quotes anew, a closed screen's late cleanup leaves a reopened screen's quote, wiping the wallet drops an in-flight move and quotes anewAppViewModelSendFlowTest.ktcases: a pending Spark send whose success was handled before it was tracked resolves as sent, and leaves the next send's contact aloneSparkFundingViewModelTest.ktcase: a max transfer's swipe approves no higher Instant claim fee than the one shownSparkRepoTest.ktcases — the claim poll stops quoting once Spark waits for the early claim and shows Adding once it claims; a failure listed or reported while a send is in doubt or in Spark's send call is no settled send event, and an earlier attempt's late failure event leaves a send in doubt pending, refused and with no failed row, also when Spark took the retry; a retry Spark took stays held while Spark lists only an earlier attempt's failure; a send whose caller was cancelled inside Spark's send call ends at its invoice's expiry without a restart; an older attempt's failure event leaves the row of a later failed attempt; a send Spark refuses for its balance stays in flight until its hold is cleared; a sync while the poll settles a send in doubt reports its failure once; a send's own failure the poll settled first is reported once when Spark's event follows; a retry Spark never lists reports its failure at expiry past an earlier failure already reported; a retry read as pending while the poll settles a send keeps its own success event; a retry that enters Spark's send call as the poll settles a send never shows the earlier send's failure and keeps its saved expiry; a retry that enters Spark's send call while a failure event is handled keeps its hold and saved send, and never shows the earlier failure; a send in doubt ends at once on its own failure, and a retry then sends again; a send in doubt fails its row and reports its failure once its invoice expires with only an earlier failure listed; a send that failed lets a retry of its invoice send again; a retry's success decides its Activity row over an earlier attempt's failure; an uncertain retry's row stays pending after a restart while Spark lists only its older failure; a held send whose own failure the launch sync lists frees its invoice even when the next read of Spark's list fails; a retry started 5 s after an earlier attempt's failure stays held while Spark lists only that failure, and at expiry fails its own row in place, also through the next start's sync; a send is refused before it goes out while Spark can't list its payments; a send held while a sync writes its list is not settled from that list; an unsynced Spark refuses a pre-restore invoice the operators show failed and sends one they show no send of; dropping rejected staged exit data asks for the stored backup to be merged again; staged exit data Spark rejects reads as rejected while other import failures stay pendingBackupRepoTest.ktcases — stored exit data that Spark can't import, or that doesn't parse, is kept apart and the upload goes through; each copy goes under its own digest key and never the plain key, and a copy already kept is not uploaded again; a restore sets aside exit data it can't read and reports it not restored; a rejected staged copy merges a stored backup another device replaced before the upload, also on the next upload after a failed merge, and stored data replaced while unreadable data was set aside is merged first; staged exit data Spark rejects is set aside as the stored backup that holds it, or on its own once the stored one moved on, and dropped; other merge errors still block it; the metadata backup carries the move hashes lowercase and sorted, leaves them out with none, and a restore adds them to the device'sBackupJsonTest.ktcase — move hashes read from a list of strings, and any other value reads as noneActivityListViewModelTest.ktcase — a move, failed too, lists under Other and not under SentLightningConnectionsViewModelTest.ktcase — a move kept for its result keeps Move to Spark offered once nothing is left to moveWipeWalletUseCaseTest.kt— a wipe resets the Move to Spark managerNotifyPaymentReceivedHandlerTest.ktandAppViewModelSendFlowTest.kt— the move check is now a suspend callEvidence
001af49fc, with the local hook.114f3a88cadds the pending and failed move rows and lists moves under Other. Unit tests cover those; the Preview doesn't show them.just compile,just test, detekt andlintDevDebugpass.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)Claude Sonnet 5.5(reasoning:high)