Skip to content

Commit 4198eda

Browse files
Tweak initialization of HTLCForwardInfo in fail_htlc_backwards_internal
Makes the next commit adding support for failing blinded HTLCs in said method easier to read.
1 parent 7bb4a23 commit 4198eda

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5249,16 +5249,20 @@ where
52495249
"Failing {}HTLC with payment_hash {} backwards from us: {:?}",
52505250
if blinded_failure.is_some() { "blinded " } else { "" }, &payment_hash, onion_error
52515251
);
5252-
let err_packet = match blinded_failure {
5252+
let failure = match blinded_failure {
52535253
Some(BlindedFailure::FromIntroductionNode) => {
52545254
let blinded_onion_error = HTLCFailReason::reason(INVALID_ONION_BLINDING, vec![0; 32]);
5255-
blinded_onion_error.get_encrypted_failure_packet(
5255+
let err_packet = blinded_onion_error.get_encrypted_failure_packet(
52565256
incoming_packet_shared_secret, phantom_shared_secret
5257-
)
5257+
);
5258+
HTLCForwardInfo::FailHTLC { htlc_id: *htlc_id, err_packet }
52585259
},
52595260
Some(BlindedFailure::FromBlindedNode) => todo!(),
52605261
None => {
5261-
onion_error.get_encrypted_failure_packet(incoming_packet_shared_secret, phantom_shared_secret)
5262+
let err_packet = onion_error.get_encrypted_failure_packet(
5263+
incoming_packet_shared_secret, phantom_shared_secret
5264+
);
5265+
HTLCForwardInfo::FailHTLC { htlc_id: *htlc_id, err_packet }
52625266
}
52635267
};
52645268

@@ -5269,10 +5273,10 @@ where
52695273
}
52705274
match forward_htlcs.entry(*short_channel_id) {
52715275
hash_map::Entry::Occupied(mut entry) => {
5272-
entry.get_mut().push(HTLCForwardInfo::FailHTLC { htlc_id: *htlc_id, err_packet });
5276+
entry.get_mut().push(failure);
52735277
},
52745278
hash_map::Entry::Vacant(entry) => {
5275-
entry.insert(vec!(HTLCForwardInfo::FailHTLC { htlc_id: *htlc_id, err_packet }));
5279+
entry.insert(vec!(failure));
52765280
}
52775281
}
52785282
mem::drop(forward_htlcs);

0 commit comments

Comments
 (0)