Skip to content

Commit a01017c

Browse files
committed
funding: revert earlier change for LDK compatibility
This removes the requirement that the zero-conf channel acceptor flow use anchors. Also adds a fail-early check for minimum depth zero in the non zero conf case. It would fail later, but it makes more sense to fail immediately when receiving AcceptChannel.
1 parent a87ff41 commit a01017c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

funding/manager.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,6 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
13581358
scid bool
13591359
)
13601360

1361-
anchors := commitType == lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx
1362-
13631361
if wasExplicit {
13641362
// Only echo back a channel type in AcceptChannel if we
13651363
// actually used explicit negotiation above.
@@ -1373,15 +1371,14 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
13731371

13741372
// If the zero-conf channel type wasn't negotiated and the
13751373
// fundee still wants a zero-conf channel, perform more checks.
1376-
// Require that this channel has anchors and both sides also
1377-
// have the scid-alias feature bit set. This is for
1378-
// compatibility with LDK.
1374+
// Require that both sides have the scid-alias feature bit set.
1375+
// We don't require anchors here - this is for compatibility
1376+
// with LDK.
13791377
if !zeroConf && acceptorResp.ZeroConf {
1380-
if !anchors || !scidFeatureVal {
1378+
if !scidFeatureVal {
13811379
// Fail the funding flow.
13821380
flowErr := fmt.Errorf("scid-alias feature " +
1383-
"must be negotiated in addition to " +
1384-
"anchors")
1381+
"must be negotiated for zero-conf")
13851382
f.failFundingFlow(
13861383
peer, msg.PendingChannelID, flowErr,
13871384
)
@@ -1784,6 +1781,15 @@ func (f *Manager) handleFundingAccept(peer lnpeer.Peer,
17841781
return
17851782
}
17861783

1784+
// Fail early if minimum depth is set to 0 and the channel is not
1785+
// zero-conf.
1786+
if !resCtx.reservation.IsZeroConf() && msg.MinAcceptDepth == 0 {
1787+
err = fmt.Errorf("non-zero-conf channel has min depth zero")
1788+
log.Warn(err)
1789+
f.failFundingFlow(peer, msg.PendingChannelID, err)
1790+
return
1791+
}
1792+
17871793
// We'll also specify the responder's preference for the number of
17881794
// required confirmations, and also the set of channel constraints
17891795
// they've specified for commitment states we can create.

0 commit comments

Comments
 (0)