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

Function self_payment

lightningd/pay.c:1472–1564  ·  view source on GitHub ↗

We're paying ourselves! */

Source from the content-addressed store, hash-verified

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