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

Function handle_invoice_request

plugins/offers_invreq_hook.c:837–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

835}
836
837struct command_result *handle_invoice_request(struct command *cmd,
838 const u8 *invreqbin,
839 struct tlv_onionmsg_payload_reply_path *reply_path)
840{
841 size_t len = tal_count(invreqbin);
842 struct invreq *ir = tal(cmd, struct invreq);
843 struct out_req *req;
844 int bad_feature;
845
846 ir->reply_path = tal_steal(ir, reply_path);
847
848 ir->invreq = fromwire_tlv_invoice_request(cmd, &invreqbin, &len);
849 if (!ir->invreq) {
850 return fail_invreq(cmd, ir,
851 "Invalid invreq %s",
852 tal_hex(tmpctx, invreqbin));
853 }
854
855 /* BOLT-offers #12:
856 *
857 * The reader of an invoice_request:
858 *...
859 * - MUST fail the request if `features` contains unknown even bits.
860 */
861 bad_feature = features_unsupported(plugin_feature_set(cmd->plugin),
862 ir->invreq->features,
863 BOLT11_FEATURE);
864 if (bad_feature != -1) {
865 return fail_invreq(cmd, ir,
866 "Unsupported invreq feature %i",
867 bad_feature);
868 }
869
870 /* BOLT-offers #12:
871 *
872 * The reader of an invoice_request:
873 *...
874 * - if `chain` is not present:
875 * - MUST fail the request if bitcoin is not a supported chain.
876 * - otherwise:
877 * - MUST fail the request if `chain` is not a supported chain.
878 */
879 if (!bolt12_chain_matches(ir->invreq->chain, chainparams)) {
880 return fail_invreq(cmd, ir,
881 "Wrong chain %s",
882 tal_hex(tmpctx, ir->invreq->chain));
883 }
884
885 /* BOLT-offers #12:
886 *
887 * The reader of an invoice_request:
888 * - MUST fail the request if `payer_key` is not present.
889 */
890 if (!ir->invreq->payer_key)
891 return fail_invreq(cmd, ir, "Missing payer key");
892
893 if (!ir->invreq->offer_id)
894 return handle_offerless_request(cmd, ir);

Callers 1

Calls 8

tal_hexFunction · 0.85
plugin_feature_setFunction · 0.85
bolt12_chain_matchesFunction · 0.85
handle_offerless_requestFunction · 0.85
send_outreqFunction · 0.70
features_unsupportedFunction · 0.50
json_add_sha256Function · 0.50

Tested by

no test coverage detected