diff --git a/htlcswitch/link.go b/htlcswitch/link.go index c245ea65..c88026f8 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -71,6 +71,9 @@ type ForwardingPolicy struct { // lifetime of the channel. MinHTLC lnwire.MilliSatoshi + // MaxHTLC is the largest HTLC that is to be forwarded. + MaxHTLC lnwire.MilliSatoshi + // BaseFee is the base fee, expressed in milli-satoshi that must be // paid for each incoming HTLC. This field, combined with FeeRate is // used to compute the required fee for a given HTLC. diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 8a9bcddb..b3b79682 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -6336,3 +6336,9 @@ func (lc *LightningChannel) RemoteCommitHeight() uint64 { func (lc *LightningChannel) FwdMinHtlc() lnwire.MilliSatoshi { return lc.localChanCfg.MinHTLC } + +// MaxPendingAmount returns the maximum HTLC value that can be pending at +// any time over this channel. +func (lc *LightningChannel) MaxPendingAmount() lnwire.MilliSatoshi { + return lc.localChanCfg.MaxPendingAmount +} diff --git a/peer.go b/peer.go index 41a55892..d8793ca4 100644 --- a/peer.go +++ b/peer.go @@ -1670,15 +1670,17 @@ out: continue } - // We'll query the localChanCfg of the new channel to - // determine the minimum HTLC value that can be - // forwarded. For fees we'll use the default values, as - // they currently are always set to the default values - // at initial channel creation. + // We'll query the localChanCfg of the new channel to determine the + // minimum HTLC value that can be forwarded. For the maximum HTLC + // value that can be forwarded and fees we'll use the default + // values, as they currently are always set to the default values + // at initial channel creation. Note that the maximum HTLC value + // defaults to the cap on the total value of outstanding HTLCs. fwdMinHtlc := lnChan.FwdMinHtlc() defaultPolicy := p.server.cc.routingPolicy forwardingPolicy := &htlcswitch.ForwardingPolicy{ MinHTLC: fwdMinHtlc, + MaxHTLC: lnChan.MaxPendingAmount(), BaseFee: defaultPolicy.BaseFee, FeeRate: defaultPolicy.FeeRate, TimeLockDelta: defaultPolicy.TimeLockDelta,