Browse Source

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>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
e899c47260
  1. 3
      bitcoin/base58.c

3
bitcoin/base58.c

@ -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…
Cancel
Save