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

Function keysend_init

plugins/keysend.c:43–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41REGISTER_PAYMENT_MODIFIER_HEADER(keysend, struct keysend_data);
42
43static struct keysend_data *keysend_init(struct payment *p)
44{
45 struct keysend_data *d;
46 struct sha256 payment_hash;
47 if (p->parent == NULL) {
48 /* If we are the root payment we generate a random preimage
49 * and populate the preimage field in the keysend_data and the
50 * payment_hash in the payment. */
51 d = tal(p, struct keysend_data);
52 randbytes(&d->preimage, sizeof(d->preimage));
53 ccan_sha256(&payment_hash, &d->preimage, sizeof(d->preimage));
54 p->payment_hash = tal_dup(p, struct sha256, &payment_hash);
55 d->extra_tlvs = NULL;
56 return d;
57 } else {
58 /* If we are a child payment (retry or split) we copy the
59 * parent's information, since the payment_hash needs to match
60 * in order to be collated at the recipient. */
61 return payment_mod_keysend_get_data(p->parent);
62 }
63}
64
65static struct command_result *keysend_cb(struct keysend_data *d, struct payment *p) {
66 struct createonion_hop *last_payload;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected