mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
funding+peer: add support for new musig2 channel funding flow
In this commit, we add support for the new musig2 channel funding flow. This flow is identical to the existing flow, but not both sides need to exchange local nonces up front, and then signatures sent are now partial signatures instead of regular signatures. The funding manager also gains some new state of the local nonces it needs to generate in order to send the funding locked message, and also process the funding locked message from the remote party. In order to allow the funding manger to generate the nonces that need to be applied to each channel, then AddNewChannel method has been modified to accept a set of options that the peer will then use to bind the nonces to a new channel.
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -28,7 +27,7 @@ func (m *MockPeer) SendMessageLazy(sync bool, msgs ...lnwire.Message) error {
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *MockPeer) AddNewChannel(channel *channeldb.OpenChannel,
|
||||
func (m *MockPeer) AddNewChannel(channel *NewChannel,
|
||||
cancel <-chan struct{}) error {
|
||||
|
||||
args := m.Called(channel, cancel)
|
||||
|
||||
@@ -6,9 +6,20 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// NewChannel is a newly funded channel. This struct couples a channel along
|
||||
// with the set of channel options that may change how the channel is created.
|
||||
// This can be used to pass along the nonce state needed for taproot channels.
|
||||
type NewChannel struct {
|
||||
*channeldb.OpenChannel
|
||||
|
||||
// ChanOpts can be used to change how the channel is created.
|
||||
ChanOpts []lnwallet.ChannelOpt
|
||||
}
|
||||
|
||||
// Peer is an interface which represents a remote lightning node.
|
||||
type Peer interface {
|
||||
// SendMessage sends a variadic number of high-priority message to
|
||||
@@ -25,7 +36,7 @@ type Peer interface {
|
||||
|
||||
// AddNewChannel adds a new channel to the peer. The channel should fail
|
||||
// to be added if the cancel channel is closed.
|
||||
AddNewChannel(channel *channeldb.OpenChannel, cancel <-chan struct{}) error
|
||||
AddNewChannel(newChan *NewChannel, cancel <-chan struct{}) error
|
||||
|
||||
// AddPendingChannel adds a pending open channel ID to the peer. The
|
||||
// channel should fail to be added if the cancel chan is closed.
|
||||
|
||||
Reference in New Issue
Block a user