Skip to content

Commit 9a8b01d

Browse files
committed
Add PaymentSecrets to HTLCSource::OutboundRoute objects
1 parent e8fa34e commit 9a8b01d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5741,6 +5741,7 @@ mod tests {
57415741
session_priv: SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
57425742
first_hop_htlc_msat: 548,
57435743
payment_id: PaymentId([42; 32]),
5744+
payment_secret: None,
57445745
}
57455746
});
57465747

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 1 deletion
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
}
@@ -2024,6 +2026,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
20242026
session_priv: session_priv.clone(),
20252027
first_hop_htlc_msat: htlc_msat,
20262028
payment_id,
2029+
payment_secret: payment_secret.clone(),
20272030
}, onion_packet, &self.logger),
20282031
channel_state, chan);
20292032

@@ -5322,10 +5325,12 @@ impl Readable for HTLCSource {
53225325
let mut first_hop_htlc_msat: u64 = 0;
53235326
let mut path = Some(Vec::new());
53245327
let mut payment_id = None;
5328+
let mut payment_secret = None;
53255329
read_tlv_fields!(reader, {
53265330
(0, session_priv, required),
53275331
(1, payment_id, option),
53285332
(2, first_hop_htlc_msat, required),
5333+
(3, payment_secret, option),
53295334
(4, path, vec_type),
53305335
});
53315336
if payment_id.is_none() {
@@ -5338,6 +5343,7 @@ impl Readable for HTLCSource {
53385343
first_hop_htlc_msat: first_hop_htlc_msat,
53395344
path: path.unwrap(),
53405345
payment_id: payment_id.unwrap(),
5346+
payment_secret,
53415347
})
53425348
}
53435349
1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
@@ -5349,13 +5355,14 @@ impl Readable for HTLCSource {
53495355
impl Writeable for HTLCSource {
53505356
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::io::Error> {
53515357
match self {
5352-
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id } => {
5358+
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret } => {
53535359
0u8.write(writer)?;
53545360
let payment_id_opt = Some(payment_id);
53555361
write_tlv_fields!(writer, {
53565362
(0, session_priv, required),
53575363
(1, payment_id_opt, option),
53585364
(2, first_hop_htlc_msat, required),
5365+
(3, payment_secret, option),
53595366
(4, path, vec_type),
53605367
});
53615368
}

0 commit comments

Comments
 (0)