mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
type_to_string: add privkey.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d97e3489a0
commit
25a37fafae
@ -7,5 +7,4 @@
|
||||
struct privkey {
|
||||
u8 secret[32];
|
||||
};
|
||||
|
||||
#endif /* LIGHTNING_BITCOIN_PRIVKEY_H */
|
||||
|
@ -88,3 +88,13 @@ int pubkey_cmp(const struct pubkey *a, const struct pubkey *b)
|
||||
pubkey_to_der(keyb, b);
|
||||
return memcmp(keya, keyb, sizeof(keya));
|
||||
}
|
||||
|
||||
static char *privkey_to_hexstr(const tal_t *ctx, const struct privkey *secret)
|
||||
{
|
||||
/* Bitcoin appends "01" to indicate the pubkey is compressed. */
|
||||
char *str = tal_arr(ctx, char, hex_str_size(sizeof(*secret) + 1));
|
||||
hex_encode(secret, sizeof(*secret), str, hex_str_size(sizeof(*secret)));
|
||||
strcat(str, "01");
|
||||
return str;
|
||||
}
|
||||
REGISTER_TYPE_TO_STRING(privkey, privkey_to_hexstr);
|
||||
|
@ -20,6 +20,7 @@ union printable_types {
|
||||
const struct netaddr *netaddr;
|
||||
const secp256k1_pubkey *secp256k1_pubkey;
|
||||
const struct channel_id *channel_id;
|
||||
const struct privkey *privkey;
|
||||
const char *charp_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user