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

Function send_payment_core

lightningd/pay.c:1073–1180  ·  view source on GitHub ↗

destination/route_channels/route_nodes are NULL (and path_secrets may be NULL) * if we're sending a raw onion. */

Source from the content-addressed store, hash-verified

1071/* destination/route_channels/route_nodes are NULL (and path_secrets may be NULL)
1072 * if we're sending a raw onion. */
1073static struct command_result *
1074send_payment_core(struct lightningd *ld,
1075 struct command *cmd,
1076 const struct sha256 *rhash,
1077 u64 partid,
1078 u64 group,
1079 const struct route_hop *first_hop,
1080 struct amount_msat msat,
1081 struct amount_msat total_msat,
1082 const char *label TAKES,
1083 const char *invstring TAKES,
1084 const char *description TAKES,
1085 const struct onionpacket *packet,
1086 const struct node_id *destination,
1087 struct node_id *route_nodes TAKES,
1088 struct short_channel_id *route_channels TAKES,
1089 struct secret *path_secrets,
1090 const struct sha256 *local_invreq_id)
1091{
1092 struct channel *channel;
1093 const u8 *failmsg;
1094 struct htlc_out *hout;
1095 struct routing_failure *fail;
1096 struct command_result *ret;
1097 const struct wallet_payment *payment;
1098
1099 /* Reconcile this with previous attempts */
1100 ret = check_progress(ld, cmd, rhash, msat, total_msat, partid, group,
1101 destination, &payment);
1102 if (ret)
1103 return ret;
1104
1105 /* Previous payment success is defined to be idempotent */
1106 if (payment)
1107 return sendpay_success(cmd, payment, NULL);
1108
1109 ret = check_invoice_request_usage(cmd, local_invreq_id);
1110 if (ret)
1111 return ret;
1112
1113 channel = find_channel_for_htlc_add(ld, cmd, &first_hop->node_id,
1114 first_hop->scid, &msat);
1115 if (!channel) {
1116 struct json_stream *data
1117 = json_stream_fail(cmd, PAY_TRY_OTHER_ROUTE,
1118 "No connection to first "
1119 "peer found");
1120
1121 json_add_routefail_info(data, 0, WIRE_UNKNOWN_NEXT_PEER,
1122 &ld->our_nodeid, NULL,
1123 node_id_idx(&ld->our_nodeid,
1124 &first_hop->node_id),
1125 NULL);
1126 json_object_end(data);
1127 return command_failed(cmd, data);
1128 }
1129
1130 if (route_channels)

Callers 2

send_paymentFunction · 0.85
json_sendonionFunction · 0.85

Calls 15

check_progressFunction · 0.85
sendpay_successFunction · 0.85
json_add_routefail_infoFunction · 0.85
node_id_idxFunction · 0.85
json_object_endFunction · 0.85
log_infoClass · 0.85
send_onionFunction · 0.85
fromwire_peektypeFunction · 0.85
sendpay_failFunction · 0.85

Tested by

no test coverage detected