Browse Source

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

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
f5f8ca5352
  1. 3
      lightningd/Makefile
  2. 19
      lightningd/onchain/onchain_wire.c
  3. 18
      lightningd/onchain/onchain_wire.h

3
lightningd/Makefile

@ -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 = \

19
lightningd/onchain/onchain_wire.c

@ -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);
}

18
lightningd/onchain/onchain_wire.h

@ -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 */
Loading…
Cancel
Save