@@ -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 ! {
@@ -246,7 +246,8 @@ fn test_get_new_address(cl: &Client) {
246
246
let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
247
247
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
248
248
249
- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
249
+ let addr =
250
+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
250
251
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
251
252
}
252
253
@@ -257,7 +258,8 @@ fn test_get_raw_change_address(cl: &Client) {
257
258
let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
258
259
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
259
260
260
- let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
261
+ let addr =
262
+ cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
261
263
assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
262
264
}
263
265
@@ -287,7 +289,9 @@ fn test_generate(cl: &Client) {
287
289
fn test_get_balance_generate_to_address ( cl : & Client ) {
288
290
let initial = cl. get_balance ( None , None ) . unwrap ( ) ;
289
291
290
- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
292
+ let blocks = cl
293
+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
294
+ . unwrap ( ) ;
291
295
assert_eq ! ( blocks. len( ) , 500 ) ;
292
296
assert_ne ! ( cl. get_balance( None , None ) . unwrap( ) , initial) ;
293
297
}
@@ -296,7 +300,9 @@ fn test_get_balances_generate_to_address(cl: &Client) {
296
300
if version ( ) >= 190000 {
297
301
let initial = cl. get_balances ( ) . unwrap ( ) ;
298
302
299
- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
303
+ let blocks = cl
304
+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
305
+ . unwrap ( ) ;
300
306
assert_eq ! ( blocks. len( ) , 500 ) ;
301
307
assert_ne ! ( cl. get_balances( ) . unwrap( ) , initial) ;
302
308
}
@@ -372,7 +378,8 @@ fn test_get_address_info(cl: &Client) {
372
378
let info = cl. get_address_info ( & addr) . unwrap ( ) ;
373
379
assert ! ( !info. witness_program. unwrap( ) . is_empty( ) ) ;
374
380
375
- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
381
+ let addr =
382
+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
376
383
let info = cl. get_address_info ( & addr) . unwrap ( ) ;
377
384
assert ! ( !info. hex. unwrap( ) . is_empty( ) ) ;
378
385
}
@@ -428,27 +435,33 @@ fn test_get_received_by_address(cl: &Client) {
428
435
let _ = cl. send_to_address ( & addr, btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
429
436
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 0 ) ) . unwrap( ) , btc( 1 ) ) ;
430
437
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 1 ) ) . unwrap( ) , btc( 0 ) ) ;
431
- let _ = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
438
+ let _ = cl
439
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
440
+ . unwrap ( ) ;
432
441
assert_eq ! ( cl. get_received_by_address( & addr, Some ( 6 ) ) . unwrap( ) , btc( 1 ) ) ;
433
442
assert_eq ! ( cl. get_received_by_address( & addr, None ) . unwrap( ) , btc( 1 ) ) ;
434
443
}
435
444
436
445
fn test_list_unspent ( cl : & Client ) {
437
446
let addr = cl. get_new_address ( None , None ) . unwrap ( ) ;
438
447
let addr_checked = addr. clone ( ) . assume_checked ( ) ;
439
- let txid = cl. send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
440
- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
448
+ let txid = cl
449
+ . send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None )
450
+ . unwrap ( ) ;
451
+ let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
441
452
assert_eq ! ( unspent[ 0 ] . txid, txid) ;
442
453
assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
443
454
assert_eq ! ( unspent[ 0 ] . amount, btc( 1 ) ) ;
444
455
445
- let txid = cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
456
+ let txid =
457
+ cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
446
458
let options = json:: ListUnspentQueryOptions {
447
459
minimum_amount : Some ( btc ( 7 ) ) ,
448
460
maximum_amount : Some ( btc ( 7 ) ) ,
449
461
..Default :: default ( )
450
462
} ;
451
- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
463
+ let unspent =
464
+ cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
452
465
assert_eq ! ( unspent. len( ) , 1 ) ;
453
466
assert_eq ! ( unspent[ 0 ] . txid, txid) ;
454
467
assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
@@ -474,7 +487,9 @@ fn test_get_raw_transaction(cl: &Client) {
474
487
let info = cl. get_raw_transaction_info ( & txid, None ) . unwrap ( ) ;
475
488
assert_eq ! ( info. txid, txid) ;
476
489
477
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
490
+ let blocks = cl
491
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
492
+ . unwrap ( ) ;
478
493
let _ = cl. get_raw_transaction_info ( & txid, Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
479
494
}
480
495
@@ -530,7 +545,9 @@ fn test_get_tx_out_proof(cl: &Client) {
530
545
cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
531
546
let txid2 =
532
547
cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
533
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
548
+ let blocks = cl
549
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
550
+ . unwrap ( ) ;
534
551
let proof = cl. get_tx_out_proof ( & [ txid1, txid2] , Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
535
552
assert ! ( !proof. is_empty( ) ) ;
536
553
}
@@ -557,7 +574,9 @@ fn test_lock_unspent_unlock_unspent(cl: &Client) {
557
574
}
558
575
559
576
fn test_get_block_filter ( cl : & Client ) {
560
- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
577
+ let blocks = cl
578
+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
579
+ . unwrap ( ) ;
561
580
if version ( ) >= 190000 {
562
581
let _ = cl. get_block_filter ( & blocks[ 0 ] ) . unwrap ( ) ;
563
582
} else {
@@ -628,7 +647,12 @@ fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) {
628
647
} ;
629
648
630
649
let res = cl
631
- . sign_raw_transaction_with_key ( & tx, & [ sk] , None , Some ( sighash:: EcdsaSighashType :: All . into ( ) ) )
650
+ . sign_raw_transaction_with_key (
651
+ & tx,
652
+ & [ sk] ,
653
+ None ,
654
+ Some ( sighash:: EcdsaSighashType :: All . into ( ) ) ,
655
+ )
632
656
. unwrap ( ) ;
633
657
assert ! ( res. complete) ;
634
658
let _ = cl. send_raw_transaction ( & res. transaction ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -1273,9 +1297,7 @@ fn test_getblocktemplate(cl: &Client) {
1273
1297
fn test_unloadwallet ( cl : & Client ) {
1274
1298
cl. create_wallet ( "testunloadwallet" , None , None , None , None ) . unwrap ( ) ;
1275
1299
1276
- let res = new_wallet_client ( "testunloadwallet" )
1277
- . unload_wallet ( None )
1278
- . unwrap ( ) ;
1300
+ let res = new_wallet_client ( "testunloadwallet" ) . unload_wallet ( None ) . unwrap ( ) ;
1279
1301
1280
1302
if version ( ) >= 210000 {
1281
1303
assert ! ( res. is_some( ) ) ;
@@ -1308,18 +1330,21 @@ fn test_get_zmq_notifications(cl: &Client) {
1308
1330
}
1309
1331
} ) ;
1310
1332
1311
- assert ! ( zmq_info == vec![
1312
- GetZmqNotificationsResult {
1313
- notification_type: "pubrawblock" . to_owned( ) ,
1314
- address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1315
- hwm: 1000
1316
- } ,
1317
- GetZmqNotificationsResult {
1318
- notification_type: "pubrawtx" . to_owned( ) ,
1319
- address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1320
- hwm: 1000
1321
- } ,
1322
- ] ) ;
1333
+ assert ! (
1334
+ zmq_info
1335
+ == vec![
1336
+ GetZmqNotificationsResult {
1337
+ notification_type: "pubrawblock" . to_owned( ) ,
1338
+ address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1339
+ hwm: 1000
1340
+ } ,
1341
+ GetZmqNotificationsResult {
1342
+ notification_type: "pubrawtx" . to_owned( ) ,
1343
+ address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1344
+ hwm: 1000
1345
+ } ,
1346
+ ]
1347
+ ) ;
1323
1348
}
1324
1349
1325
1350
fn test_stop ( cl : Client ) {
0 commit comments