Skip to content

Commit

Permalink
psbt: Use the newly exposed wally function to clone PSBTs
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Griffiths <[email protected]>
  • Loading branch information
jgriffiths authored and rustyrussell committed Aug 7, 2020
1 parent a51c655 commit 68ffecb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
14 changes: 1 addition & 13 deletions bitcoin/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
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);
Expand Down Expand Up @@ -424,7 +412,7 @@ struct wally_tx *psbt_finalize(struct wally_psbt *psbt, bool finalize_in_place)
* data, not the global tx. But 'finalizing' a tx destroys some fields
* so we 'clone' it first and then finalize it */
if (!finalize_in_place) {
if (wally_psbt_clone(psbt, &tmppsbt) != WALLY_OK)
if (wally_psbt_clone_alloc(psbt, 0, &tmppsbt) != WALLY_OK)
return NULL;
} else
tmppsbt = cast_const(struct wally_psbt *, psbt);
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ struct amount_sat;
struct bitcoin_signature;
struct pubkey;

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,
Expand Down

0 comments on commit 68ffecb

Please sign in to comment.