channel acceptor: check channel announcebility/confirmations

This commit is contained in:
positiveblue 2022-07-28 20:36:56 -07:00
parent cdb92e11f0
commit 71faeda417
No known key found for this signature in database
GPG key ID: 4FFF2510928804DC

View file

@ -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
}