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

Function handle_invoice

plugins/offers_inv_hook.c:320–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320struct command_result *handle_invoice(struct command *cmd,
321 const u8 *invbin,
322 struct tlv_onionmsg_payload_reply_path *reply_path STEALS)
323{
324 size_t len = tal_count(invbin);
325 struct inv *inv = tal(cmd, struct inv);
326 struct out_req *req;
327 struct command_result *err;
328 int bad_feature;
329 struct sha256 m, shash;
330
331 inv->reply_path = tal_steal(inv, reply_path);
332
333 inv->inv = fromwire_tlv_invoice(cmd, &invbin, &len);
334 if (!inv->inv) {
335 return fail_inv(cmd, inv,
336 "Invalid invoice %s",
337 tal_hex(tmpctx, invbin));
338 }
339
340 /* BOLT-offers #12:
341 *
342 * The reader of an invoice_request:
343 *...
344 * - MUST fail the request if `features` contains unknown even bits.
345 */
346 bad_feature = features_unsupported(plugin_feature_set(cmd->plugin),
347 inv->inv->features,
348 BOLT11_FEATURE);
349 if (bad_feature != -1) {
350 return fail_inv(cmd, inv,
351 "Unsupported inv feature %i",
352 bad_feature);
353 }
354
355 /* BOLT-offers #12:
356 *
357 * The reader of an invoice_request:
358 *...
359 * - if `chain` is not present:
360 * - MUST fail the request if bitcoin is not a supported chain.
361 * - otherwise:
362 * - MUST fail the request if `chain` is not a supported chain.
363 */
364 if (!bolt12_chain_matches(inv->inv->chain, chainparams)) {
365 return fail_inv(cmd, inv,
366 "Wrong chain %s",
367 tal_hex(tmpctx, inv->inv->chain));
368 }
369
370 /* BOLT-offers #12:
371 * - MUST reject the invoice if `signature` is not a valid signature
372 * using `node_id` as described in
373 * [Signature Calculation](#signature-calculation).
374 */
375 err = inv_must_have(cmd, inv, node_id);
376 if (err)
377 return err;

Callers 1

Calls 10

fail_invFunction · 0.85
tal_hexFunction · 0.85
plugin_feature_setFunction · 0.85
bolt12_chain_matchesFunction · 0.85
send_outreqFunction · 0.70
fromwire_tlv_invoiceFunction · 0.50
features_unsupportedFunction · 0.50
merkle_tlvFunction · 0.50
sighash_from_merkleFunction · 0.50
json_add_sha256Function · 0.50

Tested by

no test coverage detected