fundingmanager: Added additional check so that pending channels don't
timeout for the channel initiator
This commit is contained in:
parent
7f04d927a0
commit
63ee31b83f
@ -430,19 +430,23 @@ func (f *fundingManager) Start() error {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-timeoutChan:
|
case <-timeoutChan:
|
||||||
// Timeout waiting for the funding transaction
|
// Timeout channel will be triggered if the number of blocks
|
||||||
// to confirm, so we forget the channel and
|
// mined since the channel was initiated reaches
|
||||||
// delete it from the database.
|
// maxWaitNumBlocksFundingConf and we are not the channel
|
||||||
|
// initiator.
|
||||||
|
|
||||||
closeInfo := &channeldb.ChannelCloseSummary{
|
closeInfo := &channeldb.ChannelCloseSummary{
|
||||||
ChainHash: ch.ChainHash,
|
ChainHash: ch.ChainHash,
|
||||||
ChanPoint: ch.FundingOutpoint,
|
ChanPoint: ch.FundingOutpoint,
|
||||||
RemotePub: ch.IdentityPub,
|
RemotePub: ch.IdentityPub,
|
||||||
CloseType: channeldb.FundingCanceled,
|
CloseType: channeldb.FundingCanceled,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ch.CloseChannel(closeInfo); err != nil {
|
if err := ch.CloseChannel(closeInfo); err != nil {
|
||||||
fndgLog.Errorf("Failed closing channel "+
|
fndgLog.Errorf("Failed closing channel "+
|
||||||
"%v: %v", ch.FundingOutpoint, err)
|
"%v: %v", ch.FundingOutpoint, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-f.quit:
|
case <-f.quit:
|
||||||
// The fundingManager is shutting down, and will
|
// The fundingManager is shutting down, and will
|
||||||
// resume wait on startup.
|
// resume wait on startup.
|
||||||
@ -1484,10 +1488,11 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// waitForFundingWithTimeout is a wrapper around waitForFundingConfirmation that
|
// waitForFundingWithTimeout is a wrapper around waitForFundingConfirmation that
|
||||||
// will cancel the wait for confirmation if maxWaitNumBlocksFundingConf has
|
// will cancel the wait for confirmation if we are not the channel initiator and
|
||||||
// passed from bestHeight. In the case of timeout, the timeoutChan will be
|
// the maxWaitNumBlocksFundingConf has passed from bestHeight.
|
||||||
// closed. In case of error, confChan will be closed. In case of success,
|
// In the case of timeout, the timeoutChan will be closed. In case of error,
|
||||||
// a *lnwire.ShortChannelID will be passed to confChan.
|
// confChan will be closed. In case of success, a *lnwire.ShortChannelID will be
|
||||||
|
// passed to confChan.
|
||||||
func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenChannel,
|
func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenChannel,
|
||||||
confChan chan<- *lnwire.ShortChannelID, timeoutChan chan<- struct{}) {
|
confChan chan<- *lnwire.ShortChannelID, timeoutChan chan<- struct{}) {
|
||||||
|
|
||||||
@ -1523,7 +1528,9 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if uint32(epoch.Height) >= maxHeight {
|
// If we are not the channel initiator it's safe
|
||||||
|
// to timeout the channel
|
||||||
|
if uint32(epoch.Height) >= maxHeight && !completeChan.IsInitiator {
|
||||||
fndgLog.Warnf("waited for %v blocks without "+
|
fndgLog.Warnf("waited for %v blocks without "+
|
||||||
"seeing funding transaction confirmed,"+
|
"seeing funding transaction confirmed,"+
|
||||||
" cancelling.", maxWaitNumBlocksFundingConf)
|
" cancelling.", maxWaitNumBlocksFundingConf)
|
||||||
@ -1536,6 +1543,11 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC
|
|||||||
close(timeoutChan)
|
close(timeoutChan)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: If we are the channel initiator implement
|
||||||
|
// a method for recovering the funds from the funding
|
||||||
|
// transaction
|
||||||
|
|
||||||
case <-f.quit:
|
case <-f.quit:
|
||||||
// The fundingManager is shutting down, will resume
|
// The fundingManager is shutting down, will resume
|
||||||
// waiting for the funding transaction on startup.
|
// waiting for the funding transaction on startup.
|
||||||
|
Loading…
Reference in New Issue
Block a user