| 1796 | } |
| 1797 | |
| 1798 | static void payment_add_hop_onion_payload(struct payment *p, |
| 1799 | struct createonion_hop *dst, |
| 1800 | struct route_hop *node, |
| 1801 | struct route_hop *next, |
| 1802 | bool final, |
| 1803 | struct secret *payment_secret, |
| 1804 | const u8 *payment_metadata) |
| 1805 | { |
| 1806 | struct createonion_request *cr = p->createonion_request; |
| 1807 | |
| 1808 | /* The start_block takes chainlag into consideration, so no |
| 1809 | * need to adjust it here. */ |
| 1810 | u32 cltv = p->start_block + next->delay + 1; |
| 1811 | u64 msat = next->amount.millisatoshis; /* Raw: TLV payload generation*/ |
| 1812 | struct tlv_field **fields; |
| 1813 | |
| 1814 | /* This is the information of the node processing this payload, while |
| 1815 | * `next` are the instructions to include in the payload, which is |
| 1816 | * basically the channel going to the next node. */ |
| 1817 | dst->pubkey = node->node_id; |
| 1818 | |
| 1819 | dst->tlv_payload = tlv_payload_new(cr->hops); |
| 1820 | fields = &dst->tlv_payload->fields; |
| 1821 | tlvstream_set_tu64(fields, TLV_PAYLOAD_AMT_TO_FORWARD, |
| 1822 | msat); |
| 1823 | |
| 1824 | tlvstream_set_tu32(fields, TLV_PAYLOAD_OUTGOING_CLTV_VALUE, |
| 1825 | cltv); |
| 1826 | |
| 1827 | if (!final) |
| 1828 | tlvstream_set_short_channel_id(fields, |
| 1829 | TLV_PAYLOAD_SHORT_CHANNEL_ID, |
| 1830 | next->scid); |
| 1831 | |
| 1832 | if (payment_secret != NULL) { |
| 1833 | assert(final); |
| 1834 | tlvstream_set_tlv_payload_data( |
| 1835 | fields, payment_secret, |
| 1836 | p->final_amount.millisatoshis); /* Raw: TLV payload generation*/ |
| 1837 | } |
| 1838 | if (payment_metadata != NULL) { |
| 1839 | assert(final); |
| 1840 | tlvstream_set_raw(fields, TLV_PAYLOAD_PAYMENT_METADATA, |
| 1841 | payment_metadata, tal_bytelen(payment_metadata)); |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | static void payment_add_blindedpath(const tal_t *ctx, |
| 1846 | struct createonion_hop *hops, |
no test coverage detected