Skip to content

Commit 8c9b82f

Browse files
committed
multi: add tapscript root to gossip message
1 parent 1cba88a commit 8c9b82f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

channeldb/models/channel_edge_info.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/btcsuite/btcd/btcutil"
99
"github.com/btcsuite/btcd/chaincfg/chainhash"
1010
"github.com/btcsuite/btcd/wire"
11+
"github.com/lightningnetwork/lnd/fn"
1112
)
1213

1314
// ChannelEdgeInfo represents a fully authenticated channel along with all its
@@ -62,6 +63,11 @@ type ChannelEdgeInfo struct {
6263
// the value output in the outpoint that created this channel.
6364
Capacity btcutil.Amount
6465

66+
// TapscriptRoot is the optional Merkle root of the tapscript tree if
67+
// this channel is a taproot channel that also commits to a tapscript
68+
// tree (custom channel).
69+
TapscriptRoot fn.Option[chainhash.Hash]
70+
6571
// ExtraOpaqueData is the set of data that was appended to this
6672
// message, some of which we may not actually know how to iterate or
6773
// parse. By holding onto this data, we ensure that we're able to

discovery/gossiper.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/lightningnetwork/lnd/chainntnfs"
2121
"github.com/lightningnetwork/lnd/channeldb"
2222
"github.com/lightningnetwork/lnd/channeldb/models"
23+
"github.com/lightningnetwork/lnd/fn"
2324
"github.com/lightningnetwork/lnd/keychain"
2425
"github.com/lightningnetwork/lnd/kvdb"
2526
"github.com/lightningnetwork/lnd/lnpeer"
@@ -82,9 +83,10 @@ var (
8283
// can provide that serve useful when processing a specific network
8384
// announcement.
8485
type optionalMsgFields struct {
85-
capacity *btcutil.Amount
86-
channelPoint *wire.OutPoint
87-
remoteAlias *lnwire.ShortChannelID
86+
capacity *btcutil.Amount
87+
channelPoint *wire.OutPoint
88+
remoteAlias *lnwire.ShortChannelID
89+
tapscriptRoot fn.Option[chainhash.Hash]
8890
}
8991

9092
// apply applies the optional fields within the functional options.
@@ -115,6 +117,14 @@ func ChannelPoint(op wire.OutPoint) OptionalMsgField {
115117
}
116118
}
117119

120+
// TapscriptRoot is an optional field that lets the gossiper know of the root of
121+
// the tapscript tree for a custom channel.
122+
func TapscriptRoot(root fn.Option[chainhash.Hash]) OptionalMsgField {
123+
return func(f *optionalMsgFields) {
124+
f.tapscriptRoot = root
125+
}
126+
}
127+
118128
// RemoteAlias is an optional field that lets the gossiper know that a locally
119129
// sent channel update is actually an update for the peer that should replace
120130
// the ShortChannelID field with the remote's alias. This is only used for
@@ -2513,6 +2523,9 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
25132523
cp := *nMsg.optionalMsgFields.channelPoint
25142524
edge.ChannelPoint = cp
25152525
}
2526+
2527+
// Optional tapscript root for custom channels.
2528+
edge.TapscriptRoot = nMsg.optionalMsgFields.tapscriptRoot
25162529
}
25172530

25182531
log.Debugf("Adding edge for short_chan_id: %v",

funding/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,6 +3465,7 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
34653465
errChan := f.cfg.SendAnnouncement(
34663466
ann.chanAnn, discovery.ChannelCapacity(completeChan.Capacity),
34673467
discovery.ChannelPoint(completeChan.FundingOutpoint),
3468+
discovery.TapscriptRoot(completeChan.TapscriptRoot),
34683469
)
34693470
select {
34703471
case err := <-errChan:

0 commit comments

Comments
 (0)