Skip to content

Commit 835f5aa

Browse files
committed
Add from_update_add_htlc to MsgHandlerInternal impl
1 parent fd3e873 commit 835f5aa

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
@@ -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 {
@@ -6780,7 +6797,7 @@ where
67806797
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
67816798
.ok_or_else(|| {
67826799
debug_assert!(false);
6783-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
6800+
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)
67846801
})?;
67856802
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
67866803
let peer_state = &mut *peer_state_lock;
@@ -6838,7 +6855,7 @@ where
68386855
"Got an update_add_htlc message for an unfunded channel!".into())), chan_phase_entry);
68396856
}
68406857
},
6841-
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))
6858+
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))
68426859
}
68436860
Ok(())
68446861
}

0 commit comments

Comments
 (0)