mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
sphinx: Return the error in parse_onionpacket
As suggested by @niftynei here: https://github.com/ElementsProject/lightning/pull/3260#discussion_r347543999 Suggested-by: Lisa Neigut <@niftynei> Suggested-by: Rusty Russell <@rustyrussell> Signed-off-by: Christian Decker <@cdecker>
This commit is contained in:
@@ -103,21 +103,21 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion,
|
||||
{
|
||||
struct privkey seckey;
|
||||
struct route_step *step;
|
||||
struct onionpacket *packet;
|
||||
struct onionpacket packet;
|
||||
enum onion_type why_bad;
|
||||
u8 shared_secret[32];
|
||||
if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey)))
|
||||
errx(1, "Invalid private key hex '%s'", hexprivkey);
|
||||
|
||||
packet = parse_onionpacket(ctx, onion, TOTAL_PACKET_SIZE, &why_bad);
|
||||
why_bad = parse_onionpacket(onion, TOTAL_PACKET_SIZE, &packet);
|
||||
|
||||
if (!packet)
|
||||
if (why_bad != 0)
|
||||
errx(1, "Error parsing message: %s", onion_type_name(why_bad));
|
||||
|
||||
if (!onion_shared_secret(shared_secret, packet, &seckey))
|
||||
if (!onion_shared_secret(shared_secret, &packet, &seckey))
|
||||
errx(1, "Error creating shared secret.");
|
||||
|
||||
step = process_onionpacket(ctx, packet, shared_secret, assocdata,
|
||||
step = process_onionpacket(ctx, &packet, shared_secret, assocdata,
|
||||
tal_bytelen(assocdata));
|
||||
return step;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user