]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add PaymentSecrets to HTLCSource::OutboundRoute objects
authorMatt Corallo <git@bluematt.me>
Mon, 4 Oct 2021 04:04:46 +0000 (04:04 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 22 Oct 2021 18:41:42 +0000 (18:41 +0000)
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs

index 16e6576b87e5944508674b615dcdc935bb1c9367..c2e158627ad03c9a2a3333f78c28de9c1e29bb87 100644 (file)
@@ -5767,6 +5767,7 @@ mod tests {
                                session_priv: SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
                                first_hop_htlc_msat: 548,
                                payment_id: PaymentId([42; 32]),
+                               payment_secret: None,
                        }
                });
 
index ea058c581e419f6eaf3b67a68b7b1ad80ccf4862..6298a0d9ae3cbf074e6d8b49f2d54df9f863c658 100644 (file)
@@ -199,6 +199,7 @@ pub(crate) enum HTLCSource {
                /// doing a double-pass on route when we get a failure back
                first_hop_htlc_msat: u64,
                payment_id: PaymentId,
+               payment_secret: Option<PaymentSecret>,
        },
 }
 #[cfg(test)]
@@ -209,6 +210,7 @@ impl HTLCSource {
                        session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
                        first_hop_htlc_msat: 0,
                        payment_id: PaymentId([2; 32]),
+                       payment_secret: None,
                }
        }
 }
@@ -2048,6 +2050,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                                                        session_priv: session_priv.clone(),
                                                        first_hop_htlc_msat: htlc_msat,
                                                        payment_id,
+                                                       payment_secret: payment_secret.clone(),
                                                }, onion_packet, &self.logger),
                                        channel_state, chan);
 
@@ -5351,10 +5354,12 @@ impl Readable for HTLCSource {
                                let mut first_hop_htlc_msat: u64 = 0;
                                let mut path = Some(Vec::new());
                                let mut payment_id = None;
+                               let mut payment_secret = None;
                                read_tlv_fields!(reader, {
                                        (0, session_priv, required),
                                        (1, payment_id, option),
                                        (2, first_hop_htlc_msat, required),
+                                       (3, payment_secret, option),
                                        (4, path, vec_type),
                                });
                                if payment_id.is_none() {
@@ -5367,6 +5372,7 @@ impl Readable for HTLCSource {
                                        first_hop_htlc_msat: first_hop_htlc_msat,
                                        path: path.unwrap(),
                                        payment_id: payment_id.unwrap(),
+                                       payment_secret,
                                })
                        }
                        1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
@@ -5378,13 +5384,14 @@ impl Readable for HTLCSource {
 impl Writeable for HTLCSource {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::io::Error> {
                match self {
-                       HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id } => {
+                       HTLCSource::OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id, payment_secret } => {
                                0u8.write(writer)?;
                                let payment_id_opt = Some(payment_id);
                                write_tlv_fields!(writer, {
                                        (0, session_priv, required),
                                        (1, payment_id_opt, option),
                                        (2, first_hop_htlc_msat, required),
+                                       (3, payment_secret, option),
                                        (4, path, vec_type),
                                 });
                        }