| 39 | } |
| 40 | |
| 41 | static inline struct amount_sat htlc_success_fee(u32 feerate_per_kw, |
| 42 | bool option_anchor_outputs, |
| 43 | bool option_anchors_zero_fee_htlc_tx) |
| 44 | { |
| 45 | /* BOLT #3: |
| 46 | * |
| 47 | * The fee for an HTLC-success transaction: |
| 48 | * - If `option_anchors` applies: |
| 49 | * 1. MUST be 0. |
| 50 | * - Otherwise, MUST be calculated to match: |
| 51 | * 1. Multiply `feerate_per_kw` by 703 and divide by 1000 (rounding down). |
| 52 | */ |
| 53 | u32 base; |
| 54 | |
| 55 | if (option_anchors_zero_fee_htlc_tx) |
| 56 | return AMOUNT_SAT(0); |
| 57 | |
| 58 | /* FIXME: older bolt used to say "(706 if `option_anchor_outputs` applies) */ |
| 59 | if (option_anchor_outputs) |
| 60 | base = 706; |
| 61 | else |
| 62 | base = 703; |
| 63 | return amount_tx_fee(base + elements_tx_overhead(chainparams, 1, 1), |
| 64 | feerate_per_kw); |
| 65 | } |
| 66 | |
| 67 | /* Create HTLC-success tx to spend a received HTLC commitment tx |
| 68 | * output; doesn't fill in input witness. */ |
no test coverage detected