Skip to content

Commit 57c9827

Browse files
committed
refactor: make payment_hash optional in decode_next_payment_hop
Allow passing None for payment_hash to support differential fuzzing scenarios where onion decoding needs to be tested independently of payment hash.
1 parent 0440798 commit 57c9827

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7282,7 +7282,7 @@ where
72827282
&onion_packet.public_key.unwrap(),
72837283
&onion_packet.hop_data,
72847284
onion_packet.hmac,
7285-
payment_hash,
7285+
Some(payment_hash),
72867286
None,
72877287
&*self.node_signer,
72887288
);

lightning/src/ln/onion_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ where
596596

597597
let next_hop = match onion_utils::decode_next_payment_hop(
598598
Recipient::Node, &msg.onion_routing_packet.public_key.unwrap(), &msg.onion_routing_packet.hop_data[..], msg.onion_routing_packet.hmac,
599-
msg.payment_hash, msg.blinding_point, node_signer
599+
Some(msg.payment_hash), msg.blinding_point, node_signer
600600
) {
601601
Ok(res) => res,
602602
Err(onion_utils::OnionDecodeErr::Malformed { err_msg, reason }) => {

lightning/src/ln/onion_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ mod fuzzy_onion_utils {
11991199

12001200
pub fn decode_next_payment_hop<NS: Deref>(
12011201
recipient: Recipient, hop_pubkey: &PublicKey, hop_data: &[u8], hmac_bytes: [u8; 32],
1202-
payment_hash: PaymentHash, blinding_point: Option<PublicKey>, node_signer: NS,
1202+
payment_hash: Option<PaymentHash>, blinding_point: Option<PublicKey>, node_signer: NS,
12031203
) -> Result<Hop, OnionDecodeErr>
12041204
where
12051205
NS::Target: NodeSigner,
@@ -1217,7 +1217,7 @@ mod fuzzy_onion_utils {
12171217
shared_secret.secret_bytes(),
12181218
hop_data,
12191219
hmac_bytes,
1220-
Some(payment_hash),
1220+
payment_hash,
12211221
(blinding_point, &(*node_signer)),
12221222
);
12231223
match decoded_hop {
@@ -1286,7 +1286,7 @@ mod fuzzy_onion_utils {
12861286
trampoline_shared_secret,
12871287
&hop_data.trampoline_packet.hop_data,
12881288
hop_data.trampoline_packet.hmac,
1289-
Some(payment_hash),
1289+
payment_hash,
12901290
(blinding_point, node_signer),
12911291
);
12921292
match decoded_trampoline_hop {

0 commit comments

Comments
 (0)