@@ -36,6 +36,7 @@ pub struct Vout {
3636 pub scriptpubkey : ScriptBuf ,
3737}
3838
39+ ///Represents Transaction Status.
3940#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
4041pub struct TxStatus {
4142 pub confirmed : bool ,
@@ -51,6 +52,7 @@ pub struct MerkleProof {
5152 pub pos : usize ,
5253}
5354
55+ /// Struct that contains the status of an output in a transaction.
5456#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
5557pub struct OutputStatus {
5658 pub spent : bool ,
@@ -59,13 +61,19 @@ pub struct OutputStatus {
5961 pub status : Option < TxStatus > ,
6062}
6163
64+ ///A Struct represents the status of a block in the blockchain.
65+ /// `in_best_chain` - a boolean that shows whether the block is part of the main chain.
66+ /// `height` - Optional field that shows the height of the block if block is in main chain.
67+ /// `next_best` - Optional field that contains `BlockHash` of the next block that may represent
68+ /// the next block in the best chain.
6269#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
6370pub struct BlockStatus {
6471 pub in_best_chain : bool ,
6572 pub height : Option < u32 > ,
6673 pub next_best : Option < BlockHash > ,
6774}
6875
76+ ///Structure represents a complete transaction
6977#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
7078pub struct Tx {
7179 pub txid : Txid ,
@@ -81,12 +89,15 @@ pub struct Tx {
8189 pub fee : u64 ,
8290}
8391
92+ ///Returns timing information of a Block
93+ /// containg `timestamp` and `height` of block
8494#[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
8595pub struct BlockTime {
8696 pub timestamp : u64 ,
8797 pub height : u32 ,
8898}
89-
99+ ///Provides a Summary of a Bitcoin block which includes
100+ /// `BlockHash`, `BlockTime`, `previousblockhash`, `merkle_root`.
90101#[ derive( Debug , Clone , Deserialize , PartialEq , Eq ) ]
91102pub struct BlockSummary {
92103 pub id : BlockHash ,
@@ -124,6 +135,7 @@ pub struct AddressTxsSummary {
124135}
125136
126137impl Tx {
138+ ///Converts a transaction into a standard `Bitcoin transaction`.
127139 pub fn to_tx ( & self ) -> Transaction {
128140 Transaction {
129141 version : transaction:: Version :: non_standard ( self . version ) ,
@@ -154,6 +166,9 @@ impl Tx {
154166 }
155167 }
156168
169+ ///Checks Transaction status, returns a `BlockTime` struct contaning
170+ /// `height` and `timestamp` if transaction has been confirmed or
171+ /// `None` otherwise.
157172 pub fn confirmation_time ( & self ) -> Option < BlockTime > {
158173 match self . status {
159174 TxStatus {
@@ -166,6 +181,10 @@ impl Tx {
166181 }
167182 }
168183
184+ ///Takes Transaction as input
185+ /// iterates through all the inputs present in the transaction
186+ /// and checks for prevout field and creates a `TxOut` Struct for each input if it exists
187+ /// then returns all optional TxOut values as a vector.
169188 pub fn previous_outputs ( & self ) -> Vec < Option < TxOut > > {
170189 self . vin
171190 . iter ( )
@@ -178,11 +197,13 @@ impl Tx {
178197 } )
179198 . collect ( )
180199 }
181-
200+ ///Takes Transaction as input and returns
201+ /// the `Weight instance` of the weight present in Transaction.
182202 pub fn weight ( & self ) -> Weight {
183203 Weight :: from_wu ( self . weight )
184204 }
185-
205+ ///Takes Transaction as input and returns
206+ /// the `Amount instance` of the satoshis present in Transaction.
186207 pub fn fee ( & self ) -> Amount {
187208 Amount :: from_sat ( self . fee )
188209 }
0 commit comments