lnwallet+funding: pass the pending channel ID into the reservation context
In this commit, we start to thread the pending channel ID from wire protocol all the way down into the reservation context. This change will allow negotiation to take place _outside_ the protocol that may result in a particular chanfunding.Assembler being dispatched.
This commit is contained in:
parent
c3157ae2c4
commit
6e9cbc19f9
@ -1216,6 +1216,7 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
|
|||||||
chainHash := chainhash.Hash(msg.ChainHash)
|
chainHash := chainhash.Hash(msg.ChainHash)
|
||||||
req := &lnwallet.InitFundingReserveMsg{
|
req := &lnwallet.InitFundingReserveMsg{
|
||||||
ChainHash: &chainHash,
|
ChainHash: &chainHash,
|
||||||
|
PendingChanID: msg.PendingChannelID,
|
||||||
NodeID: fmsg.peer.IdentityKey(),
|
NodeID: fmsg.peer.IdentityKey(),
|
||||||
NodeAddr: fmsg.peer.Address(),
|
NodeAddr: fmsg.peer.Address(),
|
||||||
LocalFundingAmt: 0,
|
LocalFundingAmt: 0,
|
||||||
@ -2781,6 +2782,10 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
channelFlags = lnwire.FFAnnounceChannel
|
channelFlags = lnwire.FFAnnounceChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtain a new pending channel ID which is used to track this
|
||||||
|
// reservation throughout its lifetime.
|
||||||
|
chanID := f.nextPendingChanID()
|
||||||
|
|
||||||
// Initialize a funding reservation with the local wallet. If the
|
// Initialize a funding reservation with the local wallet. If the
|
||||||
// wallet doesn't have enough funds to commit to this channel, then the
|
// wallet doesn't have enough funds to commit to this channel, then the
|
||||||
// request will fail, and be aborted.
|
// request will fail, and be aborted.
|
||||||
@ -2798,6 +2803,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
tweaklessCommitment := localTweakless && remoteTweakless
|
tweaklessCommitment := localTweakless && remoteTweakless
|
||||||
req := &lnwallet.InitFundingReserveMsg{
|
req := &lnwallet.InitFundingReserveMsg{
|
||||||
ChainHash: &msg.chainHash,
|
ChainHash: &msg.chainHash,
|
||||||
|
PendingChanID: chanID,
|
||||||
NodeID: peerKey,
|
NodeID: peerKey,
|
||||||
NodeAddr: msg.peer.Address(),
|
NodeAddr: msg.peer.Address(),
|
||||||
SubtractFees: msg.subtractFees,
|
SubtractFees: msg.subtractFees,
|
||||||
@ -2823,11 +2829,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
// SubtractFees=true.
|
// SubtractFees=true.
|
||||||
capacity := reservation.Capacity()
|
capacity := reservation.Capacity()
|
||||||
|
|
||||||
// Obtain a new pending channel ID which is used to track this
|
fndgLog.Infof("Target commit tx sat/kw for pendingID(%x): %v", chanID,
|
||||||
// reservation throughout its lifetime.
|
|
||||||
chanID := f.nextPendingChanID()
|
|
||||||
|
|
||||||
fndgLog.Infof("Target commit tx sat/kw for pending_id(%x): %v", chanID,
|
|
||||||
int64(commitFeePerKw))
|
int64(commitFeePerKw))
|
||||||
|
|
||||||
// If the remote CSV delay was not set in the open channel request,
|
// If the remote CSV delay was not set in the open channel request,
|
||||||
|
@ -110,6 +110,10 @@ type ChannelReservation struct {
|
|||||||
// throughout its lifetime.
|
// throughout its lifetime.
|
||||||
reservationID uint64
|
reservationID uint64
|
||||||
|
|
||||||
|
// pendingChanID is the pending channel ID for this channel as
|
||||||
|
// identified within the wire protocol.
|
||||||
|
pendingChanID [32]byte
|
||||||
|
|
||||||
// pushMSat the amount of milli-satoshis that should be pushed to the
|
// pushMSat the amount of milli-satoshis that should be pushed to the
|
||||||
// responder of a single funding channel as part of the initial
|
// responder of a single funding channel as part of the initial
|
||||||
// commitment state.
|
// commitment state.
|
||||||
@ -129,7 +133,8 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||||||
commitFeePerKw chainfee.SatPerKWeight, wallet *LightningWallet,
|
commitFeePerKw chainfee.SatPerKWeight, wallet *LightningWallet,
|
||||||
id uint64, pushMSat lnwire.MilliSatoshi, chainHash *chainhash.Hash,
|
id uint64, pushMSat lnwire.MilliSatoshi, chainHash *chainhash.Hash,
|
||||||
flags lnwire.FundingFlag, tweaklessCommit bool,
|
flags lnwire.FundingFlag, tweaklessCommit bool,
|
||||||
fundingAssembler chanfunding.Assembler) (*ChannelReservation, error) {
|
fundingAssembler chanfunding.Assembler,
|
||||||
|
pendingChanID [32]byte) (*ChannelReservation, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ourBalance lnwire.MilliSatoshi
|
ourBalance lnwire.MilliSatoshi
|
||||||
@ -263,6 +268,7 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount,
|
|||||||
Db: wallet.Cfg.Database,
|
Db: wallet.Cfg.Database,
|
||||||
},
|
},
|
||||||
pushMSat: pushMSat,
|
pushMSat: pushMSat,
|
||||||
|
pendingChanID: pendingChanID,
|
||||||
reservationID: id,
|
reservationID: id,
|
||||||
wallet: wallet,
|
wallet: wallet,
|
||||||
chanFunder: fundingAssembler,
|
chanFunder: fundingAssembler,
|
||||||
|
@ -48,6 +48,10 @@ type InitFundingReserveMsg struct {
|
|||||||
// target channel.
|
// target channel.
|
||||||
ChainHash *chainhash.Hash
|
ChainHash *chainhash.Hash
|
||||||
|
|
||||||
|
// PendingChanID is the pending channel ID for this funding flow as
|
||||||
|
// used in the wire protocol.
|
||||||
|
PendingChanID [32]byte
|
||||||
|
|
||||||
// NodeID is the ID of the remote node we would like to open a channel
|
// NodeID is the ID of the remote node we would like to open a channel
|
||||||
// with.
|
// with.
|
||||||
NodeID *btcec.PublicKey
|
NodeID *btcec.PublicKey
|
||||||
@ -513,7 +517,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *InitFundingReserveMsg
|
|||||||
reservation, err := NewChannelReservation(
|
reservation, err := NewChannelReservation(
|
||||||
capacity, localFundingAmt, req.CommitFeePerKw, l, id,
|
capacity, localFundingAmt, req.CommitFeePerKw, l, id,
|
||||||
req.PushMSat, l.Cfg.NetParams.GenesisHash, req.Flags,
|
req.PushMSat, l.Cfg.NetParams.GenesisHash, req.Flags,
|
||||||
req.Tweakless, req.ChanFunder,
|
req.Tweakless, req.ChanFunder, req.PendingChanID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if fundingIntent != nil {
|
if fundingIntent != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user