Skip to content

fix: preserve rbf replacement fee rates - #166

Open
pwltr wants to merge 2 commits into
masterfrom
fix/rbf-activity-fee-rate
Open

pwltr wants to merge 2 commits into
masterfrom
fix/rbf-activity-fee-rate

Conversation

@pwltr

@pwltr pwltr commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: synonymdev/bitkit-ios#485

Companion: iOS #879.

This PR preserves an outgoing RBF replacement's selected fee rate when activity arrives or is refreshed, so consumer apps can show the correct confirmation estimate.

Description

  • Adds atomic RBF recording so the replacement's rate is retained as pending metadata or applied immediately when its activity already exists, without resurrecting a removed original.
  • Adds wallet-scoped, fee-preserving onchain snapshot upserts so late sync and transaction events cannot overwrite the recorded rate or create a duplicate activity under a different payment ID.
  • Preserves existing tags and metadata, rolls back partial database changes on failure, and leaves explicit generic fee-rate corrections available.
  • Exposes both operations through UniFFI and includes the generated Swift interface and FFI declarations.

Out of Scope

  • Activity history: correcting fee rates already stored incorrectly before this fix.
  • Platform SDK publication, version/checksum updates, Android consumer adoption, and incoming CPFP behavior.

Preview

N/A — shared persistence APIs; no UI changes.

QA Notes

Manual Tests

  • Consumer app → send an unconfirmed onchain transaction at a low custom fee, boost via RBF, and open its replacement → the confirmation estimate matches the boosted rate and the actual replacement fee is retained.
  • Consumer app → refresh, relaunch, and confirm the replacement → its recorded fee rate remains correct.

The author verified the fix in the iOS simulator using a local SDK built on the apps' existing 0.5.18-compatible base. The draft is rebased onto current core master; the activity implementation and tests are identical to that tested snapshot. Integration with the full current-master SDK must be checked when publishing/updating the consumer dependency.

Automated Checks

  • added rbf_tests.rs — ten regressions cover replacement arrival order, persistence across database reopen, stale snapshots, wallet isolation, invalid inputs, metadata preservation, and atomic rollback/retry.
  • ran the activity suite on the 0.5.18-compatible fix snapshot — 206 passed, zero failures; focused RBF regressions also passed.
  • ran Clippy on that snapshot — existing warnings only; none in the changed activity implementation or RBF test file.
  • ran a simulator-only SDK build and the iOS consumer regression suites — all 32 iOS tests passed, including eight RBF tests and existing activity/hardware-wallet/transfer coverage.
  • ran Rust formatting and generated Swift interface typechecking after rebasing onto master — passed.

@pwltr
pwltr marked this pull request as ready for review October 6, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant