Skip to content

Commit 99539d7

Browse files
committed
Add from_update_add_htlc to MsgHandlerInternal impl
Have the same functionality as `send_err_msg_no_close` but with `payment_hash` added as a new required argument.
1 parent 4b89261 commit 99539d7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,23 @@ struct MsgHandleErrInternal {
581581
payment_hash: Option<PaymentHash>
582582
}
583583
impl MsgHandleErrInternal {
584+
#[inline]
585+
fn from_update_add_htlc(err: String, channel_id: ChannelId, payment_hash: PaymentHash) -> Self {
586+
Self {
587+
err: LightningError {
588+
err: err.clone(),
589+
action: msgs::ErrorAction::SendErrorMessage {
590+
msg: msgs::ErrorMessage {
591+
channel_id,
592+
data: err
593+
},
594+
},
595+
},
596+
closes_channel: false,
597+
shutdown_finish: None,
598+
payment_hash: Some(payment_hash)
599+
}
600+
}
584601
#[inline]
585602
fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self {
586603
Self {
@@ -7638,7 +7655,7 @@ where
76387655
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
76397656
.ok_or_else(|| {
76407657
debug_assert!(false);
7641-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
7658+
MsgHandleErrInternal::from_update_add_htlc(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id, msg.payment_hash)
76427659
})?;
76437660
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
76447661
let peer_state = &mut *peer_state_lock;
@@ -7697,7 +7714,7 @@ where
76977714
"Got an update_add_htlc message for an unfunded channel!".into())), chan_phase_entry);
76987715
}
76997716
},
7700-
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
7717+
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::from_update_add_htlc(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id, msg.payment_hash))
77017718
}
77027719
Ok(())
77037720
}

0 commit comments

Comments
 (0)