Skip to content

Implement max HTLC sync functionality - #578

Merged
markettes merged 1 commit into
mainfrom
feat/max-htlc
Aug 26, 2026
Merged

Implement max HTLC sync functionality#578
markettes merged 1 commit into
mainfrom
feat/max-htlc

Conversation

@markettes

@markettes markettes commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Sets each managed node's advertised max_htlc_msat to MAX_HTLC_CAPACITY_RATIO (default 0.99) of channel capacity, reconciled per channel on every ChannelMonitorJob pass.

Covers all channel types (NodeGuard-created, detected, and pre-existing) since the job reconciles whatever ListChannels reports; writes echo the live base fee / fee rate / timelock and omit inbound fees, so the dynamic fee engine's values are left untouched.

@markettes
markettes requested review from Jossec101 and a lite review from Copilot August 25, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a reconciliation path that keeps each managed node’s per-channel advertised max_htlc_msat aligned to a configurable fraction of channel capacity, executed during ChannelMonitorJob passes. This extends NodeGuard’s channel monitoring loop with an additional LND policy update capability (implemented via an updated UpdateChannelPolicy request builder).

Changes:

  • Introduces MaxHtlcSyncResult and ILightningService.SyncChannelMaxHtlc(...), including auditing and “no-op” detection when already at target.
  • Extends ILightningClientService.SetChannelFeePolicy(...) to optionally set max_htlc_msat, and wires sync execution into ChannelMonitorJob.
  • Adds MAX_HTLC_CAPACITY_RATIO constant + env override and comprehensive unit tests around max-HTLC target resolution and job behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Services/LightningService.cs Implements SyncChannelMaxHtlc, adds result enum, and integrates policy read/write + auditing.
src/Services/LightningClientService.cs Extends SetChannelFeePolicy to optionally include MaxHtlcMsat in the LND policy update request.
src/Jobs/ChannelMonitorJob.cs Calls max-HTLC reconciliation per channel, containing failures per-channel to avoid aborting the job.
src/Helpers/Constants.cs Adds MAX_HTLC_CAPACITY_RATIO default and env-based configuration parsing.
test/NodeGuard.Tests/Services/LightningServiceTests.cs Adds extensive test coverage for max-HTLC sync outcomes, bounds handling, and auditing behavior.
test/NodeGuard.Tests/Services/LightningClientServiceTests.cs Updates tests for the new SetChannelFeePolicy signature (named client: arg).
test/NodeGuard.Tests/Jobs/ChannelMonitorJobTests.cs Adds job-level tests verifying sync is called for each channel and failures are contained.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Services/LightningService.cs
Comment thread src/Services/LightningService.cs
Comment thread src/Services/LightningService.cs
Comment thread src/Services/LightningService.cs
Comment thread src/Services/LightningService.cs
@Jossec101

Jossec101 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

LGTM, 0.99 its big imo but let's see

@markettes
markettes merged commit 40ad62b into main Aug 26, 2026
6 checks passed
@markettes
markettes deleted the feat/max-htlc branch August 26, 2026 11:16
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