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

Function invoice_for_invreq

common/bolt12.c:1101–1127  ·  view source on GitHub ↗

* Prepare a new invoice based on an invoice_request. */

Source from the content-addressed store, hash-verified

1099 * Prepare a new invoice based on an invoice_request.
1100 */
1101struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
1102 const struct tlv_invoice_request *invreq)
1103{
1104 const u8 *cursor;
1105 size_t start1, len1, start2, len2;
1106 u8 *wire = tal_arr(tmpctx, u8, 0);
1107
1108 towire_tlv_invoice_request(&wire, invreq);
1109
1110 /* BOLT #12:
1111 * A writer of an invoice:
1112 *...
1113 * - if the invoice is in response to an `invoice_request`:
1114 * - MUST copy all non-signature fields from the invoice request (including
1115 * unknown fields).
1116 */
1117 len1 = tlv_span(wire, 0, 159, &start1);
1118 len2 = tlv_span(wire, 1000000000, 2999999999, &start2);
1119
1120 /* Move second span adjacent first span */
1121 memmove(wire + start1 + len1, wire + start2, len2);
1122
1123 /* Unmarshal combined result */
1124 len1 = len1 + len2;
1125 cursor = wire + start1;
1126 return fromwire_tlv_invoice(ctx, &cursor, &len1);
1127}
1128
1129bool is_bolt12_signature_field(u64 typenum)
1130{

Callers 2

listoffers_doneFunction · 0.85
json_sendinvoiceFunction · 0.85

Calls 3

tlv_spanFunction · 0.85
fromwire_tlv_invoiceFunction · 0.50

Tested by

no test coverage detected