diff --git a/htlcswitch/link.go b/htlcswitch/link.go index ae923277..09257ff4 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1729,15 +1729,18 @@ func (l *channelLink) processLockedInHtlcs( fwdInfo.AmountToForward, ) - // If the amount of the incoming HTLC, minus - // our expected fee isn't equal to the - // forwarding instructions, then either the - // values have been tampered with, or the send - // used incorrect/dated information to + // If the actual fee is less than our expected + // fee, then we'll reject this HTLC as it + // didn't provide a sufficient amount of fees, + // or the values have been tampered with, or + // the send used incorrect/dated information to // construct the forwarding information for // this hop. In any case, we'll cancel this // HTLC. - if pd.Amount-expectedFee < fwdInfo.AmountToForward { + actualFee := pd.Amount - fwdInfo.AmountToForward + if pd.Amount < fwdInfo.AmountToForward || + actualFee < expectedFee { + log.Errorf("Incoming htlc(%x) has "+ "insufficient fee: expected "+ "%v, got %v", pd.RHash[:], diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 8add4e84..6602dd5a 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -777,7 +777,7 @@ func TestUpdateForwardingPolicy(t *testing.T) { testStartingHeight, n.firstBobChannelLink, n.carolChannelLink) - // First, send this 1 BTC payment over the three hops, the payment + // First, send this 10 mSAT payment over the three hops, the payment // should succeed, and all balances should be updated accordingly. payResp, err := n.makePayment(n.aliceServer, n.carolServer, n.bobServer.PubKey(), hops, amountNoFee, htlcAmt, @@ -827,7 +827,7 @@ func TestUpdateForwardingPolicy(t *testing.T) { n.firstBobChannelLink.UpdateForwardingPolicy(newPolicy) // Next, we'll send the payment again, using the exact same per-hop - // payload for each node. This payment should fail as it wont' factor + // payload for each node. This payment should fail as it won't factor // in Bob's new fee policy. _, err = n.makePayment(n.aliceServer, n.carolServer, n.bobServer.PubKey(), hops, amountNoFee, htlcAmt,