Browse Source

elements: consolidate fee outputs into a single fee output

In the case that you've got more than one fee output already on a
psbt, we consolidate them into a single fee output (the first)
bump-pyln-proto
niftynei 4 years ago
committed by Rusty Russell
parent
commit
165d039f6c
  1. 6
      bitcoin/psbt.c

6
bitcoin/psbt.c

@ -327,9 +327,15 @@ void psbt_elements_normalize_fees(struct wally_psbt *psbt)
for (size_t i = 0; i < psbt->num_outputs; i++) {
asset = wally_tx_output_get_amount(&psbt->tx->outputs[i]);
if (elements_wtx_output_is_fee(psbt->tx, i)) {
if (fee_output_idx == psbt->num_outputs) {
fee_output_idx = i;
continue;
}
/* We already have at least one fee output,
* remove this one */
psbt_rm_output(psbt, i--);
continue;
}
if (!amount_asset_is_main(&asset))
continue;

Loading…
Cancel
Save