MCPcopy Create free account
hub / github.com/ElementsProject/lightning / decode_with_privkey

Function decode_with_privkey

devtools/onion.c:110–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110static 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
134static void do_decode(int argc, char **argv, const u8 *assocdata)
135{

Callers 2

do_decodeFunction · 0.85
runtestFunction · 0.85

Calls 6

hex_decodeFunction · 0.85
errxFunction · 0.85
parse_onionpacketFunction · 0.85
tal_bytelenFunction · 0.85
onion_shared_secretFunction · 0.85
process_onionpacketFunction · 0.85

Tested by

no test coverage detected