@@ -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 ;
@@ -47,8 +49,6 @@ use bdk_wallet::{
4749use clap:: CommandFactory ;
4850use cli_table:: { Cell , CellStruct , Style , Table , format:: Justify } ;
4951use serde_json:: json;
50- #[ cfg( feature = "cbf" ) ]
51- use { crate :: utils:: BlockchainClient :: KyotoClient , bdk_kyoto:: LightClient , tokio:: select} ;
5252
5353#[ cfg( feature = "electrum" ) ]
5454use crate :: utils:: BlockchainClient :: Electrum ;
@@ -606,7 +606,7 @@ pub fn handle_offline_wallet_subcommand(
606606) ) ]
607607pub ( crate ) async fn handle_online_wallet_subcommand (
608608 wallet : & mut Wallet ,
609- client : BlockchainClient ,
609+ client : & BlockchainClient ,
610610 online_subcommand : OnlineWalletSubCommand ,
611611) -> Result < String , Error > {
612612 match online_subcommand {
@@ -633,7 +633,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
633633 client
634634 . populate_tx_cache ( wallet. tx_graph ( ) . full_txs ( ) . map ( |tx_node| tx_node. tx ) ) ;
635635
636- let update = client. full_scan ( request, _stop_gap, batch_size, false ) ?;
636+ let update = client. full_scan ( request, _stop_gap, * batch_size, false ) ?;
637637 wallet. apply_update ( update) ?;
638638 }
639639 #[ cfg( feature = "esplora" ) ]
@@ -642,7 +642,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
642642 parallel_requests,
643643 } => {
644644 let update = client
645- . full_scan ( request, _stop_gap, parallel_requests)
645+ . full_scan ( request, _stop_gap, * parallel_requests)
646646 . await
647647 . map_err ( |e| * e) ?;
648648 wallet. apply_update ( update) ?;
@@ -659,7 +659,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
659659 hash : genesis_block. block_hash ( ) ,
660660 } ) ;
661661 let mut emitter = Emitter :: new (
662- & * client,
662+ client. as_ref ( ) ,
663663 genesis_cp. clone ( ) ,
664664 genesis_cp. height ( ) ,
665665 NO_EXPECTED_MEMPOOL_TXS ,
@@ -1157,6 +1157,7 @@ pub fn handle_wallets_subcommand(datadir: &Path, pretty: bool) -> Result<String,
11571157 . wallets
11581158 . iter ( )
11591159 . map ( |( name, wallet_config) | {
1160+ #[ allow( unused_mut) ]
11601161 let mut wallet_json = json ! ( {
11611162 "name" : name,
11621163 "network" : wallet_config. network,
@@ -1247,7 +1248,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
12471248
12481249 let result = handle_online_wallet_subcommand (
12491250 & mut wallet,
1250- blockchain_client,
1251+ & blockchain_client,
12511252 online_subcommand,
12521253 )
12531254 . await ?;
@@ -1259,7 +1260,7 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
12591260 let mut wallet = new_wallet ( network, wallet_opts) ?;
12601261 let blockchain_client =
12611262 crate :: utils:: new_blockchain_client ( wallet_opts, & wallet, database_path) ?;
1262- handle_online_wallet_subcommand ( & mut wallet, blockchain_client, online_subcommand)
1263+ handle_online_wallet_subcommand ( & mut wallet, & blockchain_client, online_subcommand)
12631264 . await ?
12641265 } ;
12651266 Ok ( result)
@@ -1463,7 +1464,7 @@ async fn respond(
14631464 } => {
14641465 let blockchain =
14651466 new_blockchain_client ( wallet_opts, wallet, _datadir) . map_err ( |e| e. to_string ( ) ) ?;
1466- let value = handle_online_wallet_subcommand ( wallet, blockchain, online_subcommand)
1467+ let value = handle_online_wallet_subcommand ( wallet, & blockchain, online_subcommand)
14671468 . await
14681469 . map_err ( |e| e. to_string ( ) ) ?;
14691470 Some ( value)
@@ -1519,7 +1520,7 @@ async fn respond(
15191520 feature = "rpc"
15201521) ) ]
15211522/// Syncs a given wallet using the blockchain client.
1522- pub async fn sync_wallet ( client : BlockchainClient , wallet : & mut Wallet ) -> Result < ( ) , Error > {
1523+ pub async fn sync_wallet ( client : & BlockchainClient , wallet : & mut Wallet ) -> Result < ( ) , Error > {
15231524 #[ cfg( any( feature = "electrum" , feature = "esplora" ) ) ]
15241525 let request = wallet
15251526 . start_sync_with_revealed_spks ( )
@@ -1534,7 +1535,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15341535 // already have.
15351536 client. populate_tx_cache ( wallet. tx_graph ( ) . full_txs ( ) . map ( |tx_node| tx_node. tx ) ) ;
15361537
1537- let update = client. sync ( request, batch_size, false ) ?;
1538+ let update = client. sync ( request, * batch_size, false ) ?;
15381539 wallet
15391540 . apply_update ( update)
15401541 . map_err ( |e| Error :: Generic ( e. to_string ( ) ) )
@@ -1545,7 +1546,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15451546 parallel_requests,
15461547 } => {
15471548 let update = client
1548- . sync ( request, parallel_requests)
1549+ . sync ( request, * parallel_requests)
15491550 . await
15501551 . map_err ( |e| * e) ?;
15511552 wallet
@@ -1560,7 +1561,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
15601561 // reload the last 200 blocks in case of a reorg
15611562 let emitter_height = wallet_cp. height ( ) . saturating_sub ( 200 ) ;
15621563 let mut emitter = Emitter :: new (
1563- & * client,
1564+ client. as_ref ( ) ,
15641565 wallet_cp,
15651566 emitter_height,
15661567 wallet
@@ -1611,7 +1612,7 @@ pub async fn sync_wallet(client: BlockchainClient, wallet: &mut Wallet) -> Resul
16111612) ) ]
16121613/// Broadcasts a given transaction using the blockchain client.
16131614pub async fn broadcast_transaction (
1614- client : BlockchainClient ,
1615+ client : & BlockchainClient ,
16151616 tx : Transaction ,
16161617) -> Result < Txid , Error > {
16171618 match client {
@@ -1638,38 +1639,15 @@ pub async fn broadcast_transaction(
16381639
16391640 #[ cfg( feature = "cbf" ) ]
16401641 KyotoClient { client } => {
1641- let LightClient {
1642- requester,
1643- mut info_subscriber,
1644- mut warning_subscriber,
1645- update_subscriber : _,
1646- node,
1647- } = * client;
1648-
1649- let subscriber = tracing_subscriber:: FmtSubscriber :: new ( ) ;
1650- tracing:: subscriber:: set_global_default ( subscriber)
1651- . map_err ( |e| Error :: Generic ( format ! ( "SetGlobalDefault error: {e}" ) ) ) ?;
1652-
1653- tokio:: task:: spawn ( async move { node. run ( ) . await } ) ;
1654- tokio:: task:: spawn ( async move {
1655- select ! {
1656- info = info_subscriber. recv( ) => {
1657- if let Some ( info) = info {
1658- tracing:: info!( "{info}" ) ;
1659- }
1660- } ,
1661- warn = warning_subscriber. recv( ) => {
1662- if let Some ( warn) = warn {
1663- tracing:: warn!( "{warn}" ) ;
1664- }
1665- }
1666- }
1667- } ) ;
16681642 let txid = tx. compute_txid ( ) ;
1669- let wtxid = requester. broadcast_random ( tx. clone ( ) ) . await . map_err ( |_| {
1670- tracing:: warn!( "Broadcast was unsuccessful" ) ;
1671- Error :: Generic ( "Transaction broadcast timed out after 30 seconds" . into ( ) )
1672- } ) ?;
1643+ let wtxid = client
1644+ . requester
1645+ . broadcast_random ( tx. clone ( ) )
1646+ . await
1647+ . map_err ( |_| {
1648+ tracing:: warn!( "Broadcast was unsuccessful" ) ;
1649+ Error :: Generic ( "Transaction broadcast timed out after 30 seconds" . into ( ) )
1650+ } ) ?;
16731651 tracing:: info!( "Successfully broadcast WTXID: {wtxid}" ) ;
16741652 Ok ( txid)
16751653 }
0 commit comments