mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
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>
This commit is contained in:
committed by
Rusty Russell
parent
99988cb0e1
commit
1e7b46e3c2
@@ -23,8 +23,17 @@ static struct amount_sat calc_tx_fee(struct amount_sat sat_in,
|
|||||||
const struct bitcoin_tx *tx)
|
const struct bitcoin_tx *tx)
|
||||||
{
|
{
|
||||||
struct amount_sat amt, fee = sat_in;
|
struct amount_sat amt, fee = sat_in;
|
||||||
|
const u8 *oscript;
|
||||||
|
size_t scriptlen;
|
||||||
for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
|
for (size_t i = 0; i < tx->wtx->num_outputs; i++) {
|
||||||
amt = bitcoin_tx_output_get_amount(tx, 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))
|
if (!amount_sat_sub(&fee, fee, amt))
|
||||||
fatal("Tx spends more than input %s? %s",
|
fatal("Tx spends more than input %s? %s",
|
||||||
type_to_string(tmpctx, struct amount_sat, &sat_in),
|
type_to_string(tmpctx, struct amount_sat, &sat_in),
|
||||||
|
|||||||
Reference in New Issue
Block a user