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

Function do_inject

plugins/xpay/xpay.c:1455–1498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1453}
1454
1455static struct command_result *do_inject(struct command *aux_cmd,
1456 struct attempt *attempt)
1457{
1458 struct out_req *req;
1459 const u8 *onion;
1460 struct xpay *xpay = xpay_of(attempt->payment->plugin);
1461 /* In case a block comes in, we give CLTVs an extra 1. */
1462 u32 effective_bheight = xpay->blockheight + 1;
1463
1464 onion = create_onion(tmpctx, attempt, effective_bheight);
1465 /* FIXME: Handle this better! */
1466 if (!onion) {
1467 payment_give_up(aux_cmd, attempt->payment, PAY_UNSPECIFIED_ERROR,
1468 "Could not create payment onion: path too long!");
1469 return command_still_pending(aux_cmd);
1470 }
1471
1472 outgoing_notify_start(attempt);
1473 attempt->start_time = time_mono();
1474
1475 req = jsonrpc_request_start(aux_cmd,
1476 "injectpaymentonion",
1477 injectpaymentonion_succeeded,
1478 injectpaymentonion_failed,
1479 attempt);
1480 json_add_hex_talarr(req->js, "onion", onion);
1481 json_add_sha256(req->js, "payment_hash", &attempt->payment->payment_hash);
1482 /* If no route, its the same as delivery (self-pay) */
1483 json_add_amount_msat(req->js, "amount_msat", inject_amount(attempt));
1484 json_add_u32(req->js, "cltv_expiry", initial_cltv_delta(attempt) + effective_bheight);
1485 json_add_u64(req->js, "partid", attempt->partid);
1486 json_add_u64(req->js, "groupid", attempt->payment->group_id);
1487 /* Use invstring for payments, destination directly for keysend */
1488 if (attempt->payment->invstring)
1489 json_add_string(req->js, "invstring", attempt->payment->invstring);
1490 else
1491 json_add_pubkey(req->js, "destination", &attempt->payment->destination);
1492 json_add_amount_msat(req->js, "destination_msat", attempt_deliver(attempt));
1493 if (attempt->payment->localinvreqid)
1494 json_add_sha256(req->js, "localinvreqid", attempt->payment->localinvreqid);
1495 if (attempt->payment->label)
1496 json_add_escaped_string(req->js, "label", attempt->payment->label);
1497 return send_payment_req(aux_cmd, attempt->payment, req);
1498}
1499
1500static struct command_result *reserve_done(struct command *aux_cmd,
1501 const char *method,

Callers 2

reserve_doneFunction · 0.85
getroutes_forFunction · 0.85

Calls 15

xpay_ofFunction · 0.85
payment_give_upFunction · 0.85
outgoing_notify_startFunction · 0.85
time_monoFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_add_sha256Function · 0.85
json_add_amount_msatFunction · 0.85
inject_amountFunction · 0.85
json_add_u32Function · 0.85
json_add_u64Function · 0.85
json_add_pubkeyFunction · 0.85
attempt_deliverFunction · 0.85

Tested by

no test coverage detected