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