]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor
authordunxen <git@dunxen.dev>
Tue, 27 Aug 2024 11:28:43 +0000 (13:28 +0200)
committerGitHub <noreply@github.com>
Tue, 27 Aug 2024 11:28:43 +0000 (13:28 +0200)
Refactor `BlindedPath` construction utils

1  2 
lightning/src/blinded_path/message.rs
lightning/src/blinded_path/payment.rs
lightning/src/ln/blinded_payment_tests.rs
lightning/src/onion_message/messenger.rs

index 5c8875d80ce61de88c99eaac9c46efd74868b9f3,f6c7882da1617ab9db15a95a932fb2e7c1e9d25d..e3899b50edbb822ce66b17c82626d84b219c1c55
@@@ -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<T: secp256k1::Signing + secp256k1::Verification>(
 -      secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode], recipient_node_id: PublicKey,
 -      context: MessageContext, session_priv: &SecretKey
 +      secp_ctx: &Secp256k1<T>, intermediate_nodes: &[MessageForwardNode],
 +      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))
index ea7d0545de8c6295563507b648fe0c49afa1ba4f,ac0b78643cbdfa920b2ed05f53f40f1cd0a8334b..f741cead26dc256d113b2be6a442a50efa396e7b
@@@ -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<T: secp256k1::Signing + secp256k1::Verification>(
 -      secp_ctx: &Secp256k1<T>, intermediate_nodes: &[ForwardNode],
 -      payee_node_id: PublicKey, payee_tlvs: ReceiveTlvs, session_priv: &SecretKey
 +      secp_ctx: &Secp256k1<T>, intermediate_nodes: &[PaymentForwardNode],
 +      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)
+       let path = pks.zip(tlvs);
+       utils::construct_blinded_hops(secp_ctx, path, session_priv)
  }
  
  /// `None` if underflow occurs.