Skip to content

Commit 53389a2

Browse files
committed
Add PaymentSecrets to HTLCSource::OutboundRoute objects
1 parent e0df118 commit 53389a2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lightning/src/ln/channel.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5767,6 +5767,7 @@ mod tests {
57675767
session_priv: SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
57685768
first_hop_htlc_msat: 548,
57695769
payment_id: PaymentId([42; 32]),
5770+
payment_secret: None,
57705771
}
57715772
});
57725773

lightning/src/ln/channelmanager.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub(crate) enum HTLCSource {
199199
/// doing a double-pass on route when we get a failure back
200200
first_hop_htlc_msat: u64,
201201
payment_id: PaymentId,
202+
payment_secret: Option<PaymentSecret>,
202203
},
203204
}
204205
#[cfg(test)]
@@ -209,6 +210,7 @@ impl HTLCSource {
209210
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
210211
first_hop_htlc_msat: 0,
211212
payment_id: PaymentId([2; 32]),
213+
payment_secret: None,
212214
}
213215
}
214216
}
@@ -2026,6 +2028,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
20262028
session_priv: session_priv.clone(),
20272029
first_hop_htlc_msat: htlc_msat,
20282030
payment_id,
2031+
payment_secret: payment_secret.clone(),
20292032
}, onion_packet, &self.logger),
20302033
channel_state, chan);
20312034

@@ -5326,10 +5329,12 @@ impl Readable for HTLCSource {
53265329
let mut first_hop_htlc_msat: u64 = 0;
53275330
let mut path = Some(Vec::new());
53285331
let mut payment_id = None;
5332+
let mut payment_secret = None;
53295333
read_tlv_fields!(reader, {
53305334
(0, session_priv, required),
53315335
(1, payment_id, option),
53325336
(2, first_hop_htlc_msat, required),
5337+
(3, payment_secret, option),
53335338
(4, path, vec_type),
53345339
});
53355340
if payment_id.is_none() {
@@ -5342,6 +5347,7 @@ impl Readable for HTLCSource {
53425347
first_hop_htlc_msat: first_hop_htlc_msat,
53435348
path: path.unwrap(),
53445349
payment_id: payment_id.unwrap(),
5350+
payment_secret,
53455351
})
53465352
}
53475353
1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
@@ -5353,13 +5359,14 @@ impl Readable for HTLCSource {
53535359
impl Writeable for HTLCSource {
53545360
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::io::Error> {
53555361
match self {
5356-
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id } => {
5362+
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret } => {
53575363
0u8.write(writer)?;
53585364
let payment_id_opt = Some(payment_id);
53595365
write_tlv_fields!(writer, {
53605366
(0, session_priv, required),
53615367
(1, payment_id_opt, option),
53625368
(2, first_hop_htlc_msat, required),
5369+
(3, payment_secret, option),
53635370
(4, path, vec_type),
53645371
});
53655372
}

0 commit comments

Comments
 (0)