@@ -15,6 +15,8 @@ use crate::config::{WalletConfig, WalletConfigInner};
1515use crate :: error:: BDKCliError as Error ;
1616#[ cfg( any( feature = "sqlite" , feature = "redb" ) ) ]
1717use crate :: persister:: Persister ;
18+ #[ cfg( feature = "cbf" ) ]
19+ use crate :: utils:: BlockchainClient :: KyotoClient ;
1820use crate :: utils:: * ;
1921#[ cfg( feature = "redb" ) ]
2022use bdk_redb:: Store as RedbStore ;
@@ -46,8 +48,6 @@ use bdk_wallet::{
4648} ;
4749use cli_table:: { Cell , CellStruct , Style , Table , format:: Justify } ;
4850use serde_json:: json;
49- #[ cfg( feature = "cbf" ) ]
50- use { crate :: utils:: BlockchainClient :: KyotoClient , bdk_kyoto:: LightClient , tokio:: select} ;
5151
5252#[ cfg( feature = "electrum" ) ]
5353use crate :: utils:: BlockchainClient :: Electrum ;
@@ -605,7 +605,7 @@ pub fn handle_offline_wallet_subcommand(
605605) ) ]
606606pub ( crate ) async fn handle_online_wallet_subcommand (
607607 wallet : & mut Wallet ,
608- client : BlockchainClient ,
608+ client : & BlockchainClient ,
609609 online_subcommand : OnlineWalletSubCommand ,
610610) -> Result < String , Error > {
611611 match online_subcommand {
@@ -632,7 +632,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
632632 client
633633 . populate_tx_cache ( wallet. tx_graph ( ) . full_txs ( ) . map ( |tx_node| tx_node. tx ) ) ;
634634
635- let update = client. full_scan ( request, _stop_gap, batch_size, false ) ?;
635+ let update = client. full_scan ( request, _stop_gap, * batch_size, false ) ?;
636636 wallet. apply_update ( update) ?;
637637 }
638638 #[ cfg( feature = "esplora" ) ]
@@ -641,7 +641,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
641641 parallel_requests,
642642 } => {
643643 let update = client
644- . full_scan ( request, _stop_gap, parallel_requests)
644+ . full_scan ( request, _stop_gap, * parallel_requests)
645645 . await
646646 . map_err ( |e| * e) ?;
647647 wallet. apply_update ( update) ?;
@@ -658,7 +658,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
658658 hash : genesis_block. block_hash ( ) ,
659659 } ) ;
660660 let mut emitter = Emitter :: new (
661- & * client,
661+ client. as_ref ( ) ,
662662 genesis_cp. clone ( ) ,
663663 genesis_cp. height ( ) ,
664664 NO_EXPECTED_MEMPOOL_TXS ,
@@ -1156,6 +1156,7 @@ pub fn handle_wallets_subcommand(datadir: &Path, pretty: bool) -> Result<String,
11561156 . wallets
11571157 . iter ( )
11581158 . map ( |( name, wallet_config) | {
1159+ #[ allow( unused_mut) ]
11591160 let mut wallet_json = json ! ( {
11601161 "name" : name,
11611162 "network" : wallet_config. network,
@@ -1246,7 +1247,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
12461247
12471248 let result = handle_online_wallet_subcommand (
12481249 & mut wallet,
1249- blockchain_client,
1250+ & blockchain_client,
12501251 online_subcommand,
12511252 )
12521253 . await ?;
@@ -1258,7 +1259,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
12581259 let mut wallet = new_wallet ( network, wallet_opts) ?;
12591260 let blockchain_client =
12601261 crate :: utils:: new_blockchain_client ( wallet_opts, & wallet, database_path) ?;
1261- handle_online_wallet_subcommand ( & mut wallet, blockchain_client, online_subcommand)
1262+ handle_online_wallet_subcommand ( & mut wallet, & blockchain_client, online_subcommand)
12621263 . await ?
12631264 } ;
12641265 Ok ( result)
@@ -1452,7 +1453,7 @@ async fn respond(
14521453 } => {
14531454 let blockchain =
14541455 new_blockchain_client ( wallet_opts, wallet, _datadir) . map_err ( |e| e. to_string ( ) ) ?;
1455- let value = handle_online_wallet_subcommand ( wallet, blockchain, online_subcommand)
1456+ let value = handle_online_wallet_subcommand ( wallet, & blockchain, online_subcommand)
14561457 . await
14571458 . map_err ( |e| e. to_string ( ) ) ?;
14581459 Some ( value)
@@ -1508,7 +1509,7 @@ async fn respond(
15081509 feature = "rpc"
15091510) ) ]
15101511/// Syncs a given wallet using the blockchain client.
1511- pub async fn sync_wallet ( client : BlockchainClient , wallet : & mut Wallet ) -> Result < ( ) , Error > {
1512+ pub async fn sync_wallet ( client : & BlockchainClient , wallet : & mut Wallet ) -> Result < ( ) , Error > {
15121513 #[ cfg( any( feature = "electrum" , feature = "esplora" ) ) ]
15131514 let request = wallet
15141515 . start_sync_with_revealed_spks ( )
@@ -1523,7 +1524,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15231524 // already have.
15241525 client. populate_tx_cache ( wallet. tx_graph ( ) . full_txs ( ) . map ( |tx_node| tx_node. tx ) ) ;
15251526
1526- let update = client. sync ( request, batch_size, false ) ?;
1527+ let update = client. sync ( request, * batch_size, false ) ?;
15271528 wallet
15281529 . apply_update ( update)
15291530 . map_err ( |e| Error :: Generic ( e. to_string ( ) ) )
@@ -1534,7 +1535,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15341535 parallel_requests,
15351536 } => {
15361537 let update = client
1537- . sync ( request, parallel_requests)
1538+ . sync ( request, * parallel_requests)
15381539 . await
15391540 . map_err ( |e| * e) ?;
15401541 wallet
@@ -1549,7 +1550,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15491550 // reload the last 200 blocks in case of a reorg
15501551 let emitter_height = wallet_cp. height ( ) . saturating_sub ( 200 ) ;
15511552 let mut emitter = Emitter :: new (
1552- & * client,
1553+ client. as_ref ( ) ,
15531554 wallet_cp,
15541555 emitter_height,
15551556 wallet
@@ -1600,7 +1601,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
16001601) ) ]
16011602/// Broadcasts a given transaction using the blockchain client.
16021603pub async fn broadcast_transaction (
1603- client : BlockchainClient ,
1604+ client : & BlockchainClient ,
16041605 tx : Transaction ,
16051606) -> Result < Txid , Error > {
16061607 match client {
@@ -1627,38 +1628,15 @@ pub async fn broadcast_transaction(
16271628
16281629 #[ cfg( feature = "cbf" ) ]
16291630 KyotoClient { client } => {
1630- let LightClient {
1631- requester,
1632- mut info_subscriber,
1633- mut warning_subscriber,
1634- update_subscriber : _,
1635- node,
1636- } = * client;
1637-
1638- let subscriber = tracing_subscriber:: FmtSubscriber :: new ( ) ;
1639- tracing:: subscriber:: set_global_default ( subscriber)
1640- . map_err ( |e| Error :: Generic ( format ! ( "SetGlobalDefault error: {e}" ) ) ) ?;
1641-
1642- tokio:: task:: spawn ( async move { node. run ( ) . await } ) ;
1643- tokio:: task:: spawn ( async move {
1644- select ! {
1645- info = info_subscriber. recv( ) => {
1646- if let Some ( info) = info {
1647- tracing:: info!( "{info}" ) ;
1648- }
1649- } ,
1650- warn = warning_subscriber. recv( ) => {
1651- if let Some ( warn) = warn {
1652- tracing:: warn!( "{warn}" ) ;
1653- }
1654- }
1655- }
1656- } ) ;
16571631 let txid = tx. compute_txid ( ) ;
1658- let wtxid = requester. broadcast_random ( tx. clone ( ) ) . await . map_err ( |_| {
1659- tracing:: warn!( "Broadcast was unsuccessful" ) ;
1660- Error :: Generic ( "Transaction broadcast timed out after 30 seconds" . into ( ) )
1661- } ) ?;
1632+ let wtxid = client
1633+ . requester
1634+ . broadcast_random ( tx. clone ( ) )
1635+ . await
1636+ . map_err ( |_| {
1637+ tracing:: warn!( "Broadcast was unsuccessful" ) ;
1638+ Error :: Generic ( "Transaction broadcast timed out after 30 seconds" . into ( ) )
1639+ } ) ?;
16621640 tracing:: info!( "Successfully broadcast WTXID: {wtxid}" ) ;
16631641 Ok ( txid)
16641642 }
0 commit comments