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

Function new_payment

plugins/xpay/xpay.c:2418–2512  ·  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

2416 * On bad settings, return NULL and sets *err.
2417 */
2418static struct payment *new_payment(const tal_t *ctx,
2419 struct command *cmd,
2420 u32 retryfor,
2421 u32 maxdelay,
2422 const char **layers,
2423 const char *invstring TAKES,
2424 const struct pubkey *destination,
2425 const struct sha256 *payment_hash,
2426 struct amount_msat mpp_amount,
2427 /* If set, we're not paying mpp_amount */
2428 const struct amount_msat *partial,
2429 /* If unset, based on amount we're paying */
2430 const struct amount_msat *maxfee,
2431 const struct secret *payment_secret,
2432 const u8 *payment_metadata,
2433 u32 final_cltv,
2434 const struct json_escape *label,
2435 const struct sha256 *localinvreqid,
2436 bool as_pay,
2437 bool includefees,
2438 const char **err)
2439{
2440 struct xpay *xpay = xpay_of(cmd->plugin);
2441 struct payment *payment = tal(ctx, struct payment);
2442
2443 payment->plugin = cmd->plugin;
2444 payment->deadline = timemono_add(time_mono(), time_from_sec(retryfor));
2445 payment->start_blockheight = xpay->blockheight;
2446 payment->cmd = cmd;
2447 payment->invstring = tal_strdup_or_null(payment, invstring);
2448 payment->localinvreqid = tal_dup_or_null(payment, struct sha256, localinvreqid);
2449 if (label)
2450 payment->label = json_escape_dup(payment, label);
2451 else
2452 payment->label = NULL;
2453 if (layers)
2454 payment->layers = tal_dup_talarr(payment, const char *, layers);
2455 else
2456 payment->layers = NULL;
2457 payment->destination = *destination;
2458 payment->payment_hash = *payment_hash;
2459 payment->mpp_amount = mpp_amount;
2460 payment->includefees = includefees;
2461 if (partial) {
2462 payment->amount = *partial;
2463 if (amount_msat_greater(*partial, payment->mpp_amount)) {
2464 *err = tal_fmt(ctx, "partial_msat must be less or equal to total amount %s",
2465 fmt_amount_msat(tmpctx, payment->mpp_amount));
2466 return tal_free(payment);
2467 }
2468 if (amount_msat_is_zero(*partial)) {
2469 *err = tal_fmt(ctx, "partial_msat must be non-zero");
2470 return tal_free(payment);
2471 }
2472 } else {
2473 payment->amount = payment->mpp_amount;
2474 }
2475 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