mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
bitcoin/base58: don't segv if key_to_base58 / key_from_base58 called first.
We need to initialize b58_sha256_impl here too. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4ed259c46c
commit
e899c47260
1 changed files with 3 additions and 0 deletions
|
@ -118,6 +118,7 @@ char *key_to_base58(const tal_t *ctx, bool test_net, const struct privkey *key)
|
|||
/* Mark this as a compressed key. */
|
||||
buf[32] = 1;
|
||||
|
||||
b58_sha256_impl = my_sha256;
|
||||
b58check_enc(out, &outlen, version, buf, sizeof(buf));
|
||||
return tal_strdup(ctx, out);
|
||||
}
|
||||
|
@ -129,6 +130,8 @@ bool key_from_base58(const char *base58, size_t base58_len,
|
|||
u8 keybuf[1 + 32 + 1 + 4];
|
||||
size_t keybuflen = sizeof(keybuf);
|
||||
|
||||
b58_sha256_impl = my_sha256;
|
||||
|
||||
b58tobin(keybuf, &keybuflen, base58, base58_len);
|
||||
if (b58check(keybuf, sizeof(keybuf), base58, base58_len) < 0)
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue