* Prepare a new invoice based on an invoice_request. */
| 796 | * Prepare a new invoice based on an invoice_request. |
| 797 | */ |
| 798 | struct 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 | |
| 826 | bool is_bolt12_signature_field(u64 typenum) |
| 827 | { |
no test coverage detected