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

Function onion_final_hop

common/onion_encode.c:58–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58u8 *onion_final_hop(const tal_t *ctx,
59 struct amount_msat forward,
60 u32 outgoing_cltv,
61 struct amount_msat total_msat,
62 const struct secret *payment_secret,
63 const u8 *payment_metadata)
64{
65 struct tlv_payload *tlv = tlv_payload_new(tmpctx);
66 struct tlv_payload_payment_data tlv_pdata;
67
68 /* These go together! */
69 if (!payment_secret)
70 assert(amount_msat_eq(total_msat, forward));
71
72 /* BOLT #4:
73 *
74 * The writer of the TLV `payload`:
75 *...
76 * - For every node outside of a blinded route:
77 * - MUST include `amt_to_forward` and `outgoing_cltv_value`.
78 *...
79 * - For the final node:
80 * - MUST NOT include `short_channel_id`
81 * - if the recipient provided `payment_secret`:
82 * - MUST include `payment_data`
83 * - MUST set `payment_secret` to the one provided
84 * - MUST set `total_msat` to the total amount it will send
85 */
86 tlv->amt_to_forward = &forward.millisatoshis; /* Raw: TLV convert */
87 tlv->outgoing_cltv_value = &outgoing_cltv;
88
89 if (payment_secret) {
90 tlv_pdata.payment_secret = *payment_secret;
91 tlv_pdata.total_msat = total_msat.millisatoshis; /* Raw: TLV convert */
92 tlv->payment_data = &tlv_pdata;
93 }
94 tlv->payment_metadata = cast_const(u8 *, payment_metadata);
95 return make_tlv_hop(ctx, tlv);
96}
97
98u8 *onion_blinded_hop(const tal_t *ctx,
99 const struct amount_msat *amt_to_forward,

Callers 4

send_paymentFunction · 0.85
sphinx_append_final_hopFunction · 0.85
create_onionFunction · 0.85
do_generateFunction · 0.85

Calls 2

make_tlv_hopFunction · 0.85
amount_msat_eqFunction · 0.70

Tested by

no test coverage detected