From 5d7178d48880f90cab639f54248fd7952f243a91 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Wed, 9 Sep 2020 19:56:14 +0930 Subject: [PATCH] bitcoin/psbt.c: Add psbt_insert_output function. --- bitcoin/psbt.c | 12 ++++++++++++ bitcoin/psbt.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index 806707225..ad9d2d05f 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -183,6 +183,18 @@ struct wally_psbt_output *psbt_append_output(struct wally_psbt *psbt, wally_tx_output_free(tx_out); return out; } +struct wally_psbt_output *psbt_insert_output(struct wally_psbt *psbt, + const u8 *script, + struct amount_sat amount, + size_t insert_at) +{ + struct wally_psbt_output *out; + struct wally_tx_output *tx_out = wally_tx_output(script, amount); + + out = psbt_add_output(psbt, tx_out, insert_at); + wally_tx_output_free(tx_out); + return out; +} void psbt_rm_output(struct wally_psbt *psbt, size_t remove_at) diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index 8f08858e2..1fc8482d6 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -119,6 +119,10 @@ struct wally_psbt_output *psbt_add_output(struct wally_psbt *psbt, struct wally_psbt_output *psbt_append_output(struct wally_psbt *psbt, const u8 *script, struct amount_sat amount); +struct wally_psbt_output *psbt_insert_output(struct wally_psbt *psbt, + const u8 *script, + struct amount_sat amount, + size_t insert_at); void psbt_rm_output(struct wally_psbt *psbt, size_t remove_at);