Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix: leave room for the funding fee and change in the auto channel open wallet clamp - #621

Draft
markettes wants to merge 2 commits into
feat/auto-channel-opening-docsfrom
fix/bug-clamping-wallet-funds
Draft

markettes wants to merge 2 commits into
feat/auto-channel-opening-docsfrom
fix/bug-clamping-wallet-funds

Conversation

@markettes

Copy link
Copy Markdown
Contributor

Description:

  • The wallet clamp no longer sizes a channel to the wallet's whole confirmed balance. It now leaves room for the funding fee plus a 546 sat change output, so the open doesn't fail with negative or dust change.
  • New LightningHelper.MaxFundableChannelSats uses NBitcoin to size the transaction the open actually builds: every available coin in, a funding output and a change output out, priced at HourFee.
  • AutoChannelOpenJob takes its coins from ICoinSelectionService, so coins locked by other requests and frozen ones no longer count. Unit tests cover single-sig, multisig and a wallet too small to fund a channel; a new E2E scenario opens a channel that the wallet clamp sized.
  • The existing auto-open E2E scenario now expects the fee the sender actually offered, matching the planner since commit d4a6771. Shared test UTXO setup moved to TestUtxos.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@lunar-patrol lunar-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Automated security review — no issues found

The PR changes AutoChannelOpenJob to clamp channel size against the wallet's max fundable amount (coins minus estimated funding fee and a dust change output) instead of the raw confirmed balance, using a new LightningHelper.MaxFundableChannelSats and ICoinSelectionService for spendable UTXOs. All inputs come from the operator's own node configuration, NBXplorer's view of the wallet, and internally computed fee rates — no request, message-bus, or other attacker-controlled input reaches the new code, and the fee sizing is verified against NBitcoin's builder for both single-sig and multisig wallets in tests. I found no exploitable defect.

Reviewed 9 files at 5bb1c3e. Nothing to report.

Not a guarantee — one diff, no knowledge of your threat model.

🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.

@markettes
markettes marked this pull request as draft November 25, 2026 12:09

This branch has not been deployed

No deployments
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