1- use  crate :: bitcoin:: { OutPoint ,  PartiallySignedTransaction } ; 
1+ use  crate :: bitcoin:: { OutPoint ,  PartiallySignedTransaction ,   Transaction } ; 
22use  crate :: descriptor:: Descriptor ; 
33use  crate :: { AddressIndex ,  AddressInfo ,  Network ,  ScriptAmount } ; 
44use  crate :: { Balance ,  Script } ; 
@@ -13,6 +13,8 @@ use bdk::{SignOptions, Wallet as BdkWallet};
1313use  bdk:: wallet:: tx_builder:: ChangeSpendPolicy ; 
1414use  std:: sync:: { Arc ,  Mutex ,  MutexGuard } ; 
1515
16+ use  crate :: SentAndReceivedResult ; 
17+ 
1618#[ derive( Debug ) ]  
1719pub  struct  Wallet  { 
1820    // TODO 8: Do we really need the mutex on the wallet? Could this be an Arc? 
@@ -92,6 +94,11 @@ impl Wallet {
9294            . sign ( & mut  psbt,  SignOptions :: default ( ) ) 
9395            . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) ) 
9496    } 
97+ 
98+     pub  fn  sent_and_received ( & self ,  tx :  & Transaction )  -> SentAndReceivedResult  { 
99+         let  ( sent,  received) :  ( u64 ,  u64 )  = self . get_wallet ( ) . sent_and_received ( & tx. clone ( ) . into ( ) ) ; 
100+         SentAndReceivedResult  {  sent,  received } 
101+     } 
95102} 
96103
97104pub  struct  Update ( pub ( crate )  BdkUpdate ) ; 
0 commit comments