Skip to content

Commit 1c65c3d

Browse files
committed
funding: allow AcceptChannel with min depth of zero
Even if the channel type is not zero conf. We will still use a min depth of at least 1. We just dont fail if our peer indicates trust.
1 parent c34c042 commit 1c65c3d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

funding/manager.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,19 +2020,22 @@ func (f *Manager) funderProcessAcceptChannel(peer lnpeer.Peer,
20202020
return
20212021
}
20222022

2023-
// Fail early if minimum depth is set to 0 and the channel is not
2024-
// zero-conf.
2025-
if !resCtx.reservation.IsZeroConf() && msg.MinAcceptDepth == 0 {
2026-
err = fmt.Errorf("non-zero-conf channel has min depth zero")
2027-
log.Warn(err)
2028-
f.failFundingFlow(peer, cid, err)
2029-
return
2023+
// If this is not a zero-conf channel but the peer responded with a
2024+
// min-depth of zero, we will use our minimum of 1 instead.
2025+
minDepth := msg.MinAcceptDepth
2026+
if !resCtx.reservation.IsZeroConf() && minDepth == 0 {
2027+
log.Infof("Responder to pending_id=%v sent a minimum "+
2028+
"confirmation depth of 0 for non-zero-conf channel. "+
2029+
"We will use a minimum depth of 1 instead.",
2030+
cid.tempChanID)
2031+
2032+
minDepth = 1
20302033
}
20312034

20322035
// We'll also specify the responder's preference for the number of
20332036
// required confirmations, and also the set of channel constraints
20342037
// they've specified for commitment states we can create.
2035-
resCtx.reservation.SetNumConfsRequired(uint16(msg.MinAcceptDepth))
2038+
resCtx.reservation.SetNumConfsRequired(uint16(minDepth))
20362039
channelConstraints := &channeldb.ChannelConstraints{
20372040
DustLimit: msg.DustLimit,
20382041
ChanReserve: msg.ChannelReserve,

0 commit comments

Comments
 (0)