Merge pull request #1311 from TheBlueMatt/2022-02-0conf-part-1
[rust-lightning] / lightning-invoice / src / utils.rs
index c2bd4b49c6b2091e3c381a8a63017c3741fc9774..630411f03af6243115cc69357eeecc264e9bb018 100644 (file)
@@ -68,7 +68,7 @@ pub fn create_phantom_invoice<Signer: Sign, K: Deref>(
 
        for hint in phantom_route_hints {
                for channel in &hint.channels {
-                       let short_channel_id = match channel.short_channel_id {
+                       let short_channel_id = match channel.get_inbound_payment_scid() {
                                Some(id) => id,
                                None => continue,
                        };
@@ -165,7 +165,7 @@ where
        let our_channels = channelmanager.list_usable_channels();
        let mut route_hints = vec![];
        for channel in our_channels {
-               let short_channel_id = match channel.short_channel_id {
+               let short_channel_id = match channel.get_inbound_payment_scid() {
                        Some(id) => id,
                        None => continue,
                };
@@ -325,6 +325,13 @@ mod test {
                assert_eq!(invoice.min_final_cltv_expiry(), MIN_FINAL_CLTV_EXPIRY as u64);
                assert_eq!(invoice.description(), InvoiceDescription::Direct(&Description("test".to_string())));
 
+               // Invoice SCIDs should always use inbound SCID aliases over the real channel ID, if one is
+               // available.
+               assert_eq!(invoice.route_hints().len(), 1);
+               assert_eq!(invoice.route_hints()[0].0.len(), 1);
+               assert_eq!(invoice.route_hints()[0].0[0].short_channel_id,
+                       nodes[1].node.list_usable_channels()[0].inbound_scid_alias.unwrap());
+
                let payment_params = PaymentParameters::from_node_id(invoice.recover_payee_pub_key())
                        .with_features(invoice.features().unwrap().clone())
                        .with_route_hints(invoice.route_hints());