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

Function payment_result_infer

plugins/libplugin-pay.c:1188–1218  ·  view source on GitHub ↗

Try to infer the erring_node, erring_channel and erring_direction from what * we know, but don't override the values that are returned by `waitsendpay`. */

Source from the content-addressed store, hash-verified

1186/* Try to infer the erring_node, erring_channel and erring_direction from what
1187 * we know, but don't override the values that are returned by `waitsendpay`. */
1188static void payment_result_infer(struct route_hop *route,
1189 struct payment_result *r)
1190{
1191 int i, len;
1192 assert(r != NULL);
1193
1194 if (r->code == 0 || r->erring_index == NULL || route == NULL)
1195 return;
1196
1197 len = tal_count(route);
1198 i = *r->erring_index;
1199 /* This can actually be greater than the route length? Perhaps
1200 * multi-hop routehints? Ignore. */
1201 if (i > len)
1202 return;
1203
1204 if (r->erring_node == NULL)
1205 r->erring_node = &route[i-1].node_id;
1206
1207 /* The above check was enough for the erring_node, but might be off
1208 * by one on channel and direction, in case the destination failed on
1209 * us. */
1210 if (i == len)
1211 return;
1212
1213 if (r->erring_channel == NULL)
1214 r->erring_channel = &route[i].scid;
1215
1216 if (r->erring_direction == NULL)
1217 r->erring_direction = &route[i].direction;
1218}
1219
1220/* If a node takes too much fee or cltv, the next one reports it. We don't
1221 * know who to believe, but log it */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected