diff --git a/lightningd/htlc_wire.c b/lightningd/htlc_wire.c index 04640aa63..822576bf9 100644 --- a/lightningd/htlc_wire.c +++ b/lightningd/htlc_wire.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -58,6 +59,14 @@ void towire_shachain(u8 **pptr, const struct shachain *shachain) } } +void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx) +{ + u8 *txlin = linearize_tx(NULL, tx); + + towire(pptr, txlin, tal_len(txlin)); + tal_free(txlin); +} + void fromwire_added_htlc(const u8 **cursor, size_t *max, struct added_htlc *added) { @@ -131,3 +140,13 @@ void fromwire_shachain(const u8 **cursor, size_t *max, fromwire_sha256(cursor, max, &shachain->known[i].hash); } } + +void fromwire_bitcoin_tx(const u8 **cursor, size_t *max, struct bitcoin_tx *tx) +{ + /* FIXME: We'd really expect to allocate tx ourselves, but + * for the sake of simple structures, we don't write the + * generator that way. */ + struct bitcoin_tx *tx2 = pull_bitcoin_tx(tx, cursor, max); + if (tx2) + *tx = *tx2; +} diff --git a/lightningd/htlc_wire.h b/lightningd/htlc_wire.h index fe5c8d58c..6debd07c5 100644 --- a/lightningd/htlc_wire.h +++ b/lightningd/htlc_wire.h @@ -7,6 +7,7 @@ #include #include +struct bitcoin_tx; struct shachain; /* These are how we communicate about HTLC state to the master daemon */ @@ -41,6 +42,7 @@ void towire_changed_htlc(u8 **pptr, const struct changed_htlc *changed); void towire_htlc_state(u8 **pptr, const enum htlc_state hstate); void towire_side(u8 **pptr, const enum side side); void towire_shachain(u8 **pptr, const struct shachain *shachain); +void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx); void fromwire_added_htlc(const u8 **cursor, size_t *max, struct added_htlc *added); @@ -54,4 +56,5 @@ enum htlc_state fromwire_htlc_state(const u8 **cursor, size_t *max); enum side fromwire_side(const u8 **cursor, size_t *max); void fromwire_shachain(const u8 **cursor, size_t *max, struct shachain *shachain); +void fromwire_bitcoin_tx(const u8 **cursor, size_t *max, struct bitcoin_tx *tx); #endif /* LIGHTNING_LIGHTNINGD_HTLC_WIRE_H */