diff --git a/channel_acceptor.go b/channel_acceptor.go index cc472c9..6ccebd1 100644 --- a/channel_acceptor.go +++ b/channel_acceptor.go @@ -174,5 +174,45 @@ func (s *ChannelAcceptor) acceptChannel(_ context.Context, }, nil } - return &lndclient.AcceptorResponse{Accept: true}, nil + fundingFlags := lnwire.FundingFlag(req.ChannelFlags) + isPrivateChan := fundingFlags&lnwire.FFAnnounceChannel == 0 + + // Check that the new channel is announced/unannounced as expected. + if isPrivateChan != expectedChanBid.UnannouncedChannel { + var errMsg string + errTemplate := "expected an %s channel but received an %s one" + + if expectedChanBid.UnannouncedChannel { + errMsg = fmt.Sprintf(errTemplate, "unannounced", + "announced") + } else { + errMsg = fmt.Sprintf(errTemplate, "announced", + "unannounced") + } + + return &lndclient.AcceptorResponse{ + Accept: false, + Error: errMsg, + }, nil + } + + // Check that the channel is a zero conf channel if we were expecting + // one. + if expectedChanBid.ZeroConfChannel { + if !req.WantsZeroConf { + return &lndclient.AcceptorResponse{ + Accept: false, + Error: "expected zero conf channel", + }, nil + } + return &lndclient.AcceptorResponse{ + Accept: true, + MinAcceptDepth: 0, + ZeroConf: true, + }, nil + } + + return &lndclient.AcceptorResponse{ + Accept: true, + }, nil }