@@ -1354,15 +1354,15 @@ pub struct PhantomRouteHints {
1354
1354
}
1355
1355
1356
1356
macro_rules! handle_error {
1357
- ( $self: ident, $internal: expr, $counterparty_node_id: expr) => {
1357
+ ( $self: ident, $internal: expr, $counterparty_node_id: expr) => { {
1358
+ // In testing, ensure there are no deadlocks where the lock is already held upon
1359
+ // entering the macro.
1360
+ debug_assert_ne!( $self. pending_events. held_by_thread( ) , LockHeldState :: HeldByThread ) ;
1361
+ debug_assert_ne!( $self. per_peer_state. held_by_thread( ) , LockHeldState :: HeldByThread ) ;
1362
+
1358
1363
match $internal {
1359
1364
Ok ( msg) => Ok ( msg) ,
1360
1365
Err ( MsgHandleErrInternal { err, chan_id, shutdown_finish } ) => {
1361
- // In testing, ensure there are no deadlocks where the lock is already held upon
1362
- // entering the macro.
1363
- debug_assert_ne!( $self. pending_events. held_by_thread( ) , LockHeldState :: HeldByThread ) ;
1364
- debug_assert_ne!( $self. per_peer_state. held_by_thread( ) , LockHeldState :: HeldByThread ) ;
1365
-
1366
1366
let mut msg_events = Vec :: with_capacity( 2 ) ;
1367
1367
1368
1368
if let Some ( ( shutdown_res, update_option) ) = shutdown_finish {
@@ -1401,7 +1401,7 @@ macro_rules! handle_error {
1401
1401
Err ( err)
1402
1402
} ,
1403
1403
}
1404
- }
1404
+ } }
1405
1405
}
1406
1406
1407
1407
macro_rules! update_maps_on_chan_removal {
@@ -2786,29 +2786,34 @@ where
2786
2786
2787
2787
let mut peer_state_lock = peer_state_mutex. lock ( ) . unwrap ( ) ;
2788
2788
let peer_state = & mut * peer_state_lock;
2789
- let ( chan, msg) = {
2790
- let ( res, chan) = {
2791
- match peer_state. channel_by_id . remove ( temporary_channel_id) {
2792
- Some ( mut chan) => {
2793
- let funding_txo = find_funding_output ( & chan, & funding_transaction) ?;
2794
-
2795
- ( chan. get_outbound_funding_created ( funding_transaction, funding_txo, & self . logger )
2796
- . map_err ( |e| if let ChannelError :: Close ( msg) = e {
2797
- MsgHandleErrInternal :: from_finish_shutdown ( msg, chan. channel_id ( ) , chan. get_user_id ( ) , chan. force_shutdown ( true ) , None )
2798
- } else { unreachable ! ( ) ; } )
2799
- , chan)
2789
+ let ( msg, chan) = match peer_state. channel_by_id . remove ( temporary_channel_id) {
2790
+ Some ( mut chan) => {
2791
+ let funding_txo = find_funding_output ( & chan, & funding_transaction) ?;
2792
+
2793
+ let funding_res = chan. get_outbound_funding_created ( funding_transaction, funding_txo, & self . logger )
2794
+ . map_err ( |e| if let ChannelError :: Close ( msg) = e {
2795
+ MsgHandleErrInternal :: from_finish_shutdown ( msg, chan. channel_id ( ) , chan. get_user_id ( ) , chan. force_shutdown ( true ) , None )
2796
+ } else { unreachable ! ( ) ; } ) ;
2797
+ match funding_res {
2798
+ Ok ( funding_msg) => ( funding_msg, chan) ,
2799
+ Err ( _) => {
2800
+ mem:: drop ( peer_state_lock) ;
2801
+ mem:: drop ( per_peer_state) ;
2802
+
2803
+ let _ = handle_error ! ( self , funding_res, chan. get_counterparty_node_id( ) ) ;
2804
+ return Err ( APIError :: ChannelUnavailable {
2805
+ err : "Signer refused to sign the initial commitment transaction" . to_owned ( )
2806
+ } ) ;
2800
2807
} ,
2801
- None => { return Err ( APIError :: ChannelUnavailable { err : format ! ( "Channel with id {} not found for the passed counterparty node_id {}" , log_bytes!( * temporary_channel_id) , counterparty_node_id) } ) } ,
2802
2808
}
2803
- } ;
2804
- match handle_error ! ( self , res, chan. get_counterparty_node_id( ) ) {
2805
- Ok ( funding_msg) => {
2806
- ( chan, funding_msg)
2807
- } ,
2808
- Err ( _) => { return Err ( APIError :: ChannelUnavailable {
2809
- err : "Signer refused to sign the initial commitment transaction" . to_owned ( )
2810
- } ) } ,
2811
- }
2809
+ } ,
2810
+ None => {
2811
+ return Err ( APIError :: ChannelUnavailable {
2812
+ err : format ! (
2813
+ "Channel with id {} not found for the passed counterparty node_id {}" ,
2814
+ log_bytes!( * temporary_channel_id) , counterparty_node_id) ,
2815
+ } )
2816
+ } ,
2812
2817
} ;
2813
2818
2814
2819
peer_state. pending_msg_events . push ( events:: MessageSendEvent :: SendFundingCreated {
0 commit comments