multi: add AddPendingChannel to peer interface

The funding manager has been updated to use `AddPendingChannel`. Note
that we track the pending channel before it's confirmed as the peer may
have a block height in the future(from our view), thus they may start
operating in this channel before we consider it as fully open.

The mocked peers have been updated to implement the new interface method.
This commit is contained in:
yyforyongyu committed 2023-08-09 00:17:22 +08:00
1 parent f39c568c94
commit e46bd8e177
6 files changed
+46 -1

No files matched your search

+18 -1
View File
@@ -2172,7 +2172,16 @@ func (f *Manager) continueFundingAccept(resCtx *reservationWithCtx,
log.Infof("Generated ChannelPoint(%v) for pending_id(%x)", outPoint,
pendingChanID[:])
var err error
// Before sending FundingCreated sent, we notify Brontide to keep track
// of this pending open channel.
err := resCtx.peer.AddPendingChannel(channelID, f.quit)
if err != nil {
pubKey := resCtx.peer.IdentityKey().SerializeCompressed()
log.Errorf("Unable to add pending channel %v with peer %x: %v",
channelID, pubKey, err)
}
// Send the FundingCreated msg.
fundingCreated := &lnwire.FundingCreated{
PendingChannelID: pendingChanID,
FundingPoint: *outPoint,
@@ -2294,6 +2303,14 @@ func (f *Manager) handleFundingCreated(peer lnpeer.Peer,
return
}
// Before sending FundingSigned, we notify Brontide first to keep track
// of this pending open channel.
if err := peer.AddPendingChannel(channelID, f.quit); err != nil {
pubKey := peer.IdentityKey().SerializeCompressed()
log.Errorf("Unable to add pending channel %v with peer %x: %v",
channelID, pubKey, err)
}
fundingSigned := &lnwire.FundingSigned{
ChanID: channelID,
CommitSig: ourCommitSig,
+6
View File
@@ -321,6 +321,12 @@ func (n *testNode) AddNewChannel(channel *channeldb.OpenChannel,
}
}
func (n *testNode) AddPendingChannel(_ lnwire.ChannelID,
quit <-chan struct{}) error {
return nil
}
func createTestWallet(cdb *channeldb.ChannelStateDB, netParams *chaincfg.Params,
notifier chainntnfs.ChainNotifier, wc lnwallet.WalletController,
signer input.Signer, keyRing keychain.SecretKeyRing,