|
@ -373,23 +373,22 @@ static struct routing_failure* |
|
|
remote_routing_failure(const tal_t *ctx, |
|
|
remote_routing_failure(const tal_t *ctx, |
|
|
struct lightningd *ld, |
|
|
struct lightningd *ld, |
|
|
const struct wallet_payment *payment, |
|
|
const struct wallet_payment *payment, |
|
|
const struct onionreply *failure, |
|
|
const u8 *failuremsg, |
|
|
|
|
|
int origin_index, |
|
|
struct log *log, |
|
|
struct log *log, |
|
|
int *pay_errcode) |
|
|
int *pay_errcode) |
|
|
{ |
|
|
{ |
|
|
enum onion_type failcode = fromwire_peektype(failure->msg); |
|
|
enum onion_type failcode = fromwire_peektype(failuremsg); |
|
|
struct routing_failure *routing_failure; |
|
|
struct routing_failure *routing_failure; |
|
|
const struct node_id *route_nodes; |
|
|
const struct node_id *route_nodes; |
|
|
const struct node_id *erring_node; |
|
|
const struct node_id *erring_node; |
|
|
const struct short_channel_id *route_channels; |
|
|
const struct short_channel_id *route_channels; |
|
|
const struct short_channel_id *erring_channel; |
|
|
const struct short_channel_id *erring_channel; |
|
|
int origin_index; |
|
|
|
|
|
int dir; |
|
|
int dir; |
|
|
|
|
|
|
|
|
routing_failure = tal(ctx, struct routing_failure); |
|
|
routing_failure = tal(ctx, struct routing_failure); |
|
|
route_nodes = payment->route_nodes; |
|
|
route_nodes = payment->route_nodes; |
|
|
route_channels = payment->route_channels; |
|
|
route_channels = payment->route_channels; |
|
|
origin_index = failure->origin_index; |
|
|
|
|
|
|
|
|
|
|
|
assert(route_nodes == NULL || origin_index < tal_count(route_nodes)); |
|
|
assert(route_nodes == NULL || origin_index < tal_count(route_nodes)); |
|
|
|
|
|
|
|
@ -448,7 +447,7 @@ remote_routing_failure(const tal_t *ctx, |
|
|
* following node. */ |
|
|
* following node. */ |
|
|
if (failcode & BADONION) { |
|
|
if (failcode & BADONION) { |
|
|
log_debug(log, "failcode %u from onionreply %s", |
|
|
log_debug(log, "failcode %u from onionreply %s", |
|
|
failcode, tal_hex(tmpctx, failure->msg)); |
|
|
failcode, tal_hex(tmpctx, failuremsg)); |
|
|
erring_node = &route_nodes[origin_index + 1]; |
|
|
erring_node = &route_nodes[origin_index + 1]; |
|
|
} else |
|
|
} else |
|
|
erring_node = &route_nodes[origin_index]; |
|
|
erring_node = &route_nodes[origin_index]; |
|
@ -460,14 +459,14 @@ remote_routing_failure(const tal_t *ctx, |
|
|
erring_node, |
|
|
erring_node, |
|
|
erring_channel, |
|
|
erring_channel, |
|
|
dir, |
|
|
dir, |
|
|
failure->msg); |
|
|
failuremsg); |
|
|
subd_send_msg(ld->gossip, take(gossip_msg)); |
|
|
subd_send_msg(ld->gossip, take(gossip_msg)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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->msg = tal_dup_arr(routing_failure, u8, failure->msg, |
|
|
routing_failure->msg = tal_dup_arr(routing_failure, u8, failuremsg, |
|
|
tal_count(failure->msg), 0); |
|
|
tal_count(failuremsg), 0); |
|
|
|
|
|
|
|
|
if (erring_node != NULL) |
|
|
if (erring_node != NULL) |
|
|
routing_failure->erring_node = |
|
|
routing_failure->erring_node = |
|
@ -557,11 +556,12 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, |
|
|
failmsg = "reply from remote"; |
|
|
failmsg = "reply from remote"; |
|
|
/* Try to parse reply. */ |
|
|
/* Try to parse reply. */ |
|
|
struct secret *path_secrets = payment->path_secrets; |
|
|
struct secret *path_secrets = payment->path_secrets; |
|
|
struct onionreply *reply; |
|
|
u8 *reply; |
|
|
|
|
|
int origin_index; |
|
|
|
|
|
|
|
|
reply = unwrap_onionreply(tmpctx, path_secrets, |
|
|
reply = unwrap_onionreply(tmpctx, path_secrets, |
|
|
tal_count(path_secrets), |
|
|
tal_count(path_secrets), |
|
|
hout->failuremsg); |
|
|
hout->failuremsg, &origin_index); |
|
|
if (!reply) { |
|
|
if (!reply) { |
|
|
log_info(hout->key.channel->log, |
|
|
log_info(hout->key.channel->log, |
|
|
"htlc %"PRIu64" failed with bad reply (%s)", |
|
|
"htlc %"PRIu64" failed with bad reply (%s)", |
|
@ -571,18 +571,19 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, |
|
|
fail = NULL; |
|
|
fail = NULL; |
|
|
pay_errcode = PAY_UNPARSEABLE_ONION; |
|
|
pay_errcode = PAY_UNPARSEABLE_ONION; |
|
|
} else { |
|
|
} else { |
|
|
enum onion_type failcode = fromwire_peektype(reply->msg); |
|
|
enum onion_type failcode = fromwire_peektype(reply); |
|
|
log_info(hout->key.channel->log, |
|
|
log_info(hout->key.channel->log, |
|
|
"htlc %"PRIu64" " |
|
|
"htlc %"PRIu64" " |
|
|
"failed from %ith node " |
|
|
"failed from %ith node " |
|
|
"with code 0x%04x (%s)", |
|
|
"with code 0x%04x (%s)", |
|
|
hout->key.id, |
|
|
hout->key.id, |
|
|
reply->origin_index, |
|
|
origin_index, |
|
|
failcode, onion_type_name(failcode)); |
|
|
failcode, onion_type_name(failcode)); |
|
|
log_debug(hout->key.channel->log, "failmsg: %s", |
|
|
log_debug(hout->key.channel->log, "failmsg: %s", |
|
|
tal_hex(tmpctx, reply->msg)); |
|
|
tal_hex(tmpctx, reply)); |
|
|
fail = remote_routing_failure(tmpctx, ld, |
|
|
fail = remote_routing_failure(tmpctx, ld, |
|
|
payment, reply, |
|
|
payment, reply, |
|
|
|
|
|
origin_index, |
|
|
hout->key.channel->log, |
|
|
hout->key.channel->log, |
|
|
&pay_errcode); |
|
|
&pay_errcode); |
|
|
} |
|
|
} |
|
|