diff --git a/fundingmanager.go b/fundingmanager.go index e87dd9f1..55875734 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. diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 83a9c70e..4a68172b 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 diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 46e0ba8a..38c4a1b7 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 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(