common/derive_basepoints: add routines for marshal/unmarshal.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-07-09 20:47:59 +09:30
committed by Christian Decker
parent ad9dbaaa3f
commit b2b85100d7
9 changed files with 48 additions and 42 deletions

View File

@@ -2,6 +2,7 @@
#include <ccan/crypto/sha256/sha256.h>
#include <common/derive_basepoints.h>
#include <common/utils.h>
#include <wire/wire.h>
bool derive_basepoints(const struct secret *seed,
struct pubkey *funding_pubkey,
@@ -85,3 +86,20 @@ bool per_commit_point(const struct sha256 *shaseed,
return true;
}
void towire_basepoints(u8 **pptr, const struct basepoints *b)
{
towire_pubkey(pptr, &b->revocation);
towire_pubkey(pptr, &b->payment);
towire_pubkey(pptr, &b->htlc);
towire_pubkey(pptr, &b->delayed_payment);
}
void fromwire_basepoints(const u8 **ptr, size_t *max,
struct basepoints *b)
{
fromwire_pubkey(ptr, max, &b->revocation);
fromwire_pubkey(ptr, max, &b->payment);
fromwire_pubkey(ptr, max, &b->htlc);
fromwire_pubkey(ptr, max, &b->delayed_payment);
}

View File

@@ -75,4 +75,9 @@ static inline u64 revocations_received(const struct shachain *shachain)
{
return (1ULL << SHACHAIN_BITS) - (shachain_next_index(shachain) + 1);
}
void towire_basepoints(u8 **pptr, const struct basepoints *b);
void fromwire_basepoints(const u8 **ptr, size_t *max,
struct basepoints *b);
#endif /* LIGHTNING_COMMON_DERIVE_BASEPOINTS_H */