Skip to content

Commit

Permalink
peer: clamp a link's max HTLC forwarding policy to current max HTLC p…
Browse files Browse the repository at this point in the history
…ay 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.
  • Loading branch information
Roasbeef committed Dec 4, 2019
1 parent 392c1a9 commit c943d85
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c943d85

Please sign in to comment.