From a55cfab00dd8a29896962ab3306250b979080b44 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 26 Jan 2022 12:42:34 +1030 Subject: [PATCH] elements: fix gross weight differential. Firstly, we were not adding the extra fee output on our dummy tx, because the fee amount was 0. We probably should always do this, even if it's 0. Secondly, there are 6 witnesses, not 1, for elements txs. Signed-off-by: Rusty Russell --- bitcoin/tx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 9d89ec696..6a4fc788f 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -162,7 +162,7 @@ static int elements_tx_add_fee_output(struct bitcoin_tx *tx) int pos; /* If we aren't using elements, we don't add explicit fee outputs */ - if (!chainparams->is_elements || amount_sat_eq(fee, AMOUNT_SAT(0))) + if (!chainparams->is_elements) return -1; /* Try to find any existing fee output */ @@ -462,9 +462,12 @@ size_t bitcoin_tx_weight(const struct bitcoin_tx *tx) /* If we don't have witnesses *yet*, libwally doesn't encode * in BIP 141 style, omitting the flag and marker bytes */ wally_tx_get_witness_count(tx->wtx, &num_witnesses); - if (num_witnesses == 0) - extra = 2; - else + if (num_witnesses == 0) { + if (chainparams->is_elements) + extra = 7; + else + extra = 2; + } else extra = 0; return extra + wally_tx_weight(tx->wtx);