Skip to content

Commit 51d9218

Browse files
committed
Add a construct_keys_callback for blinded paths
When constructing a BlindedPath, an Option<Destination> parameter to construct_keys_callback is never passed. Make a separate utility function that doesn't take this parameter. This allows for using the build_keys_helper macro with a Iterator yielding items other than PublicKey.
1 parent 4922548 commit 51d9218

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lightning/src/blinded_path/utils.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,23 @@ where
114114
Ok(())
115115
}
116116

117+
#[inline]
118+
pub(super) fn construct_keys_callback_for_blinded_path<'a, T, I, F>(
119+
secp_ctx: &Secp256k1<T>, unblinded_path: I, session_priv: &SecretKey, mut callback: F,
120+
) -> Result<(), secp256k1::Error>
121+
where
122+
T: secp256k1::Signing + secp256k1::Verification,
123+
I: Iterator<Item=PublicKey>,
124+
F: FnMut(PublicKey, SharedSecret, PublicKey, [u8; 32], Option<PublicKey>, Option<Vec<u8>>),
125+
{
126+
build_keys_helper!(session_priv, secp_ctx, callback);
127+
128+
for pk in unblinded_path {
129+
build_keys_in_loop!(pk, false, None);
130+
}
131+
Ok(())
132+
}
133+
117134
// Panics if `unblinded_tlvs` length is less than `unblinded_pks` length
118135
pub(crate) fn construct_blinded_hops<'a, T, I1, I2>(
119136
secp_ctx: &Secp256k1<T>, unblinded_pks: I1, mut unblinded_tlvs: I2, session_priv: &SecretKey
@@ -125,8 +142,8 @@ where
125142
I2::Item: Writeable
126143
{
127144
let mut blinded_hops = Vec::with_capacity(unblinded_pks.size_hint().0);
128-
construct_keys_callback(
129-
secp_ctx, unblinded_pks, None, session_priv,
145+
construct_keys_callback_for_blinded_path(
146+
secp_ctx, unblinded_pks, session_priv,
130147
|blinded_node_id, _, _, encrypted_payload_rho, _, _| {
131148
blinded_hops.push(BlindedHop {
132149
blinded_node_id,

0 commit comments

Comments
 (0)