@@ -19,14 +19,14 @@ use bdk_wallet::{KeychainKind, LoadError, LoadMismatch, LoadWithPersistError};
1919use bitcoin:: constants:: { ChainHash , COINBASE_MATURITY } ;
2020use bitcoin:: hashes:: Hash ;
2121use bitcoin:: key:: Secp256k1 ;
22- use bitcoin:: psbt;
2322use bitcoin:: script:: PushBytesBuf ;
2423use bitcoin:: sighash:: { EcdsaSighashType , TapSighashType } ;
2524use bitcoin:: taproot:: TapNodeHash ;
2625use bitcoin:: {
2726 absolute, transaction, Address , Amount , BlockHash , FeeRate , Network , OutPoint , ScriptBuf ,
2827 Sequence , Transaction , TxIn , TxOut , Txid , Weight ,
2928} ;
29+ use bitcoin:: { psbt, SignedAmount } ;
3030use miniscript:: { descriptor:: KeyMap , Descriptor , DescriptorPublicKey } ;
3131use rand:: rngs:: StdRng ;
3232use rand:: SeedableRng ;
@@ -4617,3 +4617,26 @@ fn test_wallet_transactions_relevant() {
46174617 assert ! ( full_tx_count_before < full_tx_count_after) ;
46184618 assert ! ( canonical_tx_count_before < canonical_tx_count_after) ;
46194619}
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