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

Function invoice_secret

lightningd/invoice.c:129–142  ·  view source on GitHub ↗

We derive invoice secret using 1-way function from payment_preimage * (just a different one from the payment_hash!) */

Source from the content-addressed store, hash-verified

127/* We derive invoice secret using 1-way function from payment_preimage
128 * (just a different one from the payment_hash!) */
129static void invoice_secret(const struct preimage *payment_preimage,
130 struct secret *payment_secret)
131{
132 struct preimage modified;
133 struct sha256 secret;
134
135 modified = *payment_preimage;
136 modified.r[0] ^= 1;
137
138 sha256(&secret, modified.r,
139 ARRAY_SIZE(modified.r) * sizeof(*modified.r));
140 BUILD_ASSERT(sizeof(secret.u.u8) == sizeof(payment_secret->data));
141 memcpy(payment_secret->data, secret.u.u8, sizeof(secret.u.u8));
142}
143
144/* FIXME: This is a hack. The real secret should be a signature of some
145 * onion key, using the payer_id */

Callers 3

invoice_check_paymentFunction · 0.85
invoice_completeFunction · 0.85
json_invoiceFunction · 0.85

Calls 1

sha256Class · 0.70

Tested by

no test coverage detected