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

Function send_payment_core

lightningd/pay.c:859–1129  ·  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

857/* destination/route_channels/route_nodes are NULL (and path_secrets may be NULL)
858 * if we're sending a raw onion. */
859static struct command_result *
860send_payment_core(struct lightningd *ld,
861 struct command *cmd,
862 const struct sha256 *rhash,
863 u64 partid,
864 u64 group,
865 const struct route_hop *first_hop,
866 struct amount_msat msat,
867 struct amount_msat total_msat,
868 const char *label TAKES,
869 const char *invstring TAKES,
870 const char *description TAKES,
871 const struct onionpacket *packet,
872 const struct node_id *destination,
873 struct node_id *route_nodes TAKES,
874 struct short_channel_id *route_channels TAKES,
875 struct secret *path_secrets,
876 const struct sha256 *local_offer_id)
877{
878 const struct wallet_payment **payments, *old_payment = NULL;
879 struct channel *channel;
880 const u8 *failmsg;
881 struct htlc_out *hout;
882 struct routing_failure *fail;
883 struct amount_msat msat_already_pending = AMOUNT_MSAT(0);
884 bool have_complete = false;
885
886 /* Now, do we already have one or more payments? */
887 payments = wallet_payment_list(tmpctx, ld->wallet, rhash);
888 for (size_t i = 0; i < tal_count(payments); i++) {
889 log_debug(ld->log, "Payment %zu/%zu: %s %s",
890 i, tal_count(payments),
891 type_to_string(tmpctx, struct amount_msat,
892 &payments[i]->msatoshi),
893 payments[i]->status == PAYMENT_COMPLETE ? "COMPLETE"
894 : payments[i]->status == PAYMENT_PENDING ? "PENDING"
895 : "FAILED");
896
897 switch (payments[i]->status) {
898 case PAYMENT_COMPLETE:
899 have_complete = true;
900 if (payments[i]->partid != partid)
901 continue;
902
903 /* Must match successful payment parameters. */
904 if (!amount_msat_eq(payments[i]->msatoshi, msat)) {
905 return command_fail(cmd, PAY_RHASH_ALREADY_USED,
906 "Already succeeded "
907 "with amount %s (not %s)",
908 type_to_string(tmpctx,
909 struct amount_msat,
910 &payments[i]->msatoshi),
911 type_to_string(tmpctx,
912 struct amount_msat, &msat));
913 }
914 if (payments[i]->destination && destination
915 && !node_id_eq(payments[i]->destination,
916 destination)) {

Callers 2

send_paymentFunction · 0.85
json_sendonionFunction · 0.85

Calls 15

wallet_payment_listFunction · 0.85
node_id_eqFunction · 0.85
sendpay_successFunction · 0.85
json_sendpay_in_progressFunction · 0.85
amount_msat_addFunction · 0.85
amount_msat_greater_eqFunction · 0.85
check_offer_usageFunction · 0.85
json_add_routefail_infoFunction · 0.85
node_id_idxFunction · 0.85
send_onionFunction · 0.85

Tested by

no test coverage detected