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)) */
| 376 | * - incoming `amount_msat` - `fee` < `amt_to_forward` (where `fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#htlc-fees)) |
| 377 | */ |
| 378 | static bool check_fwd_amount(struct htlc_in *hin, |
| 379 | struct amount_msat amt_to_forward, |
| 380 | struct amount_msat amt_in_htlc, |
| 381 | u32 feerate_base, u32 feerate_ppm) |
| 382 | { |
| 383 | struct amount_msat fee; |
| 384 | struct amount_msat fwd; |
| 385 | |
| 386 | if (!amount_msat_fee(&fee, amt_to_forward, |
| 387 | feerate_base, feerate_ppm)) { |
| 388 | log_broken(hin->key.channel->log, "Fee overflow forwarding %s!", |
| 389 | fmt_amount_msat(tmpctx, amt_to_forward)); |
| 390 | return false; |
| 391 | } |
| 392 | |
| 393 | if (amount_msat_sub(&fwd, amt_in_htlc, fee) |
| 394 | && amount_msat_greater_eq(fwd, amt_to_forward)) |
| 395 | return true; |
| 396 | |
| 397 | log_debug(hin->key.channel->log, "HTLC %"PRIu64" incorrect amount:" |
| 398 | " %s in, %s out, fee reqd %s", |
| 399 | hin->key.id, |
| 400 | fmt_amount_msat(tmpctx, amt_in_htlc), |
| 401 | fmt_amount_msat(tmpctx, amt_to_forward), |
| 402 | fmt_amount_msat(tmpctx, fee)); |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | /* BOLT #4: |
| 407 | * |
no test coverage detected