Skip to content

fix: use send-all fee estimation for max channel fundable amount#475

Merged
ovitrif merged 2 commits intomasterfrom
fix/use-send-all-fee-est
Mar 5, 2026
Merged

fix: use send-all fee estimation for max channel fundable amount#475
ovitrif merged 2 commits intomasterfrom
fix/use-send-all-fee-est

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Mar 5, 2026

Summary

  • maxChannelFundableAmount() was using calculateTotalFee() with the full onchain balance as the send amount. When balance ≈ amount + fees, the change output falls below the dust limit (546 sats), causing ldk-node's coin selection to reject with CoinSelectionFailed.
  • Switched to estimateSendAllFee(), which builds a drain transaction (no change output) — the correct API for computing "balance minus fees".
  • Fix Claude Code Review workflow: add --comment flag and --allowedTools so reviews are posted as PR comments instead of silently discarded; add concurrency group to cancel redundant runs on force-pushes. (workflow changes take effect on PRs opened after merge)
  • This unblocks the ldk-node rc.32 upgrade (chore/bump-ldk-node branch).

Test plan

  • Build the project in Xcode
  • Run on regtest with ~100k sats onchain balance
  • Confirm the "Coin selection failed" / "Could not calculate channel funding fee" errors no longer appear in logs
  • Confirm channelFundableBalanceSats shows a reasonable value (balance minus estimated fee)
  • Confirm channel funding still works with the calculated amount
  • After merge: open a new PR and verify Claude Code Review posts comments and has fewer permission denials

🤖 Generated with Claude Code

maxChannelFundableAmount() passes the full onchain balance as the send
amount to calculateTotalFee(), which creates a change output that falls
below the dust limit (546 sats) when balance ≈ amount + fees. This
causes ldk-node's coin selection to fail with "CoinSelectionFailed".

Use estimateSendAllFee() instead, which builds a drain transaction with
no change output — the correct API for computing "balance minus fees".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ovitrif ovitrif requested review from ben-kaufman and pwltr March 5, 2026 13:41
ben-kaufman
ben-kaufman previously approved these changes Mar 5, 2026
Add --comment flag to prompt so review output is posted as PR comments
instead of discarded. Add --allowedTools to permit gh/git commands.
Add concurrency group to cancel redundant runs on force-pushes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ovitrif ovitrif merged commit 3f2c07a into master Mar 5, 2026
10 of 11 checks passed
@ovitrif ovitrif deleted the fix/use-send-all-fee-est branch March 5, 2026 17:22
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.

3 participants