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

Function self_payment

lightningd/pay.c:1469–1561  ·  view source on GitHub ↗

We're paying ourselves! */

Source from the content-addressed store, hash-verified

1467
1468/* We're paying ourselves! */
1469static struct command_result *self_payment(struct lightningd *ld,
1470 struct command *cmd,
1471 const struct sha256 *rhash,
1472 u64 partid,
1473 u64 groupid,
1474 struct amount_msat msat,
1475 const char *label TAKES,
1476 const char *invstring TAKES,
1477 const char *description TAKES,
1478 const struct sha256 *local_invreq_id,
1479 const struct secret *payment_secret,
1480 const u8 *payment_metadata)
1481{
1482 struct wallet_payment *payment;
1483 const struct invoice_details *inv;
1484 u64 inv_dbid;
1485 const char *err;
1486
1487 payment = wallet_add_payment(tmpctx,
1488 ld->wallet,
1489 clock_time().ts.tv_sec,
1490 NULL,
1491 rhash,
1492 partid,
1493 groupid,
1494 PAYMENT_PENDING,
1495 &ld->our_nodeid,
1496 msat,
1497 msat,
1498 msat,
1499 NULL,
1500 NULL,
1501 NULL,
1502 NULL,
1503 invstring,
1504 label,
1505 description,
1506 NULL,
1507 local_invreq_id);
1508
1509 /* Now, resolve the invoice */
1510 inv = invoice_check_payment(tmpctx, ld, rhash, msat, NULL, payment_secret, &err);
1511 if (!inv) {
1512 struct routing_failure *fail;
1513 wallet_payment_set_status(ld->wallet, rhash, partid, groupid,
1514 PAYMENT_FAILED, NULL);
1515
1516 /* tell_waiters_failed expects one of these! */
1517 fail = tal(payment, struct routing_failure);
1518 fail->failcode = WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS;
1519 fail->erring_node = &ld->our_nodeid;
1520 fail->erring_index = 0;
1521 fail->erring_channel = NULL;
1522 fail->msg = NULL;
1523
1524 /* Only some of these fields make sense for self payments */
1525 wallet_payment_set_failinfo(ld->wallet,
1526 rhash,

Callers 1

json_sendpayFunction · 0.85

Calls 14

wallet_add_paymentFunction · 0.85
clock_timeFunction · 0.85
tell_waiters_failedFunction · 0.85
sendpay_failFunction · 0.85
log_infoClass · 0.85
sendpay_successFunction · 0.85
invoice_check_paymentFunction · 0.70
notify_invoice_paymentFunction · 0.70
payment_succeededFunction · 0.70
invoices_find_by_rhashFunction · 0.50

Tested by

no test coverage detected