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

Function next_field_check

common/bolt12_proof.c:218–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216};
217
218static const struct tlv_field *next_field_check(bool *is_omitted,
219 struct checker *checker)
220{
221 const struct tlv_field *included, *omitted;
222
223 /* BOLT-payer_proof #12:
224 * A reader of a payer_proof:
225 * - MUST reject the payer_proof if:
226 *...
227 * - `signature` is not a valid signature using `invoice_node_id` as
228 * described in [Signature Calculation](#signature-calculation)
229 * (with `messagename` "invoice") of the reconstructed merkle-root
230 * of the invoice (i.e. without fields 1001 through 999999999
231 * inclusive).
232 */
233next:
234 if (checker->included_n < tal_count(checker->pptlv->fields)) {
235 included = &checker->pptlv->fields[checker->included_n];
236 if (included->numtype >= 1001 && included->numtype <= 999999999) {
237 checker->included_n++;
238 goto next;
239 }
240 } else
241 included = NULL;
242
243 if (checker->omitted_n < tal_count(checker->omitted))
244 omitted = &checker->omitted[checker->omitted_n];
245 else
246 omitted = NULL;
247
248 /* Both exhausted? We finish. */
249 if (!included && !omitted)
250 return NULL;
251
252 /* Only omitted left, or both and omitted comes first */
253 if ((omitted && !included)
254 || (omitted && included && omitted->numtype < included->numtype)) {
255 checker->omitted_n++;
256 *is_omitted = true;
257 return omitted;
258 }
259
260 *is_omitted = false;
261 checker->included_n++;
262 return included;
263}
264
265static void get_leaf_hash(const struct sha256_ctx *lnnonce_ctx,
266 bigsize_t fieldtype,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected