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

Function decode_p

common/bolt11.c:149–177  ·  view source on GitHub ↗

BOLT #11: * * `p` (1): `data_length` 52. 256-bit SHA256 payment_hash. Preimage of this * provides proof of payment */

Source from the content-addressed store, hash-verified

147 * provides proof of payment
148 */
149static void decode_p(struct bolt11 *b11,
150 struct hash_u5 *hu5,
151 u5 **data, size_t *data_len,
152 size_t data_length, bool *have_p)
153{
154 /* BOLT #11:
155 *
156 * A payer... SHOULD use the first `p` field that it did NOT
157 * skip as the payment hash.
158 */
159 if (*have_p) {
160 unknown_field(b11, hu5, data, data_len, 'p', data_length);
161 return;
162 }
163
164 /* BOLT #11:
165 *
166 * A reader... MUST skip over unknown fields, OR an `f` field
167 * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
168 * NOT have `data_length`s of 52, 52, 52 or 53, respectively.
169 */
170 if (data_length != 52) {
171 unknown_field(b11, hu5, data, data_len, 'p', data_length);
172 return;
173 }
174
175 pull_bits_certain(hu5, data, data_len, &b11->payment_hash, 256, false);
176 *have_p = true;
177}
178
179/* BOLT #11:
180 *

Callers 1

bolt11_decode_nosigFunction · 0.85

Calls 1

unknown_fieldFunction · 0.85

Tested by

no test coverage detected