Checks BOLT 7 HTLC fee condition: * recv >= base_fee + (send*proportional_fee)/1000000 */
| 137 | /* Checks BOLT 7 HTLC fee condition: |
| 138 | * recv >= base_fee + (send*proportional_fee)/1000000 */ |
| 139 | bool 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`. |