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.
This commit is contained in:
eugene 2022-05-19 12:01:49 -04:00 committed by Olaoluwa Osuntokun
parent 78d7545e4d
commit c8395475c8

View File

@ -1358,8 +1358,6 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
scid bool
)
anchors := commitType == lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx
if wasExplicit {
// Only echo back a channel type in AcceptChannel if we
// actually used explicit negotiation above.
@ -1373,15 +1371,14 @@ func (f *Manager) handleFundingOpen(peer lnpeer.Peer,
// If the zero-conf channel type wasn't negotiated and the
// fundee still wants a zero-conf channel, perform more checks.
// Require that this channel has anchors and both sides also
// have the scid-alias feature bit set. This is for
// compatibility with LDK.
// Require that both sides have the scid-alias feature bit set.
// We don't require anchors here - this is for compatibility
// with LDK.
if !zeroConf && acceptorResp.ZeroConf {
if !anchors || !scidFeatureVal {
if !scidFeatureVal {
// Fail the funding flow.
flowErr := fmt.Errorf("scid-alias feature " +
"must be negotiated in addition to " +
"anchors")
"must be negotiated for zero-conf")
f.failFundingFlow(
peer, msg.PendingChannelID, flowErr,
)
@ -1784,6 +1781,15 @@ func (f *Manager) handleFundingAccept(peer lnpeer.Peer,
return
}
// Fail early if minimum depth is set to 0 and the channel is not
// zero-conf.
if !resCtx.reservation.IsZeroConf() && msg.MinAcceptDepth == 0 {
err = fmt.Errorf("non-zero-conf channel has min depth zero")
log.Warn(err)
f.failFundingFlow(peer, msg.PendingChannelID, err)
return
}
// We'll also specify the responder's preference for the number of
// required confirmations, and also the set of channel constraints
// they've specified for commitment states we can create.