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

Function decode_n

common/bolt11.c:289–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289static char *decode_n(struct bolt11 *b11,
290 struct hash_u5 *hu5,
291 u5 **data, size_t *data_len,
292 size_t data_length, bool *have_n)
293{
294 if (*have_n)
295 return unknown_field(b11, hu5, data, data_len, 'n',
296 data_length);
297
298 /* BOLT #11:
299 *
300 * A reader... MUST skip over unknown fields, OR an `f` field
301 * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
302 * NOT have `data_length`s of 52, 52, 52 or 53, respectively. */
303 if (data_length != 53)
304 return unknown_field(b11, hu5, data, data_len, 'n',
305 data_length);
306
307 pull_bits_certain(hu5, data, data_len, &b11->receiver_id.k,
308 data_length * 5, false);
309 if (!node_id_valid(&b11->receiver_id))
310 return tal_fmt(b11, "n: invalid pubkey %s",
311 node_id_to_hexstr(tmpctx, &b11->receiver_id));
312
313 *have_n = true;
314 return NULL;
315}
316
317/* BOLT #11:
318 *

Callers 1

bolt11_decode_nosigFunction · 0.85

Calls 3

unknown_fieldFunction · 0.85
node_id_validFunction · 0.85
node_id_to_hexstrFunction · 0.70

Tested by

no test coverage detected