Browse Source

elements: Ignore fee outputs when computing the fee

Turns out we get a wrong fee otherwise...

Signed-off-by: Christian Decker <decker.christian@gmail.com>
travis-debug
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
1e7b46e3c2
  1. 9
      lightningd/closing_control.c

9
lightningd/closing_control.c

@ -23,8 +23,17 @@ static struct amount_sat calc_tx_fee(struct amount_sat sat_in,
const struct bitcoin_tx *tx)
{
struct amount_sat amt, fee = sat_in;
const u8 *oscript;
size_t scriptlen;
for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
amt = bitcoin_tx_output_get_amount(tx, i);
oscript = bitcoin_tx_output_get_script(NULL, tx, i);
scriptlen = tal_bytelen(oscript);
tal_free(oscript);
if (is_elements && scriptlen == 0)
continue;
if (!amount_sat_sub(&fee, fee, amt))
fatal("Tx spends more than input %s? %s",
type_to_string(tmpctx, struct amount_sat, &sat_in),

Loading…
Cancel
Save