@@ -28,6 +28,7 @@ use electrsd::{corepc_node, ElectrsD};
2828use electrum_client:: ElectrumApi ;
2929use ldk_node:: config:: {
3030 AsyncPaymentsRole , CbfSyncConfig , Config , ElectrumSyncConfig , EsploraSyncConfig ,
31+ SyncTimeoutsConfig ,
3132} ;
3233use ldk_node:: entropy:: { generate_entropy_mnemonic, NodeEntropy } ;
3334use ldk_node:: io:: sqlite_store:: SqliteStore ;
@@ -498,7 +499,18 @@ pub(crate) fn setup_node(chain_source: &TestChainSource, config: TestConfig) ->
498499 TestChainSource :: Cbf ( bitcoind) => {
499500 let p2p_socket = bitcoind. params . p2p_socket . expect ( "P2P must be enabled for CBF" ) ;
500501 let peer_addr = format ! ( "{}" , p2p_socket) ;
501- let sync_config = CbfSyncConfig { background_sync_config : None , ..Default :: default ( ) } ;
502+ let timeouts_config = SyncTimeoutsConfig {
503+ onchain_wallet_sync_timeout_secs : 3 ,
504+ lightning_wallet_sync_timeout_secs : 3 ,
505+ fee_rate_cache_update_timeout_secs : 3 ,
506+ tx_broadcast_timeout_secs : 3 ,
507+ per_request_timeout_secs : 3 ,
508+ } ;
509+ let sync_config = CbfSyncConfig {
510+ background_sync_config : None ,
511+ timeouts_config,
512+ ..Default :: default ( )
513+ } ;
502514 builder. set_chain_source_cbf ( vec ! [ peer_addr] , Some ( sync_config) , None ) ;
503515 } ,
504516 }
@@ -628,31 +640,6 @@ pub(crate) async fn wait_for_outpoint_spend<E: ElectrumApi>(electrs: &E, outpoin
628640 . await ;
629641}
630642
631- /// Wait until a transaction spending the given outpoint appears in bitcoind's mempool.
632- ///
633- /// This is more reliable than the electrum-based `wait_for_outpoint_spend` for CBF nodes,
634- /// where the close tx is broadcast via P2P and electrs may not index it immediately.
635- pub ( crate ) async fn wait_for_outpoint_spend_in_mempool (
636- bitcoind : & BitcoindClient , outpoint : OutPoint ,
637- ) {
638- let check = || {
639- let mempool = bitcoind. get_raw_mempool ( ) . unwrap ( ) . into_model ( ) . unwrap ( ) ;
640- for txid in mempool. 0 {
641- let tx = bitcoind. get_raw_transaction ( txid) . unwrap ( ) . into_model ( ) . unwrap ( ) . 0 ;
642- if tx. input . iter ( ) . any ( |inp| inp. previous_output == outpoint) {
643- return Some ( ( ) ) ;
644- }
645- }
646- None
647- } ;
648-
649- if check ( ) . is_some ( ) {
650- return ;
651- }
652-
653- exponential_backoff_poll ( check) . await ;
654- }
655-
656643pub ( crate ) async fn wait_for_cbf_sync ( node : & TestNode ) {
657644 let before = node. status ( ) . latest_onchain_wallet_sync_timestamp ;
658645 let mut delay = Duration :: from_millis ( 200 ) ;
@@ -1364,10 +1351,8 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
13641351
13651352 // After splices, the latest funding outpoint is from the last splice.
13661353 // We must wait for the close tx (which spends the latest funding output)
1367- // to reach bitcoind's mempool before mining. For CBF nodes the close tx
1368- // is broadcast via P2P so we poll bitcoind directly rather than relying
1369- // on electrs indexing.
1370- wait_for_outpoint_spend_in_mempool ( bitcoind, splice_in_txo) . await ;
1354+ // to propagate before mining.
1355+ wait_for_outpoint_spend ( electrsd, splice_in_txo) . await ;
13711356
13721357 generate_blocks_and_wait ( & bitcoind, electrsd, 1 ) . await ;
13731358 node_a. sync_wallets ( ) . unwrap ( ) ;
0 commit comments