From ee549a2af9202e2e6206ad6a824701367e203858 Mon Sep 17 00:00:00 2001 From: niftynei Date: Tue, 16 Jun 2020 17:07:28 -0500 Subject: [PATCH] tx: fix case where input amounts are less than total outputs when attempting to calculate the fees for a tx where we don't own all of the outputs, we can overshoot the feerate --- bitcoin/tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 57cc593fd..2056bc195 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -121,7 +121,9 @@ struct amount_sat bitcoin_tx_compute_fee_w_inputs(const struct bitcoin_tx *tx, ok = amount_sat_sub(&input_val, input_val, amount_asset_to_sat(&asset)); - assert(ok); + if (!ok) + return AMOUNT_SAT(0); + } return input_val; }