mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 06:44:24 +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:
@@ -969,7 +969,7 @@ static struct command_result *json_sendonion(struct command *cmd,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
u8 *onion;
|
||||
struct onionpacket *packet;
|
||||
struct onionpacket packet;
|
||||
enum onion_type failcode;
|
||||
struct htlc_out *hout;
|
||||
struct route_hop *first_hop;
|
||||
@@ -989,9 +989,9 @@ static struct command_result *json_sendonion(struct command *cmd,
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
packet = parse_onionpacket(cmd, onion, tal_bytelen(onion), &failcode);
|
||||
failcode = parse_onionpacket(onion, tal_bytelen(onion), &packet);
|
||||
|
||||
if (!packet)
|
||||
if (failcode != 0)
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Could not parse the onion. Parsing failed "
|
||||
"with failcode=%d",
|
||||
@@ -1032,7 +1032,7 @@ static struct command_result *json_sendonion(struct command *cmd,
|
||||
wallet_local_htlc_out_delete(ld->wallet, channel, payment_hash);
|
||||
}
|
||||
|
||||
failcode = send_onion(cmd->ld, packet, first_hop, payment_hash, channel,
|
||||
failcode = send_onion(cmd->ld, &packet, first_hop, payment_hash, channel,
|
||||
&hout);
|
||||
|
||||
payment = tal(hout, struct wallet_payment);
|
||||
|
||||
@@ -894,7 +894,7 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
|
||||
{
|
||||
struct htlc_in *hin;
|
||||
struct route_step *rs;
|
||||
struct onionpacket *op;
|
||||
struct onionpacket op;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
struct htlc_accepted_hook_payload *hook_payload;
|
||||
|
||||
@@ -947,10 +947,10 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
|
||||
|
||||
/* channeld calls both parse_onionpacket and process_onionpacket,
|
||||
* so they should succeed.. */
|
||||
op = parse_onionpacket(tmpctx, hin->onion_routing_packet,
|
||||
sizeof(hin->onion_routing_packet),
|
||||
failcode);
|
||||
if (!op) {
|
||||
*failcode = parse_onionpacket(hin->onion_routing_packet,
|
||||
sizeof(hin->onion_routing_packet),
|
||||
&op);
|
||||
if (*failcode != 0) {
|
||||
channel_internal_error(channel,
|
||||
"bad onion in got_revoke: %s",
|
||||
tal_hexstr(channel, hin->onion_routing_packet,
|
||||
@@ -958,7 +958,7 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
|
||||
return false;
|
||||
}
|
||||
|
||||
rs = process_onionpacket(tmpctx, op, hin->shared_secret->data,
|
||||
rs = process_onionpacket(tmpctx, &op, hin->shared_secret->data,
|
||||
hin->payment_hash.u.u8,
|
||||
sizeof(hin->payment_hash));
|
||||
if (!rs) {
|
||||
|
||||
Reference in New Issue
Block a user