@@ -181,7 +181,7 @@ impl CbfChainSource {
181181 ///
182182 /// Delegates to [`Self::build_cbf_node_static`], passing all needed fields.
183183 fn build_cbf_node ( & self ) -> ( CbfNode , Client ) {
184- let wallet = self . onchain_wallet . lock ( ) . unwrap ( ) . clone ( ) ;
184+ let wallet = self . onchain_wallet . lock ( ) . expect ( "lock" ) . clone ( ) ;
185185 Self :: build_cbf_node_static (
186186 & self . peers ,
187187 & self . sync_config ,
@@ -262,14 +262,14 @@ impl CbfChainSource {
262262 /// processing tasks — up to [`MAX_RESTART_RETRIES`] consecutive failures
263263 /// with exponential backoff starting at [`INITIAL_BACKOFF_MS`].
264264 pub ( crate ) fn start ( & self , runtime : Arc < Runtime > , onchain_wallet : Arc < Wallet > ) {
265- let mut status = self . cbf_runtime_status . lock ( ) . unwrap ( ) ;
265+ let mut status = self . cbf_runtime_status . lock ( ) . expect ( "lock" ) ;
266266 if matches ! ( * status, CbfRuntimeStatus :: Started { .. } ) {
267267 debug_assert ! ( false , "We shouldn't call start if we're already started" ) ;
268268 return ;
269269 }
270270
271271 // Store the wallet reference for future restarts.
272- * self . onchain_wallet . lock ( ) . unwrap ( ) = Some ( Arc :: clone ( & onchain_wallet) ) ;
272+ * self . onchain_wallet . lock ( ) . expect ( "lock" ) = Some ( Arc :: clone ( & onchain_wallet) ) ;
273273
274274 let ( node, client) = self . build_cbf_node ( ) ;
275275
@@ -338,7 +338,7 @@ impl CbfChainSource {
338338 retries,
339339 e,
340340 ) ;
341- * restart_status. lock ( ) . unwrap ( ) = CbfRuntimeStatus :: Stopped ;
341+ * restart_status. lock ( ) . expect ( "lock" ) = CbfRuntimeStatus :: Stopped ;
342342 break ;
343343 }
344344 log_error ! (
@@ -375,7 +375,7 @@ impl CbfChainSource {
375375 } = new_client;
376376
377377 // Swap the requester so callers pick up the new handle.
378- * restart_status. lock ( ) . unwrap ( ) =
378+ * restart_status. lock ( ) . expect ( "lock" ) =
379379 CbfRuntimeStatus :: Started { requester : new_requester } ;
380380
381381 current_node = new_node;
@@ -390,7 +390,7 @@ impl CbfChainSource {
390390
391391 /// Shut down the bip157 node and stop all background tasks.
392392 pub ( crate ) fn stop ( & self ) {
393- let mut status = self . cbf_runtime_status . lock ( ) . unwrap ( ) ;
393+ let mut status = self . cbf_runtime_status . lock ( ) . expect ( "lock" ) ;
394394 match & * status {
395395 CbfRuntimeStatus :: Started { requester } => {
396396 let _ = requester. shutdown ( ) ;
@@ -428,7 +428,7 @@ impl CbfChainSource {
428428 tip. height,
429429 tip. hash,
430430 ) ;
431- if let Some ( tx) = state. sync_completion_tx . lock ( ) . unwrap ( ) . take ( ) {
431+ if let Some ( tx) = state. sync_completion_tx . lock ( ) . expect ( "lock" ) . take ( ) {
432432 let _ = tx. send ( sync_update) ;
433433 }
434434 } ,
@@ -457,12 +457,12 @@ impl CbfChainSource {
457457 if skip_height > 0 && indexed_filter. height ( ) <= skip_height {
458458 continue ;
459459 }
460- let scripts = state. watched_scripts . read ( ) . unwrap ( ) ;
460+ let scripts = state. watched_scripts . read ( ) . expect ( "lock" ) ;
461461 if !scripts. is_empty ( ) && indexed_filter. contains_any ( scripts. iter ( ) ) {
462462 state
463463 . matched_block_hashes
464464 . lock ( )
465- . unwrap ( )
465+ . expect ( "lock" )
466466 . push ( ( indexed_filter. height ( ) , indexed_filter. block_hash ( ) ) ) ;
467467 }
468468 log_trace ! ( logger, "CBF received filter at height {}" , indexed_filter. height( ) , ) ;
@@ -472,7 +472,7 @@ impl CbfChainSource {
472472 }
473473
474474 fn requester ( & self ) -> Result < Requester , Error > {
475- let status = self . cbf_runtime_status . lock ( ) . unwrap ( ) ;
475+ let status = self . cbf_runtime_status . lock ( ) . expect ( "lock" ) ;
476476 match & * status {
477477 CbfRuntimeStatus :: Started { requester } if requester. is_running ( ) => {
478478 Ok ( requester. clone ( ) )
@@ -500,21 +500,21 @@ impl CbfChainSource {
500500 /// leaks between scans. The success path performs inline cleanup instead.
501501 fn cleanup_scan_state ( & self ) {
502502 self . filter_skip_height . store ( 0 , Ordering :: Release ) ;
503- self . watched_scripts . write ( ) . unwrap ( ) . clear ( ) ;
504- self . matched_block_hashes . lock ( ) . unwrap ( ) . clear ( ) ;
505- if let Some ( tx) = self . sync_completion_tx . lock ( ) . unwrap ( ) . take ( ) {
503+ self . watched_scripts . write ( ) . expect ( "lock" ) . clear ( ) ;
504+ self . matched_block_hashes . lock ( ) . expect ( "lock" ) . clear ( ) ;
505+ if let Some ( tx) = self . sync_completion_tx . lock ( ) . expect ( "lock" ) . take ( ) {
506506 drop ( tx) ;
507507 }
508508 }
509509
510510 /// Register a transaction script for Lightning channel monitoring.
511511 pub ( crate ) fn register_tx ( & self , _txid : & Txid , script_pubkey : & Script ) {
512- self . registered_scripts . lock ( ) . unwrap ( ) . push ( script_pubkey. to_owned ( ) ) ;
512+ self . registered_scripts . lock ( ) . expect ( "lock" ) . push ( script_pubkey. to_owned ( ) ) ;
513513 }
514514
515515 /// Register a watched output script for Lightning channel monitoring.
516516 pub ( crate ) fn register_output ( & self , output : WatchedOutput ) {
517- self . registered_scripts . lock ( ) . unwrap ( ) . push ( output. script_pubkey . clone ( ) ) ;
517+ self . registered_scripts . lock ( ) . expect ( "lock" ) . push ( output. script_pubkey . clone ( ) ) ;
518518 }
519519
520520 /// Run a CBF filter scan: set watched scripts, trigger a rescan, wait for
@@ -530,11 +530,11 @@ impl CbfChainSource {
530530 let _scan_guard = self . scan_lock . lock ( ) . await ;
531531
532532 self . filter_skip_height . store ( skip_before_height. unwrap_or ( 0 ) , Ordering :: Release ) ;
533- self . matched_block_hashes . lock ( ) . unwrap ( ) . clear ( ) ;
534- * self . watched_scripts . write ( ) . unwrap ( ) = scripts;
533+ self . matched_block_hashes . lock ( ) . expect ( "lock" ) . clear ( ) ;
534+ * self . watched_scripts . write ( ) . expect ( "lock" ) = scripts;
535535
536536 let ( tx, rx) = oneshot:: channel ( ) ;
537- * self . sync_completion_tx . lock ( ) . unwrap ( ) = Some ( tx) ;
537+ * self . sync_completion_tx . lock ( ) . expect ( "lock" ) = Some ( tx) ;
538538
539539 if let Err ( e) = requester. rescan ( ) . map_err ( |e| {
540540 log_error ! ( self . logger, "Failed to trigger CBF rescan: {:?}" , e) ;
@@ -547,8 +547,8 @@ impl CbfChainSource {
547547 match rx. await {
548548 Ok ( sync_update) => {
549549 self . filter_skip_height . store ( 0 , Ordering :: Release ) ;
550- self . watched_scripts . write ( ) . unwrap ( ) . clear ( ) ;
551- let matched = std:: mem:: take ( & mut * self . matched_block_hashes . lock ( ) . unwrap ( ) ) ;
550+ self . watched_scripts . write ( ) . expect ( "lock" ) . clear ( ) ;
551+ let matched = std:: mem:: take ( & mut * self . matched_block_hashes . lock ( ) . expect ( "lock" ) ) ;
552552 Ok ( ( sync_update, matched) )
553553 } ,
554554 Err ( e) => {
@@ -564,7 +564,7 @@ impl CbfChainSource {
564564 & self , onchain_wallet : Arc < Wallet > ,
565565 ) -> Result < ( ) , Error > {
566566 let receiver_res = {
567- let mut status_lock = self . onchain_wallet_sync_status . lock ( ) . unwrap ( ) ;
567+ let mut status_lock = self . onchain_wallet_sync_status . lock ( ) . expect ( "lock" ) ;
568568 status_lock. register_or_subscribe_pending_sync ( )
569569 } ;
570570 if let Some ( mut sync_receiver) = receiver_res {
@@ -638,7 +638,7 @@ impl CbfChainSource {
638638 }
639639 . await ;
640640
641- self . onchain_wallet_sync_status . lock ( ) . unwrap ( ) . propagate_result_to_subscribers ( res) ;
641+ self . onchain_wallet_sync_status . lock ( ) . expect ( "lock" ) . propagate_result_to_subscribers ( res) ;
642642
643643 res
644644 }
@@ -660,7 +660,7 @@ impl CbfChainSource {
660660 // unknown. This mirrors what the Bitcoind chain source does in
661661 // `Wallet::block_connected` by inserting registered tx outputs.
662662 let mut all_scripts = scripts;
663- all_scripts. extend ( self . registered_scripts . lock ( ) . unwrap ( ) . iter ( ) . cloned ( ) ) ;
663+ all_scripts. extend ( self . registered_scripts . lock ( ) . expect ( "lock" ) . iter ( ) . cloned ( ) ) ;
664664 let skip_height =
665665 onchain_wallet. latest_checkpoint ( ) . height ( ) . checked_sub ( REORG_SAFETY_BLOCKS ) ;
666666 let ( sync_update, matched) = self . run_filter_scan ( all_scripts, skip_height) . await ?;
@@ -710,7 +710,7 @@ impl CbfChainSource {
710710 output_sweeper : Arc < Sweeper > ,
711711 ) -> Result < ( ) , Error > {
712712 let receiver_res = {
713- let mut status_lock = self . lightning_wallet_sync_status . lock ( ) . unwrap ( ) ;
713+ let mut status_lock = self . lightning_wallet_sync_status . lock ( ) . expect ( "lock" ) ;
714714 status_lock. register_or_subscribe_pending_sync ( )
715715 } ;
716716 if let Some ( mut sync_receiver) = receiver_res {
@@ -726,7 +726,7 @@ impl CbfChainSource {
726726 let requester = self . requester ( ) ?;
727727 let now = Instant :: now ( ) ;
728728
729- let scripts: Vec < ScriptBuf > = self . registered_scripts . lock ( ) . unwrap ( ) . clone ( ) ;
729+ let scripts: Vec < ScriptBuf > = self . registered_scripts . lock ( ) . expect ( "lock" ) . clone ( ) ;
730730 if scripts. is_empty ( ) {
731731 log_debug ! ( self . logger, "No registered scripts for CBF lightning sync." ) ;
732732 } else {
@@ -771,7 +771,10 @@ impl CbfChainSource {
771771 }
772772 . await ;
773773
774- self . lightning_wallet_sync_status . lock ( ) . unwrap ( ) . propagate_result_to_subscribers ( res) ;
774+ self . lightning_wallet_sync_status
775+ . lock ( )
776+ . expect ( "lock" )
777+ . propagate_result_to_subscribers ( res) ;
775778
776779 res
777780 }
0 commit comments