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