@@ -1576,12 +1576,12 @@ fn test_create_tx_increment_change_index() {
1576
1576
descriptor : & ' static str ,
1577
1577
change_descriptor : Option < & ' static str > ,
1578
1578
// amount to send
1579
- to_send : u64 ,
1579
+ to_send : Amount ,
1580
1580
// (derivation index, next unused index) of *change keychain*
1581
1581
expect : ( Option < u32 > , u32 ) ,
1582
1582
}
1583
1583
// total wallet funds
1584
- let amount = 10_000 ;
1584
+ let amount = Amount :: from_sat ( 10_000 ) ;
1585
1585
let recipient = Address :: from_str ( "bcrt1q3qtze4ys45tgdvguj66zrk4fu6hq3a3v9pfly5" )
1586
1586
. unwrap ( )
1587
1587
. assume_checked ( )
@@ -1592,55 +1592,55 @@ fn test_create_tx_increment_change_index() {
1592
1592
name : "two wildcard, builder error" ,
1593
1593
descriptor : desc,
1594
1594
change_descriptor : Some ( change_desc) ,
1595
- to_send : amount + 1 ,
1595
+ to_send : amount + Amount :: from_sat ( 1 ) ,
1596
1596
// should not use or derive change index
1597
1597
expect : ( None , 0 ) ,
1598
1598
} ,
1599
1599
TestCase {
1600
1600
name : "two wildcard, create change" ,
1601
1601
descriptor : desc,
1602
1602
change_descriptor : Some ( change_desc) ,
1603
- to_send : 5_000 ,
1603
+ to_send : Amount :: from_sat ( 5_000 ) ,
1604
1604
// should use change index
1605
1605
expect : ( Some ( 0 ) , 1 ) ,
1606
1606
} ,
1607
1607
TestCase {
1608
1608
name : "two wildcard, no change" ,
1609
1609
descriptor : desc,
1610
1610
change_descriptor : Some ( change_desc) ,
1611
- to_send : 9_850 ,
1611
+ to_send : Amount :: from_sat ( 9_850 ) ,
1612
1612
// should not use change index
1613
1613
expect : ( None , 0 ) ,
1614
1614
} ,
1615
1615
TestCase {
1616
1616
name : "one wildcard, create change" ,
1617
1617
descriptor : desc,
1618
1618
change_descriptor : None ,
1619
- to_send : 5_000 ,
1619
+ to_send : Amount :: from_sat ( 5_000 ) ,
1620
1620
// should use change index of external keychain
1621
1621
expect : ( Some ( 1 ) , 2 ) ,
1622
1622
} ,
1623
1623
TestCase {
1624
1624
name : "one wildcard, no change" ,
1625
1625
descriptor : desc,
1626
1626
change_descriptor : None ,
1627
- to_send : 9_850 ,
1627
+ to_send : Amount :: from_sat ( 9_850 ) ,
1628
1628
// should not use change index
1629
1629
expect : ( Some ( 0 ) , 1 ) ,
1630
1630
} ,
1631
1631
TestCase {
1632
1632
name : "single key, create change" ,
1633
1633
descriptor : get_test_tr_single_sig ( ) ,
1634
1634
change_descriptor : None ,
1635
- to_send : 5_000 ,
1635
+ to_send : Amount :: from_sat ( 5_000 ) ,
1636
1636
// single key only has one derivation index (0)
1637
1637
expect : ( Some ( 0 ) , 0 ) ,
1638
1638
} ,
1639
1639
TestCase {
1640
1640
name : "single key, no change" ,
1641
1641
descriptor : get_test_tr_single_sig ( ) ,
1642
1642
change_descriptor : None ,
1643
- to_send : 9_850 ,
1643
+ to_send : Amount :: from_sat ( 9_850 ) ,
1644
1644
expect : ( Some ( 0 ) , 0 ) ,
1645
1645
} ,
1646
1646
]
@@ -1665,7 +1665,7 @@ fn test_create_tx_increment_change_index() {
1665
1665
receive_output ( & mut wallet, amount, ReceiveTo :: Mempool ( 0 ) ) ;
1666
1666
// create tx
1667
1667
let mut builder = wallet. build_tx ( ) ;
1668
- builder. add_recipient ( recipient. clone ( ) , Amount :: from_sat ( test. to_send ) ) ;
1668
+ builder. add_recipient ( recipient. clone ( ) , test. to_send ) ;
1669
1669
let res = builder. finish ( ) ;
1670
1670
if !test. name . contains ( "error" ) {
1671
1671
assert ! ( res. is_ok( ) ) ;
@@ -2557,7 +2557,7 @@ fn test_legacy_bump_fee_add_input() {
2557
2557
#[ test]
2558
2558
fn test_bump_fee_absolute_add_input ( ) {
2559
2559
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2560
- receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2560
+ receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2561
2561
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2562
2562
. unwrap ( )
2563
2563
. assume_checked ( ) ;
@@ -2605,7 +2605,7 @@ fn test_bump_fee_absolute_add_input() {
2605
2605
#[ test]
2606
2606
fn test_legacy_bump_fee_absolute_add_input ( ) {
2607
2607
let ( mut wallet, _) = get_funded_wallet_single ( get_test_pkh ( ) ) ;
2608
- receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2608
+ receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2609
2609
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2610
2610
. unwrap ( )
2611
2611
. assume_checked ( ) ;
@@ -2653,7 +2653,7 @@ fn test_legacy_bump_fee_absolute_add_input() {
2653
2653
#[ test]
2654
2654
fn test_bump_fee_no_change_add_input_and_change ( ) {
2655
2655
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2656
- let op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2656
+ let op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2657
2657
2658
2658
// initially make a tx without change by using `drain_to`
2659
2659
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
@@ -2716,7 +2716,7 @@ fn test_bump_fee_no_change_add_input_and_change() {
2716
2716
#[ test]
2717
2717
fn test_bump_fee_add_input_change_dust ( ) {
2718
2718
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2719
- receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2719
+ receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2720
2720
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2721
2721
. unwrap ( )
2722
2722
. assume_checked ( ) ;
@@ -2786,7 +2786,7 @@ fn test_bump_fee_add_input_change_dust() {
2786
2786
#[ test]
2787
2787
fn test_bump_fee_force_add_input ( ) {
2788
2788
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2789
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2789
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2790
2790
2791
2791
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2792
2792
. unwrap ( )
@@ -2843,7 +2843,7 @@ fn test_bump_fee_force_add_input() {
2843
2843
#[ test]
2844
2844
fn test_bump_fee_absolute_force_add_input ( ) {
2845
2845
let ( mut wallet, _) = get_funded_wallet_wpkh ( ) ;
2846
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 25_000 ) ;
2846
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 25_000 ) ) ;
2847
2847
2848
2848
let addr = Address :: from_str ( "2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX" )
2849
2849
. unwrap ( )
@@ -2917,7 +2917,7 @@ fn test_bump_fee_unconfirmed_inputs_only() {
2917
2917
let psbt = builder. finish ( ) . unwrap ( ) ;
2918
2918
// Now we receive one transaction with 0 confirmations. We won't be able to use that for
2919
2919
// fee bumping, as it's still unconfirmed!
2920
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
2920
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
2921
2921
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2922
2922
let txid = tx. compute_txid ( ) ;
2923
2923
for txin in & mut tx. input {
@@ -2943,7 +2943,7 @@ fn test_bump_fee_unconfirmed_input() {
2943
2943
. assume_checked ( ) ;
2944
2944
// We receive a tx with 0 confirmations, which will be used as an input
2945
2945
// in the drain tx.
2946
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
2946
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
2947
2947
let mut builder = wallet. build_tx ( ) ;
2948
2948
builder. drain_wallet ( ) . drain_to ( addr. script_pubkey ( ) ) ;
2949
2949
let psbt = builder. finish ( ) . unwrap ( ) ;
@@ -2982,7 +2982,7 @@ fn test_fee_amount_negative_drain_val() {
2982
2982
. unwrap ( )
2983
2983
. assume_checked ( ) ;
2984
2984
let fee_rate = FeeRate :: from_sat_per_kwu ( 500 ) ;
2985
- let incoming_op = receive_output_in_latest_block ( & mut wallet, 8859 ) ;
2985
+ let incoming_op = receive_output_in_latest_block ( & mut wallet, Amount :: from_sat ( 8859 ) ) ;
2986
2986
2987
2987
let mut builder = wallet. build_tx ( ) ;
2988
2988
builder
@@ -3354,7 +3354,7 @@ fn test_next_unused_address() {
3354
3354
assert_eq ! ( next_unused_addr. index, 0 ) ;
3355
3355
3356
3356
// use the above address
3357
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
3357
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
3358
3358
3359
3359
assert_eq ! (
3360
3360
wallet
@@ -4431,7 +4431,7 @@ fn test_keychains_with_overlapping_spks() {
4431
4431
} ,
4432
4432
confirmation_time : 0 ,
4433
4433
} ;
4434
- let _outpoint = receive_output_to_address ( & mut wallet, addr, 8000 , anchor) ;
4434
+ let _outpoint = receive_output_to_address ( & mut wallet, addr, Amount :: from_sat ( 8000 ) , anchor) ;
4435
4435
assert_eq ! ( wallet. balance( ) . confirmed, Amount :: from_sat( 58000 ) ) ;
4436
4436
}
4437
4437
@@ -4521,14 +4521,14 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4521
4521
. create_wallet_no_persist ( )
4522
4522
. unwrap ( ) ;
4523
4523
assert_eq ! ( wallet. keychains( ) . count( ) , 1 ) ;
4524
- let amt = Amount :: from_sat ( 5_000 ) ;
4525
- receive_output ( & mut wallet, 2 * amt . to_sat ( ) , ReceiveTo :: Mempool ( 2 ) ) ;
4524
+ let amount = Amount :: from_sat ( 5_000 ) ;
4525
+ receive_output ( & mut wallet, amount * 2 , ReceiveTo :: Mempool ( 2 ) ) ;
4526
4526
// create spend tx that produces a change output
4527
4527
let addr = Address :: from_str ( "bcrt1qc6fweuf4xjvz4x3gx3t9e0fh4hvqyu2qw4wvxm" )
4528
4528
. unwrap ( )
4529
4529
. assume_checked ( ) ;
4530
4530
let mut builder = wallet. build_tx ( ) ;
4531
- builder. add_recipient ( addr. script_pubkey ( ) , amt ) ;
4531
+ builder. add_recipient ( addr. script_pubkey ( ) , amount ) ;
4532
4532
let mut psbt = builder. finish ( ) . unwrap ( ) ;
4533
4533
assert ! ( wallet. sign( & mut psbt, SignOptions :: default ( ) ) . unwrap( ) ) ;
4534
4534
let tx = psbt. extract_tx ( ) . unwrap ( ) ;
@@ -4537,7 +4537,7 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4537
4537
let unspent: Vec < _ > = wallet. list_unspent ( ) . collect ( ) ;
4538
4538
assert_eq ! ( unspent. len( ) , 1 ) ;
4539
4539
let utxo = unspent. first ( ) . unwrap ( ) ;
4540
- assert ! ( utxo. txout. value < amt ) ;
4540
+ assert ! ( utxo. txout. value < amount ) ;
4541
4541
assert_eq ! (
4542
4542
utxo. keychain,
4543
4543
KeychainKind :: External ,
@@ -4548,7 +4548,7 @@ fn single_descriptor_wallet_can_create_tx_and_receive_change() {
4548
4548
#[ test]
4549
4549
fn test_transactions_sort_by ( ) {
4550
4550
let ( mut wallet, _txid) = get_funded_wallet_wpkh ( ) ;
4551
- receive_output ( & mut wallet, 25_000 , ReceiveTo :: Mempool ( 0 ) ) ;
4551
+ receive_output ( & mut wallet, Amount :: from_sat ( 25_000 ) , ReceiveTo :: Mempool ( 0 ) ) ;
4552
4552
4553
4553
// sort by chain position, unconfirmed then confirmed by descending block height
4554
4554
let sorted_txs: Vec < WalletTx > =
0 commit comments