mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
onchaind: add BOLT 3 comment for fee calculations.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -110,6 +110,18 @@ static u64 grind_htlc_tx_fee(struct bitcoin_tx *tx,
|
|||||||
u64 input_amount = *tx->input[0].amount;
|
u64 input_amount = *tx->input[0].amount;
|
||||||
|
|
||||||
for (u64 i = min_possible_feerate; i <= max_possible_feerate; i++) {
|
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;
|
u64 fee = i * multiplier / 1000;
|
||||||
|
|
||||||
if (fee > input_amount)
|
if (fee > input_amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user