@@ -27,13 +27,13 @@ use crate::json::BlockStatsFields as BsFields;
27
27
use bitcoin:: consensus:: encode:: { deserialize, serialize_hex} ;
28
28
use bitcoin:: hashes:: hex:: FromHex ;
29
29
use bitcoin:: hashes:: Hash ;
30
- use bitcoin:: { secp256k1, ScriptBuf , sighash } ;
30
+ use bitcoin:: { secp256k1, sighash , ScriptBuf } ;
31
31
use bitcoin:: {
32
- Address , Amount , Network , OutPoint , PrivateKey ,
33
- Sequence , SignedAmount , Transaction , TxIn , TxOut , Txid , Witness ,
32
+ Address , Amount , Network , OutPoint , PrivateKey , Sequence , SignedAmount , Transaction , TxIn ,
33
+ TxOut , Txid , Witness ,
34
34
} ;
35
35
use bitcoincore_rpc:: bitcoincore_rpc_json:: {
36
- GetBlockTemplateModes , GetBlockTemplateRules , ScanTxOutRequest , GetZmqNotificationsResult ,
36
+ GetBlockTemplateModes , GetBlockTemplateRules , GetZmqNotificationsResult , ScanTxOutRequest ,
37
37
} ;
38
38
39
39
lazy_static ! {
@@ -250,7 +250,8 @@ fn test_get_new_address(cl: &Client) {
250
250
let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
251
251
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
252
252
253
- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
253
+ let addr =
254
+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
254
255
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
255
256
}
256
257
@@ -261,7 +262,8 @@ fn test_get_raw_change_address(cl: &Client) {
261
262
let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
262
263
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
263
264
264
- let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
265
+ let addr =
266
+ cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
265
267
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
266
268
}
267
269
@@ -291,7 +293,9 @@ fn test_generate(cl: &Client) {
291
293
fn test_get_balance_generate_to_address ( cl : & Client ) {
292
294
let initial = cl. get_balance ( None , None ) . unwrap ( ) ;
293
295
294
- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
296
+ let blocks = cl
297
+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
298
+ . unwrap ( ) ;
295
299
assert_eq ! ( blocks. len( ) , 500 ) ;
296
300
assert_ne ! ( cl. get_balance( None , None ) . unwrap( ) , initial) ;
297
301
}
@@ -300,7 +304,9 @@ fn test_get_balances_generate_to_address(cl: &Client) {
300
304
if version ( ) >= 190000 {
301
305
let initial = cl. get_balances ( ) . unwrap ( ) ;
302
306
303
- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
307
+ let blocks = cl
308
+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
309
+ . unwrap ( ) ;
304
310
assert_eq ! ( blocks. len( ) , 500 ) ;
305
311
assert_ne ! ( cl. get_balances( ) . unwrap( ) , initial) ;
306
312
}
@@ -376,7 +382,8 @@ fn test_get_address_info(cl: &Client) {
376
382
let info = cl. get_address_info ( & addr) . unwrap ( ) ;
377
383
assert ! ( !info. witness_program. unwrap( ) . is_empty( ) ) ;
378
384
379
- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
385
+ let addr =
386
+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
380
387
let info = cl. get_address_info ( & addr) . unwrap ( ) ;
381
388
assert ! ( !info. hex. unwrap( ) . is_empty( ) ) ;
382
389
}
@@ -432,27 +439,33 @@ fn test_get_received_by_address(cl: &Client) {
432
439
let _ = cl. send_to_address ( & addr, btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
433
440
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 0 ) ) . unwrap( ) , btc( 1 ) ) ;
434
441
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 1 ) ) . unwrap( ) , btc( 0 ) ) ;
435
- let _ = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
442
+ let _ = cl
443
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
444
+ . unwrap ( ) ;
436
445
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 6 ) ) . unwrap( ) , btc( 1 ) ) ;
437
446
assert_eq ! ( cl. get_received_by_address( & addr, None ) . unwrap( ) , btc( 1 ) ) ;
438
447
}
439
448
440
449
fn test_list_unspent ( cl : & Client ) {
441
450
let addr = cl. get_new_address ( None , None ) . unwrap ( ) ;
442
451
let addr_checked = addr. clone ( ) . assume_checked ( ) ;
443
- let txid = cl. send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
444
- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
452
+ let txid = cl
453
+ . send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None )
454
+ . unwrap ( ) ;
455
+ let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
445
456
assert_eq ! ( unspent[ 0 ] . txid, txid) ;
446
457
assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
447
458
assert_eq ! ( unspent[ 0 ] . amount, btc( 1 ) ) ;
448
459
449
- let txid = cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
460
+ let txid =
461
+ cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
450
462
let options = json:: ListUnspentQueryOptions {
451
463
minimum_amount : Some ( btc ( 7 ) ) ,
452
464
maximum_amount : Some ( btc ( 7 ) ) ,
453
465
..Default :: default ( )
454
466
} ;
455
- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
467
+ let unspent =
468
+ cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
456
469
assert_eq ! ( unspent. len( ) , 1 ) ;
457
470
assert_eq ! ( unspent[ 0 ] . txid, txid) ;
458
471
assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
@@ -478,7 +491,9 @@ fn test_get_raw_transaction(cl: &Client) {
478
491
let info = cl. get_raw_transaction_info ( & txid, None ) . unwrap ( ) ;
479
492
assert_eq ! ( info. txid, txid) ;
480
493
481
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
494
+ let blocks = cl
495
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
496
+ . unwrap ( ) ;
482
497
let _ = cl. get_raw_transaction_info ( & txid, Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
483
498
}
484
499
@@ -534,7 +549,9 @@ fn test_get_tx_out_proof(cl: &Client) {
534
549
cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
535
550
let txid2 =
536
551
cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
537
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
552
+ let blocks = cl
553
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
554
+ . unwrap ( ) ;
538
555
let proof = cl. get_tx_out_proof ( & [ txid1, txid2] , Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
539
556
assert ! ( !proof. is_empty( ) ) ;
540
557
}
@@ -561,7 +578,9 @@ fn test_lock_unspent_unlock_unspent(cl: &Client) {
561
578
}
562
579
563
580
fn test_get_block_filter ( cl : & Client ) {
564
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
581
+ let blocks = cl
582
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
583
+ . unwrap ( ) ;
565
584
if version ( ) >= 190000 {
566
585
let _ = cl. get_block_filter ( & blocks[ 0 ] ) . unwrap ( ) ;
567
586
} else {
@@ -632,7 +651,12 @@ fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) {
632
651
} ;
633
652
634
653
let res = cl
635
- . sign_raw_transaction_with_key ( & tx, & [ sk] , None , Some ( sighash:: EcdsaSighashType :: All . into ( ) ) )
654
+ . sign_raw_transaction_with_key (
655
+ & tx,
656
+ & [ sk] ,
657
+ None ,
658
+ Some ( sighash:: EcdsaSighashType :: All . into ( ) ) ,
659
+ )
636
660
. unwrap ( ) ;
637
661
assert ! ( res. complete) ;
638
662
let _ = cl. send_raw_transaction ( & res. transaction ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -1277,9 +1301,7 @@ fn test_getblocktemplate(cl: &Client) {
1277
1301
fn test_unloadwallet ( cl : & Client ) {
1278
1302
cl. create_wallet ( "testunloadwallet" , None , None , None , None ) . unwrap ( ) ;
1279
1303
1280
- let res = new_wallet_client ( "testunloadwallet" )
1281
- . unload_wallet ( None )
1282
- . unwrap ( ) ;
1304
+ let res = new_wallet_client ( "testunloadwallet" ) . unload_wallet ( None ) . unwrap ( ) ;
1283
1305
1284
1306
if version ( ) >= 210000 {
1285
1307
assert ! ( res. is_some( ) ) ;
@@ -1337,18 +1359,21 @@ fn test_get_zmq_notifications(cl: &Client) {
1337
1359
}
1338
1360
} ) ;
1339
1361
1340
- assert ! ( zmq_info == vec![
1341
- GetZmqNotificationsResult {
1342
- notification_type: "pubrawblock" . to_owned( ) ,
1343
- address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1344
- hwm: 1000
1345
- } ,
1346
- GetZmqNotificationsResult {
1347
- notification_type: "pubrawtx" . to_owned( ) ,
1348
- address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1349
- hwm: 1000
1350
- } ,
1351
- ] ) ;
1362
+ assert ! (
1363
+ zmq_info
1364
+ == vec![
1365
+ GetZmqNotificationsResult {
1366
+ notification_type: "pubrawblock" . to_owned( ) ,
1367
+ address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1368
+ hwm: 1000
1369
+ } ,
1370
+ GetZmqNotificationsResult {
1371
+ notification_type: "pubrawtx" . to_owned( ) ,
1372
+ address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1373
+ hwm: 1000
1374
+ } ,
1375
+ ]
1376
+ ) ;
1352
1377
}
1353
1378
1354
1379
fn test_stop ( cl : Client ) {
0 commit comments