Skip to content

Commit 16d412d

Browse files
committed
f: alternative (more legible?) approach for older Rust version CI fixes for the façade method
1 parent 6511395 commit 16d412d

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -949,25 +949,29 @@ where
949949
_ => unreachable!(),
950950
};
951951

952-
let secondary_session_priv = path.has_trampoline_hops().then(|| {
952+
if path.has_trampoline_hops() {
953953
// If we have Trampoline hops, the outer onion session_priv is a hash of the inner one.
954954
let session_priv_hash = Sha256::hash(&primary_session_priv.secret_bytes()).to_byte_array();
955-
SecretKey::from_slice(&session_priv_hash[..]).expect("You broke SHA-256!")
956-
});
957-
958-
// the outer onion's session priv is the secondary (if it's set), or the primary as its fallback
959-
let outer_session_priv = secondary_session_priv.as_ref().unwrap_or(primary_session_priv);
960-
// the inner onion's session priv is only set if there is a secondary
961-
let inner_session_priv = secondary_session_priv.as_ref().map(|_| primary_session_priv);
962-
963-
process_onion_failure_inner(
964-
secp_ctx,
965-
logger,
966-
htlc_source,
967-
outer_session_priv,
968-
inner_session_priv,
969-
encrypted_packet,
970-
)
955+
let outer_session_priv =
956+
SecretKey::from_slice(&session_priv_hash[..]).expect("You broke SHA-256!");
957+
process_onion_failure_inner(
958+
secp_ctx,
959+
logger,
960+
htlc_source,
961+
&outer_session_priv,
962+
Some(primary_session_priv),
963+
encrypted_packet,
964+
)
965+
} else {
966+
process_onion_failure_inner(
967+
secp_ctx,
968+
logger,
969+
htlc_source,
970+
primary_session_priv,
971+
None,
972+
encrypted_packet,
973+
)
974+
}
971975
}
972976

973977
/// Process failure we got back from upstream on a payment we sent (implying htlc_source is an

0 commit comments

Comments
 (0)