From fef155a9e2806cebc38ea4aa341e9468ee3d7a34 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Thu, 30 Jul 2020 15:10:58 +1200 Subject: [PATCH] psbt: Use wallys function to check PST finalization status Signed-off-by: Jon Griffiths --- bitcoin/psbt.c | 13 +++++-------- bitcoin/psbt.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index 98bdd0672..fdf8be49c 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -60,15 +60,12 @@ struct wally_psbt *new_psbt(const tal_t *ctx, const struct wally_tx *wtx) return tal_steal(ctx, psbt); } -bool psbt_is_finalized(struct wally_psbt *psbt) +bool psbt_is_finalized(const struct wally_psbt *psbt) { - for (size_t i = 0; i < psbt->num_inputs; i++) { - if (!psbt->inputs[i].final_scriptsig && - !psbt->inputs[i].final_witness) - return false; - } - - return true; + size_t is_finalized; + int wally_err = wally_psbt_is_finalized(psbt, &is_finalized); + assert(wally_err == WALLY_OK); + return is_finalized ? true : false; } struct wally_psbt_input *psbt_add_input(struct wally_psbt *psbt, diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index cc72f8169..335c8b5fb 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -29,7 +29,7 @@ struct wally_psbt *new_psbt(const tal_t *ctx, * a psbt has the finalized script sig and/or witness data populated * for such a call */ -bool psbt_is_finalized(struct wally_psbt *psbt); +bool psbt_is_finalized(const struct wally_psbt *psbt); struct wally_tx *psbt_finalize(struct wally_psbt *psbt, bool finalize_in_place);