diff --git a/plugins/Makefile b/plugins/Makefile index fce5bfd3e..b3cb29d4d 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -59,7 +59,7 @@ plugins/fundchannel: common/addr.o $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS) plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/keysend: bitcoin/chainparams.o wire/gen_onion_wire.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/gen_onion_wire.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(PLUGIN_PAY_OBJS) $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS): $(PLUGIN_LIB_HEADER) diff --git a/wire/tlvstream.c b/wire/tlvstream.c new file mode 100644 index 000000000..257b53f0c --- /dev/null +++ b/wire/tlvstream.c @@ -0,0 +1,21 @@ +#include +#include + +void towire_tlvstream_raw(u8 **pptr, const struct tlv_field *fields) +{ + if (!fields) + return; + + for (size_t i = 0; i < tal_count(fields); i++) { + const struct tlv_field *field = &fields[i]; + /* BOLT #1: + * + * The sending node: + ... + * - MUST minimally encode `type` and `length`. + */ + towire_bigsize(pptr, field->numtype); + towire_bigsize(pptr, field->length); + towire(pptr, field->value, field->length); + } +} diff --git a/wire/tlvstream.h b/wire/tlvstream.h index 256feb5e8..5ec9939a7 100644 --- a/wire/tlvstream.h +++ b/wire/tlvstream.h @@ -34,4 +34,7 @@ void towire_tlvs(u8 **pptr, size_t num_types, const void *record); +/* Given any tlvstream serialize the raw fields (untyped ones). */ +void towire_tlvstream_raw(u8 **pptr, const struct tlv_field *fields); + #endif /* LIGHTNING_WIRE_TLVSTREAM_H */