peer: clamp a link's max HTLC forwarding policy to current max HTLC pay size

In this commit, we start to clamp the max HTLC forwarding policy to the
current register max HTLC payment size. By doing this, we ensure that
any links that have a advertised max HTLC transit size above the max
payment size will reject any incoming or outgoing attempts for such
large payments.
This commit is contained in:
Olaoluwa Osuntokun 2019-12-04 15:01:38 -08:00
parent 392c1a9a1b
commit c943d85019
No known key found for this signature in database
GPG Key ID: BC13F65E2DC84465

@ -535,6 +535,9 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) (
FeeRate: selfPolicy.FeeProportionalMillionths,
TimeLockDelta: uint32(selfPolicy.TimeLockDelta),
}
if forwardingPolicy.MaxHTLC > MaxPaymentMSat {
forwardingPolicy.MaxHTLC = MaxPaymentMSat
}
} else {
peerLog.Warnf("Unable to find our forwarding policy "+
"for channel %v, using default values",
@ -1866,6 +1869,9 @@ out:
FeeRate: defaultPolicy.FeeRate,
TimeLockDelta: defaultPolicy.TimeLockDelta,
}
if forwardingPolicy.MaxHTLC > MaxPaymentMSat {
forwardingPolicy.MaxHTLC = MaxPaymentMSat
}
// Create the link and add it to the switch.
err = p.addLink(