@@ -1427,12 +1427,12 @@ fn test_create_tx_increment_change_index() {
1427
1427
descriptor : & ' static str ,
1428
1428
change_descriptor : Option < & ' static str > ,
1429
1429
// amount to send
1430
- to_send : u64 ,
1430
+ to_send : Amount ,
1431
1431
// (derivation index, next unused index) of *change keychain*
1432
1432
expect : ( Option < u32 > , u32 ) ,
1433
1433
}
1434
1434
// total wallet funds
1435
- let amount = 10_000 ;
1435
+ let amount = Amount :: from_sat ( 10_000 ) ;
1436
1436
let recipient = Address :: from_str ( "bcrt1q3qtze4ys45tgdvguj66zrk4fu6hq3a3v9pfly5" )
1437
1437
. unwrap ( )
1438
1438
. assume_checked ( )
@@ -1443,55 +1443,55 @@ fn test_create_tx_increment_change_index() {
1443
1443
name : "two wildcard, builder error" ,
1444
1444
descriptor : desc,
1445
1445
change_descriptor : Some ( change_desc) ,
1446
- to_send : amount + 1 ,
1446
+ to_send : amount + Amount :: from_sat ( 1 ) ,
1447
1447
// should not use or derive change index
1448
1448
expect : ( None , 0 ) ,
1449
1449
} ,
1450
1450
TestCase {
1451
1451
name : "two wildcard, create change" ,
1452
1452
descriptor : desc,
1453
1453
change_descriptor : Some ( change_desc) ,
1454
- to_send : 5_000 ,
1454
+ to_send : Amount :: from_sat ( 5_000 ) ,
1455
1455
// should use change index
1456
1456
expect : ( Some ( 0 ) , 1 ) ,
1457
1457
} ,
1458
1458
TestCase {
1459
1459
name : "two wildcard, no change" ,
1460
1460
descriptor : desc,
1461
1461
change_descriptor : Some ( change_desc) ,
1462
- to_send : 9_850 ,
1462
+ to_send : Amount :: from_sat ( 9_850 ) ,
1463
1463
// should not use change index
1464
1464
expect : ( None , 0 ) ,
1465
1465
} ,
1466
1466
TestCase {
1467
1467
name : "one wildcard, create change" ,
1468
1468
descriptor : desc,
1469
1469
change_descriptor : None ,
1470
- to_send : 5_000 ,
1470
+ to_send : Amount :: from_sat ( 5_000 ) ,
1471
1471
// should use change index of external keychain
1472
1472
expect : ( Some ( 1 ) , 2 ) ,
1473
1473
} ,
1474
1474
TestCase {
1475
1475
name : "one wildcard, no change" ,
1476
1476
descriptor : desc,
1477
1477
change_descriptor : None ,
1478
- to_send : 9_850 ,
1478
+ to_send : Amount :: from_sat ( 9_850 ) ,
1479
1479
// should not use change index
1480
1480
expect : ( Some ( 0 ) , 1 ) ,
1481
1481
} ,
1482
1482
TestCase {
1483
1483
name : "single key, create change" ,
1484
1484
descriptor : get_test_tr_single_sig ( ) ,
1485
1485
change_descriptor : None ,
1486
- to_send : 5_000 ,
1486
+ to_send : Amount :: from_sat ( 5_000 ) ,
1487
1487
// single key only has one derivation index (0)
1488
1488
expect : ( Some ( 0 ) , 0 ) ,
1489
1489
} ,
1490
1490
TestCase {
1491
1491
name : "single key, no change" ,
1492
1492
descriptor : get_test_tr_single_sig ( ) ,
1493
1493
change_descriptor : None ,
1494
- to_send : 9_850 ,
1494
+ to_send : Amount :: from_sat ( 9_850 ) ,
1495
1495
expect : ( Some ( 0 ) , 0 ) ,
1496
1496
} ,
1497
1497
]
@@ -1516,7 +1516,7 @@ fn test_create_tx_increment_change_index() {
1516
1516
receive_output ( & mut wallet, amount, ReceiveTo :: Mempool ( 0 ) ) ;
1517
1517
// create tx
1518
1518
let mut builder = wallet. build_tx ( ) ;
1519
- builder. add_recipient ( recipient. clone ( ) , Amount :: from_sat ( test. to_send ) ) ;
1519
+ builder. add_recipient ( recipient. clone ( ) , test. to_send ) ;
1520
1520
let res = builder. finish ( ) ;
1521
1521
if !test. name . contains ( "error" ) {
1522
1522
assert ! ( res. is_ok( ) ) ;
@@ -2289,7 +2289,7 @@ fn test_bump_fee_add_input() {
2289
2289
#[ test]
2290
2290
fn test_bump_fee_absolute_add_input ( ) {
2291
2291
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2292
- receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2292
+ receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2293
2293
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2294
2294
. unwrap ( )
2295
2295
. assume_checked ( ) ;
@@ -2343,7 +2343,7 @@ fn test_bump_fee_absolute_add_input() {
2343
2343
#[ test]
2344
2344
fn test_bump_fee_no_change_add_input_and_change ( ) {
2345
2345
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2346
- let op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2346
+ let op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2347
2347
2348
2348
// initially make a tx without change by using `drain_to`
2349
2349
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
@@ -2409,7 +2409,7 @@ fn test_bump_fee_no_change_add_input_and_change() {
2409
2409
#[ test]
2410
2410
fn test_bump_fee_add_input_change_dust ( ) {
2411
2411
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2412
- receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2412
+ receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2413
2413
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2414
2414
. unwrap ( )
2415
2415
. assume_checked ( ) ;
@@ -2481,7 +2481,7 @@ fn test_bump_fee_add_input_change_dust() {
2481
2481
#[ test]
2482
2482
fn test_bump_fee_force_add_input ( ) {
2483
2483
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2484
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2484
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2485
2485
2486
2486
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2487
2487
. unwrap ( )
@@ -2543,7 +2543,7 @@ fn test_bump_fee_force_add_input() {
2543
2543
#[ test]
2544
2544
fn test_bump_fee_absolute_force_add_input ( ) {
2545
2545
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2546
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2546
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2547
2547
2548
2548
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2549
2549
. unwrap ( )
@@ -2622,7 +2622,7 @@ fn test_bump_fee_unconfirmed_inputs_only() {
2622
2622
let psbt = builder. finish ( ) . unwrap ( ) ;
2623
2623
// Now we receive one transaction with 0 confirmations. We won't be able to use that for
2624
2624
// fee bumping, as it's still unconfirmed!
2625
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
2625
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
2626
2626
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2627
2627
let txid = tx. compute_txid ( ) ;
2628
2628
for txin in & mut tx. input {
@@ -2647,7 +2647,7 @@ fn test_bump_fee_unconfirmed_input() {
2647
2647
. assume_checked ( ) ;
2648
2648
// We receive a tx with 0 confirmations, which will be used as an input
2649
2649
// in the drain tx.
2650
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
2650
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
2651
2651
let mut builder = wallet. build_tx ( ) ;
2652
2652
builder. drain_wallet ( ) . drain_to ( addr. script_pubkey ( ) ) ;
2653
2653
let psbt = builder. finish ( ) . unwrap ( ) ;
@@ -2685,7 +2685,7 @@ fn test_fee_amount_negative_drain_val() {
2685
2685
. unwrap ( )
2686
2686
. assume_checked ( ) ;
2687
2687
let fee_rate = FeeRate :: from_sat_per_kwu ( 500 ) ;
2688
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 8859 ) ;
2688
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 8859 ) ) ;
2689
2689
2690
2690
let mut builder = wallet. build_tx ( ) ;
2691
2691
builder
@@ -3057,7 +3057,7 @@ fn test_next_unused_address() {
3057
3057
assert_eq ! ( next_unused_addr. index, 0 ) ;
3058
3058
3059
3059
// use the above address
3060
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
3060
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
3061
3061
3062
3062
assert_eq ! (
3063
3063
wallet
@@ -4133,7 +4133,7 @@ fn test_keychains_with_overlapping_spks() {
4133
4133
} ,
4134
4134
confirmation_time : 0 ,
4135
4135
} ;
4136
- let _outpoint = receive_output_to_address ( & mut wallet, addr, 8000 , anchor) ;
4136
+ let _outpoint = receive_output_to_address ( & mut wallet, addr, Amount :: from_sat ( 8000 ) , anchor) ;
4137
4137
assert_eq ! ( wallet. balance( ) . confirmed, Amount :: from_sat( 58000 ) ) ;
4138
4138
}
4139
4139
@@ -4222,14 +4222,14 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4222
4222
. create_wallet_no_persist ( )
4223
4223
. unwrap ( ) ;
4224
4224
assert_eq ! ( wallet. keychains( ) . count( ) , 1 ) ;
4225
- let amt = Amount :: from_sat ( 5_000 ) ;
4226
- receive_output ( & mut wallet, 2 * amt . to_sat ( ) , ReceiveTo :: Mempool ( 2 ) ) ;
4225
+ let amount = Amount :: from_sat ( 5_000 ) ;
4226
+ receive_output ( & mut wallet, amount * 2 , ReceiveTo :: Mempool ( 2 ) ) ;
4227
4227
// create spend tx that produces a change output
4228
4228
let addr = Address :: from_str ( "bcrt1qc6fweuf4xjvz4x3gx3t9e0fh4hvqyu2qw4wvxm" )
4229
4229
. unwrap ( )
4230
4230
. assume_checked ( ) ;
4231
4231
let mut builder = wallet. build_tx ( ) ;
4232
- builder. add_recipient ( addr. script_pubkey ( ) , amt ) ;
4232
+ builder. add_recipient ( addr. script_pubkey ( ) , amount ) ;
4233
4233
let mut psbt = builder. finish ( ) . unwrap ( ) ;
4234
4234
assert ! ( wallet. sign( & mut psbt, SignOptions :: default ( ) ) . unwrap( ) ) ;
4235
4235
let tx = psbt. extract_tx ( ) . unwrap ( ) ;
@@ -4238,7 +4238,7 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4238
4238
let unspent: Vec < _ > = wallet. list_unspent ( ) . collect ( ) ;
4239
4239
assert_eq ! ( unspent. len( ) , 1 ) ;
4240
4240
let utxo = unspent. first ( ) . unwrap ( ) ;
4241
- assert ! ( utxo. txout. value < amt ) ;
4241
+ assert ! ( utxo. txout. value < amount ) ;
4242
4242
assert_eq ! (
4243
4243
utxo. keychain,
4244
4244
KeychainKind :: External ,
@@ -4249,7 +4249,7 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4249
4249
#[ test]
4250
4250
fn test_transactions_sort_by ( ) {
4251
4251
let ( mut wallet, _txid) = get_funded_wallet_wpkh ( ) ;
4252
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
4252
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
4253
4253
4254
4254
// sort by chain position, unconfirmed then confirmed by descending block height
4255
4255
let sorted_txs: Vec < WalletTx > =
0 commit comments