elements: Compute correct weight in wallet_select for elements TXs

They are a bit larger, so account for that.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-05-20 21:23:52 +02:00 committed by Rusty Russell
parent d89962213c
commit 17af57e504

View File

@ -354,6 +354,7 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w,
size_t i = 0; size_t i = 0;
struct utxo **available; struct utxo **available;
u64 weight; u64 weight;
size_t num_outputs = may_have_change ? 2 : 1;
const struct utxo **utxos = tal_arr(ctx, const struct utxo *, 0); const struct utxo **utxos = tal_arr(ctx, const struct utxo *, 0);
tal_add_destructor2(utxos, destroy_utxos, w); tal_add_destructor2(utxos, destroy_utxos, w);
@ -370,6 +371,18 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w,
if (may_have_change) if (may_have_change)
weight += (8 + 1 + BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN) * 4; weight += (8 + 1 + BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN) * 4;
/* A couple of things need to change for elements: */
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;
/* Each output additionally has an asset_tag (1 + 32), value
* is prefixed by a version (1 byte) and an empty nonce (1
* byte). */
weight += (32 + 1 + 1 + 1) * 4 * num_outputs;
}
*fee_estimate = AMOUNT_SAT(0); *fee_estimate = AMOUNT_SAT(0);
*satoshi_in = AMOUNT_SAT(0); *satoshi_in = AMOUNT_SAT(0);