lncfg: split off protocol options into normal and legacy, normal reqs no build tag
In this commit, we split off the protocol options into a normal and legacy sub-config. The legacy sub-config protected by a built tag, and will only be populated if thet tag is set. Legacy options now have a `legacy` prefix. So `--protocol.legacyonion` is now `--protocol.onion`, and `--protocol.committweak`, is now `--protocol.legacy.committweak`. We also create a new experimental protocol feature sub-config for newer features that may not yet been fully complete, so they require a build tag.
This commit is contained in:
parent
73cdb6a50f
commit
43a355321f
15
lncfg/protocol.go
Normal file
15
lncfg/protocol.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package lncfg
|
||||||
|
|
||||||
|
// ProtocolOptions is a struct that we use to be able to test backwards
|
||||||
|
// compatibility of protocol additions, while defaulting to the latest within
|
||||||
|
// lnd, or to enable experimental protocol changes.
|
||||||
|
type ProtocolOptions struct {
|
||||||
|
// LegacyProtocol is a sub-config that houses all the legacy protocol
|
||||||
|
// options. These are mostly used for integration tests as most modern
|
||||||
|
// nodes shuld always run with them on by default.
|
||||||
|
LegacyProtocol `group:"legacy" namespace:"legacy"`
|
||||||
|
|
||||||
|
// ExperimentalProtocol is a sub-config that houses any experimental
|
||||||
|
// protocol features that also require a build-tag to activate.
|
||||||
|
ExperimentalProtocol
|
||||||
|
}
|
14
lncfg/protocol_experimental_off.go
Normal file
14
lncfg/protocol_experimental_off.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// +build !dev
|
||||||
|
|
||||||
|
package lncfg
|
||||||
|
|
||||||
|
// ExperimentalProtocol is a sub-config that houses any experimental protocol
|
||||||
|
// features that also require a build-tag to activate.
|
||||||
|
type ExperimentalProtocol struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnchorCommitments returns true if support for the anchor commitment type
|
||||||
|
// should be signaled.
|
||||||
|
func (l *ExperimentalProtocol) AnchorCommitments() bool {
|
||||||
|
return false
|
||||||
|
}
|
17
lncfg/protocol_experimental_on.go
Normal file
17
lncfg/protocol_experimental_on.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build dev
|
||||||
|
|
||||||
|
package lncfg
|
||||||
|
|
||||||
|
// ExperimentalProtocol is a sub-config that houses any experimental protocol
|
||||||
|
// features that also require a build-tag to activate.
|
||||||
|
type ExperimentalProtocol struct {
|
||||||
|
// Anchors should be set if we want to support opening or accepting
|
||||||
|
// channels having the anchor commitment type.
|
||||||
|
Anchors bool `long:"anchors" description:"EXPERIMENTAL: enable experimental support for anchor commitments, won't work with watchtowers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnchorCommitments returns true if support for the anchor commitment type
|
||||||
|
// should be signaled.
|
||||||
|
func (l *ExperimentalProtocol) AnchorCommitments() bool {
|
||||||
|
return l.Anchors
|
||||||
|
}
|
@ -2,27 +2,21 @@
|
|||||||
|
|
||||||
package lncfg
|
package lncfg
|
||||||
|
|
||||||
// ProtocolOptions is a struct that we use to be able to test backwards
|
// Legacy is a sub-config that houses all the legacy protocol options. These
|
||||||
// compatibility of protocol additions, while defaulting to the latest within
|
// are mostly used for integration tests as most modern nodes shuld always run
|
||||||
// lnd, or to enable experimental protocol changes.
|
// with them on by default.
|
||||||
type ProtocolOptions struct {
|
type LegacyProtocol struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LegacyOnion returns true if the old legacy onion format should be used when
|
// LegacyOnion returns true if the old legacy onion format should be used when
|
||||||
// we're an intermediate or final hop. This controls if we set the
|
// we're an intermediate or final hop. This controls if we set the
|
||||||
// TLVOnionPayloadOptional bit or not.
|
// TLVOnionPayloadOptional bit or not.
|
||||||
func (l *ProtocolOptions) LegacyOnion() bool {
|
func (l *LegacyProtocol) LegacyOnion() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoStaticRemoteKey returns true if the old commitment format with a tweaked
|
// NoStaticRemoteKey returns true if the old commitment format with a tweaked
|
||||||
// remote key should be used for new funded channels.
|
// remote key should be used for new funded channels.
|
||||||
func (l *ProtocolOptions) NoStaticRemoteKey() bool {
|
func (l *LegacyProtocol) NoStaticRemoteKey() bool {
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// AnchorCommitments returns true if support for the the anchor commitment type
|
|
||||||
// should be signaled.
|
|
||||||
func (l *ProtocolOptions) AnchorCommitments() bool {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -2,41 +2,31 @@
|
|||||||
|
|
||||||
package lncfg
|
package lncfg
|
||||||
|
|
||||||
// ProtocolOptions is a struct that we use to be able to test backwards
|
// Legacy is a sub-config that houses all the legacy protocol options. These
|
||||||
// compatibility of protocol additions, while defaulting to the latest within
|
// are mostly used for integration tests as most modern nodes shuld always run
|
||||||
// lnd, or to enable experimental protocol changes.
|
// with them on by default.
|
||||||
type ProtocolOptions struct {
|
type LegacyProtocol struct {
|
||||||
// LegacyOnionFormat if set to true, then we won't signal
|
// LegacyOnionFormat if set to true, then we won't signal
|
||||||
// TLVOnionPayloadOptional. As a result, nodes that include us in the
|
// TLVOnionPayloadOptional. As a result, nodes that include us in the
|
||||||
// route won't use the new modern onion framing.
|
// route won't use the new modern onion framing.
|
||||||
LegacyOnionFormat bool `long:"legacyonion" description:"force node to not advertise the new modern TLV onion format"`
|
LegacyOnionFormat bool `long:"onion" description:"force node to not advertise the new modern TLV onion format"`
|
||||||
|
|
||||||
// CommitmentTweak guards if we should use the old legacy commitment
|
// CommitmentTweak guards if we should use the old legacy commitment
|
||||||
// protocol, or the newer variant that doesn't have a tweak for the
|
// protocol, or the newer variant that doesn't have a tweak for the
|
||||||
// remote party's output in the commitment. If set to true, then we
|
// remote party's output in the commitment. If set to true, then we
|
||||||
// won't signal StaticRemoteKeyOptional.
|
// won't signal StaticRemoteKeyOptional.
|
||||||
CommitmentTweak bool `long:"committweak" description:"force node to not advertise the new commitment format"`
|
CommitmentTweak bool `long:"committweak" description:"force node to not advertise the new commitment format"`
|
||||||
|
|
||||||
// Anchors should be set if we want to support opening or accepting
|
|
||||||
// channels having the anchor commitment type.
|
|
||||||
Anchors bool `long:"anchors" description:"EXPERIMENTAL: enable experimental support for anchor commitments, won't work with watchtowers"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LegacyOnion returns true if the old legacy onion format should be used when
|
// LegacyOnion returns true if the old legacy onion format should be used when
|
||||||
// we're an intermediate or final hop. This controls if we set the
|
// we're an intermediate or final hop. This controls if we set the
|
||||||
// TLVOnionPayloadOptional bit or not.
|
// TLVOnionPayloadOptional bit or not.
|
||||||
func (l *ProtocolOptions) LegacyOnion() bool {
|
func (l *LegacyProtocol) LegacyOnion() bool {
|
||||||
return l.LegacyOnionFormat
|
return l.LegacyOnionFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoStaticRemoteKey returns true if the old commitment format with a tweaked
|
// NoStaticRemoteKey returns true if the old commitment format with a tweaked
|
||||||
// remote key should be used for new funded channels.
|
// remote key should be used for new funded channels.
|
||||||
func (l *ProtocolOptions) NoStaticRemoteKey() bool {
|
func (l *LegacyProtocol) NoStaticRemoteKey() bool {
|
||||||
return l.CommitmentTweak
|
return l.CommitmentTweak
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnchorCommitments returns true if support for the anchor commitment type
|
|
||||||
// should be signaled.
|
|
||||||
func (l *ProtocolOptions) AnchorCommitments() bool {
|
|
||||||
return l.Anchors
|
|
||||||
}
|
|
||||||
|
@ -48,7 +48,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
//
|
//
|
||||||
// First, we'll create Dave and establish a channel to Alice. Dave will
|
// First, we'll create Dave and establish a channel to Alice. Dave will
|
||||||
// be running an older node that requires the legacy onion payload.
|
// be running an older node that requires the legacy onion payload.
|
||||||
daveArgs := []string{"--protocol.legacyonion"}
|
daveArgs := []string{"--protocol.legacy.onion"}
|
||||||
dave, err := net.NewNode("Dave", daveArgs)
|
dave, err := net.NewNode("Dave", daveArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create new nodes: %v", err)
|
t.Fatalf("unable to create new nodes: %v", err)
|
||||||
|
@ -1178,7 +1178,7 @@ func (c commitType) String() string {
|
|||||||
func (c commitType) Args() []string {
|
func (c commitType) Args() []string {
|
||||||
switch c {
|
switch c {
|
||||||
case commitTypeLegacy:
|
case commitTypeLegacy:
|
||||||
return []string{"--protocol.committweak"}
|
return []string{"--protocol.legacy.committweak"}
|
||||||
case commitTypeTweakless:
|
case commitTypeTweakless:
|
||||||
return []string{}
|
return []string{}
|
||||||
case commitTypeAnchors:
|
case commitTypeAnchors:
|
||||||
|
Loading…
Reference in New Issue
Block a user