Skip to content

Commit

Permalink
devtools: in decodemsg, add newline and fix decoding a node_announcem…
Browse files Browse the repository at this point in the history
…ent 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
  • Loading branch information
SimonVrouwe authored and rustyrussell committed Feb 28, 2022
1 parent 05bd62f commit 760c271
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions devtools/decodemsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ int main(int argc, char *argv[])
tal_free(m);
}
}
printf("\n");
return 0;
}
8 changes: 6 additions & 2 deletions devtools/print_wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 760c271

Please sign in to comment.