diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index c7ea7d5646..653cc5c076 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -581,6 +581,23 @@ struct MsgHandleErrInternal { payment_hash: Option } impl MsgHandleErrInternal { + #[inline] + fn from_update_add_htlc(err: String, channel_id: ChannelId, payment_hash: PaymentHash) -> Self { + Self { + err: LightningError { + err: err.clone(), + action: msgs::ErrorAction::SendErrorMessage { + msg: msgs::ErrorMessage { + channel_id, + data: err + }, + }, + }, + closes_channel: false, + shutdown_finish: None, + payment_hash: Some(payment_hash) + } + } #[inline] fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self { Self { @@ -7638,7 +7655,7 @@ where let peer_state_mutex = per_peer_state.get(counterparty_node_id) .ok_or_else(|| { debug_assert!(false); - MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id) + 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) })?; let mut peer_state_lock = peer_state_mutex.lock().unwrap(); let peer_state = &mut *peer_state_lock; @@ -7697,7 +7714,7 @@ where "Got an update_add_htlc message for an unfunded channel!".into())), chan_phase_entry); } }, - 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)) + 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)) } Ok(()) }