From 0d1f1bc66e68b1ad82ef4866695043f193653e9d Mon Sep 17 00:00:00 2001 From: niftynei Date: Sat, 6 Jun 2020 14:44:00 -0500 Subject: [PATCH] psbt: add helper method for setting a psbt input's redeemscript --- bitcoin/psbt.c | 11 +++++++++++ bitcoin/psbt.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index c825e17c6..383f51f4f 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -312,6 +312,17 @@ void psbt_input_set_prev_utxo_wscript(struct wally_psbt *psbt, size_t in, psbt_input_set_prev_utxo(psbt, in, scriptPubkey, amt); } +bool psbt_input_set_redeemscript(struct wally_psbt *psbt, size_t in, + const u8 *redeemscript) +{ + int wally_err; + assert(psbt->num_inputs > in); + wally_err = wally_psbt_input_set_redeem_script(&psbt->inputs[in], + cast_const(u8 *, redeemscript), + tal_bytelen(redeemscript)); + return wally_err == WALLY_OK; +} + struct amount_sat psbt_input_get_amount(struct wally_psbt *psbt, size_t in) { diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index d43681da5..8a483d682 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -57,6 +57,8 @@ void psbt_input_set_prev_utxo(struct wally_psbt *psbt, size_t in, const u8 *wscript, struct amount_sat amt); void psbt_input_set_prev_utxo_wscript(struct wally_psbt *psbt, size_t in, const u8 *wscript, struct amount_sat amt); +bool psbt_input_set_redeemscript(struct wally_psbt *psbt, size_t in, + const u8 *redeemscript); struct amount_sat psbt_input_get_amount(struct wally_psbt *psbt, size_t in);