Skip to content

Commit 418dc62

Browse files
committed
f Panic in case of APIMisuseError
1 parent c2bea3d commit 418dc62

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/event.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::logger::{log_error, log_given_level, log_info, log_internal, Logger};
88
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
99
use lightning::ln::PaymentHash;
1010
use lightning::routing::gossip::NodeId;
11+
use lightning::util::errors::APIError;
1112
use lightning::util::events::Event as LdkEvent;
1213
use lightning::util::events::EventHandler as LdkEventHandler;
1314
use lightning::util::events::PaymentPurpose;
@@ -305,16 +306,30 @@ where
305306
) {
306307
Ok(final_tx) => {
307308
// Give the funding transaction back to LDK for opening the channel.
308-
if self
309-
.channel_manager
310-
.funding_transaction_generated(
311-
&temporary_channel_id,
312-
&counterparty_node_id,
313-
final_tx,
314-
)
315-
.is_err()
316-
{
317-
log_error!(self.logger, "Channel went away before we could fund it. The peer disconnected or refused the channel");
309+
match self.channel_manager.funding_transaction_generated(
310+
&temporary_channel_id,
311+
&counterparty_node_id,
312+
final_tx,
313+
) {
314+
Ok(()) => {}
315+
Err(APIError::APIMisuseError { err }) => {
316+
log_error!(self.logger, "Panicking due to APIMisuseError: {}", err);
317+
panic!("APIMisuseError: {}", err);
318+
}
319+
Err(APIError::ChannelUnavailable { err }) => {
320+
log_error!(
321+
self.logger,
322+
"Failed to process funding transaction as channel went away before we could fund it: {}",
323+
err
324+
)
325+
}
326+
Err(err) => {
327+
log_error!(
328+
self.logger,
329+
"Failed to process funding transaction: {:?}",
330+
err
331+
)
332+
}
318333
}
319334
}
320335
Err(_err) => {

0 commit comments

Comments
 (0)