From c6656dcbe8944fe5227758247d00c72d9899b015 Mon Sep 17 00:00:00 2001 From: niftynei Date: Thu, 13 Aug 2020 11:38:03 -0500 Subject: [PATCH] psbt: use elements input init alloc --- bitcoin/psbt.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index c2a2c73f4..e417c5d47 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -112,18 +112,27 @@ struct wally_psbt_input *psbt_append_input(struct wally_psbt *psbt, { struct wally_tx_input *tx_in; struct wally_psbt_input *input; - size_t insert_at; - insert_at = psbt->num_inputs; - - if (wally_tx_input_init_alloc(txid->shad.sha.u.u8, - sizeof(struct bitcoin_txid), - outnum, sequence, NULL, 0, NULL, - &tx_in) != WALLY_OK) - abort(); + if (chainparams->is_elements) { + if (wally_tx_elements_input_init_alloc(txid->shad.sha.u.u8, + sizeof(txid->shad.sha.u.u8), + outnum, sequence, NULL, 0, + NULL, + NULL, 0, + NULL, 0, NULL, 0, + NULL, 0, NULL, 0, + NULL, 0, NULL, + &tx_in) != WALLY_OK) + abort(); + } else { + if (wally_tx_input_init_alloc(txid->shad.sha.u.u8, + sizeof(txid->shad.sha.u.u8), + outnum, sequence, NULL, 0, NULL, + &tx_in) != WALLY_OK) + abort(); + } - tx_in->features = chainparams->is_elements ? WALLY_TX_IS_ELEMENTS : 0; - input = psbt_add_input(psbt, tx_in, insert_at); + input = psbt_add_input(psbt, tx_in, psbt->num_inputs); wally_tx_input_free(tx_in); return input; }