Skip to content

Commit 787fc8c

Browse files
committed
Add PaymentSecrets to HTLCSource::OutboundRoute objects
1 parent 1910d54 commit 787fc8c

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
}
@@ -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
assert!(payment.insert(session_priv_bytes, path.last().unwrap().fee_msat));
@@ -5314,10 +5317,12 @@ impl Readable for HTLCSource {
53145317
let mut first_hop_htlc_msat: u64 = 0;
53155318
let mut path = Some(Vec::new());
53165319
let mut payment_id = None;
5320+
let mut payment_secret = None;
53175321
read_tlv_fields!(reader, {
53185322
(0, session_priv, required),
53195323
(1, payment_id, option),
53205324
(2, first_hop_htlc_msat, required),
5325+
(3, payment_secret, option),
53215326
(4, path, vec_type),
53225327
});
53235328
if payment_id.is_none() {
@@ -5330,6 +5335,7 @@ impl Readable for HTLCSource {
53305335
first_hop_htlc_msat: first_hop_htlc_msat,
53315336
path: path.unwrap(),
53325337
payment_id: payment_id.unwrap(),
5338+
payment_secret,
53335339
})
53345340
}
53355341
1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
@@ -5341,13 +5347,14 @@ impl Readable for HTLCSource {
53415347
impl Writeable for HTLCSource {
53425348
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::io::Error> {
53435349
match self {
5344-
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id } => {
5350+
HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret } => {
53455351
0u8.write(writer)?;
53465352
let payment_id_opt = Some(payment_id);
53475353
write_tlv_fields!(writer, {
53485354
(0, session_priv, required),
53495355
(1, payment_id_opt, option),
53505356
(2, first_hop_htlc_msat, required),
5357+
(3, payment_secret, option),
53515358
(4, path, vec_type),
53525359
});
53535360
}

0 commit comments

Comments
 (0)