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

Function decode_with_privkey

devtools/onion.c:111–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

do_decodeFunction · 0.85
runtestFunction · 0.85

Calls 7

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

Tested by

no test coverage detected