secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey,
context: MessageContext, session_priv: &SecretKey
) -> Result<Vec<BlindedHop>, secp256k1::Error> {
- let pks = intermediate_nodes.iter().map(|node| &node.node_id)
- .chain(core::iter::once(&recipient_node_id));
+ let pks = intermediate_nodes.iter().map(|node| node.node_id)
+ .chain(core::iter::once(recipient_node_id));
let tlvs = pks.clone()
.skip(1) // The first node's TLVs contains the next node's pubkey
.zip(intermediate_nodes.iter().map(|node| node.short_channel_id))
.map(|(pubkey, scid)| match scid {
Some(scid) => NextMessageHop::ShortChannelId(scid),
- None => NextMessageHop::NodeId(*pubkey),
+ None => NextMessageHop::NodeId(pubkey),
})
.map(|next_hop| ControlTlvs::Forward(ForwardTlvs { next_hop, next_blinding_override: None }))
.chain(core::iter::once(ControlTlvs::Receive(ReceiveTlvs{ context: Some(context) })));
secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode],
payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey
) -> Result<Vec<BlindedHop>, secp256k1::Error> {
- let pks = intermediate_nodes.iter().map(|node| &node.node_id)
- .chain(core::iter::once(&payee_node_id));
+ let pks = intermediate_nodes.iter().map(|node| node.node_id)
+ .chain(core::iter::once(payee_node_id));
let tlvs = intermediate_nodes.iter().map(|node| BlindedPaymentTlvsRef::Forward(&node.tlvs))
.chain(core::iter::once(BlindedPaymentTlvsRef::Receive(&payee_tlvs)));
utils::construct_blinded_hops(secp_ctx, pks, tlvs, session_priv)
) -> Result<(), secp256k1::Error>
where
T: secp256k1::Signing + secp256k1::Verification,
- I: Iterator<Item=&'a PublicKey>,
+ I: Iterator<Item=PublicKey>,
F: FnMut(PublicKey, SharedSecret, PublicKey, [u8; 32], Option<PublicKey>, Option<Vec<u8>>),
{
build_keys_helper!(session_priv, secp_ctx, callback);
for pk in unblinded_path {
- build_keys_in_loop!(*pk, false, None);
+ build_keys_in_loop!(pk, false, None);
}
if let Some(dest) = destination {
match dest {
) -> Result<Vec<BlindedHop>, secp256k1::Error>
where
T: secp256k1::Signing + secp256k1::Verification,
- I1: Iterator<Item=&'a PublicKey>,
+ I1: Iterator<Item=PublicKey>,
I2: Iterator,
I2::Item: Writeable
{
}
};
let (packet_payloads, packet_keys) = packet_payloads_and_keys(
- &secp_ctx, &intermediate_nodes, destination, contents, reply_path, &blinding_secret
+ &secp_ctx, intermediate_nodes, destination, contents, reply_path, &blinding_secret
)?;
let prng_seed = entropy_source.get_secure_random_bytes();
/// Construct onion packet payloads and keys for sending an onion message along the given
/// `unblinded_path` to the given `destination`.
fn packet_payloads_and_keys<T: OnionMessageContents, S: secp256k1::Signing + secp256k1::Verification>(
- secp_ctx: &Secp256k1<S>, unblinded_path: &[PublicKey], destination: Destination, message: T,
+ secp_ctx: &Secp256k1<S>, unblinded_path: Vec<PublicKey>, destination: Destination, message: T,
mut reply_path: Option<BlindedMessagePath>, session_priv: &SecretKey
) -> Result<(Vec<(Payload<T>, [u8; 32])>, Vec<onion_utils::OnionKeys>), SendError> {
let num_hops = unblinded_path.len() + destination.num_hops();
let mut blinded_path_idx = 0;
let mut prev_control_tlvs_ss = None;
let mut final_control_tlvs = None;
- utils::construct_keys_callback(secp_ctx, unblinded_path.iter(), Some(destination), session_priv,
+ utils::construct_keys_callback(
+ secp_ctx, unblinded_path.into_iter(), Some(destination), session_priv,
|_, onion_packet_ss, ephemeral_pubkey, control_tlvs_ss, unblinded_pk_opt, enc_payload_opt| {
if num_unblinded_hops != 0 && unblinded_path_idx < num_unblinded_hops {
if let Some(ss) = prev_control_tlvs_ss.take() {