| 108 | } |
| 109 | |
| 110 | static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion, char *hexprivkey, const u8 *assocdata) |
| 111 | { |
| 112 | struct privkey seckey; |
| 113 | struct route_step *step; |
| 114 | struct onionpacket *packet; |
| 115 | enum onion_wire why_bad; |
| 116 | struct secret shared_secret; |
| 117 | if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey))) |
| 118 | errx(1, "Invalid private key hex '%s'", hexprivkey); |
| 119 | |
| 120 | packet = parse_onionpacket(tmpctx, onion, tal_bytelen(onion), &why_bad); |
| 121 | |
| 122 | if (!packet) |
| 123 | errx(1, "Error parsing message: %s", onion_wire_name(why_bad)); |
| 124 | |
| 125 | if (!onion_shared_secret(&shared_secret, packet, &seckey)) |
| 126 | errx(1, "Error creating shared secret."); |
| 127 | |
| 128 | step = process_onionpacket(ctx, packet, &shared_secret, assocdata, |
| 129 | tal_bytelen(assocdata)); |
| 130 | return step; |
| 131 | |
| 132 | } |
| 133 | |
| 134 | static void do_decode(int argc, char **argv, const u8 *assocdata) |
| 135 | { |
no test coverage detected