mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
type_to_string: add privkey.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -7,5 +7,4 @@
|
|||||||
struct privkey {
|
struct privkey {
|
||||||
u8 secret[32];
|
u8 secret[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* LIGHTNING_BITCOIN_PRIVKEY_H */
|
#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);
|
pubkey_to_der(keyb, b);
|
||||||
return memcmp(keya, keyb, sizeof(keya));
|
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 struct netaddr *netaddr;
|
||||||
const secp256k1_pubkey *secp256k1_pubkey;
|
const secp256k1_pubkey *secp256k1_pubkey;
|
||||||
const struct channel_id *channel_id;
|
const struct channel_id *channel_id;
|
||||||
|
const struct privkey *privkey;
|
||||||
const char *charp_;
|
const char *charp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user