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"
This commit is contained in:
niftynei 2021-04-21 15:45:05 -05:00 committed by Rusty Russell
parent 7c76363e20
commit 9ba2f614bb
2 changed files with 14 additions and 0 deletions

View File

@ -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;
}

View File

@ -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 */