|
@ -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 |
|
|