mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
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:
parent
4e67b4fd03
commit
66ffd7a73f
2 changed files with 8 additions and 11 deletions
|
@ -24,13 +24,12 @@ static char *to_base58(const tal_t *ctx, u8 version,
|
||||||
buf[0] = version;
|
buf[0] = version;
|
||||||
memcpy(buf + 1, rmd, sizeof(*rmd));
|
memcpy(buf + 1, rmd, sizeof(*rmd));
|
||||||
|
|
||||||
if (wally_base58_from_bytes((const unsigned char *) buf, total_length, BASE58_FLAG_CHECKSUM, &out) != WALLY_OK) {
|
if (wally_base58_from_bytes((const unsigned char *) buf,
|
||||||
return NULL;
|
total_length, BASE58_FLAG_CHECKSUM, &out)
|
||||||
}else{
|
!= WALLY_OK)
|
||||||
char *res = tal_strdup(ctx, out);
|
out = NULL;
|
||||||
wally_free_string(out);
|
|
||||||
return res;
|
return tal_steal(ctx, out);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *bitcoin_to_base58(const tal_t *ctx, const struct chainparams *chainparams,
|
char *bitcoin_to_base58(const tal_t *ctx, const struct chainparams *chainparams,
|
||||||
|
|
|
@ -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 *psbt_to_b64(const tal_t *ctx, const struct wally_psbt *psbt)
|
||||||
{
|
{
|
||||||
char *serialized_psbt, *ret_val;
|
char *serialized_psbt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = wally_psbt_to_base64(psbt, 0, &serialized_psbt);
|
ret = wally_psbt_to_base64(psbt, 0, &serialized_psbt);
|
||||||
assert(ret == WALLY_OK);
|
assert(ret == WALLY_OK);
|
||||||
|
|
||||||
ret_val = tal_strdup(ctx, serialized_psbt);
|
return tal_steal(ctx, serialized_psbt);
|
||||||
wally_free_string(serialized_psbt);
|
|
||||||
return ret_val;
|
|
||||||
}
|
}
|
||||||
REGISTER_TYPE_TO_STRING(wally_psbt, psbt_to_b64);
|
REGISTER_TYPE_TO_STRING(wally_psbt, psbt_to_b64);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue