Skip to content

Commit

Permalink
elements: consolidate fee outputs into a single fee output
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
niftynei authored and rustyrussell committed Sep 10, 2020
1 parent 9771273 commit 165d039
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bitcoin/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,13 @@ 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)) {
fee_output_idx = 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))
Expand Down

0 comments on commit 165d039

Please sign in to comment.