Skip to content

Expose ChannelCounterparty and ReserveType in ChannelDetails#841

Open
enigbe wants to merge 2 commits intolightningdevkit:mainfrom
enigbe:2026-03-channel-reserve-type-exposure
Open

Expose ChannelCounterparty and ReserveType in ChannelDetails#841
enigbe wants to merge 2 commits intolightningdevkit:mainfrom
enigbe:2026-03-channel-reserve-type-exposure

Conversation

@enigbe
Copy link
Contributor

@enigbe enigbe commented Mar 24, 2026

What this PR does

In #305, we needed a way to expose channel type and the channel reserve without leaking implementation details not useful to users. The related discussion in #141 proposed a ReserveType abstraction that bakes in both in a user-relevant way. This PR introduces the said enumeration to ChannelDetails with the following variants:

  • Legacy: signifying pre-anchor channel types where on-chain fees paying for broadcast transactions following channel closure were pre-determined
  • TrustedPeersNoReserve: for anchor type channels with trusted peers
  • Adaptive: indicating anchor channel with adaptive reserve, reflecting dynamic best-effort attempt at fee-bumping.
    (see @jkczyz's suggestion)

We modify the ChannelDetails constructor to accept an optional anchor channels config to address the challenge of users cross-referencing the channel details and config to determine if counterparties are trusted.

Additionally, following recommendation in #810 about negotiated features, this PR exposes per-peer InitFeatures, and as a consequence, modifies ChannelDetails by replacing the flattened counterparty_* with ChannelCounterparty that encapsulates them and mirror LDK's.

Issue Addressed

Closes #305.
Builds on discussions and recommendations from #141 and #810.

enigbe added 2 commits March 24, 2026 11:47
We previously flattened ChannelCounterparty fields
into ChannelDetails as individual counterparty_*
fields, and InitFeatures was entirely omitted.
This made it impossible for consumers to access per-peer
feature flags, and awkward to access counterparty
forwarding information without navigating the flattened
field names.

This commit replaces the flattened fields with a
structured ChannelCounterparty type that mirrors
LDK's ChannelCounterparty, exposing InitFeatures
and CounterpartyForwardingInfo that were previously
inaccessible.

Breaking change!
We expose the reserve type of each channel through
a new ReserveType enum on ChannelDetails. This tells
users whether a channel uses adaptive anchor reserves,
has no reserve due to a trusted peer, or is a legacy
pre-anchor channel.

The reserve type is derived at query time in list_channels
by checking the channel's type features against
trusted_peers_no_reserve.

Additionally, We replace the From<LdkChannelDetails>
impl with an explicit from_ldk method that takes the
anchor channels config.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 24, 2026

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.

enigbe added a commit to enigbe/ldk-node that referenced this pull request Mar 24, 2026
This fixup moves node feature exposure from freestanding APIs
to NodeStatus, as suggested in review. Rather than exposing
init_features(), channel_features(), bolt11_invoice_features(),
and node_features() as separate public methods on Node, this
embeds NodeFeatures in the NodeStatus struct returned by
Node::status().

Additionally, channel and invoice features at node level are
confusing. Users would expect negotiated per-peer/channel/invoice
features, not what the node generally supports. Access to
negotiated features are addressed in lightningdevkit#841
@ldk-reviews-bot ldk-reviews-bot requested a review from tnull March 24, 2026 21:13
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.

Expose a way to access channel or reserve type

2 participants