From: dunxen Date: Tue, 27 Aug 2024 11:28:43 +0000 (+0200) Subject: Merge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor X-Git-Tag: v0.0.124-rc1~9 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=cf2fa9d60a2f851fceeda5a358e84fe8a7015c55;p=rust-lightning Merge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor Refactor `BlindedPath` construction utils --- cf2fa9d60a2f851fceeda5a358e84fe8a7015c55 diff --cc lightning/src/blinded_path/message.rs index 5c8875d80,f6c7882da..e3899b50e --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@@ -371,11 -371,11 +371,11 @@@ impl_writeable_tlv_based_enum!(OffersCo /// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`. pub(super) fn blinded_hops( - secp_ctx: &Secp256k1, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey, - context: MessageContext, session_priv: &SecretKey + secp_ctx: &Secp256k1, intermediate_nodes: &[MessageForwardNode], + recipient_node_id: PublicKey, context: MessageContext, session_priv: &SecretKey, ) -> Result, 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)) diff --cc lightning/src/blinded_path/payment.rs index ea7d0545d,ac0b78643..f741cead2 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@@ -459,14 -459,17 +459,17 @@@ impl Readable for BlindedPaymentTlvs /// Construct blinded payment hops for the given `intermediate_nodes` and payee info. pub(super) fn blinded_hops( - secp_ctx: &Secp256k1, intermediate_nodes: &[ForwardNode], - payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey + secp_ctx: &Secp256k1, intermediate_nodes: &[PaymentForwardNode], + payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey, ) -> Result, 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) + + let path = pks.zip(tlvs); + + utils::construct_blinded_hops(secp_ctx, path, session_priv) } /// `None` if underflow occurs.