mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
psbt: add method to confirm 'finalized' status of psbt
calling `wally_psbt_finalize` doesn't return a status indicator; instead you must call `psbt_is_finalized` to check that it's eligible for 'extraction' -- extraction will fail if the psbt is not in a finalized state.
This commit is contained in:
parent
000ef2079c
commit
052d40ae98
2 changed files with 22 additions and 0 deletions
|
@ -80,6 +80,17 @@ 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)
|
||||
{
|
||||
for (size_t i = 0; i < psbt->num_inputs; i++) {
|
||||
if (!psbt->inputs[i].final_script_sig &&
|
||||
!psbt->inputs[i].final_witness)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct wally_psbt_input *psbt_add_input(struct wally_psbt *psbt,
|
||||
struct wally_tx_input *input,
|
||||
size_t insert_at)
|
||||
|
|
|
@ -21,6 +21,17 @@ void psbt_destroy(struct wally_psbt *psbt);
|
|||
struct wally_psbt *new_psbt(const tal_t *ctx,
|
||||
const struct wally_tx *wtx);
|
||||
|
||||
/**
|
||||
* psbt_is_finalized - Check if tx is ready to be extracted
|
||||
*
|
||||
* The libwally library requires a transaction be *ready* for
|
||||
* extraction before it will add/append all of the sigs/witnesses
|
||||
* onto the global transaction. This check returns true if
|
||||
* a psbt has the finalized script sig and/or witness data populated
|
||||
* for such a call
|
||||
*/
|
||||
bool psbt_is_finalized(struct wally_psbt *psbt);
|
||||
|
||||
struct wally_psbt_input *psbt_add_input(struct wally_psbt *psbt,
|
||||
struct wally_tx_input *input,
|
||||
size_t insert_at);
|
||||
|
|
Loading…
Add table
Reference in a new issue