onchain/onchain_wire: routines to marshal/unmarshal htlc stubs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-08-18 14:13:52 +09:30
parent 0ab1fb3688
commit f5f8ca5352
3 changed files with 39 additions and 1 deletions

View File

@ -102,7 +102,8 @@ LIGHTNINGD_HEADERS_NOGEN = \
$(CORE_HEADERS) \
$(CORE_TX_HEADERS) \
$(DAEMON_HEADERS) \
$(WALLET_LIB_HEADERS)
$(WALLET_LIB_HEADERS) \
lightningd/onchain/onchain_wire.h
# Generated headers
LIGHTNINGD_HEADERS_GEN = \

View File

@ -0,0 +1,19 @@
#include <ccan/structeq/structeq.h>
#include <lightningd/htlc_wire.h>
#include <lightningd/onchain/onchain_wire.h>
#include <wire/wire.h>
void towire_htlc_stub(u8 **pptr, const struct htlc_stub *htlc_stub)
{
towire_side(pptr, htlc_stub->owner);
towire_u32(pptr, htlc_stub->cltv_expiry);
towire_ripemd160(pptr, &htlc_stub->ripemd);
}
void fromwire_htlc_stub(const u8 **cursor, size_t *max,
struct htlc_stub *htlc_stub)
{
htlc_stub->owner = fromwire_side(cursor, max);
htlc_stub->cltv_expiry = fromwire_u32(cursor, max);
fromwire_ripemd160(cursor, max, &htlc_stub->ripemd);
}

View File

@ -0,0 +1,18 @@
#ifndef LIGHTNING_LIGHTNINGD_ONCHAIN_WIRE_H
#define LIGHTNING_LIGHTNINGD_ONCHAIN_WIRE_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <daemon/htlc.h>
/* The minimal info about an htlc. */
struct htlc_stub {
enum side owner;
u32 cltv_expiry;
struct ripemd160 ripemd;
};
void towire_htlc_stub(u8 **pptr, const struct htlc_stub *htlc_stub);
void fromwire_htlc_stub(const u8 **cursor, size_t *max,
struct htlc_stub *htlc_stub);
#endif /* LIGHTNING_LIGHTNINGD_ONCHAIN_WIRE_H */