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

Function invoice_matches_request

plugins/fetchinvoice.c:137–157  ·  view source on GitHub ↗

BOLT #12: * - if the invoice is a response to an `invoice_request`: * - MUST reject the invoice if all fields in ranges 0 to 159 and 1000000000 to 2999999999 (inclusive) do not exactly match the invoice request. */

Source from the content-addressed store, hash-verified

135 * - MUST reject the invoice if all fields in ranges 0 to 159 and 1000000000 to 2999999999 (inclusive) do not exactly match the invoice request.
136 */
137static bool invoice_matches_request(struct command *cmd,
138 const u8 *invbin,
139 const struct tlv_invoice_request *invreq)
140{
141 size_t ir_len1, ir_len2, ir_start1, ir_start2;
142 size_t inv_len1, inv_len2, inv_start1, inv_start2;
143 u8 *wire;
144
145 /* We linearize then strip signature. This is dumb! */
146 wire = tal_arr(tmpctx, u8, 0);
147 towire_tlv_invoice_request(&wire, invreq);
148 ir_len1 = tlv_span(wire, 0, 159, &ir_start1);
149 ir_len2 = tlv_span(wire, 1000000000, 2999999999, &ir_start2);
150
151 inv_len1 = tlv_span(invbin, 0, 159, &inv_start1);
152 inv_len2 = tlv_span(invbin, 1000000000, 2999999999, &inv_start2);
153 return memeq(wire + ir_start1, ir_len1,
154 invbin + inv_start1, inv_len1)
155 && memeq(wire + ir_start2, ir_len2,
156 invbin + inv_start2, inv_len2);
157}
158
159static struct command_result *handle_invreq_response(struct command *cmd,
160 struct sent *sent,

Callers 1

handle_invreq_responseFunction · 0.85

Calls 3

tlv_spanFunction · 0.85
memeqFunction · 0.85

Tested by

no test coverage detected