mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
onchaind: add BOLT 3 comment for fee calculations.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1764d6c907
commit
b4db228aa1
1 changed files with 12 additions and 0 deletions
|
@ -110,6 +110,18 @@ static u64 grind_htlc_tx_fee(struct bitcoin_tx *tx,
|
|||
u64 input_amount = *tx->input[0].amount;
|
||||
|
||||
for (u64 i = min_possible_feerate; i <= max_possible_feerate; i++) {
|
||||
/* BOLT #3:
|
||||
*
|
||||
* The fee for an HTLC-timeout transaction:
|
||||
* - MUST BE calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 663 and divide by 1000
|
||||
* (rounding down).
|
||||
*
|
||||
* The fee for an HTLC-success transaction:
|
||||
* - MUST BE calculated to match:
|
||||
* 1. Multiply `feerate_per_kw` by 703 and divide by 1000
|
||||
* (rounding down).
|
||||
*/
|
||||
u64 fee = i * multiplier / 1000;
|
||||
|
||||
if (fee > input_amount)
|
||||
|
|
Loading…
Add table
Reference in a new issue