Repository navigation
fix: preserve boosted activity fee rates - #1429
Conversation
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
eb891e2 to
c05ad86
Compare
[Medium impact] This PR appears safe to merge; no actionable issues were found. SummaryPreserves the approved fee rate for outgoing RBF replacements.
No actionable issues were found. Tests were inspected, not run. Acknowledged scope: pwltr states that sheet teardown before recording, boosts from another device, historical corrections, and incoming CPFP are outside this fix. DiagramsequenceDiagram
participant VM as BoostTransactionViewModel
participant Node as LightningRepo
participant Repo as ActivityRepo
participant Core as Core
VM->>Node: Broadcast replacement with approved rate
Node-->>VM: Replacement transaction ID
VM->>Repo: recordRbfBoost(original, replacement, approved rate)
Repo->>Core: Record replacement fee rate
Core-->>Repo: Success or failure
Note over VM,Repo: A recording failure logs a warning
VM->>Repo: publishRbfBoost(original, replacement)
Repo->>Core: Discover and link replacement
Note over Core: Later snapshot writes preserve the stored rate
Reviews (1) · Last reviewed commit: "fix: preserve boosted activity fee rates" · Reviewed by Greptile |
|
Milestone 3.2.0: this PR is the Android twin of synonymdev/bitkit-ios#879, whose issue synonymdev/bitkit-ios#485 is in 3.2.0, and it needs bitkit-core 0.8.0-rc15, which ships only in 3.2.0. It closes no issue, so the milestone sits on this PR. |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Records the approved Boost quote's rate through core's recordRbfBoost and moves the sync, replaced, replacement, reorg and eviction writes onto upsertOnchainActivityPreservingFeeRate, so the boosted rate survives. Reviewed c05ad86, full tier, static: per the Bitkit track's rule the branch was not built here; CI built and tested it.
What I checked, and 5 candidates I ruled out
Read in full: the diff of BoostTransactionViewModel.kt, ActivityRepo.kt, CoreService.kt (processOnchainPayment, buildUpdatedOnchainActivity, publishRbfBoost, markReplacedActivity, updateReplacementActivity, reorg and eviction handlers), and bitkit-core v0.8.0-rc15 record_rbf_boost and upsert_onchain_activities_with_fee_rate_policy.
Call sites traced: recordRbfBoost (one caller, the RBF success branch), every remaining updateActivity / upsertActivity / upsertActivities in ActivityService.
CI: green, including build-and-test, lint, detekt, compose-ui and all e2e-tests-local shards (onchain_boost_receive_widgets included).
Ruled out
- Record before the replacement row exists: core writes
pre_activity_metadatakeyed by the replacement txid, and the preserving upsert transfers it inside the same transaction when the row first appears throughgetOrCreateReplacementActivity. - Preserving upsert keeps the original's 1 sat/vB on the replacement: the core statement keeps the stored rate only on conflict for the same wallet and id, and resolves the id by txid, so the replacement row gets its own rate.
- Stale
isBoostedon the original afterrecordRbfBoost:markReplacedActivityre-reads the original by txid insidepublishRbfBoostbefore writingisBoosted = false, so the in-memory activity the sheet holds is never written back. - Publication retry records a later fee edit: the rate comes from
broadcast.quote, captured when the broadcast started and locked byfeeLocked. - Hardware-wallet and backup paths:
mergeHwSnapshot,upsertListandrepairVerifiedSentOnchainFeekeep the generic writes; none of them can carry a boosted native rate, and the last is an intended correction.
Merge confidence: 4/5, CI green and ActivityServiceRbfTest.kt covers the write paths, but this review is static and the branch was not run here.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at c05ad86d8: no findings.
- The replacement records the same
RbfBroadcastAttempt.quote.feeRatepassed tobumpFeeByRbf. The next boost's floor (feeRate + RBF_MIN_INCREASE) now starts from the replacement's real rate instead of the1default, so a second boost can't be quoted below it. - Core's preserving upsert keeps a stored rate above 0 on sync, and
record_rbf_boosthandles both arrival orders throughpre_activity_metadata. All changed writes run on the singleServiceQueue.CORE. - No schema change:
v3.1.0already pins core rc11 with these columns. - One changelog fragment.
journeys/boost/rbf-replacement-fee-rate.xmlmatches the iOS twin's actions.
I checked one concern on device, and it didn't hold up. The worry was that recordRbfBoost marks the original boosted before publishing, so a replacement that never lands could leave the original stuck on "Boosting". With the network cut after opening the sheet, ldk-node fails the bump (Persistence failed writing the broadcast record to VSS) before returning a txid. So nothing is recorded, and the original stays "Confirming" with Boost enabled after a restart. The only window left needs VSS reachable while the Electrum broadcast fails, which I couldn't stage.
Device gate (partial): c05ad86d8 — not run yet; pending: boost/rbf-replacement-fee-rate.xml (J1) and rbf-own-send.xml (J2). Device results and the final review type follow. perf: one extra short transaction on the core queue before publish.
Reviewer model: Claude Fable 5.2 (claude-fable-5-2), Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: not exposed
jvsena42
left a comment
There was a problem hiding this comment.
Device gate result: approving, nothing above LOW.
Device gate: c05ad86d8 — journeys: 2 passed (boost/rbf-replacement-fee-rate.xml 12/12; boost/rbf-own-send.xml 13/13 on a clean re-run). perf: not relevant; l10n: no UI text changed.
- Setup: Gate_Throwaway emulator, dev regtest on staging Electrum, fresh wallet with 250 000 sats.
- J1: a 1 sat/vB send (fee 141) boosted to the Fast tier (fee 422, new txid). The Home row reads "Confirms in ±10m" instead of the 1 sat/vB estimate, keeps it after background and reopen, and confirms after a block. The second-boost floor isn't reachable on this route ("Already Boosted" after one RBF);
BoostTransactionViewModelTestcovers it. - J2's first run failed actions 7-8 on a timing race in
publishRbfBoost, code this PR doesn't change. One sync didn't find the replacement yet (Failed to publish RBF replacement [AppError='RBF replacement is not available']), and the replace event arrived 6 s later. The sheet took the pending path, and the original briefly showed "Removed from Mempool" before the replacement row healed. A clean re-run passed all 13 actions. NoFailed to record RBF fee ratein either run, and the replacement kept the boosted estimate.
J2 run 1 log
16:34:38.651 DEBUG [BoostTransactionViewModel.kt:277] Boost successful. newTxId: 6ed355ff…
16:34:42.005 WARN [BoostTransactionViewModel.kt:281] Failed to publish RBF replacement [AppError='RBF replacement is not available']
16:34:47.533 INFO [ldk_node::chain:565] Onchain transaction d7b2c773… was replaced by 1 transaction(s)
16:34:48.593 INFO [CoreService.kt:1828] Updated replacement '6ed355ff…' with boostTxId 'd7b2c773…'
|
Merging, as it is approved at c05ad86 with both boost journeys passing on device, and checks are green. |
Related: iOS #485.
Twin: synonymdev/bitkit-ios#879
Dependency: synonymdev/bitkit-core#166 (released in bitkit-core 0.8.0-rc15, already pinned on master)
This PR preserves the fee rate a user picks for an outgoing RBF boost, so the replacement transaction keeps the correct confirmation estimate through publication, wallet sync, reorgs and evictions.
Description
recordRbfBoost) right after the node returns the replacement, beforepublishRbfBoostpublishes it. This works in either arrival order: core stores the rate as pre-activity metadata for a replacement it has not seen yet, and updates it directly if it already exists.upsertOnchainActivityPreservingFeeRate) — payment sync merges, replaced-original retirement, replacement linking, reorg and eviction — so a stale or fallback rate cannot overwrite the recorded one.repairVerifiedSentOnchainFeekeeps the generic upsert because it is an intentional fee correction.journeys/boost/, next torbf-own-send.xml, with the same path and actions as iOS.Out of Scope
Design
N/A — no UI changes.
Preview
before.mov
Screen.Recording.2026-10-06.at.17.44.28.mov
Note: both recordings were made on the earlier revision of this PR, with a local core SDK build, before it was merged onto master's current boost flow and the released 0.8.0-rc15 core. They show the intended behaviour but were not re-recorded on the current head.
QA Notes
Setup
Dev flavor on staging regtest with a disposable native wallet holding at least 100,000 confirmed Savings sats (
./lspdeposit and mine — see Backend preconditions injourneys/README.md), plus a regtest recipient address from another wallet. Core:com.synonym:bitkit-core-android0.8.0-rc15 as pinned on master; no local SDK substitution.Journeys
rbf-replacement-fee-rate.xml— a low-fee outgoing send's replacement shows the boosted confirmation estimate, keeps its higher real total fee after sync and reopening, and confirms normally.rbf-own-send.xml(file unchanged) — the same Boost route now records the fee rate before publication; the replacement still appears immediately as Boosting with a new TXID, and confirms after a block.Manual Tests
c05ad86d8against staging regtest: passed.Automated Checks
ActivityServiceRbfTest.kt— the atomic core call receives the wallet, ids and rate; publication, external replacement, payment sync, reorg and eviction keep a recorded replacement rate and never use a generic write (updateActivity,upsertActivity,upsertActivitiesorinsertActivity).ActivityRepoTest.kt—recordRbfBoostpasses the wallet-scoped ids and rate, notifies activity and tag observers, propagates storage failure without notifying, and preserves cancellation.BoostTransactionViewModelTest.kt— the quoted rate is recorded before publication; a recording failure still publishes and reports success; a failed broadcast records nothing; a publication retry records the approved quote, not later fee edits.ActivityServicePaykitContactsTest.kt,ActivityServiceTest.kt— the harnesses capture writes through the fee-preserving upsert, which the sync path now uses.Evidence
On the branch with origin/master
2eb505a51merged in, against bitkit-core-android 0.8.0-rc15:just compile,just test(5,883 tests, 0 failures, 2 skipped),just lint(detekt andlintDevDebug) andjust build(dev debug APKs) all passed locally. After adding the generic-write guard toActivityServiceRbfTest, the three RBF test classes (18, 28 and 87 tests) andjust lintpassed again; temporarily switching the reorg/eviction writes toupsertActivitymade the guard fail as intended.Gaps
journeys/boost/path) against rc15 on a simulator: the replacement kept the boosted 3 sat/vB through reopening and confirmation.recordRbfBoost, or the boost is made on another device, the replacement keeps core's default rate; out of scope here.Models used
Claude Opus 5.5(reasoning: Not exposed)Claude Opus 5.5(reasoning: Not exposed)Claude Opus 5.5, independent read-only review of the full diff; no correctness bugs found, the test-guard finding is addressedMetadata note: the original revision of this PR was written in an earlier session whose model metadata is not available here.
🤖 Generated with Claude Code