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

Function selfpay

plugins/pay.c:477–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477static struct command_result *selfpay(struct command *cmd, struct payment *p)
478{
479 struct out_req *req;
480
481 /* This "struct payment" simply gets freed once command is done. */
482 tal_steal(cmd, p);
483
484 req = jsonrpc_request_start(cmd, "sendpay",
485 selfpay_success,
486 forward_error, p);
487 /* Empty route means "to-self" */
488 json_array_start(req->js, "route");
489 json_array_end(req->js);
490 json_add_sha256(req->js, "payment_hash", p->payment_hash);
491 if (p->label)
492 json_add_string(req->js, "label", p->label);
493 /* FIXME: This will fail if we try to do a partial amount to
494 * ourselves! */
495 json_add_amount_msat(req->js, "amount_msat", p->our_amount);
496 json_add_string(req->js, "bolt11", p->invstring);
497 if (p->payment_secret)
498 json_add_secret(req->js, "payment_secret", p->payment_secret);
499 json_add_u64(req->js, "groupid", p->groupid);
500 if (p->payment_metadata)
501 json_add_hex_talarr(req->js, "payment_metadata", p->payment_metadata);
502 if (p->description)
503 json_add_string(req->js, "description", p->description);
504 return send_outreq(req);
505}
506
507/* We are interested in any prior attempts to pay this payment_hash /
508 * invoice so we can set the `groupid` correctly and ensure we don't

Callers 1

Calls 9

json_array_startFunction · 0.85
json_array_endFunction · 0.85
json_add_sha256Function · 0.85
json_add_amount_msatFunction · 0.85
json_add_secretFunction · 0.85
json_add_u64Function · 0.85
json_add_hex_talarrFunction · 0.85
send_outreqFunction · 0.70
json_add_stringFunction · 0.50

Tested by

no test coverage detected