Browse Source

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>
travis-debug
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
b356dda0ba
  1. 2
      channeld/commit_tx.c
  2. 2
      common/close_tx.c
  3. 2
      common/funding_tx.c
  4. 2
      common/htlc_tx.c
  5. 1
      common/initial_commit_tx.c
  6. 1
      common/withdraw_tx.c

2
channeld/commit_tx.c

@ -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;
}

2
common/close_tx.c

@ -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;
}

2
common/funding_tx.c

@ -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;
}

2
common/htlc_tx.c

@ -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;

1
common/initial_commit_tx.c

@ -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;

1
common/withdraw_tx.c

@ -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;
}

Loading…
Cancel
Save