Skip to content

Conversation

@Camillarhi
Copy link
Contributor

This update replaces the flat fee requirement for anchor channel reserves with a more accurate estimation using the new lightning::util::anchor_channel_reserves utility.

  • Integrated anchor_channel_reserves for dynamic reserve estimation
  • Removed flat static fee for anchors
  • Updated relevant logic and documentation to reflect the new estimation approach

Closes #668

…serve estimation

Replaced flat fee-based reserve logic with estimation using
`get_reserve_per_channel`, following changes introduced in
lightningdevkit/rust-lightning#3487.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 22, 2025

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot ldk-reviews-bot requested a review from tnull October 22, 2025 11:59
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 6th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 7th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 8th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 9th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 10th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 11th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 12th Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse the delay here, this looks already pretty good, but I have a few comments. This unfortunately also needs a rebase by now - sorry!

Given how high the current dynamic estimation result currently is I do wonder if we need to give other defaults or if we even can realistically switch to it.

}

/// Returns the configured anchor channel reserve per channel in satoshis.
pub fn get_anchor_reserve_per_channel() -> u64 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make this public, esp. given the only other call site is our tests.

let addr_b = node_b.onchain_payment().new_address().unwrap();

let premine_amount_sat = if expect_anchor_channel { 2_125_000 } else { 2_100_000 };
let anchor_reserve = if expect_anchor_channel { get_anchor_reserve_per_channel() } else { 0 };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than calling this to get the dynamic value, can we still keep a fixated value here that would also allow us to check if the method works as expected and detect if/when something changes.

/// **Note:** Depending on the fee market at the time of closure, this reserve amount might or
/// might not suffice to successfully spend the Anchor output and have the HTLC transactions
/// confirmed on-chain, i.e., you may want to adjust this value accordingly.
pub per_channel_reserve_sats: u64,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to keep this as an override and make it an Option<u64> so that user can still set a specific value if they want. But probably the default should be None, i.e., dynamic estimation.

/// Returns the configured anchor channel reserve per channel in satoshis.
pub fn get_anchor_reserve_per_channel() -> u64 {
let context = AnchorChannelReserveContext::default();
get_reserve_per_channel(&context).to_sat()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it seems the current defaults would result in a channel reserve of 336513sats (~$300) per channel. This seems very conservative, and much too high for the typical use case we currently expect in LDK Node. This makes me wonder if we either need to use different defaults, or not opt for dynamic estimation right now. Will discuss this with a few other devs and get back to this.

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.

Make use of lightning::util::anchor_channel_reserves to improve anchor reserve estimation?

3 participants