]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid slices without inner references
authorMatt Corallo <git@bluematt.me>
Thu, 28 Sep 2023 03:05:09 +0000 (03:05 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 14 May 2024 20:46:40 +0000 (20:46 +0000)
As we cannot express slices without inner references in bindings
wrappers.

lightning/src/blinded_path/mod.rs
lightning/src/ln/channelmanager.rs
lightning/src/routing/gossip.rs
lightning/src/routing/router.rs

index a61eb12b9ae72c8313768fe495954576b07a2282..672a0273793e784775c40640044c7c22475d2e3b 100644 (file)
@@ -152,7 +152,7 @@ impl BlindedPath {
                // be in relation to a specific channel.
                let htlc_maximum_msat = u64::max_value();
                Self::new_for_payment(
-                       &[], payee_node_id, payee_tlvs, htlc_maximum_msat, min_final_cltv_expiry_delta,
+                       Vec::new(), payee_node_id, payee_tlvs, htlc_maximum_msat, min_final_cltv_expiry_delta,
                        entropy_source, secp_ctx
                )
        }
@@ -167,7 +167,7 @@ impl BlindedPath {
        /// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
        //  TODO: make all payloads the same size with padding + add dummy hops
        pub fn new_for_payment<ES: Deref, T: secp256k1::Signing + secp256k1::Verification>(
-               intermediate_nodes: &[payment::ForwardNode], payee_node_id: PublicKey,
+               intermediate_nodes: Vec<payment::ForwardNode>, payee_node_id: PublicKey,
                payee_tlvs: payment::ReceiveTlvs, htlc_maximum_msat: u64, min_final_cltv_expiry_delta: u16,
                entropy_source: ES, secp_ctx: &Secp256k1<T>
        ) -> Result<(BlindedPayInfo, Self), ()> where ES::Target: EntropySource {
@@ -178,13 +178,13 @@ impl BlindedPath {
                let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted");
 
                let blinded_payinfo = payment::compute_payinfo(
-                       intermediate_nodes, &payee_tlvs, htlc_maximum_msat, min_final_cltv_expiry_delta
+                       &intermediate_nodes, &payee_tlvs, htlc_maximum_msat, min_final_cltv_expiry_delta
                )?;
                Ok((blinded_payinfo, BlindedPath {
                        introduction_node,
                        blinding_point: PublicKey::from_secret_key(secp_ctx, &blinding_secret),
                        blinded_hops: payment::blinded_hops(
-                               secp_ctx, intermediate_nodes, payee_node_id, payee_tlvs, &blinding_secret
+                               secp_ctx, &intermediate_nodes, payee_node_id, payee_tlvs, &blinding_secret
                        ).map_err(|_| ())?,
                }))
        }
index 5bca7b4e06632036283fc79d7edbbf62c3f3dbe9..cc69a3e315803c1c4718dea07cac1fcf3ff5c597 100644 (file)
@@ -4772,7 +4772,7 @@ where
        /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
        /// [`APIMisuseError`]: APIError::APIMisuseError
        pub fn update_partial_channel_config(
-               &self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config_update: &ChannelConfigUpdate,
+               &self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config_update: &ChannelConfigUpdate,
        ) -> Result<(), APIError> {
                if config_update.cltv_expiry_delta.map(|delta| delta < MIN_CLTV_EXPIRY_DELTA).unwrap_or(false) {
                        return Err(APIError::APIMisuseError {
@@ -4787,14 +4787,14 @@ where
                let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                let peer_state = &mut *peer_state_lock;
 
-               for channel_id in channel_ids {
+               for channel_id in channel_ids.iter() {
                        if !peer_state.has_channel(channel_id) {
                                return Err(APIError::ChannelUnavailable {
                                        err: format!("Channel with id {} not found for the passed counterparty node_id {}", channel_id, counterparty_node_id),
                                });
                        };
                }
-               for channel_id in channel_ids {
+               for channel_id in channel_ids.iter() {
                        if let Some(channel_phase) = peer_state.channel_by_id.get_mut(channel_id) {
                                let mut config = channel_phase.context().config();
                                config.apply(config_update);
@@ -4849,7 +4849,7 @@ where
        /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
        /// [`APIMisuseError`]: APIError::APIMisuseError
        pub fn update_channel_config(
-               &self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config: &ChannelConfig,
+               &self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config: &ChannelConfig,
        ) -> Result<(), APIError> {
                return self.update_partial_channel_config(counterparty_node_id, channel_ids, &(*config).into());
        }
index 7831e20fa039c391b3432f99c185b180e239b707..39a7a2185afcfc7950e4bc25c2cb57fb8b4b1078 100644 (file)
@@ -89,7 +89,7 @@ impl NodeId {
        }
 
        /// Get the public key as an array from this NodeId
-       pub fn as_array(&self) -> &[u8; PUBLIC_KEY_SIZE] {
+       pub fn as_array(&self) -> &[u8; 33] {
                &self.0
        }
 
index 53a12ed914f7b569e0f9cb976433f943a4fca66c..e8fb7d404e61e197b7b1cedce5d9579d55589d04 100644 (file)
@@ -132,7 +132,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref> Router f
                        })
                        .map(|forward_node| {
                                BlindedPath::new_for_payment(
-                                       &[forward_node], recipient, tlvs.clone(), u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA,
+                                       vec![forward_node], recipient, tlvs.clone(), u64::MAX, MIN_FINAL_CLTV_EXPIRY_DELTA,
                                        &*self.entropy_source, secp_ctx
                                )
                        })