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

Function new_payment

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

2562 * On bad settings, return NULL and sets *err.
2563 */
2564static struct payment *new_payment(const tal_t *ctx,
2565 struct command *cmd,
2566 u32 retryfor,
2567 u32 maxdelay,
2568 const char **layers,
2569 const char *invstring TAKES,
2570 const struct pubkey *destination,
2571 const struct sha256 *payment_hash,
2572 struct amount_msat mpp_amount,
2573 /* If set, we're not paying mpp_amount */
2574 const struct amount_msat *partial,
2575 /* If unset, based on amount we're paying */
2576 const struct amount_msat *maxfee,
2577 const struct secret *payment_secret,
2578 const u8 *payment_metadata,
2579 u32 final_cltv,
2580 const struct json_escape *label,
2581 const struct sha256 *localinvreqid,
2582 bool as_pay,
2583 bool includefees,
2584 const char **err)
2585{
2586 struct xpay *xpay = xpay_of(cmd->plugin);
2587 struct payment *payment = tal(ctx, struct payment);
2588
2589 payment->plugin = cmd->plugin;
2590 payment->deadline = timemono_add(time_mono(), time_from_sec(retryfor));
2591 payment->start_blockheight = xpay->blockheight;
2592 payment->cmd = cmd;
2593 payment->invstring = tal_strdup_or_null(payment, invstring);
2594 payment->localinvreqid = tal_dup_or_null(payment, struct sha256, localinvreqid);
2595 if (label)
2596 payment->label = json_escape_dup(payment, label);
2597 else
2598 payment->label = NULL;
2599 if (layers)
2600 payment->layers = tal_dup_talarr(payment, const char *, layers);
2601 else
2602 payment->layers = NULL;
2603 payment->destination = *destination;
2604 payment->payment_hash = *payment_hash;
2605 payment->mpp_amount = mpp_amount;
2606 payment->includefees = includefees;
2607 if (partial) {
2608 payment->amount = *partial;
2609 if (amount_msat_greater(*partial, payment->mpp_amount)) {
2610 *err = tal_fmt(ctx, "partial_msat must be less or equal to total amount %s",
2611 fmt_amount_msat(tmpctx, payment->mpp_amount));
2612 return tal_free(payment);
2613 }
2614 if (amount_msat_is_zero(*partial)) {
2615 *err = tal_fmt(ctx, "partial_msat must be non-zero");
2616 return tal_free(payment);
2617 }
2618 } else {
2619 payment->amount = payment->mpp_amount;
2620 }
2621 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