Browse Source
Neater than using a u8 array as we do now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>ppa-0.6.1
Rusty Russell
8 years ago
9 changed files with 57 additions and 40 deletions
@ -0,0 +1,25 @@ |
|||
#include <lightningd/bip32.h> |
|||
#include <wally_bip32.h> |
|||
#include <wire/wire.h> |
|||
|
|||
/* We only ever send out the public seed. */ |
|||
void towire_ext_key(u8 **pptr, const struct ext_key *bip32) |
|||
{ |
|||
unsigned char out[BIP32_SERIALIZED_LEN]; |
|||
|
|||
if (bip32_key_serialize(bip32, BIP32_FLAG_KEY_PUBLIC, out, |
|||
sizeof(out))) |
|||
abort(); |
|||
|
|||
towire(pptr, out, sizeof(out)); |
|||
} |
|||
|
|||
void fromwire_ext_key(const u8 **cursor, size_t *max, struct ext_key *bip32) |
|||
{ |
|||
const u8 *in = fromwire(cursor, max, NULL, BIP32_SERIALIZED_LEN); |
|||
if (!in) |
|||
return; |
|||
|
|||
if (bip32_key_unserialize(in, BIP32_SERIALIZED_LEN, bip32) != WALLY_OK) |
|||
fromwire_fail(cursor, max); |
|||
} |
@ -0,0 +1,12 @@ |
|||
#ifndef LIGHTNING_LIGHTNINGD_BIP32_H |
|||
#define LIGHTNING_LIGHTNINGD_BIP32_H |
|||
#include "config.h" |
|||
#include <ccan/short_types/short_types.h> |
|||
#include <stddef.h> |
|||
|
|||
struct ext_key; |
|||
|
|||
void towire_ext_key(u8 **pptr, const struct ext_key *bip32); |
|||
void fromwire_ext_key(const u8 **cursor, size_t *max, struct ext_key *bip32); |
|||
|
|||
#endif /* LIGHTNING_LIGHTNINGD_BIP32_H */ |
Can't render this file because it has a wrong number of fields in line 2.
|
Can't render this file because it has a wrong number of fields in line 2.
|
Loading…
Reference in new issue