config: add new legacy protocol build tag protected sub-config for legacy onion
In this commit, we add a new build tag protected sub-config for legacy protocol features. The goal of this addition is to be able to default to new feature within lnd, but expose hooks at the config level to allow integration tests to force the old behavior to ensure that we're able to support both the old+new versions.
This commit is contained in:
parent
1345ca2038
commit
653d557fec
@ -328,6 +328,8 @@ type config struct {
|
|||||||
WtClient *lncfg.WtClient `group:"wtclient" namespace:"wtclient"`
|
WtClient *lncfg.WtClient `group:"wtclient" namespace:"wtclient"`
|
||||||
|
|
||||||
Watchtower *lncfg.Watchtower `group:"watchtower" namespace:"watchtower"`
|
Watchtower *lncfg.Watchtower `group:"watchtower" namespace:"watchtower"`
|
||||||
|
|
||||||
|
LegacyProtocol *lncfg.LegacyProtocol `group:"legacyprotocol" namespace:"legacyprotocol"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadConfig initializes and parses the config using a config file and command
|
// loadConfig initializes and parses the config using a config file and command
|
||||||
|
16
lncfg/protocol_legacy_off.go
Normal file
16
lncfg/protocol_legacy_off.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// +build !dev
|
||||||
|
|
||||||
|
package lncfg
|
||||||
|
|
||||||
|
// LegacyProtocol is a struct that we use to be able to test backwards
|
||||||
|
// compatibility of protocol additions, while defaulting to the latest within
|
||||||
|
// lnd.
|
||||||
|
type LegacyProtocol struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// TLVOnionPayloadOptional bit or not.
|
||||||
|
func (l *LegacyProtocol) LegacyOnion() bool {
|
||||||
|
return false
|
||||||
|
}
|
20
lncfg/protocol_legacy_on.go
Normal file
20
lncfg/protocol_legacy_on.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// +build dev
|
||||||
|
|
||||||
|
package lncfg
|
||||||
|
|
||||||
|
// LegacyProtocol is a struct that we use to be able to test backwards
|
||||||
|
// compatibility of protocol additions, while defaulting to the latest within
|
||||||
|
// lnd.
|
||||||
|
type LegacyProtocol struct {
|
||||||
|
// Onion if set to true, then we won't signal TLVOnionPayloadOptional.
|
||||||
|
// As a result, nodes that include us in the route won't use the new
|
||||||
|
// modern onion framing.
|
||||||
|
Onion bool `long:"onion" description:"force node to not advertise the new modern TLV onion format"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// TLVOnionPayloadOptional bit or not.
|
||||||
|
func (l *LegacyProtocol) LegacyOnion() bool {
|
||||||
|
return l.Onion
|
||||||
|
}
|
@ -312,7 +312,12 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
globalFeatures := lnwire.NewRawFeatureVector()
|
globalFeatures := lnwire.NewRawFeatureVector()
|
||||||
globalFeatures.Set(lnwire.TLVOnionPayloadOptional)
|
|
||||||
|
// Only if we're not being forced to use the legacy onion format, will
|
||||||
|
// we signal our knowledge of the new TLV onion format.
|
||||||
|
if !cfg.LegacyProtocol.LegacyOnion() {
|
||||||
|
globalFeatures.Set(lnwire.TLVOnionPayloadOptional)
|
||||||
|
}
|
||||||
|
|
||||||
var serializedPubKey [33]byte
|
var serializedPubKey [33]byte
|
||||||
copy(serializedPubKey[:], privKey.PubKey().SerializeCompressed())
|
copy(serializedPubKey[:], privKey.PubKey().SerializeCompressed())
|
||||||
|
Loading…
Reference in New Issue
Block a user