Skip to content

Commit 830ffa0

Browse files
authored
Merge pull request #3684 from joostjager/remove-unused-code
Remove unused code in process_onion_failure
2 parents b18e0d9 + 0b3f0af commit 830ffa0

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

lightning/src/ln/onion_utils.rs

+4-29
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ where
957957
process_onion_failure_inner(
958958
secp_ctx,
959959
logger,
960-
htlc_source,
960+
path,
961961
&outer_session_priv,
962962
Some(primary_session_priv),
963963
encrypted_packet,
@@ -966,7 +966,7 @@ where
966966
process_onion_failure_inner(
967967
secp_ctx,
968968
logger,
969-
htlc_source,
969+
path,
970970
primary_session_priv,
971971
None,
972972
encrypted_packet,
@@ -978,19 +978,12 @@ where
978978
/// OutboundRoute).
979979
#[inline]
980980
pub(super) fn process_onion_failure_inner<T: secp256k1::Signing, L: Deref>(
981-
secp_ctx: &Secp256k1<T>, logger: &L, htlc_source: &HTLCSource, outer_session_priv: &SecretKey,
981+
secp_ctx: &Secp256k1<T>, logger: &L, path: &Path, outer_session_priv: &SecretKey,
982982
inner_session_priv: Option<&SecretKey>, mut encrypted_packet: OnionErrorPacket,
983983
) -> DecodedOnionFailure
984984
where
985985
L::Target: Logger,
986986
{
987-
let (path, first_hop_htlc_msat) = match htlc_source {
988-
HTLCSource::OutboundRoute { ref path, ref first_hop_htlc_msat, .. } => {
989-
(path, first_hop_htlc_msat)
990-
},
991-
_ => unreachable!(),
992-
};
993-
994987
// Check that there is at least enough data for an hmac, otherwise none of the checking that we may do makes sense.
995988
// Also prevent slice out of bounds further down.
996989
if encrypted_packet.data.len() < 32 {
@@ -1022,7 +1015,6 @@ where
10221015
failed_within_blinded_path: bool,
10231016
}
10241017
let mut res: Option<FailureLearnings> = None;
1025-
let mut htlc_msat = *first_hop_htlc_msat;
10261018
let mut _error_code_ret = None;
10271019
let mut _error_packet_ret = None;
10281020
let mut is_from_final_non_blinded_node = false;
@@ -1038,13 +1030,6 @@ where
10381030
}
10391031

10401032
impl<'a> ErrorHop<'a> {
1041-
fn fee_msat(&self) -> u64 {
1042-
match self {
1043-
ErrorHop::RouteHop(rh) => rh.fee_msat,
1044-
ErrorHop::TrampolineHop(th) => th.fee_msat,
1045-
}
1046-
}
1047-
10481033
fn pubkey(&self) -> &PublicKey {
10491034
match self {
10501035
ErrorHop::RouteHop(rh) => rh.node_pubkey(),
@@ -1161,9 +1146,6 @@ where
11611146
}
11621147
};
11631148

1164-
let amt_to_forward = htlc_msat - route_hop.fee_msat();
1165-
htlc_msat = amt_to_forward;
1166-
11671149
crypt_failure_packet(shared_secret.as_ref(), &mut encrypted_packet);
11681150

11691151
let um = gen_um_from_shared_secret(shared_secret.as_ref());
@@ -2539,20 +2521,13 @@ mod tests {
25392521
let trampoline_session_priv = SecretKey::from_slice(&[3; 32]).unwrap();
25402522
let outer_session_priv = SecretKey::from_slice(&[4; 32]).unwrap();
25412523

2542-
let htlc_source = HTLCSource::OutboundRoute {
2543-
path: build_trampoline_test_path(),
2544-
session_priv: trampoline_session_priv,
2545-
first_hop_htlc_msat: dummy_amt_msat,
2546-
payment_id: PaymentId([1; 32]),
2547-
};
2548-
25492524
let error_packet_hex = "f8941a320b8fde4ad7b9b920c69cbf334114737497d93059d77e591eaa78d6334d3e2aeefcb0cc83402eaaf91d07d695cd895d9cad1018abdaf7d2a49d7657b1612729db7f393f0bb62b25afaaaa326d72a9214666025385033f2ec4605dcf1507467b5726d806da180ea224a7d8631cd31b0bdd08eead8bfe14fc8c7475e17768b1321b54dd4294aecc96da391efe0ca5bd267a45ee085c85a60cf9a9ac152fa4795fff8700a3ea4f848817f5e6943e855ab2e86f6929c9e885d8b20c49b14d2512c59ed21f10bd38691110b0d82c00d9fa48a20f10c7550358724c6e8e2b966e56a0aadf458695b273768062fa7c6e60eb72d4cdc67bf525c194e4a17fdcaa0e9d80480b586bf113f14eea530b6728a1c53fe5cee092e24a90f21f4b764015e7ed5e23";
25502525
let error_packet =
25512526
OnionErrorPacket { data: <Vec<u8>>::from_hex(error_packet_hex).unwrap() };
25522527
let decrypted_failure = process_onion_failure_inner(
25532528
&secp_ctx,
25542529
&logger,
2555-
&htlc_source,
2530+
&build_trampoline_test_path(),
25562531
&outer_session_priv,
25572532
Some(&trampoline_session_priv),
25582533
error_packet,

0 commit comments

Comments
 (0)