@@ -17,9 +17,9 @@ use bitcoin::block::Header;
1717use bitcoin:: constants:: genesis_block;
1818use bitcoin:: network:: Network ;
1919use bitcoin:: { Amount , BlockHash , Txid } ;
20- use bitcoind :: bitcoincore_rpc :: RpcApi ;
21- use electrsd:: bitcoind :: bitcoincore_rpc :: bitcoincore_rpc_json :: AddressType ;
22- use electrsd:: { bitcoind , bitcoind :: BitcoinD , ElectrsD } ;
20+
21+ use electrsd:: corepc_node :: Node as BitcoinD ;
22+ use electrsd:: { corepc_node , ElectrsD } ;
2323
2424use std:: collections:: { HashMap , HashSet } ;
2525use std:: env;
@@ -28,10 +28,10 @@ use std::time::Duration;
2828
2929pub fn setup_bitcoind_and_electrsd ( ) -> ( BitcoinD , ElectrsD ) {
3030 let bitcoind_exe =
31- env:: var ( "BITCOIND_EXE" ) . ok ( ) . or_else ( || bitcoind :: downloaded_exe_path ( ) . ok ( ) ) . expect (
31+ env:: var ( "BITCOIND_EXE" ) . ok ( ) . or_else ( || corepc_node :: downloaded_exe_path ( ) . ok ( ) ) . expect (
3232 "you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature" ,
3333 ) ;
34- let mut bitcoind_conf = bitcoind :: Conf :: default ( ) ;
34+ let mut bitcoind_conf = corepc_node :: Conf :: default ( ) ;
3535 bitcoind_conf. network = "regtest" ;
3636 let bitcoind = BitcoinD :: with_conf ( bitcoind_exe, & bitcoind_conf) . unwrap ( ) ;
3737
@@ -47,14 +47,15 @@ pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
4747}
4848
4949pub fn generate_blocks_and_wait ( bitcoind : & BitcoinD , electrsd : & ElectrsD , num : usize ) {
50- let cur_height = bitcoind. client . get_block_count ( ) . expect ( "failed to get current block height" ) ;
51- let address = bitcoind
50+ let cur_height = bitcoind
5251 . client
53- . get_new_address ( Some ( "test" ) , Some ( AddressType :: Legacy ) )
54- . expect ( "failed to get new address" )
55- . assume_checked ( ) ;
52+ . get_block_count ( )
53+ . expect ( "failed to get current block height" )
54+ . into_model ( )
55+ . 0 ;
56+ let address = bitcoind. client . new_address ( ) . expect ( "failed to get new address" ) ;
5657 // TODO: expect this Result once the WouldBlock issue is resolved upstream.
57- let _block_hashes_res = bitcoind. client . generate_to_address ( num as u64 , & address) ;
58+ let _block_hashes_res = bitcoind. client . generate_to_address ( num, & address) ;
5859 wait_for_block ( electrsd, cur_height as usize + num) ;
5960}
6061
@@ -175,36 +176,20 @@ macro_rules! test_syncing {
175176 assert_eq!( events. len( ) , 1 ) ;
176177
177178 // Check registered confirmed transactions are marked confirmed
178- let new_address = $bitcoind
179- . client
180- . get_new_address( Some ( "test" ) , Some ( AddressType :: Legacy ) )
181- . unwrap( )
182- . assume_checked( ) ;
179+ let new_address = $bitcoind. client. new_address( ) . unwrap( ) ;
183180 let txid = $bitcoind
184181 . client
185- . send_to_address(
186- & new_address,
187- Amount :: from_sat( 5000 ) ,
188- None ,
189- None ,
190- None ,
191- None ,
192- None ,
193- None ,
194- )
182+ . send_to_address( & new_address, Amount :: from_sat( 5000 ) )
183+ . unwrap( )
184+ . 0
185+ . parse( )
195186 . unwrap( ) ;
196187 let second_txid = $bitcoind
197188 . client
198- . send_to_address(
199- & new_address,
200- Amount :: from_sat( 5000 ) ,
201- None ,
202- None ,
203- None ,
204- None ,
205- None ,
206- None ,
207- )
189+ . send_to_address( & new_address, Amount :: from_sat( 5000 ) )
190+ . unwrap( )
191+ . 0
192+ . parse( )
208193 . unwrap( ) ;
209194 $tx_sync. register_tx( & txid, & new_address. script_pubkey( ) ) ;
210195
@@ -224,16 +209,12 @@ macro_rules! test_syncing {
224209 assert!( $confirmable. unconfirmed_txs. lock( ) . unwrap( ) . is_empty( ) ) ;
225210
226211 // Now take an arbitrary output of the second transaction and check we'll confirm its spend.
227- let tx_res = $bitcoind. client. get_transaction( & second_txid, None ) . unwrap( ) ;
228- let block_hash = tx_res. info . blockhash . unwrap( ) ;
229- let tx = tx_res. transaction ( ) . unwrap ( ) ;
212+ let tx_res = $bitcoind. client. get_transaction( second_txid) . unwrap ( ) . into_model ( ) . unwrap( ) ;
213+ let block_hash = tx_res. block_hash . unwrap( ) ;
214+ let tx = tx_res. tx ;
230215 let prev_outpoint = tx. input. first( ) . unwrap( ) . previous_output;
231- let prev_tx = $bitcoind
232- . client
233- . get_transaction( & prev_outpoint. txid, None )
234- . unwrap( )
235- . transaction( )
236- . unwrap( ) ;
216+ let prev_tx =
217+ $bitcoind. client. get_transaction( prev_outpoint. txid) . unwrap( ) . into_model( ) . unwrap( ) . tx;
237218 let prev_script_pubkey = prev_tx. output[ prev_outpoint. vout as usize ] . script_pubkey. clone( ) ;
238219 let output = WatchedOutput {
239220 block_hash: Some ( block_hash) ,
@@ -251,19 +232,26 @@ macro_rules! test_syncing {
251232 assert!( $confirmable. unconfirmed_txs. lock( ) . unwrap( ) . is_empty( ) ) ;
252233
253234 // Check previously confirmed transactions are marked unconfirmed when they are reorged.
254- let best_block_hash = $bitcoind. client. get_best_block_hash( ) . unwrap( ) ;
255- $bitcoind. client. invalidate_block( & best_block_hash) . unwrap( ) ;
235+ let best_block_hash =
236+ $bitcoind. client. get_best_block_hash( ) . unwrap( ) . into_model( ) . unwrap( ) . 0 ;
237+ $bitcoind. client. invalidate_block( best_block_hash) . unwrap( ) ;
256238
257239 // We're getting back to the previous height with a new tip, but best block shouldn't change.
258240 generate_blocks_and_wait( & $bitcoind, & $electrsd, 1 ) ;
259- assert_ne!( $bitcoind. client. get_best_block_hash( ) . unwrap( ) , best_block_hash) ;
241+ assert_ne!(
242+ $bitcoind. client. get_best_block_hash( ) . unwrap( ) . into_model( ) . unwrap( ) . 0 ,
243+ best_block_hash
244+ ) ;
260245 maybe_await!( $tx_sync. sync( vec![ & $confirmable] ) ) . unwrap( ) ;
261246 let events = std:: mem:: take( & mut * $confirmable. events. lock( ) . unwrap( ) ) ;
262247 assert_eq!( events. len( ) , 0 ) ;
263248
264249 // Now we're surpassing previous height, getting new tip.
265250 generate_blocks_and_wait( & $bitcoind, & $electrsd, 1 ) ;
266- assert_ne!( $bitcoind. client. get_best_block_hash( ) . unwrap( ) , best_block_hash) ;
251+ assert_ne!(
252+ $bitcoind. client. get_best_block_hash( ) . unwrap( ) . into_model( ) . unwrap( ) . 0 ,
253+ best_block_hash
254+ ) ;
267255 maybe_await!( $tx_sync. sync( vec![ & $confirmable] ) ) . unwrap( ) ;
268256
269257 // Transactions still confirmed but under new tip.
0 commit comments