@@ -57,35 +57,14 @@ impl Writeable for ReceiveTlvs {
5757pub ( super )  fn  blinded_hops < T :  secp256k1:: Signing  + secp256k1:: Verification > ( 
5858	secp_ctx :  & Secp256k1 < T > ,  unblinded_path :  & [ PublicKey ] ,  session_priv :  & SecretKey 
5959)  -> Result < Vec < BlindedHop > ,  secp256k1:: Error >  { 
60- 	let  mut  blinded_hops = Vec :: with_capacity ( unblinded_path. len ( ) ) ; 
60+ 	let  blinded_tlvs = unblinded_path. iter ( ) 
61+ 		. skip ( 1 )  // The first node's TLVs contains the next node's pubkey 
62+ 		. map ( |pk| { 
63+ 			ControlTlvs :: Forward ( ForwardTlvs  {  next_node_id :  * pk,  next_blinding_override :  None  } ) 
64+ 		} ) 
65+ 		. chain ( core:: iter:: once ( ControlTlvs :: Receive ( ReceiveTlvs  {  path_id :  None  } ) ) ) ; 
6166
62- 	let  mut  prev_ss_and_blinded_node_id = None ; 
63- 	utils:: construct_keys_callback ( secp_ctx,  unblinded_path. iter ( ) ,  None ,  session_priv, 
64- 		|blinded_node_id,  _,  _,  encrypted_payload_ss,  unblinded_pk,  _| { 
65- 			if  let  Some ( ( prev_ss,  prev_blinded_node_id) )  = prev_ss_and_blinded_node_id { 
66- 				if  let  Some ( pk)  = unblinded_pk { 
67- 					let  payload = ForwardTlvs  { 
68- 						next_node_id :  pk, 
69- 						next_blinding_override :  None , 
70- 					} ; 
71- 					blinded_hops. push ( BlindedHop  { 
72- 						blinded_node_id :  prev_blinded_node_id, 
73- 						encrypted_payload :  utils:: encrypt_payload ( payload,  prev_ss) , 
74- 					} ) ; 
75- 				}  else  {  debug_assert ! ( false ) ;  } 
76- 			} 
77- 			prev_ss_and_blinded_node_id = Some ( ( encrypted_payload_ss,  blinded_node_id) ) ; 
78- 		} ) ?; 
79- 
80- 	if  let  Some ( ( final_ss,  final_blinded_node_id) )  = prev_ss_and_blinded_node_id { 
81- 		let  final_payload = ReceiveTlvs  {  path_id :  None  } ; 
82- 		blinded_hops. push ( BlindedHop  { 
83- 			blinded_node_id :  final_blinded_node_id, 
84- 			encrypted_payload :  utils:: encrypt_payload ( final_payload,  final_ss) , 
85- 		} ) ; 
86- 	}  else  {  debug_assert ! ( false )  } 
87- 
88- 	Ok ( blinded_hops) 
67+ 	utils:: construct_blinded_hops ( secp_ctx,  unblinded_path. iter ( ) ,  blinded_tlvs,  session_priv) 
8968} 
9069
9170// Advance the blinded onion message path by one hop, so make the second hop into the new 
0 commit comments