bitcoin/: neaten use of libwally base58 and bas64 routines.

Now libwally uses tal, we don't need to make copies.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-09-23 20:06:46 +09:30 committed by Christian Decker
parent 4e67b4fd03
commit 66ffd7a73f
2 changed files with 8 additions and 11 deletions

View File

@ -24,13 +24,12 @@ static char *to_base58(const tal_t *ctx, u8 version,
buf[0] = version;
memcpy(buf + 1, rmd, sizeof(*rmd));
if (wally_base58_from_bytes((const unsigned char *) buf, total_length, BASE58_FLAG_CHECKSUM, &out) != WALLY_OK) {
return NULL;
}else{
char *res = tal_strdup(ctx, out);
wally_free_string(out);
return res;
}
if (wally_base58_from_bytes((const unsigned char *) buf,
total_length, BASE58_FLAG_CHECKSUM, &out)
!= WALLY_OK)
out = NULL;
return tal_steal(ctx, out);
}
char *bitcoin_to_base58(const tal_t *ctx, const struct chainparams *chainparams,

View File

@ -645,15 +645,13 @@ struct wally_psbt *psbt_from_b64(const tal_t *ctx,
char *psbt_to_b64(const tal_t *ctx, const struct wally_psbt *psbt)
{
char *serialized_psbt, *ret_val;
char *serialized_psbt;
int ret;
ret = wally_psbt_to_base64(psbt, 0, &serialized_psbt);
assert(ret == WALLY_OK);
ret_val = tal_strdup(ctx, serialized_psbt);
wally_free_string(serialized_psbt);
return ret_val;
return tal_steal(ctx, serialized_psbt);
}
REGISTER_TYPE_TO_STRING(wally_psbt, psbt_to_b64);