diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c index 30b1b616a..3d2253736 100644 --- a/bitcoin/psbt.c +++ b/bitcoin/psbt.c @@ -17,6 +17,18 @@ memmove((arr) + (pos), (arr) + (pos) + 1, \ sizeof(*(arr)) * ((num) - ((pos) + 1))) +/* FIXME: someday this will break, because it's been exposed in libwally */ +int wally_psbt_clone(const struct wally_psbt *psbt, struct wally_psbt **output) +{ + int ret; + size_t byte_len; + const u8 *bytes = psbt_get_bytes(NULL, psbt, &byte_len); + + ret = wally_psbt_from_bytes(bytes, byte_len, output); + tal_free(bytes); + return ret; +} + void psbt_destroy(struct wally_psbt *psbt) { wally_psbt_free(psbt); diff --git a/bitcoin/psbt.h b/bitcoin/psbt.h index 23c0b3529..39d6805f1 100644 --- a/bitcoin/psbt.h +++ b/bitcoin/psbt.h @@ -12,6 +12,8 @@ struct wally_psbt_input; struct wally_tx; struct amount_sat; +int wally_psbt_clone(const struct wally_psbt *psbt, struct wally_psbt **output); + void psbt_destroy(struct wally_psbt *psbt); struct wally_psbt *new_psbt(const tal_t *ctx,