| 620 | } |
| 621 | |
| 622 | bool amount_msat_fee(struct amount_msat *fee, |
| 623 | struct amount_msat amt, |
| 624 | u32 fee_base_msat, |
| 625 | u32 fee_proportional_millionths) |
| 626 | { |
| 627 | struct amount_msat fee_base, fee_prop; |
| 628 | |
| 629 | /* BOLT #7: |
| 630 | * |
| 631 | * - SHOULD accept HTLCs that pay a fee equal to or greater than: |
| 632 | * - fee_base_msat + ( amount_to_forward * fee_proportional_millionths / 1000000 ) |
| 633 | */ |
| 634 | fee_base.millisatoshis = fee_base_msat; |
| 635 | if (!amount_msat_mul_div(&fee_prop, amt, fee_proportional_millionths, |
| 636 | 1000000)) |
| 637 | return false; |
| 638 | |
| 639 | return amount_msat_add(fee, fee_base, fee_prop); |
| 640 | } |
| 641 | |
| 642 | /* Does this input give enough to provide fee for output? */ |
| 643 | static bool within_fee(struct amount_msat in, |