Repository navigation
feat: LDK-aligned dynamic fee estimation - #202
Open
ABallarini wants to merge 4 commits into
Open
ABallarini wants to merge 4 commits into
ABallarini wants to merge 4 commits into
Conversation
ABallarini
force-pushed
the
feature/dynamic-fee-estimation-utexo
branch
from
October 9, 2026 19:47
b3618bd to
dc03a8d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the hardcoded static fee (
7 sat/vB) with a dynamic, thread-safe fee estimation system built in compliance with LDK Fee Estimation Guidelines.The default behavior is RLN will update the fees for each confirmation target dynamically every 60s in the background (as LDK recommends here) based on fee estimates from bitcoind, esplora, or electrum.
So in order of priority the fallback chain is:
fee_rateoptionally passed in the request (for API endpoints likesendbtc,sendrgb,createutxos,inflate)Key Highlights
/estimatefeeand the four spend APIs all read the one atomic cache LDK already polls every 60s; fee queries stay non-blocking (no I/O on the transaction path).store_fee_estimatesis the single gatekeeper for all three poll loops, validating every estimate within[MIN_FEERATE, MAX_FEERATE](1.0–2500 sat/vB / 253–625,000 sat/kWu). Out-of-range remote responses log a warning and retain last-known-good values.resolve_fee_sat_per_vb()— an explicit> 0rate wins, an absent or0rate falls back to theOutputSpendingFeetier, the same tier channel funding reads directly./estimatefeeAPI: exposes structuredfee_ratestiers (background,normal,high_prio,very_high_prioin sat/kWu) directly from the LDK fee cache alongside the legacyfee_rate.fee_ratebecomes optional (additive schema), so existing clients keep working. A black-box regtest test (src/test/dynamic_fee.rs) measures real on-chain feerates, funding vs/estimatefeebackground, an explicit 120 sat/vB override, and the omitted-fee fallback, and passes alongside the existing suite.Documentation Links