@@ -19,14 +19,14 @@ use bdk_wallet::{KeychainKind, LoadError, LoadMismatch, LoadWithPersistError};
19
19
use bitcoin:: constants:: { ChainHash , COINBASE_MATURITY } ;
20
20
use bitcoin:: hashes:: Hash ;
21
21
use bitcoin:: key:: Secp256k1 ;
22
- use bitcoin:: psbt;
23
22
use bitcoin:: script:: PushBytesBuf ;
24
23
use bitcoin:: sighash:: { EcdsaSighashType , TapSighashType } ;
25
24
use bitcoin:: taproot:: TapNodeHash ;
26
25
use bitcoin:: {
27
26
absolute, transaction, Address , Amount , BlockHash , FeeRate , Network , OutPoint , ScriptBuf ,
28
27
Sequence , Transaction , TxIn , TxOut , Txid , Weight ,
29
28
} ;
29
+ use bitcoin:: { psbt, SignedAmount } ;
30
30
use miniscript:: { descriptor:: KeyMap , Descriptor , DescriptorPublicKey } ;
31
31
use rand:: rngs:: StdRng ;
32
32
use rand:: SeedableRng ;
@@ -4617,3 +4617,26 @@ fn test_wallet_transactions_relevant() {
4617
4617
assert ! ( full_tx_count_before < full_tx_count_after) ;
4618
4618
assert ! ( canonical_tx_count_before < canonical_tx_count_after) ;
4619
4619
}
4620
+
4621
+ #[ test]
4622
+ fn test_tx_details_method ( ) {
4623
+ let ( test_wallet, txid_1) = get_funded_wallet_wpkh ( ) ;
4624
+ let tx_details_1_option = test_wallet. tx_details ( txid_1) ;
4625
+
4626
+ assert ! ( tx_details_1_option. is_some( ) ) ;
4627
+ let tx_details_1 = tx_details_1_option. unwrap ( ) ;
4628
+
4629
+ assert_eq ! (
4630
+ tx_details_1. txid. to_string( ) ,
4631
+ "f2a03cdfe1bb6a295b0a4bb4385ca42f95e4b2c6d9a7a59355d32911f957a5b3"
4632
+ ) ;
4633
+ assert_eq ! ( tx_details_1. received, Amount :: from_sat( 50000 ) ) ;
4634
+ assert_eq ! ( tx_details_1. sent, Amount :: from_sat( 76000 ) ) ;
4635
+ assert_eq ! ( tx_details_1. fee. unwrap( ) , Amount :: from_sat( 1000 ) ) ;
4636
+ assert_eq ! ( tx_details_1. balance_delta, SignedAmount :: from_sat( -26000 ) ) ;
4637
+
4638
+ // Transaction id not part of the TxGraph
4639
+ let txid_2 = Txid :: from_raw_hash ( Hash :: all_zeros ( ) ) ;
4640
+ let tx_details_2_option = test_wallet. tx_details ( txid_2) ;
4641
+ assert ! ( tx_details_2_option. is_none( ) ) ;
4642
+ }
0 commit comments