Skip to content

Commit 1518e67

Browse files
committed
Clean up Hop match arms
Essentially a follow-up to 38284a0, deduplicating some additional code.
1 parent 38284a0 commit 1518e67

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4427,27 +4427,16 @@ where
44274427
}
44284428
}
44294429
match decoded_hop {
4430-
onion_utils::Hop::Receive(next_hop_data) => {
4431-
// OUR PAYMENT!
4432-
let current_height: u32 = self.best_block.read().unwrap().height;
4433-
match create_recv_pending_htlc_info(msgs::InboundOnionPayload::Receive(next_hop_data), shared_secret, msg.payment_hash,
4434-
msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
4435-
current_height)
4436-
{
4437-
Ok(info) => {
4438-
// Note that we could obviously respond immediately with an update_fulfill_htlc
4439-
// message, however that would leak that we are the recipient of this payment, so
4440-
// instead we stay symmetric with the forwarding case, only responding (after a
4441-
// delay) once they've send us a commitment_signed!
4442-
PendingHTLCStatus::Forward(info)
4443-
},
4444-
Err(InboundHTLCErr { err_code, err_data, msg }) => return_err!(msg, err_code, &err_data)
4445-
}
4446-
},
4447-
onion_utils::Hop::BlindedReceive(next_hop_data) => {
4430+
onion_utils::Hop::Receive { .. } | onion_utils::Hop::BlindedReceive { .. } => {
4431+
let inbound_onion_payload = match decoded_hop {
4432+
onion_utils::Hop::Receive(hop_data) => msgs::InboundOnionPayload::Receive(hop_data),
4433+
onion_utils::Hop::BlindedReceive(hop_data) => msgs::InboundOnionPayload::BlindedReceive(hop_data),
4434+
_ => unreachable!()
4435+
};
4436+
44484437
// OUR PAYMENT!
44494438
let current_height: u32 = self.best_block.read().unwrap().height;
4450-
match create_recv_pending_htlc_info(msgs::InboundOnionPayload::BlindedReceive(next_hop_data), shared_secret, msg.payment_hash,
4439+
match create_recv_pending_htlc_info(inbound_onion_payload, shared_secret, msg.payment_hash,
44514440
msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
44524441
current_height)
44534442
{

0 commit comments

Comments
 (0)