BOLT #4: * * * `amt_to_forward`: The amount, in millisatoshis, to forward to the next * receiving peer specified within the routing information. * * For non-final nodes, this value amount MUST include the origin node's computed _fee_ for the * receiving peer. When processing an incoming Sphinx packet and the HTLC * message that it is encapsulated within, if the following inequality
| 256 | * #7](07-routing-gossip.md#htlc-fees)). |
| 257 | */ |
| 258 | static bool check_fwd_amount(struct htlc_in *hin, |
| 259 | struct amount_msat amt_to_forward, |
| 260 | struct amount_msat amt_in_htlc, |
| 261 | u32 feerate_base, u32 feerate_ppm) |
| 262 | { |
| 263 | struct amount_msat fee; |
| 264 | struct amount_msat fwd; |
| 265 | |
| 266 | if (!amount_msat_fee(&fee, amt_to_forward, |
| 267 | feerate_base, feerate_ppm)) { |
| 268 | log_broken(hin->key.channel->log, "Fee overflow forwarding %s!", |
| 269 | type_to_string(tmpctx, struct amount_msat, |
| 270 | &amt_to_forward)); |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | if (amount_msat_sub(&fwd, amt_in_htlc, fee) |
| 275 | && amount_msat_greater_eq(fwd, amt_to_forward)) |
| 276 | return true; |
| 277 | |
| 278 | log_debug(hin->key.channel->log, "HTLC %"PRIu64" incorrect amount:" |
| 279 | " %s in, %s out, fee reqd %s", |
| 280 | hin->key.id, |
| 281 | type_to_string(tmpctx, struct amount_msat, &amt_in_htlc), |
| 282 | type_to_string(tmpctx, struct amount_msat, &amt_to_forward), |
| 283 | type_to_string(tmpctx, struct amount_msat, &fee)); |
| 284 | return false; |
| 285 | } |
| 286 | |
| 287 | /* BOLT #4: |
| 288 | * |
no test coverage detected