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

Function decode_h

common/bolt11.c:229–251  ·  view source on GitHub ↗

BOLT #11: * * `h` (23): `data_length` 52. 256-bit description of purpose of payment * (SHA256). This is used to commit to an associated description that is over * 639 bytes, but the transport mechanism for the description in that case is * transport specific and not defined here. */

Source from the content-addressed store, hash-verified

227 * transport specific and not defined here.
228 */
229static const char *decode_h(struct bolt11 *b11,
230 const struct feature_set *our_features,
231 struct hash_u5 *hu5,
232 const u5 **data, size_t *field_len,
233 bool *have_h)
234{
235 const char *err;
236 struct sha256 hash;
237
238 assert(!*have_h);
239 /* BOLT #11:
240 *
241 * A reader...
242 * - MUST fail the payment if any field with fixed `data_length` (`p`, `h`, `s`, `n`)
243 * does not have the correct length (52, 52, 52, 53). */
244 err = pull_expected_length(b11, hu5, data, field_len, 52, 'h',
245 have_h, &hash);
246
247 /* If that gave us the hash, store it */
248 if (*have_h)
249 b11->description_hash = tal_dup(b11, struct sha256, &hash);
250 return err;
251}
252
253/* BOLT #11:
254 *

Callers

nothing calls this directly

Calls 1

pull_expected_lengthFunction · 0.85

Tested by

no test coverage detected