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

Function new_payment

plugins/xpay/xpay.c:2503–2597  ·  view source on GitHub ↗

Does NOT set: * ->maxparts * ->use_shadow * * On bad settings, return NULL and sets *err. */

Source from the content-addressed store, hash-verified

2501 * On bad settings, return NULL and sets *err.
2502 */
2503static struct payment *new_payment(const tal_t *ctx,
2504 struct command *cmd,
2505 u32 retryfor,
2506 u32 maxdelay,
2507 const char **layers,
2508 const char *invstring TAKES,
2509 const struct pubkey *destination,
2510 const struct sha256 *payment_hash,
2511 struct amount_msat mpp_amount,
2512 /* If set, we're not paying mpp_amount */
2513 const struct amount_msat *partial,
2514 /* If unset, based on amount we're paying */
2515 const struct amount_msat *maxfee,
2516 const struct secret *payment_secret,
2517 const u8 *payment_metadata,
2518 u32 final_cltv,
2519 const struct json_escape *label,
2520 const struct sha256 *localinvreqid,
2521 bool as_pay,
2522 bool includefees,
2523 const char **err)
2524{
2525 struct xpay *xpay = xpay_of(cmd->plugin);
2526 struct payment *payment = tal(ctx, struct payment);
2527
2528 payment->plugin = cmd->plugin;
2529 payment->deadline = timemono_add(time_mono(), time_from_sec(retryfor));
2530 payment->start_blockheight = xpay->blockheight;
2531 payment->cmd = cmd;
2532 payment->invstring = tal_strdup_or_null(payment, invstring);
2533 payment->localinvreqid = tal_dup_or_null(payment, struct sha256, localinvreqid);
2534 if (label)
2535 payment->label = json_escape_dup(payment, label);
2536 else
2537 payment->label = NULL;
2538 if (layers)
2539 payment->layers = tal_dup_talarr(payment, const char *, layers);
2540 else
2541 payment->layers = NULL;
2542 payment->destination = *destination;
2543 payment->payment_hash = *payment_hash;
2544 payment->mpp_amount = mpp_amount;
2545 payment->includefees = includefees;
2546 if (partial) {
2547 payment->amount = *partial;
2548 if (amount_msat_greater(*partial, payment->mpp_amount)) {
2549 *err = tal_fmt(ctx, "partial_msat must be less or equal to total amount %s",
2550 fmt_amount_msat(tmpctx, payment->mpp_amount));
2551 return tal_free(payment);
2552 }
2553 if (amount_msat_is_zero(*partial)) {
2554 *err = tal_fmt(ctx, "partial_msat must be non-zero");
2555 return tal_free(payment);
2556 }
2557 } else {
2558 payment->amount = payment->mpp_amount;
2559 }
2560 if (maxfee) {

Callers 2

xpay_coreFunction · 0.85
json_xkeysendFunction · 0.85

Calls 14

xpay_ofFunction · 0.85
timemono_addFunction · 0.85
time_monoFunction · 0.85
time_from_secFunction · 0.85
tal_strdup_or_nullFunction · 0.85
json_escape_dupFunction · 0.85
amount_msat_greaterFunction · 0.85
tal_freeFunction · 0.85
amount_msat_is_zeroFunction · 0.85
amount_msat_feeFunction · 0.85
amount_msat_maxFunction · 0.85
list_head_initFunction · 0.85

Tested by

no test coverage detected