Skip to content

Commit e01edf6

Browse files
committed
Avoid slices without inner references
As we cannot express slices without inner references in bindings wrappers.
1 parent 780cbe9 commit e01edf6

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

lightning/src/blinded_path/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl BlindedPath {
9292
// be in relation to a specific channel.
9393
let htlc_maximum_msat = u64::max_value();
9494
Self::new_for_payment(
95-
&[], payee_node_id, payee_tlvs, htlc_maximum_msat, entropy_source, secp_ctx
95+
Vec::new(), payee_node_id, payee_tlvs, htlc_maximum_msat, entropy_source, secp_ctx
9696
)
9797
}
9898

@@ -106,19 +106,19 @@ impl BlindedPath {
106106
/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
107107
// TODO: make all payloads the same size with padding + add dummy hops
108108
pub fn new_for_payment<ES: EntropySource + ?Sized, T: secp256k1::Signing + secp256k1::Verification>(
109-
intermediate_nodes: &[payment::ForwardNode], payee_node_id: PublicKey,
109+
intermediate_nodes: Vec<payment::ForwardNode>, payee_node_id: PublicKey,
110110
payee_tlvs: payment::ReceiveTlvs, htlc_maximum_msat: u64, entropy_source: &ES,
111111
secp_ctx: &Secp256k1<T>
112112
) -> Result<(BlindedPayInfo, Self), ()> {
113113
let blinding_secret_bytes = entropy_source.get_secure_random_bytes();
114114
let blinding_secret = SecretKey::from_slice(&blinding_secret_bytes[..]).expect("RNG is busted");
115115

116-
let blinded_payinfo = payment::compute_payinfo(intermediate_nodes, &payee_tlvs, htlc_maximum_msat)?;
116+
let blinded_payinfo = payment::compute_payinfo(&intermediate_nodes, &payee_tlvs, htlc_maximum_msat)?;
117117
Ok((blinded_payinfo, BlindedPath {
118118
introduction_node_id: intermediate_nodes.first().map_or(payee_node_id, |n| n.node_id),
119119
blinding_point: PublicKey::from_secret_key(secp_ctx, &blinding_secret),
120120
blinded_hops: payment::blinded_hops(
121-
secp_ctx, intermediate_nodes, payee_node_id, payee_tlvs, &blinding_secret
121+
secp_ctx, &intermediate_nodes, payee_node_id, payee_tlvs, &blinding_secret
122122
).map_err(|_| ())?,
123123
}))
124124
}

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,7 +4013,7 @@ where
40134013
/// [`ChannelUnavailable`]: APIError::ChannelUnavailable
40144014
/// [`APIMisuseError`]: APIError::APIMisuseError
40154015
pub fn update_partial_channel_config(
4016-
&self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config_update: &ChannelConfigUpdate,
4016+
&self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config_update: &ChannelConfigUpdate,
40174017
) -> Result<(), APIError> {
40184018
if config_update.cltv_expiry_delta.map(|delta| delta < MIN_CLTV_EXPIRY_DELTA).unwrap_or(false) {
40194019
return Err(APIError::APIMisuseError {
@@ -4027,14 +4027,14 @@ where
40274027
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
40284028
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
40294029
let peer_state = &mut *peer_state_lock;
4030-
for channel_id in channel_ids {
4030+
for channel_id in channel_ids.iter() {
40314031
if !peer_state.has_channel(channel_id) {
40324032
return Err(APIError::ChannelUnavailable {
40334033
err: format!("Channel with id {} not found for the passed counterparty node_id {}", channel_id, counterparty_node_id),
40344034
});
40354035
};
40364036
}
4037-
for channel_id in channel_ids {
4037+
for channel_id in channel_ids.iter() {
40384038
if let Some(channel_phase) = peer_state.channel_by_id.get_mut(channel_id) {
40394039
let mut config = channel_phase.context().config();
40404040
config.apply(config_update);
@@ -4088,7 +4088,7 @@ where
40884088
/// [`ChannelUnavailable`]: APIError::ChannelUnavailable
40894089
/// [`APIMisuseError`]: APIError::APIMisuseError
40904090
pub fn update_channel_config(
4091-
&self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config: &ChannelConfig,
4091+
&self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config: &ChannelConfig,
40924092
) -> Result<(), APIError> {
40934093
return self.update_partial_channel_config(counterparty_node_id, channel_ids, &(*config).into());
40944094
}

lightning/src/routing/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl NodeId {
8080
}
8181

8282
/// Get the public key as an array from this NodeId
83-
pub fn as_array(&self) -> &[u8; PUBLIC_KEY_SIZE] {
83+
pub fn as_array(&self) -> &[u8; 33] {
8484
&self.0
8585
}
8686

lightning/src/routing/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, ES: Deref, S: Deref> Router f
132132
})
133133
.map(|forward_node| {
134134
BlindedPath::new_for_payment(
135-
&[forward_node], recipient, tlvs.clone(), u64::MAX, &*self.entropy_source, secp_ctx
135+
vec![forward_node], recipient, tlvs.clone(), u64::MAX, &*self.entropy_source, secp_ctx
136136
)
137137
})
138138
.take(MAX_PAYMENT_PATHS)

0 commit comments

Comments
 (0)