@@ -690,8 +690,8 @@ async fn handle_ldk_events(
690690 {
691691 tracing:: error!(
692692 "ERROR: Channel went away before we could fund it. The peer disconnected or refused the channel." ) ;
693- * unlocked_state. rgb_send_lock . lock ( ) . unwrap ( ) = false ;
694693 }
694+ * unlocked_state. rgb_send_lock . lock ( ) . unwrap ( ) = false ;
695695 }
696696 Event :: FundingTxBroadcastSafe { .. } => {
697697 // We don't use the manual broadcasting feature, so this event should never be seen.
@@ -1055,21 +1055,28 @@ async fn handle_ldk_events(
10551055 is_channel_rgb ( & channel_id, & PathBuf :: from ( & static_state. ldk_data_dir ) ) ;
10561056 tracing:: info!( "Initiator of the channel (colored: {})" , is_chan_colored) ;
10571057
1058- let _txid = tokio:: task:: spawn_blocking ( move || {
1058+ * unlocked_state. rgb_send_lock . lock ( ) . unwrap ( ) = false ;
1059+
1060+ let txid_result = tokio:: task:: spawn_blocking ( move || {
10591061 if is_chan_colored {
10601062 state_copy. rgb_send_end ( psbt_str_copy) . map ( |r| r. txid )
10611063 } else {
10621064 state_copy. rgb_send_btc_end ( psbt_str_copy)
10631065 }
10641066 } )
1065- . await
1066- . unwrap ( )
1067- . map_err ( |e| {
1068- tracing:: error!( "Error completing channel opening: {e:?}" ) ;
1069- ReplayEvent ( )
1070- } ) ?;
1067+ . await ;
10711068
1072- * unlocked_state. rgb_send_lock . lock ( ) . unwrap ( ) = false ;
1069+ match txid_result {
1070+ Ok ( Ok ( _txid) ) => { }
1071+ Ok ( Err ( e) ) => {
1072+ tracing:: error!( "Error completing channel opening: {e:?}" ) ;
1073+ return Err ( ReplayEvent ( ) ) ;
1074+ }
1075+ Err ( e) => {
1076+ tracing:: error!( "Channel opening task panicked: {e:?}" ) ;
1077+ return Err ( ReplayEvent ( ) ) ;
1078+ }
1079+ }
10731080 } else {
10741081 // acceptor
10751082 let consignment_path = static_state
@@ -1102,20 +1109,25 @@ async fn handle_ldk_events(
11021109 hex_str( & counterparty_node_id. serialize( ) ) ,
11031110 ) ;
11041111
1105- tokio:: task:: spawn_blocking ( move || {
1112+ match tokio:: task:: spawn_blocking ( move || {
11061113 unlocked_state. rgb_refresh ( false ) . unwrap ( ) ;
11071114 unlocked_state. rgb_refresh ( true ) . unwrap ( )
11081115 } )
11091116 . await
1110- . unwrap ( ) ;
1117+ {
1118+ Ok ( _) => { }
1119+ Err ( e) => {
1120+ tracing:: error!( "RGB refresh task panicked on channel ready: {e:?}" ) ;
1121+ }
1122+ }
11111123 }
11121124 Event :: ChannelClosed {
11131125 channel_id,
11141126 reason,
11151127 user_channel_id : _,
11161128 counterparty_node_id,
11171129 channel_capacity_sats : _,
1118- channel_funding_txo : _ ,
1130+ channel_funding_txo,
11191131 last_local_balance_msat : _,
11201132 } => {
11211133 tracing:: info!(
@@ -1127,6 +1139,10 @@ async fn handle_ldk_events(
11271139 reason
11281140 ) ;
11291141
1142+ if channel_funding_txo. is_none ( ) {
1143+ * unlocked_state. rgb_send_lock . lock ( ) . unwrap ( ) = false ;
1144+ }
1145+
11301146 unlocked_state. delete_channel_id ( channel_id) ;
11311147 }
11321148 Event :: DiscardFunding { channel_id, .. } => {
0 commit comments