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
This commit is contained in:
Simon Vrouwe 2022-01-14 20:01:34 +02:00 committed by Rusty Russell
parent 05bd62fee4
commit 760c271381
2 changed files with 7 additions and 2 deletions

View File

@ -78,5 +78,6 @@ int main(int argc, char *argv[])
tal_free(m);
}
}
printf("\n");
return 0;
}

View File

@ -85,14 +85,18 @@ hexdump:
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;