multi: verify channel constraints on funding request

In this commit, the sanity checks in the CommitConstraints method is
moved out into a helper function called VerifyConstraints. This is done
so that the sanity checks can be performed more easily else where in the
code base. The new helper method is then called in the
handleInitFundingMsg method of the funding manager before the
OpenChannelMessage is sent.
This commit is contained in:
Elle Mouton committed 2022-10-07 14:57:05 +02:00
1 parent bc5638428e
commit 10f0eddd51
2 files changed
+91 -54

No files matched your search

+23
View File
@@ -4136,6 +4136,29 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
// remote party.
chanReserve := f.cfg.RequiredRemoteChanReserve(capacity, ourDustLimit)
// Check the sanity of the selected channel constraints.
channelConstraints := &channeldb.ChannelConstraints{
DustLimit: ourDustLimit,
ChanReserve: chanReserve,
MaxPendingAmount: maxValue,
MinHTLC: minHtlcIn,
MaxAcceptedHtlcs: maxHtlcs,
CsvDelay: remoteCsvDelay,
}
err = lnwallet.VerifyConstraints(
channelConstraints, resCtx.maxLocalCsv, capacity,
)
if err != nil {
_, reserveErr := f.cancelReservationCtx(peerKey, chanID, false)
if reserveErr != nil {
log.Errorf("unable to cancel reservation: %v",
reserveErr)
}
msg.Err <- err
return
}
// When opening a script enforced channel lease, include the required
// expiry TLV record in our proposal.
var leaseExpiry *lnwire.LeaseExpiry