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

Function payment_add_hop_onion_payload

plugins/libplugin-pay.c:1625–1667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1623}
1624
1625static void payment_add_hop_onion_payload(struct payment *p,
1626 struct createonion_hop *dst,
1627 struct route_hop *node,
1628 struct route_hop *next,
1629 bool final,
1630 struct secret *payment_secret,
1631 const u8 *payment_metadata)
1632{
1633 struct createonion_request *cr = p->createonion_request;
1634 u32 cltv = p->start_block + next->delay + 1;
1635 u64 msat = next->amount.millisatoshis; /* Raw: TLV payload generation*/
1636 struct tlv_field **fields;
1637 struct payment *root = payment_root(p);
1638
1639 /* This is the information of the node processing this payload, while
1640 * `next` are the instructions to include in the payload, which is
1641 * basically the channel going to the next node. */
1642 dst->pubkey = node->node_id;
1643
1644 dst->tlv_payload = tlv_tlv_payload_new(cr->hops);
1645 fields = &dst->tlv_payload->fields;
1646 tlvstream_set_tu64(fields, TLV_TLV_PAYLOAD_AMT_TO_FORWARD,
1647 msat);
1648 tlvstream_set_tu32(fields, TLV_TLV_PAYLOAD_OUTGOING_CLTV_VALUE,
1649 cltv);
1650
1651 if (!final)
1652 tlvstream_set_short_channel_id(fields,
1653 TLV_TLV_PAYLOAD_SHORT_CHANNEL_ID,
1654 &next->scid);
1655
1656 if (payment_secret != NULL) {
1657 assert(final);
1658 tlvstream_set_tlv_payload_data(
1659 fields, payment_secret,
1660 root->amount.millisatoshis); /* Raw: TLV payload generation*/
1661 }
1662 if (payment_metadata != NULL) {
1663 assert(final);
1664 tlvstream_set_raw(fields, TLV_TLV_PAYLOAD_PAYMENT_METADATA,
1665 payment_metadata, tal_bytelen(payment_metadata));
1666 }
1667}
1668
1669static void payment_compute_onion_payloads(struct payment *p)
1670{

Callers 1

Calls 7

payment_rootFunction · 0.85
tlvstream_set_tu64Function · 0.85
tlvstream_set_tu32Function · 0.85
tlvstream_set_rawFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected