From 06e8d1c5ca9add8a6b4cc2f95f4344647f2a1148 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Dec 2019 14:34:18 -0800 Subject: [PATCH 1/4] htlcswitch: fix inconsistency between attribute name and godoc comment --- htlcswitch/link.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 83a9c70ef..4a68172b6 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -257,9 +257,9 @@ type ChannelLinkConfig struct { // configured set of watchtowers. TowerClient TowerClient - // MaxCltvExpiry is the maximum outgoing timelock that the link should - // accept for a forwarded HTLC. The value is relative to the current - // block height. + // MaxOutgoingCltvExpiry is the maximum outgoing timelock that the link + // should accept for a forwarded HTLC. The value is relative to the + // current block height. MaxOutgoingCltvExpiry uint32 // MaxFeeAllocation is the highest allocation we'll allow a channel's From 392c1a9a1b6e42df9c5d168f2b61fa941c1e3a07 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Dec 2019 14:35:43 -0800 Subject: [PATCH 2/4] lnrpc/routerrpc: make SendToRoute consistent with other payment RPCs In this commitment, we make the `SendToRoute` RPC call consistent with all the other payment RPCs which will properly adhere to the current max payment sat limit. This is a prep commit for the future wumbo soft cap that will eventually land in lnd. --- lnrpc/routerrpc/router_backend.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 46e0ba8a6..38c4a1b77 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -470,6 +470,13 @@ func (r *RouterBackend) UnmarshallRoute(rpcroute *lnrpc.Route) ( return nil, err } + if routeHop.AmtToForward > r.MaxPaymentMSat { + return nil, fmt.Errorf("payment of %v is too large, "+ + "max payment allowed is %v", + routeHop.AmtToForward, + r.MaxPaymentMSat.ToSatoshis()) + } + hops[i] = routeHop prevNodePubKey = routeHop.PubKeyBytes From c943d850193a476be1bc37ed922d1954cf040948 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Dec 2019 15:01:38 -0800 Subject: [PATCH 3/4] 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 a007701b7..0b4b85611 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( From 9b3385e87de8b2da51a9c979cd4e8ef770078ae2 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Dec 2019 15:01:58 -0800 Subject: [PATCH 4/4] funding: ensure the chan policy max htlc size is below max pay size --- fundingmanager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fundingmanager.go b/fundingmanager.go index e87dd9f11..558757347 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -2359,6 +2359,9 @@ func (f *fundingManager) annAfterSixConfs(completeChan *channeldb.OpenChannel, if fwdMaxHTLC > capacityMSat { fwdMaxHTLC = capacityMSat } + if fwdMaxHTLC > MaxPaymentMSat { + fwdMaxHTLC = MaxPaymentMSat + } // Create and broadcast the proofs required to make this channel // public and usable for other nodes for routing.