elements: Add explicit fee outputs to various transactions we create

Elements requires us to have an explicit fee output instead of bitcoin's
implied fee. We add the fee output mostly after sorting the other outputs
since that matches the behavior in elements itself.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-05-09 13:04:24 +02:00 committed by Rusty Russell
parent cd93a855ce
commit b356dda0ba
6 changed files with 10 additions and 0 deletions

View File

@ -289,5 +289,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
u32 sequence = (0x80000000 | ((obscured_commitment_number>>24) & 0xFFFFFF));
bitcoin_tx_add_input(tx, funding_txid, funding_txout, sequence, funding, NULL);
bitcoin_tx_add_fee_output(tx);
return tx;
}

View File

@ -61,6 +61,8 @@ struct bitcoin_tx *create_close_tx(const tal_t *ctx,
return tal_free(tx);
permute_outputs(tx, NULL, NULL);
bitcoin_tx_add_fee_output(tx);
assert(bitcoin_tx_check(tx));
return tx;
}

View File

@ -48,6 +48,8 @@ struct bitcoin_tx *funding_tx(const tal_t *ctx,
}
permute_inputs(tx, (const void **)utxomap);
bitcoin_tx_add_fee_output(tx);
assert(bitcoin_tx_check(tx));
return tx;
}

View File

@ -63,6 +63,8 @@ static struct bitcoin_tx *htlc_tx(const tal_t *ctx,
wscript = bitcoin_wscript_htlc_tx(tx, to_self_delay, revocation_pubkey,
local_delayedkey);
bitcoin_tx_add_output(tx, scriptpubkey_p2wsh(tx, wscript), amount);
bitcoin_tx_add_fee_output(tx);
tal_free(wscript);
return tx;

View File

@ -238,6 +238,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
sequence = (0x80000000 | ((obscured_commitment_number>>24) & 0xFFFFFF));
bitcoin_tx_add_input(tx, funding_txid, funding_txout, sequence, funding, NULL);
bitcoin_tx_add_fee_output(tx);
assert(bitcoin_tx_check(tx));
return tx;

View File

@ -38,6 +38,7 @@ struct bitcoin_tx *withdraw_tx(const tal_t *ctx,
} else if (change_outnum)
*change_outnum = -1;
permute_inputs(tx, (const void **)utxos);
bitcoin_tx_add_fee_output(tx);
assert(bitcoin_tx_check(tx));
return tx;
}