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

Function handle_invoice_request

plugins/offers_invreq_hook.c:1126–1250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1124}
1125
1126struct command_result *handle_invoice_request(struct command *cmd,
1127 const u8 *invreqbin,
1128 struct blinded_path *reply_path,
1129 const struct secret *secret)
1130{
1131 struct out_req *req;
1132 int bad_feature;
1133 size_t len = tal_count(invreqbin);
1134 const u8 *cursor = invreqbin;
1135 struct invreq *ir = tal(cmd, struct invreq);
1136 char *err;
1137
1138 ir->reply_path = tal_steal(ir, reply_path);
1139 ir->secret = tal_dup_or_null(ir, struct secret, secret);
1140 ir->invreq = fromwire_tlv_invoice_request(cmd, &cursor, &len);
1141
1142 if (!ir->invreq) {
1143 return fail_invreq(cmd, ir, "Invalid invreq");
1144 }
1145
1146 /* BOLT #12:
1147 * The reader:
1148 * ...
1149 * - MUST reject the invoice request if any non-signature TLV fields are outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999
1150 */
1151 /* BOLT #12:
1152 * Each form is signed using one or more *signature TLV elements*:
1153 * TLV types 240 through 1000 (inclusive)
1154 */
1155 if (any_field_outside_range(ir->invreq->fields, true,
1156 0, 159,
1157 1000000000, 2999999999)) {
1158 return fail_invreq(cmd, ir, "Invalid high fields");
1159 }
1160
1161 /* BOLT #12:
1162 *
1163 * The reader:
1164 * - MUST reject the invoice request if `invreq_payer_id` or `invreq_metadata`
1165 * are not present.
1166 */
1167 if (!ir->invreq->invreq_payer_id)
1168 return fail_invreq(cmd, ir, "Missing invreq_payer_id");
1169 if (!ir->invreq->invreq_metadata)
1170 return fail_invreq(cmd, ir, "Missing invreq_metadata");
1171
1172 /* BOLT #12:
1173 *
1174 * The reader:
1175 *...
1176 * - if `invreq_features` contains unknown _even_ bits that are non-zero:
1177 * - MUST reject the invoice request.
1178 */
1179 bad_feature = features_unsupported(plugin_feature_set(cmd->plugin),
1180 ir->invreq->invreq_features,
1181 BOLT12_INVREQ_FEATURE);
1182 if (bad_feature != -1) {
1183 return fail_invreq(cmd, ir,

Callers 1

onion_message_recvFunction · 0.70

Calls 12

any_field_outside_rangeFunction · 0.85
tal_bytelenFunction · 0.85
bolt12_chain_matchesFunction · 0.85
tal_hexFunction · 0.85
invreq_offer_idFunction · 0.85
json_add_sha256Function · 0.85
plugin_feature_setFunction · 0.70
send_outreqFunction · 0.70
features_unsupportedFunction · 0.50

Tested by

no test coverage detected