| 524 | } |
| 525 | |
| 526 | bool amount_msat_fee(struct amount_msat *fee, |
| 527 | struct amount_msat amt, |
| 528 | u32 fee_base_msat, |
| 529 | u32 fee_proportional_millionths) |
| 530 | { |
| 531 | struct amount_msat fee_base, fee_prop; |
| 532 | |
| 533 | /* BOLT #7: |
| 534 | * |
| 535 | * - SHOULD accept HTLCs that pay a fee equal to or greater than: |
| 536 | * - fee_base_msat + ( amount_to_forward * fee_proportional_millionths / 1000000 ) |
| 537 | */ |
| 538 | fee_base.millisatoshis = fee_base_msat; |
| 539 | |
| 540 | if (mul_overflows_u64(amt.millisatoshis, fee_proportional_millionths)) |
| 541 | return false; |
| 542 | fee_prop.millisatoshis = amt.millisatoshis * fee_proportional_millionths |
| 543 | / 1000000; |
| 544 | |
| 545 | return amount_msat_add(fee, fee_base, fee_prop); |
| 546 | } |
| 547 | |
| 548 | bool amount_msat_add_fee(struct amount_msat *amt, |
| 549 | u32 fee_base_msat, |
no test coverage detected