Skip to content

Commit 7df3773

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 a40d49a commit 7df3773

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
@@ -580,6 +580,23 @@ struct MsgHandleErrInternal {
580580
payment_hash: Option<PaymentHash>
581581
}
582582
impl MsgHandleErrInternal {
583+
#[inline]
584+
fn from_update_add_htlc(err: String, channel_id: ChannelId, payment_hash: PaymentHash) -> Self {
585+
Self {
586+
err: LightningError {
587+
err: err.clone(),
588+
action: msgs::ErrorAction::SendErrorMessage {
589+
msg: msgs::ErrorMessage {
590+
channel_id,
591+
data: err
592+
},
593+
},
594+
},
595+
closes_channel: false,
596+
shutdown_finish: None,
597+
payment_hash: Some(payment_hash)
598+
}
599+
}
583600
#[inline]
584601
fn send_err_msg_no_close(err: String, channel_id: ChannelId) -> Self {
585602
Self {
@@ -7637,7 +7654,7 @@ where
76377654
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
76387655
.ok_or_else(|| {
76397656
debug_assert!(false);
7640-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
7657+
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)
76417658
})?;
76427659
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
76437660
let peer_state = &mut *peer_state_lock;
@@ -7696,7 +7713,7 @@ where
76967713
"Got an update_add_htlc message for an unfunded channel!".into())), chan_phase_entry);
76977714
}
76987715
},
7699-
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))
7716+
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))
77007717
}
77017718
Ok(())
77027719
}

0 commit comments

Comments
 (0)