From 93045945be14a325f09aa9b5bcbb4d98bba03ccb Mon Sep 17 00:00:00 2001 From: niftynei Date: Tue, 15 Sep 2020 16:38:31 -0500 Subject: [PATCH] psbt: add helper to set the non-witness utxo for an input We need this info for every dual-funded open --- bitcoin/psbt.c | 11 +++++++++++ bitcoin/psbt.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index 8b751f740..3fefdef25 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -314,6 +314,17 @@ void psbt_input_set_wit_utxo(struct wally_psbt *psbt, size_t in, tal_wally_end(psbt); } +void psbt_input_set_utxo(struct wally_psbt *psbt, size_t in, + const struct wally_tx *prev_tx) +{ + int wally_err; + tal_wally_start(); + wally_err = wally_psbt_input_set_utxo(&psbt->inputs[in], + prev_tx); + tal_wally_end(psbt); + assert(wally_err == WALLY_OK); +} + void psbt_input_set_witscript(struct wally_psbt *psbt, size_t in, const u8 *wscript) { int wally_err; diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index 5da2c01bd..46b28a4f9 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -122,6 +122,10 @@ struct wally_psbt_input *psbt_append_input(struct wally_psbt *psbt, void psbt_input_set_wit_utxo(struct wally_psbt *psbt, size_t in, const u8 *scriptPubkey, struct amount_sat amt); +/* psbt_input_set_utxo - Set the non-witness utxo field for this PSBT input */ +void psbt_input_set_utxo(struct wally_psbt *psbt, size_t in, + const struct wally_tx *prev_tx); + /* psbt_elements_input_set_asset - Set the asset/value fields for an * Elements PSBT (PSET, technically */ void psbt_elements_input_set_asset(struct wally_psbt *psbt, size_t in,