diff --git a/devtools/Makefile b/devtools/Makefile index 1ca419d7de3f..c220ecd23e38 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -8,7 +8,7 @@ DEVTOOLS_TOOL_OBJS := $(DEVTOOLS_TOOL_SRC:.c=.o) # Make sure these depend on everything. ALL_C_SOURCES += $(DEVTOOLS_TOOL_SRC) -ALL_C_HEADERS += +ALL_C_HEADERS += devtools/print_wire.h ALL_PROGRAMS += $(DEVTOOLS) # Don't include this in ALL_PROGRAMS as we need a special link line for -lz @@ -90,7 +90,7 @@ devtools/onion: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(BITCOIN_OBJS) common/onio devtools/gossipwith: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o wire/peer_wiregen.o devtools/gossipwith.o common/cryptomsg.o common/cryptomsg.o -$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h +$(DEVTOOLS_OBJS) $(DEVTOOLS_TOOL_OBJS): wire/wire.h devtools/print_wire.h devtools/mkcommit: $(DEVTOOLS_COMMON_OBJS) $(BITCOIN_OBJS) common/derive_basepoints.o common/channel_type.o common/keyset.o common/key_derive.o common/initial_commit_tx.o common/permute_tx.o wire/fromwire.o wire/towire.o devtools/mkcommit.o channeld/full_channel.o common/initial_channel.o common/htlc_state.o common/pseudorand.o common/htlc_tx.o channeld/commit_tx.o common/htlc_trim.o diff --git a/devtools/print_wire.c b/devtools/print_wire.c index 15669899dd95..98a559ef5206 100644 --- a/devtools/print_wire.c +++ b/devtools/print_wire.c @@ -51,6 +51,17 @@ bool printwire_u64(const char *fieldname, const u8 **cursor, size_t *plen) return true; } +bool printwire_bigsize(const char *fieldname, const u8 **cursor, size_t *plen) +{ + u64 v = fromwire_bigsize(cursor, plen); + if (!*cursor) { + printf("**TRUNCATED bigsize %s**\n", fieldname); + return false; + } + printf("%"PRIu64"\n", v); + return true; +} + bool printwire_s8(const char *fieldname, const u8 **cursor, size_t *plen) { s8 v = fromwire_s8(cursor, plen); diff --git a/devtools/print_wire.h b/devtools/print_wire.h index 54536d7ef046..6886b5129e1e 100644 --- a/devtools/print_wire.h +++ b/devtools/print_wire.h @@ -13,13 +13,13 @@ struct tlv_print_record_type { }; typedef u64 bigsize; -#define printwire_bigsize printwire_u64 struct wireaddr; bool printwire_u8(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_u16(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_u32(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_u64(const char *fieldname, const u8 **cursor, size_t *plen); +bool printwire_bigsize(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_s8(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_s16(const char *fieldname, const u8 **cursor, size_t *plen); bool printwire_s32(const char *fieldname, const u8 **cursor, size_t *plen); diff --git a/wire/Makefile b/wire/Makefile index f9660294b591..5bcabd9708ec 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -40,6 +40,7 @@ WIRE_OBJS := $(WIRE_SRC:.c=.o) common/sciddir_or_pubkey.o WIRE_PRINT_OBJS := $(WIRE_PRINT_SRC:.c=.o) WIRE_BOLT12_OBJS := $(WIRE_BOLT12_SRC:.c=.o) $(WIRE_OBJS) $(WIRE_PRINT_OBJS) $(WIRE_BOLT12_OBJS): $(WIRE_HEADERS) $(WIRE_PRINT_HEADERS) +$(WIRE_PRINT_OBJS): devtools/print_wire.h ALL_C_SOURCES += $(WIRE_SRC) $(WIRE_BOLT12_SRC) $(WIRE_PRINT_SRC)