mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
devtools/gossipwith: option to print out messages in hex.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3437f7e25d
commit
2e9b8f42fb
1 changed files with 11 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
#define io_close simple_close
|
||||
static bool stream_stdin = false;
|
||||
static bool no_init = false;
|
||||
static bool hex = false;
|
||||
static int timeout_after = -1;
|
||||
|
||||
static struct io_plan *simple_write(struct io_conn *conn,
|
||||
|
@ -183,10 +184,14 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||
msg = sync_crypto_read(NULL, pps);
|
||||
if (!msg)
|
||||
err(1, "Reading msg");
|
||||
if (hex) {
|
||||
printf("%s\n", tal_hex(msg, msg));
|
||||
} else {
|
||||
belen = cpu_to_be16(tal_bytelen(msg));
|
||||
if (!write_all(STDOUT_FILENO, &belen, sizeof(belen))
|
||||
|| !write_all(STDOUT_FILENO, msg, tal_bytelen(msg)))
|
||||
err(1, "Writing out msg");
|
||||
}
|
||||
tal_free(msg);
|
||||
--max_messages;
|
||||
}
|
||||
|
@ -237,6 +242,8 @@ int main(int argc, char *argv[])
|
|||
opt_register_arg("--timeout-after", opt_set_intval, opt_show_intval,
|
||||
&timeout_after,
|
||||
"Exit (success) this many seconds after no msgs rcvd");
|
||||
opt_register_noarg("--hex", opt_set_bool, &hex,
|
||||
"Print out messages in hex");
|
||||
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
||||
"id@addr[:port] [hex-msg-tosend...]\n"
|
||||
"Connect to a lightning peer and relay gossip messages from it",
|
||||
|
|
Loading…
Add table
Reference in a new issue