Skip to content

Account for UTXO base weight in anchor reserve checks#4670

Merged
wpaulino merged 1 commit into
lightningdevkit:mainfrom
tnull:2026-06-anchor-reserve-input-weight
Jun 10, 2026
Merged

Account for UTXO base weight in anchor reserve checks#4670
wpaulino merged 1 commit into
lightningdevkit:mainfrom
tnull:2026-06-anchor-reserve-input-weight

Conversation

@tnull

@tnull tnull commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

get_supportable_anchor_channels estimates how much each reserve UTXO can contribute after spending fees. Include the base input weight in that fee so UTXOs just below the public per-channel reserve are not counted as supporting another anchor channel.

Co-Authored-By: HAL 9000

This finding was discovered by Project Loupe

get_supportable_anchor_channels estimates how much each reserve UTXO can contribute after spending fees. Include the base input weight in that fee so UTXOs just below the public per-channel reserve are not counted as supporting another anchor channel.

Co-Authored-By: HAL 9000

This finding was discovered by Project Loupe
@ldk-reviews-bot

ldk-reviews-bot commented Jun 10, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @wpaulino 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-claude-review-bot

Copy link
Copy Markdown
Collaborator

No issues found.

The change in anchor_channel_reserves.rs:243-247 correctly includes BASE_INPUT_WEIGHT in the per-UTXO spend fee. Utxo.satisfaction_weight only covers the witness/scriptSig portion and excludes the base input weight (txid + vout + sequence), so adding BASE_INPUT_WEIGHT is necessary and matches the consistent pattern used everywhere else in the codebase (wallet_utils.rs, funding.rs, chan_utils.rs). The math checks out (BASE_INPUT_WEIGHT + p2wpkh satisfaction == P2WPKH_INPUT_WEIGHT), and the added test correctly exercises the off-by-one boundary that the fix addresses.

@ldk-reviews-bot

Copy link
Copy Markdown

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@wpaulino wpaulino merged commit 5b76e6b into lightningdevkit:main Jun 10, 2026
1 check passed
@tnull tnull self-assigned this Jun 11, 2026
@tnull tnull moved this from Done to Goal: Merge in Weekly Goals Jun 11, 2026
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Backported to 0.2 in #4683.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Goal: Merge

Development

Successfully merging this pull request may close these issues.

5 participants