mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
pay: Make erring_channel
optional in struct routing_failure
Same rationale as the previous commit: we may not have the channels in the path so we don't try to infer the failing channel from the error.
This commit is contained in:
parent
88961aa4b0
commit
7e41d6c9c4
@ -25,7 +25,7 @@ struct routing_failure {
|
|||||||
unsigned int erring_index;
|
unsigned int erring_index;
|
||||||
enum onion_type failcode;
|
enum onion_type failcode;
|
||||||
const struct node_id *erring_node;
|
const struct node_id *erring_node;
|
||||||
struct short_channel_id erring_channel;
|
const struct short_channel_id *erring_channel;
|
||||||
int channel_dir;
|
int channel_dir;
|
||||||
/* If remote sent us a message, this is it. */
|
/* If remote sent us a message, this is it. */
|
||||||
const u8 *msg;
|
const u8 *msg;
|
||||||
@ -139,11 +139,15 @@ json_add_routefail_info(struct json_stream *js,
|
|||||||
/* FIXME: Better way to detect this? */
|
/* FIXME: Better way to detect this? */
|
||||||
if (!strstarts(failcodename, "INVALID "))
|
if (!strstarts(failcodename, "INVALID "))
|
||||||
json_add_string(js, "failcodename", failcodename);
|
json_add_string(js, "failcodename", failcodename);
|
||||||
json_add_short_channel_id(js, "erring_channel", erring_channel);
|
|
||||||
json_add_num(js, "erring_direction", channel_dir);
|
|
||||||
|
|
||||||
if (erring_node != NULL)
|
if (erring_node != NULL)
|
||||||
json_add_node_id(js, "erring_node", erring_node);
|
json_add_node_id(js, "erring_node", erring_node);
|
||||||
|
|
||||||
|
if (erring_channel != NULL) {
|
||||||
|
json_add_short_channel_id(js, "erring_channel", erring_channel);
|
||||||
|
json_add_num(js, "erring_direction", channel_dir);
|
||||||
|
}
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
json_add_hex_talarr(js, "raw_message", msg);
|
json_add_hex_talarr(js, "raw_message", msg);
|
||||||
}
|
}
|
||||||
@ -164,7 +168,7 @@ void json_sendpay_fail_fields(struct json_stream *js,
|
|||||||
fail->erring_index,
|
fail->erring_index,
|
||||||
fail->failcode,
|
fail->failcode,
|
||||||
fail->erring_node,
|
fail->erring_node,
|
||||||
&fail->erring_channel,
|
fail->erring_channel,
|
||||||
fail->channel_dir,
|
fail->channel_dir,
|
||||||
fail->msg);
|
fail->msg);
|
||||||
}
|
}
|
||||||
@ -290,7 +294,8 @@ immediate_routing_failure(const tal_t *ctx,
|
|||||||
routing_failure->failcode = failcode;
|
routing_failure->failcode = failcode;
|
||||||
routing_failure->erring_node =
|
routing_failure->erring_node =
|
||||||
tal_dup(routing_failure, struct node_id, &ld->id);
|
tal_dup(routing_failure, struct node_id, &ld->id);
|
||||||
routing_failure->erring_channel = *channel0;
|
routing_failure->erring_channel =
|
||||||
|
tal_dup(routing_failure, struct short_channel_id, channel0);
|
||||||
routing_failure->channel_dir = node_id_idx(&ld->id, dstid);
|
routing_failure->channel_dir = node_id_idx(&ld->id, dstid);
|
||||||
routing_failure->msg = NULL;
|
routing_failure->msg = NULL;
|
||||||
|
|
||||||
@ -314,9 +319,17 @@ local_routing_failure(const tal_t *ctx,
|
|||||||
routing_failure->failcode = hout->failcode;
|
routing_failure->failcode = hout->failcode;
|
||||||
routing_failure->erring_node =
|
routing_failure->erring_node =
|
||||||
tal_dup(routing_failure, struct node_id, &ld->id);
|
tal_dup(routing_failure, struct node_id, &ld->id);
|
||||||
routing_failure->erring_channel = payment->route_channels[0];
|
|
||||||
routing_failure->channel_dir = node_id_idx(&ld->id,
|
if (payment->route_nodes != NULL && payment->route_channels != NULL) {
|
||||||
&payment->route_nodes[0]);
|
routing_failure->erring_channel =
|
||||||
|
tal_dup(routing_failure, struct short_channel_id,
|
||||||
|
&payment->route_channels[0]);
|
||||||
|
routing_failure->channel_dir =
|
||||||
|
node_id_idx(&ld->id, &payment->route_nodes[0]);
|
||||||
|
} else {
|
||||||
|
routing_failure->erring_channel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
routing_failure->msg = NULL;
|
routing_failure->msg = NULL;
|
||||||
|
|
||||||
log_debug(hout->key.channel->log, "local_routing_failure: %u (%s)",
|
log_debug(hout->key.channel->log, "local_routing_failure: %u (%s)",
|
||||||
@ -405,9 +418,6 @@ remote_routing_failure(const tal_t *ctx,
|
|||||||
|
|
||||||
routing_failure->erring_index = (unsigned int) (origin_index + 1);
|
routing_failure->erring_index = (unsigned int) (origin_index + 1);
|
||||||
routing_failure->failcode = failcode;
|
routing_failure->failcode = failcode;
|
||||||
routing_failure->erring_channel = *erring_channel;
|
|
||||||
routing_failure->erring_node = tal_dup(routing_failure, struct node_id, erring_node);
|
|
||||||
routing_failure->channel_dir = dir;
|
|
||||||
routing_failure->msg = tal_dup_arr(routing_failure, u8, failure->msg,
|
routing_failure->msg = tal_dup_arr(routing_failure, u8, failure->msg,
|
||||||
tal_count(failure->msg), 0);
|
tal_count(failure->msg), 0);
|
||||||
|
|
||||||
@ -417,6 +427,15 @@ remote_routing_failure(const tal_t *ctx,
|
|||||||
else
|
else
|
||||||
routing_failure->erring_node = NULL;
|
routing_failure->erring_node = NULL;
|
||||||
|
|
||||||
|
if (erring_channel != NULL) {
|
||||||
|
routing_failure->erring_channel = tal_dup(
|
||||||
|
routing_failure, struct short_channel_id, erring_channel);
|
||||||
|
routing_failure->channel_dir = dir;
|
||||||
|
} else {
|
||||||
|
routing_failure->erring_channel = NULL;
|
||||||
|
routing_failure->channel_dir = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return routing_failure;
|
return routing_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +548,7 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
|
|||||||
fail ? fail->erring_index : -1,
|
fail ? fail->erring_index : -1,
|
||||||
fail ? fail->failcode : 0,
|
fail ? fail->failcode : 0,
|
||||||
fail ? fail->erring_node : NULL,
|
fail ? fail->erring_node : NULL,
|
||||||
fail ? &fail->erring_channel : NULL,
|
fail ? fail->erring_channel : NULL,
|
||||||
NULL,
|
NULL,
|
||||||
failmsg,
|
failmsg,
|
||||||
fail ? fail->channel_dir : 0);
|
fail ? fail->channel_dir : 0);
|
||||||
@ -605,7 +624,8 @@ static struct command_result *wait_payment(struct lightningd *ld,
|
|||||||
fail->failcode = failcode;
|
fail->failcode = failcode;
|
||||||
fail->erring_node =
|
fail->erring_node =
|
||||||
tal_dup(fail, struct node_id, failnode);
|
tal_dup(fail, struct node_id, failnode);
|
||||||
fail->erring_channel = *failchannel;
|
fail->erring_channel =
|
||||||
|
tal_dup(fail, struct short_channel_id, failchannel);
|
||||||
fail->channel_dir = faildirection;
|
fail->channel_dir = faildirection;
|
||||||
/* FIXME: We don't store this! */
|
/* FIXME: We don't store this! */
|
||||||
fail->msg = NULL;
|
fail->msg = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user