BOLT #4: * * - if it is not the final node: * - MUST return an error if: * ... * - incoming `amount_msat` - `fee` < `amt_to_forward` (where `fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#htlc-fees)) */
| 332 | * - incoming `amount_msat` - `fee` < `amt_to_forward` (where `fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#htlc-fees)) |
| 333 | */ |
| 334 | static bool check_fwd_amount(struct htlc_in *hin, |
| 335 | struct amount_msat amt_to_forward, |
| 336 | struct amount_msat amt_in_htlc, |
| 337 | u32 feerate_base, u32 feerate_ppm) |
| 338 | { |
| 339 | struct amount_msat fee; |
| 340 | struct amount_msat fwd; |
| 341 | |
| 342 | if (!amount_msat_fee(&fee, amt_to_forward, |
| 343 | feerate_base, feerate_ppm)) { |
| 344 | log_broken(hin->key.channel->log, "Fee overflow forwarding %s!", |
| 345 | fmt_amount_msat(tmpctx, amt_to_forward)); |
| 346 | return false; |
| 347 | } |
| 348 | |
| 349 | if (amount_msat_sub(&fwd, amt_in_htlc, fee) |
| 350 | && amount_msat_greater_eq(fwd, amt_to_forward)) |
| 351 | return true; |
| 352 | |
| 353 | log_debug(hin->key.channel->log, "HTLC %"PRIu64" incorrect amount:" |
| 354 | " %s in, %s out, fee reqd %s", |
| 355 | hin->key.id, |
| 356 | fmt_amount_msat(tmpctx, amt_in_htlc), |
| 357 | fmt_amount_msat(tmpctx, amt_to_forward), |
| 358 | fmt_amount_msat(tmpctx, fee)); |
| 359 | return false; |
| 360 | } |
| 361 | |
| 362 | /* BOLT #4: |
| 363 | * |
no test coverage detected