Browse Source

psbt: add 'wally_psbt_clone' function, to clone a psbt

We'll need this for settng the tx correctly, for reasons
nifty/pset-pre
niftynei 5 years ago
committed by Christian Decker
parent
commit
3c6e3eecee
  1. 12
      bitcoin/psbt.c
  2. 2
      bitcoin/psbt.h

12
bitcoin/psbt.c

@ -17,6 +17,18 @@
memmove((arr) + (pos), (arr) + (pos) + 1, \ memmove((arr) + (pos), (arr) + (pos) + 1, \
sizeof(*(arr)) * ((num) - ((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) void psbt_destroy(struct wally_psbt *psbt)
{ {
wally_psbt_free(psbt); wally_psbt_free(psbt);

2
bitcoin/psbt.h

@ -12,6 +12,8 @@ struct wally_psbt_input;
struct wally_tx; struct wally_tx;
struct amount_sat; struct amount_sat;
int wally_psbt_clone(const struct wally_psbt *psbt, struct wally_psbt **output);
void psbt_destroy(struct wally_psbt *psbt); void psbt_destroy(struct wally_psbt *psbt);
struct wally_psbt *new_psbt(const tal_t *ctx, struct wally_psbt *new_psbt(const tal_t *ctx,

Loading…
Cancel
Save