@@ -109,50 +109,76 @@ use crate::ln::script::ShutdownScript;
109
109
// Alternatively, we can fill an outbound HTLC with a HTLCSource::OutboundRoute indicating this is
110
110
// our payment, which we can use to decode errors or inform the user that the payment was sent.
111
111
112
- /// Routing info for an inbound HTLC onion.
112
+ /// Information about where a received HTLC('s onion) has indicated the HTLC should go .
113
113
#[derive(Clone)] // See Channel::revoke_and_ack for why, tl;dr: Rust bug
114
114
pub enum PendingHTLCRouting {
115
- /// A forwarded HTLC .
115
+ /// An HTLC which should be forwarded on to another node .
116
116
Forward {
117
- /// BOLT 4 onion packet.
117
+ /// The onion which should be included in the forwarded HTLC, telling the next hop what to
118
+ /// do with the HTLC.
118
119
onion_packet: msgs::OnionPacket,
119
- /// The SCID from the onion that we should forward to. This could be a real SCID or a fake one
120
- /// generated using `get_fake_scid` from the scid_utils::fake_scid module.
120
+ /// The short channel ID of the channel which we were instructed to forward this HTLC to.
121
+ ///
122
+ /// This could be a real on-chain SCID, an SCID alias, or some other SCID which has meaning
123
+ /// to the receiving node, such as one returned from
124
+ /// [`ChannelManager::get_intercept_scid`] or [`ChannelManager::get_phantom_scid`].
121
125
short_channel_id: u64, // This should be NonZero<u64> eventually when we bump MSRV
122
126
/// Set if this HTLC is being forwarded within a blinded path.
123
127
blinded: Option<BlindedForward>,
124
128
},
125
- /// An HTLC paid to an invoice (supposedly) generated by us.
126
- /// At this point, we have not checked that the invoice being paid was actually generated by us,
127
- /// but rather it's claiming to pay an invoice of ours.
129
+ /// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
130
+ ///
131
+ /// Note that at this point, we have not checked that the invoice being paid was actually
132
+ /// generated by us, but rather it's claiming to pay an invoice of ours.
128
133
Receive {
129
- /// Payment secret and total msat received.
134
+ /// Information about the amount the sender intended to pay and (potential) proof that this
135
+ /// is a payment for an invoice we generated, which is also used to associate MPP parts of
136
+ /// a larger payment.
130
137
payment_data: msgs::FinalOnionHopData,
131
- /// See [`RecipientOnionFields::payment_metadata`] for more info.
138
+ /// Additional data which we (allegedly) instructed the sender to include in the onion.
139
+ ///
140
+ /// For HTLCs received by LDK, this will ultimately bubble back up as
141
+ /// [`RecipientOnionFields::payment_metadata`].
132
142
payment_metadata: Option<Vec<u8>>,
133
143
/// CLTV expiry of the received HTLC.
144
+ ///
134
145
/// Used to track when we should expire pending HTLCs that go unclaimed.
135
146
incoming_cltv_expiry: u32,
136
- /// Shared secret derived using a phantom node secret key. If this field is Some, the
137
- /// payment was sent to a phantom node (one hop beyond the current node), but can be
138
- /// settled by this node .
147
+ /// If the onion had forwarding instructions to one of our phantom node SCIDs, this will
148
+ /// provide the onion shared secret used to decrypt the second level of forwarding
149
+ /// instructions .
139
150
phantom_shared_secret: Option<[u8; 32]>,
140
- /// See [`RecipientOnionFields::custom_tlvs`] for more info.
151
+ /// Custom TLVs which were set by the sender.
152
+ ///
153
+ /// For HTLCs received by LDK, these will ultimately bubble back up as
154
+ /// [`RecipientOnionFields::custom_tlvs`].
141
155
custom_tlvs: Vec<(u64, Vec<u8>)>,
142
156
},
143
- /// Incoming keysend (sender provided the preimage in a TLV).
157
+ /// The onion indicates that this is for payment to us but which contains the preimage for
158
+ /// claiming included, and is unrelated to any invoice we'd previously generated (aka a
159
+ /// "keysend" or "spontaneous" payment).
144
160
ReceiveKeysend {
145
- /// This was added in 0.0.116 and will break deserialization on downgrades.
161
+ /// Information about the amount the sender intended to pay and possibly a token to
162
+ /// associate MPP parts of a larger payment.
163
+ ///
164
+ /// This will only be filled in if receiving MPP keysend payments is enabled, and it being
165
+ /// present may break downgrades to versions of LDK prior to 0.0.116.
146
166
payment_data: Option<msgs::FinalOnionHopData>,
147
167
/// Preimage for this onion payment. This preimage is provided by the sender and will be
148
168
/// used to settle the spontaneous payment.
149
169
payment_preimage: PaymentPreimage,
150
- /// See [`RecipientOnionFields::payment_metadata`] for more info.
170
+ /// Additional data which we (allegedly) instructed the sender to include in the onion.
171
+ ///
172
+ /// For HTLCs received by LDK, this will ultimately bubble back up as
173
+ /// [`RecipientOnionFields::payment_metadata`].
151
174
payment_metadata: Option<Vec<u8>>,
152
175
/// CLTV expiry of the received HTLC.
153
176
/// Used to track when we should expire pending HTLCs that go unclaimed.
154
177
incoming_cltv_expiry: u32,
155
- /// See [`RecipientOnionFields::custom_tlvs`] for more info.
178
+ /// Custom TLVs which were set by the sender.
179
+ ///
180
+ /// For HTLCs received by LDK, these will ultimately bubble back up as
181
+ /// [`RecipientOnionFields::custom_tlvs`].
156
182
custom_tlvs: Vec<(u64, Vec<u8>)>,
157
183
},
158
184
}
0 commit comments