File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ interface Wallet {
9595
9696  [Throws=BdkError]
9797  boolean sign(PartiallySignedTransaction psbt);
98+ 
99+   SentAndReceivedResult sent_and_received([ByRef] Transaction tx);
98100};
99101
100102interface Update {};
@@ -235,6 +237,11 @@ dictionary ScriptAmount {
235237  u64 amount;
236238};
237239
240+ dictionary SentAndReceivedResult {
241+     u64 sent;
242+     u64 received;
243+ };
244+ 
238245// ------------------------------------------------------------------------
239246// bdk crate - bitcoin re-exports
240247// ------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ pub struct ScriptAmount {
3939    pub  amount :  u64 , 
4040} 
4141
42+ pub  struct  SentAndReceivedResult  { 
43+     pub  sent :  u64 , 
44+     pub  received :  u64 , 
45+ } 
46+ 
4247/// A derived address and the index it was found at. 
4348pub  struct  AddressInfo  { 
4449    /// Child index of this address. 
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ use bdk::{SignOptions, Wallet as BdkWallet};
1313use  bdk:: wallet:: tx_builder:: ChangeSpendPolicy ; 
1414use  std:: sync:: { Arc ,  Mutex ,  MutexGuard } ; 
1515
16+ use  crate :: SentAndReceivedResult ; 
17+ use  crate :: Transaction ; 
18+ 
1619#[ derive( Debug ) ]  
1720pub  struct  Wallet  { 
1821    // TODO 8: Do we really need the mutex on the wallet? Could this be an Arc? 
@@ -92,6 +95,11 @@ impl Wallet {
9295            . sign ( & mut  psbt,  SignOptions :: default ( ) ) 
9396            . map_err ( |e| BdkError :: Generic ( e. to_string ( ) ) ) 
9497    } 
98+ 
99+     pub  fn  sent_and_received ( & self ,  tx :  & Transaction )  -> SentAndReceivedResult  { 
100+         let  ( sent,  received) :  ( u64 ,  u64 )  = self . get_wallet ( ) . sent_and_received ( & tx. clone ( ) . into ( ) ) ; 
101+         SentAndReceivedResult  {  sent,  received } 
102+     } 
95103} 
96104
97105pub  struct  Update ( pub ( crate )  BdkUpdate ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments