mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
multi: add tapscript root to gossip message
This commit is contained in:
parent
1402f087ab
commit
18dca6f4c8
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelEdgeInfo represents a fully authenticated channel along with all its
|
// ChannelEdgeInfo represents a fully authenticated channel along with all its
|
||||||
@ -62,6 +63,11 @@ type ChannelEdgeInfo struct {
|
|||||||
// the value output in the outpoint that created this channel.
|
// the value output in the outpoint that created this channel.
|
||||||
Capacity btcutil.Amount
|
Capacity btcutil.Amount
|
||||||
|
|
||||||
|
// TapscriptRoot is the optional Merkle root of the tapscript tree if
|
||||||
|
// this channel is a taproot channel that also commits to a tapscript
|
||||||
|
// tree (custom channel).
|
||||||
|
TapscriptRoot fn.Option[chainhash.Hash]
|
||||||
|
|
||||||
// ExtraOpaqueData is the set of data that was appended to this
|
// ExtraOpaqueData is the set of data that was appended to this
|
||||||
// message, some of which we may not actually know how to iterate or
|
// message, some of which we may not actually know how to iterate or
|
||||||
// parse. By holding onto this data, we ensure that we're able to
|
// parse. By holding onto this data, we ensure that we're able to
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/graph"
|
"github.com/lightningnetwork/lnd/graph"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/kvdb"
|
"github.com/lightningnetwork/lnd/kvdb"
|
||||||
@ -85,6 +86,7 @@ type optionalMsgFields struct {
|
|||||||
capacity *btcutil.Amount
|
capacity *btcutil.Amount
|
||||||
channelPoint *wire.OutPoint
|
channelPoint *wire.OutPoint
|
||||||
remoteAlias *lnwire.ShortChannelID
|
remoteAlias *lnwire.ShortChannelID
|
||||||
|
tapscriptRoot fn.Option[chainhash.Hash]
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply applies the optional fields within the functional options.
|
// apply applies the optional fields within the functional options.
|
||||||
@ -115,6 +117,14 @@ func ChannelPoint(op wire.OutPoint) OptionalMsgField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TapscriptRoot is an optional field that lets the gossiper know of the root of
|
||||||
|
// the tapscript tree for a custom channel.
|
||||||
|
func TapscriptRoot(root fn.Option[chainhash.Hash]) OptionalMsgField {
|
||||||
|
return func(f *optionalMsgFields) {
|
||||||
|
f.tapscriptRoot = root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RemoteAlias is an optional field that lets the gossiper know that a locally
|
// RemoteAlias is an optional field that lets the gossiper know that a locally
|
||||||
// sent channel update is actually an update for the peer that should replace
|
// sent channel update is actually an update for the peer that should replace
|
||||||
// the ShortChannelID field with the remote's alias. This is only used for
|
// the ShortChannelID field with the remote's alias. This is only used for
|
||||||
@ -2578,6 +2588,9 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
|
|||||||
cp := *nMsg.optionalMsgFields.channelPoint
|
cp := *nMsg.optionalMsgFields.channelPoint
|
||||||
edge.ChannelPoint = cp
|
edge.ChannelPoint = cp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optional tapscript root for custom channels.
|
||||||
|
edge.TapscriptRoot = nMsg.optionalMsgFields.tapscriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Adding edge for short_chan_id: %v", scid.ToUint64())
|
log.Debugf("Adding edge for short_chan_id: %v", scid.ToUint64())
|
||||||
|
@ -3515,6 +3515,7 @@ func (f *Manager) addToGraph(completeChan *channeldb.OpenChannel,
|
|||||||
errChan := f.cfg.SendAnnouncement(
|
errChan := f.cfg.SendAnnouncement(
|
||||||
ann.chanAnn, discovery.ChannelCapacity(completeChan.Capacity),
|
ann.chanAnn, discovery.ChannelCapacity(completeChan.Capacity),
|
||||||
discovery.ChannelPoint(completeChan.FundingOutpoint),
|
discovery.ChannelPoint(completeChan.FundingOutpoint),
|
||||||
|
discovery.TapscriptRoot(completeChan.TapscriptRoot),
|
||||||
)
|
)
|
||||||
select {
|
select {
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
@ -4441,9 +4442,9 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
|
|||||||
//
|
//
|
||||||
// We can pass in zeroes for the min and max htlc policy, because we
|
// We can pass in zeroes for the min and max htlc policy, because we
|
||||||
// only use the channel announcement message from the returned struct.
|
// only use the channel announcement message from the returned struct.
|
||||||
ann, err := f.newChanAnnouncement(localIDKey, remoteIDKey,
|
ann, err := f.newChanAnnouncement(
|
||||||
localFundingKey, remoteFundingKey, shortChanID, chanID,
|
localIDKey, remoteIDKey, localFundingKey, remoteFundingKey,
|
||||||
0, 0, nil, chanType,
|
shortChanID, chanID, 0, 0, nil, chanType,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("can't generate channel announcement: %v", err)
|
log.Errorf("can't generate channel announcement: %v", err)
|
||||||
|
@ -1092,8 +1092,8 @@ func (b *Builder) addZombieEdge(chanID uint64) error {
|
|||||||
// segwit v1 (taproot) channels.
|
// segwit v1 (taproot) channels.
|
||||||
//
|
//
|
||||||
// TODO(roasbeef: export and use elsewhere?
|
// TODO(roasbeef: export and use elsewhere?
|
||||||
func makeFundingScript(bitcoinKey1, bitcoinKey2 []byte,
|
func makeFundingScript(bitcoinKey1, bitcoinKey2 []byte, chanFeatures []byte,
|
||||||
chanFeatures []byte) ([]byte, error) {
|
tapscriptRoot fn.Option[chainhash.Hash]) ([]byte, error) {
|
||||||
|
|
||||||
legacyFundingScript := func() ([]byte, error) {
|
legacyFundingScript := func() ([]byte, error) {
|
||||||
witnessScript, err := input.GenMultiSigScript(
|
witnessScript, err := input.GenMultiSigScript(
|
||||||
@ -1140,7 +1140,7 @@ func makeFundingScript(bitcoinKey1, bitcoinKey2 []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fundingScript, _, err := input.GenTaprootFundingScript(
|
fundingScript, _, err := input.GenTaprootFundingScript(
|
||||||
pubKey1, pubKey2, 0, fn.None[chainhash.Hash](),
|
pubKey1, pubKey2, 0, tapscriptRoot,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1272,7 +1272,7 @@ func (b *Builder) processUpdate(msg interface{},
|
|||||||
// reality.
|
// reality.
|
||||||
fundingPkScript, err := makeFundingScript(
|
fundingPkScript, err := makeFundingScript(
|
||||||
msg.BitcoinKey1Bytes[:], msg.BitcoinKey2Bytes[:],
|
msg.BitcoinKey1Bytes[:], msg.BitcoinKey2Bytes[:],
|
||||||
msg.Features,
|
msg.Features, msg.TapscriptRoot,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user