elements: unify overhead calculation.
And in particular, fix onchaind grinding code which used the actual number of inputs and outputs (which already includes the fee output); that breaks with the next patch which fixes other calculations. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
c88dc7883e
commit
8a8d7c4243
@@ -4,6 +4,7 @@
|
||||
#include "config.h"
|
||||
#include <bitcoin/chainparams.h>
|
||||
#include <bitcoin/pubkey.h>
|
||||
#include <bitcoin/tx.h>
|
||||
#include <common/htlc.h>
|
||||
#include <common/utils.h>
|
||||
|
||||
@@ -47,26 +48,8 @@ static inline size_t commit_tx_base_weight(size_t num_untrimmed_htlcs,
|
||||
*/
|
||||
weight += 172 * num_untrimmed_htlcs;
|
||||
|
||||
if (chainparams->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 */
|
||||
}
|
||||
/* Extra fields for Elements */
|
||||
weight += elements_tx_overhead(chainparams, 1, 1);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user