peer: send taproot addrs during co-op close based on new feature bit

If the ShutdownAnySegwitOptional option is active, then we can safely
send these newer addresses.
This commit is contained in:
Olaoluwa Osuntokun committed 2022-08-10 18:44:35 -07:00
1 parent 99d37f254e
commit fffad49ad1
3 files changed
+28 -11

No files matched your search

+15 -1
View File
@@ -657,6 +657,13 @@ func (p *Brontide) initGossipSync() {
}
}
// taprootShutdownAllowed returns true if both parties have negotiated the
// shutdown-any-segwit feature.
func (p *Brontide) taprootShutdownAllowed() bool {
return p.RemoteFeatures().HasFeature(lnwire.ShutdownAnySegwitOptional) &&
p.LocalFeatures().HasFeature(lnwire.ShutdownAnySegwitOptional)
}
// QuitSignal is a method that should return a channel which will be sent upon
// or closed once the backing peer exits. This allows callers using the
// interface to cancel any processing in the event the backing implementation
@@ -2244,8 +2251,15 @@ func (p *Brontide) ChannelSnapshots() []*channeldb.ChannelSnapshot {
// genDeliveryScript returns a new script to be used to send our funds to in
// the case of a cooperative channel close negotiation.
func (p *Brontide) genDeliveryScript() ([]byte, error) {
// We'll send a normal p2wkh address unless we've negotiated the
// shutdown-any-segwit feature.
addrType := lnwallet.WitnessPubKey
if p.taprootShutdownAllowed() {
addrType = lnwallet.TaprootPubkey
}
deliveryAddr, err := p.cfg.Wallet.NewAddress(
lnwallet.WitnessPubKey, false, lnwallet.DefaultAccountName,
addrType, false, lnwallet.DefaultAccountName,
)
if err != nil {
return nil, err