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

Function invoice_for_invreq

common/bolt12.c:798–824  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

796 * Prepare a new invoice based on an invoice_request.
797 */
798struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
799 const struct tlv_invoice_request *invreq)
800{
801 const u8 *cursor;
802 size_t start1, len1, start2, len2;
803 u8 *wire = tal_arr(tmpctx, u8, 0);
804
805 towire_tlv_invoice_request(&wire, invreq);
806
807 /* BOLT #12:
808 * A writer of an invoice:
809 *...
810 * - if the invoice is in response to an `invoice_request`:
811 * - MUST copy all non-signature fields from the invoice request (including
812 * unknown fields).
813 */
814 len1 = tlv_span(wire, 0, 159, &start1);
815 len2 = tlv_span(wire, 1000000000, 2999999999, &start2);
816
817 /* Move second span adjacent first span */
818 memmove(wire + start1 + len1, wire + start2, len2);
819
820 /* Unmarshal combined result */
821 len1 = len1 + len2;
822 cursor = wire + start1;
823 return fromwire_tlv_invoice(ctx, &cursor, &len1);
824}
825
826bool is_bolt12_signature_field(u64 typenum)
827{

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