From 760c271381f87907d200ebcda1aae72867f1cf20 Mon Sep 17 00:00:00 2001 From: Simon Vrouwe Date: Fri, 14 Jan 2022 20:01:34 +0200 Subject: [PATCH] devtools: in decodemsg, add newline and fix decoding a node_announcement with tlvs Terminal prompt got messed up because missing newline in case of empty fields. printwire_addresses expected it to be the last field, which is not the case of a node_announcement with tlv --- devtools/decodemsg.c | 1 + devtools/print_wire.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/devtools/decodemsg.c b/devtools/decodemsg.c index 8512b4793ea7..fc943999818e 100644 --- a/devtools/decodemsg.c +++ b/devtools/decodemsg.c @@ -78,5 +78,6 @@ int main(int argc, char *argv[]) tal_free(m); } } + printf("\n"); return 0; } diff --git a/devtools/print_wire.c b/devtools/print_wire.c index 08bfc7cdbcb3..d73e7cb07a70 100644 --- a/devtools/print_wire.c +++ b/devtools/print_wire.c @@ -85,14 +85,18 @@ static void printwire_alias(const u8 **cursor, size_t *plen, size_t len) static void printwire_addresses(const u8 **cursor, size_t *plen, size_t len) { struct wireaddr addr; + size_t to_go = len; + const size_t len_ref = *plen; printf("["); - while (*plen && fromwire_wireaddr(cursor, plen, &addr)) + while (to_go && fromwire_wireaddr(cursor, plen, &addr)) { + to_go = len - (len_ref - *plen); printf(" %s", fmt_wireaddr(NULL, &addr)); + } if (!*cursor) return; - if (*plen != 0) { + if (to_go) { printf(" UNKNOWN:"); if (!print_hexstring(cursor, plen, len)) return;