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

Function payment_result_infer

plugins/libplugin-pay.c:1037–1064  ·  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

1035/* Try to infer the erring_node, erring_channel and erring_direction from what
1036 * we know, but don't override the values that are returned by `waitsendpay`. */
1037static void payment_result_infer(struct route_hop *route,
1038 struct payment_result *r)
1039{
1040 int i, len;
1041 assert(r != NULL);
1042
1043 if (r->code == 0 || r->erring_index == NULL || route == NULL)
1044 return;
1045
1046 len = tal_count(route);
1047 i = *r->erring_index;
1048 assert(i <= len);
1049
1050 if (r->erring_node == NULL)
1051 r->erring_node = &route[i-1].node_id;
1052
1053 /* The above assert was enough for the erring_node, but might be off
1054 * by one on channel and direction, in case the destination failed on
1055 * us. */
1056 if (i == len)
1057 return;
1058
1059 if (r->erring_channel == NULL)
1060 r->erring_channel = &route[i].scid;
1061
1062 if (r->erring_direction == NULL)
1063 r->erring_direction = &route[i].direction;
1064}
1065
1066/* If a node takes too much fee or cltv, the next one reports it. We don't
1067 * know who to believe, but log it */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected