mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
elements: Fix fee estimation for commitment transactions
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
557f6063a7
commit
e6d5b70e72
@@ -6,7 +6,6 @@
|
|||||||
#include <common/permute_tx.h>
|
#include <common/permute_tx.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
/* BOLT #3:
|
/* BOLT #3:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <common/amount.h>
|
#include <common/amount.h>
|
||||||
#include <common/htlc.h>
|
#include <common/htlc.h>
|
||||||
|
#include <common/utils.h>
|
||||||
|
|
||||||
struct bitcoin_txid;
|
struct bitcoin_txid;
|
||||||
struct keyset;
|
struct keyset;
|
||||||
@@ -42,6 +43,27 @@ static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw,
|
|||||||
*/
|
*/
|
||||||
weight += 172 * num_untrimmed_htlcs;
|
weight += 172 * num_untrimmed_htlcs;
|
||||||
|
|
||||||
|
if (is_elements) {
|
||||||
|
/* Each transaction has surjection and rangeproof (both empty
|
||||||
|
* for us as long as we use unblinded L-BTC transactions). */
|
||||||
|
weight += 2 * 4;
|
||||||
|
|
||||||
|
/* Inputs have 6 bytes of blank proofs attached. This TX only
|
||||||
|
* has a single input. */
|
||||||
|
weight += 6;
|
||||||
|
|
||||||
|
/* Each direct output has a bit more weight to it */
|
||||||
|
weight += (32 + 1 + 1 + 1) * 4 * 2; /* Elements added fields */
|
||||||
|
|
||||||
|
/* Each HTLC output also carries a bit more weight */
|
||||||
|
weight += (32 + 1 + 1 + 1) * 4 * num_untrimmed_htlcs;
|
||||||
|
|
||||||
|
/* For elements we also need to add the fee output and the
|
||||||
|
* overhead for rangeproofs into the mix. */
|
||||||
|
weight += (8 + 1) * 4; /* Bitcoin style output */
|
||||||
|
weight += (32 + 1 + 1 + 1) * 4; /* Elements added fields */
|
||||||
|
}
|
||||||
|
|
||||||
/* BOLT #3:
|
/* BOLT #3:
|
||||||
*
|
*
|
||||||
* 3. Multiply `feerate_per_kw` by `weight`, divide by 1000 (rounding
|
* 3. Multiply `feerate_per_kw` by `weight`, divide by 1000 (rounding
|
||||||
|
|||||||
Reference in New Issue
Block a user