From c943d850193a476be1bc37ed922d1954cf040948 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Dec 2019 15:01:38 -0800 Subject: [PATCH] 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. --- peer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/peer.go b/peer.go index a007701b..0b4b8561 100644 --- a/peer.go +++ b/peer.go @@ -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(