mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
channel acceptor: check channel announcebility/confirmations
This commit is contained in:
parent
cdb92e11f0
commit
71faeda417
1 changed files with 41 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue