mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
devtools/onion: fix --decode
Add odd-length string can never be valid hex! In addition, don't try to print the next hop if there isn't one, but always print the (raw) payload. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
cd6d0ccde7
commit
1b8adabd4f
@ -62,7 +62,7 @@ static void do_decode(int argc, char **argv)
|
||||
struct privkey seckey;
|
||||
const tal_t *ctx = talz(NULL, tal_t);
|
||||
u8 serialized[TOTAL_PACKET_SIZE];
|
||||
char hextemp[2 * sizeof(serialized) + 1];
|
||||
char hextemp[2 * sizeof(serialized)];
|
||||
memset(hextemp, 0, sizeof(hextemp));
|
||||
u8 shared_secret[32];
|
||||
u8 assocdata[32];
|
||||
@ -97,11 +97,13 @@ static void do_decode(int argc, char **argv)
|
||||
if (!step || !step->next)
|
||||
errx(1, "Error processing message.");
|
||||
|
||||
u8 *ser = serialize_onionpacket(ctx, step->next);
|
||||
if (!ser)
|
||||
errx(1, "Error serializing message.");
|
||||
|
||||
printf("%s\n", tal_hex(ctx, ser));
|
||||
printf("payload=%s\n", tal_hex(ctx, step->raw_payload));
|
||||
if (step->nextcase == ONION_FORWARD) {
|
||||
u8 *ser = serialize_onionpacket(ctx, step->next);
|
||||
if (!ser)
|
||||
errx(1, "Error serializing message.");
|
||||
printf("next=%s\n", tal_hex(ctx, ser));
|
||||
}
|
||||
tal_free(ctx);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user