MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_fee_inequality

Function check_fee_inequality

plugins/renepay/chan_extra.c:139–151  ·  view source on GitHub ↗

Checks BOLT 7 HTLC fee condition: * recv >= base_fee + (send*proportional_fee)/1000000 */

Source from the content-addressed store, hash-verified

137/* Checks BOLT 7 HTLC fee condition:
138 * recv >= base_fee + (send*proportional_fee)/1000000 */
139bool check_fee_inequality(struct amount_msat recv, struct amount_msat send,
140 u64 base_fee, u64 proportional_fee)
141{
142 // nothing to forward, any incoming amount is good
143 if (amount_msat_is_zero(send))
144 return true;
145 // FIXME If this addition fails we return false. The caller will not be
146 // able to know that there was an addition overflow, he will just assume
147 // that the fee inequality was not satisfied.
148 if (!amount_msat_add_fee(&send, base_fee, proportional_fee))
149 return false;
150 return amount_msat_greater_eq(recv, send);
151}
152
153/* Let `recv` be the maximum amount this channel can receive, this function
154 * computes the maximum amount this channel can forward `send`.

Callers 2

channel_maximum_forwardFunction · 0.85

Calls 3

amount_msat_is_zeroFunction · 0.85
amount_msat_add_feeFunction · 0.85
amount_msat_greater_eqFunction · 0.85

Tested by 1