Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions chanacceptor/rpcacceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,30 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT

case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ZeroConfRequired,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL

case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ZeroConfRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL

case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL

case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
Comment on lines +359 to +381
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

These four case statements for SIMPLE_TAPROOT_FINAL are all setting the same commitmentType and are quite repetitive. This could be simplified to improve readability and maintainability. A single case can handle all combinations by checking for the base feature and ensuring no other unexpected features are present.

This pattern of repeated case statements is also used for other commitment types in this switch block and could be refactored similarly.

Suggested change
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ZeroConfRequired,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ZeroConfRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
lnwire.ScidAliasRequired,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
case channelFeatures.OnlyContains(
lnwire.SimpleTaprootChannelsRequiredFinal,
):
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
case channelFeatures.IsSet(lnwire.SimpleTaprootChannelsRequiredFinal):
// We'll clone the feature vector and unset all allowed
// bits. If the vector is empty after, we know that
// no other unexpected bits were set.
clone := (&channelFeatures).Clone()
clone.Unset(lnwire.SimpleTaprootChannelsRequiredFinal)
clone.Unset(lnwire.ZeroConfRequired)
clone.Unset(lnwire.ScidAliasRequired)
if clone.IsEmpty() {
commitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT_FINAL
}


case channelFeatures.OnlyContains(
lnwire.SimpleTaprootOverlayChansRequired,
lnwire.ZeroConfRequired,
Expand Down
10 changes: 10 additions & 0 deletions docs/release-notes/release-notes-0.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
subscriptions and the hodl queue, preventing orphaned subscriptions from
blocking invoice resolution.

* [Fixed two follow-ups to the production taproot channels
work](https://github.com/lightningnetwork/lnd/pull/10763). The RPC channel
acceptor switch now maps `SIMPLE_TAPROOT_FINAL` (with every combination of
the `scid-alias` / `zero-conf` modifiers) so final-taproot opens are
reported to external acceptor clients with the correct commitment type
instead of `UNKNOWN_COMMITMENT_TYPE`. The taproot RBF cooperative-close
auto-enable is also narrowed to skip taproot-overlay channels, since the
RBF close state machine does not yet thread through the `AuxCloser` hook
that overlay channels rely on to build aux-aware close transactions.

# New Features

- [Basic Support](https://github.com/lightningnetwork/lnd/pull/9868) for onion
Expand Down
17 changes: 12 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,18 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
"in a standalone lnd build")
}

// If either taproot channel type is enabled, we also need to enable
// the RBF cooperative close protocol, as it is required for taproot
// channel interoperability.
if cfg.ProtocolOptions.TaprootChans ||
cfg.ProtocolOptions.TaprootOverlayChans {
// If taproot channels are enabled, we also enable the RBF cooperative
// close protocol, as it is required for taproot channel
// interoperability.
//
// Exception: when taproot-overlay channels are enabled we do NOT
// auto-enable RBF, because the RBF coop close state machine does not
// yet thread through the AuxCloser hook that overlay channels rely on
// to build the aux-aware close transaction. Forcing RBF on for a
// node that holds overlay channels would silently break their coop
// closes.
if cfg.ProtocolOptions.TaprootChans &&
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

does this mean if we have overlay channels the rbf protocol is also switch off for the normal taproot channels ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

but if the user sets it via the config it still breaks the coop close flow for overlay channels, we should prio this fix on the taproot assets side then.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes we don't want to auto-enable it for overlay chans

the proper fix involves LND diff (integrating the AuxCloser in the RBF closer) and maybe some supporting code in taproot assets. Since we're already at the rc phase this should be enough. We control the flags in litd so for now we'll just try to protect & discourage the user from setting the flag (or even fail early in litd).

!cfg.ProtocolOptions.TaprootOverlayChans {

cfg.ProtocolOptions.RbfCoopClose = true
}
Expand Down
Loading