Skip to content

Commit 1e4b75f

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 4436b65 commit 1e4b75f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lightning/src/ln/channelmanager.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,23 @@ struct MsgHandleErrInternal {
575575
payment_hash: Option<PaymentHash>
576576
}
577577
impl MsgHandleErrInternal {
578+
#[inline]
579+
fn from_update_add_htlc(err: String, channel_id: ChannelId, payment_hash: PaymentHash) -> Self {
580+
Self {
581+
err: LightningError {
582+
err: err.clone(),
583+
action: msgs::ErrorAction::SendErrorMessage {
584+
msg: msgs::ErrorMessage {
585+
channel_id,
586+
data: err
587+
},
588+
},
589+
},
590+
closes_channel: false,
591+
shutdown_finish: None,
592+
payment_hash: Some(payment_hash)
593+
}
594+
}
578595
#[inline]
579596
fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self {
580597
Self {
@@ -6959,7 +6976,7 @@ where
69596976
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
69606977
.ok_or_else(|| {
69616978
debug_assert!(false);
6962-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
6979+
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)
69636980
})?;
69646981
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
69656982
let peer_state = &mut *peer_state_lock;
@@ -7018,7 +7035,7 @@ where
70187035
"Got an update_add_htlc message for an unfunded channel!".into())), chan_phase_entry);
70197036
}
70207037
},
7021-
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))
7038+
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))
70227039
}
70237040
Ok(())
70247041
}

0 commit comments

Comments
 (0)