From 9ba2f614bba2ca6d1683fe598e2879aa00886724 Mon Sep 17 00:00:00 2001 From: niftynei Date: Wed, 21 Apr 2021 15:45:05 -0500 Subject: [PATCH] psbt-open: method to quickly check if has our input For dual-funding's accepter plugin, we only want to send psbts that need to be signed to `signpsbt`; this lets us quickly check if they're "signable" --- common/psbt_open.c | 10 ++++++++++ common/psbt_open.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/common/psbt_open.c b/common/psbt_open.c index c8b83cce9..eb654a02f 100644 --- a/common/psbt_open.c +++ b/common/psbt_open.c @@ -481,3 +481,13 @@ bool psbt_input_is_ours(const struct wally_psbt_input *input) PSBT_TYPE_INPUT_MARKER, &unused); return !(!result); } + +bool psbt_has_our_input(const struct wally_psbt *psbt) +{ + for (size_t i = 0; i < psbt->num_inputs; i++) { + if (psbt_input_is_ours(&psbt->inputs[i])) + return true; + } + + return false; +} diff --git a/common/psbt_open.h b/common/psbt_open.h index f6bc07eb3..bb7a5e57e 100644 --- a/common/psbt_open.h +++ b/common/psbt_open.h @@ -174,4 +174,8 @@ void psbt_input_mark_ours(const tal_t *ctx, */ bool psbt_input_is_ours(const struct wally_psbt_input *input); +/* psbt_has_our_input - Returns true if this psbt contains + * any input that is ours + */ +bool psbt_has_our_input(const struct wally_psbt *psbt); #endif /* LIGHTNING_COMMON_PSBT_OPEN_H */