lncfg+lnd: gate usage of tweakless commitments based on local/global feature bits

In this commit, we add a new legacy protocol command line flag:
`committweak`. When set, this forces the node to NOT signal usage of the
new commitment format. This allows us to test that we're able to
properly establish channels with legacy nodes. Within the server, we'll
now gate our signalling of this new feature based on the legacy protocol
config. Finally, when accepting/initiating a new channel funding, we'll
now check both the local and remote global feature bits, only using the
new commitment format if both signal the global feature bit.
This commit is contained in:
Olaoluwa Osuntokun
2019-09-11 05:44:31 -07:00
parent 3f8526a0ca
commit 2dddbc84d9
4 changed files with 59 additions and 7 deletions

View File

@ -324,6 +324,12 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
globalFeatures.Set(lnwire.TLVOnionPayloadOptional)
}
// Similarly, we default to the new modern commitment format unless the
// legacy commitment config is set to true.
if !cfg.LegacyProtocol.LegacyCommitment() {
globalFeatures.Set(lnwire.StaticRemoteKeyOptional)
}
var serializedPubKey [33]byte
copy(serializedPubKey[:], privKey.PubKey().SerializeCompressed())
@ -388,8 +394,9 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB,
peerConnectedListeners: make(map[string][]chan<- lnpeer.Peer),
peerDisconnectedListeners: make(map[string][]chan<- struct{}),
globalFeatures: lnwire.NewFeatureVector(globalFeatures,
lnwire.GlobalFeatures),
globalFeatures: lnwire.NewFeatureVector(
globalFeatures, lnwire.GlobalFeatures,
),
quit: make(chan struct{}),
}