From 0ab1fb3688f5e8eaff34a03d1a30dcf50bfe079f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 Aug 2017 14:13:52 +0930 Subject: [PATCH] wire: add ripemd marshal/unmarshal routines. This is for htlc stubs. Signed-off-by: Rusty Russell --- wire/fromwire.c | 5 +++++ wire/towire.c | 6 ++++++ wire/wire.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/wire/fromwire.c b/wire/fromwire.c index fc853da67..854ab8fd4 100644 --- a/wire/fromwire.c +++ b/wire/fromwire.c @@ -165,6 +165,11 @@ void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage fromwire(cursor, max, preimage, sizeof(*preimage)); } +void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd) +{ + fromwire(cursor, max, ripemd, sizeof(*ripemd)); +} + void fromwire_ipaddr(const u8 **cursor, size_t *max, struct ipaddr *addr) { /* Skip any eventual padding */ diff --git a/wire/towire.c b/wire/towire.c index 92b694658..830bda3d5 100644 --- a/wire/towire.c +++ b/wire/towire.c @@ -2,6 +2,7 @@ #include "wire.h" #include #include +#include #include #include #include @@ -109,6 +110,11 @@ void towire_preimage(u8 **pptr, const struct preimage *preimage) towire(pptr, preimage, sizeof(*preimage)); } +void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd) +{ + towire(pptr, ripemd, sizeof(*ripemd)); +} + void towire_ipaddr(u8 **pptr, const struct ipaddr *addr) { towire_u8(pptr, addr->type); diff --git a/wire/wire.h b/wire/wire.h index 8c0ce6177..8a0b986c4 100644 --- a/wire/wire.h +++ b/wire/wire.h @@ -34,6 +34,7 @@ struct ipaddr { }; struct preimage; +struct ripemd160; void derive_channel_id(struct channel_id *channel_id, struct sha256_double *txid, u16 txout); @@ -54,6 +55,7 @@ void towire_short_channel_id(u8 **pptr, void towire_sha256(u8 **pptr, const struct sha256 *sha256); void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d); void towire_preimage(u8 **pptr, const struct preimage *preimage); +void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd); void towire_ipaddr(u8 **pptr, const struct ipaddr *addr); void towire_u8(u8 **pptr, u8 v); void towire_u16(u8 **pptr, u16 v); @@ -83,6 +85,7 @@ void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256); void fromwire_sha256_double(const u8 **cursor, size_t *max, struct sha256_double *sha256d); void fromwire_preimage(const u8 **cursor, size_t *max, struct preimage *preimage); +void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd); void fromwire_ipaddr(const u8 **cursor, size_t *max, struct ipaddr *addr); void fromwire_pad(const u8 **cursor, size_t *max, size_t num);