@@ -124,15 +124,15 @@ use bdk::bitcoin::secp256k1::Secp256k1;
124124use bdk:: bitcoin:: util:: bip32:: { DerivationPath , ExtendedPrivKey , KeySource } ;
125125use bdk:: bitcoin:: util:: psbt:: PartiallySignedTransaction ;
126126use bdk:: bitcoin:: { Address , Network , OutPoint , Script , Txid } ;
127- #[ cfg( feature = "reserves" ) ]
128- use bdk:: blockchain:: Capability ;
129127#[ cfg( any(
130128 feature = "electrum" ,
131129 feature = "esplora" ,
132130 feature = "compact_filters" ,
133131 feature = "rpc"
134132) ) ]
135133use bdk:: blockchain:: { log_progress, Blockchain } ;
134+ #[ cfg( feature = "reserves" ) ]
135+ use bdk:: blockchain:: { Capability , GetHeight } ;
136136use bdk:: database:: BatchDatabase ;
137137use bdk:: descriptor:: Segwitv0 ;
138138#[ cfg( feature = "compiler" ) ]
@@ -1136,12 +1136,11 @@ where
11361136 } => {
11371137 let psbt = base64:: decode ( & psbt) . unwrap ( ) ;
11381138 let psbt: PartiallySignedTransaction = deserialize ( & psbt) . unwrap ( ) ;
1139- let current_height = wallet . client ( ) . get_height ( ) ?;
1139+ let current_height = blockchain . get_height ( ) ?;
11401140 let max_confirmation_height = if confirmations == 0 {
11411141 None
11421142 } else {
1143- if !wallet
1144- . client ( )
1143+ if !blockchain
11451144 . get_capabilities ( )
11461145 . contains ( & Capability :: GetAnyTx )
11471146 {
@@ -2275,20 +2274,30 @@ mod test {
22752274 #[ cfg( all( feature = "reserves" , feature = "electrum" ) ) ]
22762275 #[ test]
22772276 fn test_proof_of_reserves_wallet ( ) {
2277+ use bdk:: SyncOptions ;
2278+ use bdk:: blockchain:: log_progress;
2279+
22782280 let descriptor = "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)" . to_string ( ) ;
22792281 let message = "Those coins belong to Satoshi Nakamoto" ;
22802282
22812283 let client = Client :: new ( "ssl://electrum.blockstream.info:60002" ) . unwrap ( ) ;
2284+ let blockchain = ElectrumBlockchain :: from ( client) ;
22822285 let wallet = Wallet :: new (
22832286 & descriptor,
22842287 None ,
22852288 Network :: Testnet ,
22862289 MemoryDatabase :: default ( ) ,
2287- ElectrumBlockchain :: from ( client) ,
22882290 )
22892291 . unwrap ( ) ;
22902292
2291- wallet. sync ( noop_progress ( ) , None ) . unwrap ( ) ;
2293+ wallet
2294+ . sync (
2295+ & blockchain,
2296+ SyncOptions {
2297+ progress : Some ( Box :: new ( log_progress ( ) ) ) ,
2298+ } ,
2299+ )
2300+ . unwrap ( ) ;
22922301 let balance = wallet. get_balance ( ) . unwrap ( ) ;
22932302
22942303 let addr = wallet. get_address ( bdk:: wallet:: AddressIndex :: New ) . unwrap ( ) ;
@@ -2317,7 +2326,7 @@ mod test {
23172326 } => online_subcommand,
23182327 _ => panic ! ( "unexpected subcommand" ) ,
23192328 } ;
2320- let result = handle_online_wallet_subcommand ( & wallet, wallet_subcmd) . unwrap ( ) ;
2329+ let result = handle_online_wallet_subcommand ( & wallet, & blockchain , wallet_subcmd) . unwrap ( ) ;
23212330 let psbt: PartiallySignedTransaction =
23222331 serde_json:: from_str ( & result. as_object ( ) . unwrap ( ) . get ( "psbt" ) . unwrap ( ) . to_string ( ) )
23232332 . unwrap ( ) ;
@@ -2355,7 +2364,7 @@ mod test {
23552364 } => online_subcommand,
23562365 _ => panic ! ( "unexpected subcommand" ) ,
23572366 } ;
2358- let result = handle_online_wallet_subcommand ( & wallet, wallet_subcmd) . unwrap ( ) ;
2367+ let result = handle_online_wallet_subcommand ( & wallet, & blockchain , wallet_subcmd) . unwrap ( ) ;
23592368 let spendable = result
23602369 . as_object ( )
23612370 . unwrap ( )
0 commit comments