@@ -32,53 +32,53 @@ impl Asset {
3232 asset : AssetId ,
3333 bf : AssetBlindingFactor ,
3434 ) -> Self {
35- Asset :: Confidential ( Generator :: new_blinded ( secp, asset. into_tag ( ) , bf. into_inner ( ) ) )
35+ Self :: Confidential ( Generator :: new_blinded ( secp, asset. into_tag ( ) , bf. into_inner ( ) ) )
3636 }
3737
3838 /// Serialized length, in bytes
3939 pub fn encoded_length ( & self ) -> usize {
4040 match * self {
41- Asset :: Null => 1 ,
42- Asset :: Explicit ( ..) => 33 ,
43- Asset :: Confidential ( ..) => 33 ,
41+ Self :: Null => 1 ,
42+ Self :: Explicit ( ..) => 33 ,
43+ Self :: Confidential ( ..) => 33 ,
4444 }
4545 }
4646
4747 /// Create from commitment.
4848 pub fn from_commitment ( bytes : & [ u8 ] ) -> Result < Self , encode:: Error > {
49- Ok ( Asset :: Confidential ( Generator :: from_slice ( bytes) ?) )
49+ Ok ( Self :: Confidential ( Generator :: from_slice ( bytes) ?) )
5050 }
5151
5252 /// Check if the object is null.
53- pub fn is_null ( & self ) -> bool { matches ! ( * self , Asset :: Null ) }
53+ pub fn is_null ( & self ) -> bool { matches ! ( * self , Self :: Null ) }
5454
5555 /// Check if the object is explicit.
56- pub fn is_explicit ( & self ) -> bool { matches ! ( * self , Asset :: Explicit ( _) ) }
56+ pub fn is_explicit ( & self ) -> bool { matches ! ( * self , Self :: Explicit ( _) ) }
5757
5858 /// Check if the object is confidential.
59- pub fn is_confidential ( & self ) -> bool { matches ! ( * self , Asset :: Confidential ( _) ) }
59+ pub fn is_confidential ( & self ) -> bool { matches ! ( * self , Self :: Confidential ( _) ) }
6060
6161 /// Returns the explicit inner value.
62- /// Returns [None] if [`Asset ::is_explicit`] returns false.
62+ /// Returns [None] if [`Self ::is_explicit`] returns false.
6363 pub fn explicit ( & self ) -> Option < AssetId > {
6464 match * self {
65- Asset :: Explicit ( i) => Some ( i) ,
65+ Self :: Explicit ( i) => Some ( i) ,
6666 _ => None ,
6767 }
6868 }
6969
7070 /// Returns the confidential commitment in case of a confidential value.
71- /// Returns [None] if [`Asset ::is_confidential`] returns false.
71+ /// Returns [None] if [`Self ::is_confidential`] returns false.
7272 pub fn commitment ( & self ) -> Option < Generator > {
7373 match * self {
74- Asset :: Confidential ( i) => Some ( i) ,
74+ Self :: Confidential ( i) => Some ( i) ,
7575 _ => None ,
7676 }
7777 }
7878
7979 /// Internally used function for getting the generator from asset
8080 /// Used in the amount verification check
81- /// Returns [`None`] is the asset is [`Asset ::Null`]
81+ /// Returns [`None`] is the asset is [`Self ::Null`]
8282 /// Converts a explicit asset into a generator and returns the confidential
8383 /// generator as is.
8484 pub fn into_asset_gen < C : secp256k1_zkp:: Signing > (
@@ -88,36 +88,36 @@ impl Asset {
8888 match self {
8989 // Only error is Null error which is dealt with later
9090 // when we have more context information about it.
91- Asset :: Null => None ,
92- Asset :: Explicit ( x) => Some ( Generator :: new_unblinded ( secp, x. into_tag ( ) ) ) ,
93- Asset :: Confidential ( gen) => Some ( gen) ,
91+ Self :: Null => None ,
92+ Self :: Explicit ( x) => Some ( Generator :: new_unblinded ( secp, x. into_tag ( ) ) ) ,
93+ Self :: Confidential ( gen) => Some ( gen) ,
9494 }
9595 }
9696}
9797
9898impl From < Generator > for Asset {
99- fn from ( from : Generator ) -> Self { Asset :: Confidential ( from) }
99+ fn from ( from : Generator ) -> Self { Self :: Confidential ( from) }
100100}
101101
102102impl fmt:: Display for Asset {
103103 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
104104 match * self {
105- Asset :: Null => f. write_str ( "null" ) ,
106- Asset :: Explicit ( n) => write ! ( f, "{}" , n) ,
107- Asset :: Confidential ( generator) => write ! ( f, "{:02x}" , generator) ,
105+ Self :: Null => f. write_str ( "null" ) ,
106+ Self :: Explicit ( n) => write ! ( f, "{}" , n) ,
107+ Self :: Confidential ( generator) => write ! ( f, "{:02x}" , generator) ,
108108 }
109109 }
110110}
111111
112112impl Encodable for Asset {
113113 fn consensus_encode < S : io:: Write > ( & self , mut s : S ) -> Result < usize , encode:: Error > {
114114 match * self {
115- Asset :: Null => 0u8 . consensus_encode ( s) ,
116- Asset :: Explicit ( n) => {
115+ Self :: Null => 0u8 . consensus_encode ( s) ,
116+ Self :: Explicit ( n) => {
117117 1u8 . consensus_encode ( & mut s) ?;
118118 Ok ( 1 + n. consensus_encode ( & mut s) ?)
119119 }
120- Asset :: Confidential ( generator) => {
120+ Self :: Confidential ( generator) => {
121121 s. write_all ( & generator. serialize ( ) ) ?;
122122 Ok ( 33 )
123123 }
@@ -130,16 +130,16 @@ impl Decodable for Asset {
130130 let prefix = u8:: consensus_decode ( & mut d) ?;
131131
132132 match prefix {
133- 0 => Ok ( Asset :: Null ) ,
133+ 0 => Ok ( Self :: Null ) ,
134134 1 => {
135135 let explicit = Decodable :: consensus_decode ( & mut d) ?;
136- Ok ( Asset :: Explicit ( explicit) )
136+ Ok ( Self :: Explicit ( explicit) )
137137 }
138138 p if p == 0x0a || p == 0x0b => {
139139 let mut comm = [ 0u8 ; 33 ] ;
140140 comm[ 0 ] = p;
141141 d. read_exact ( & mut comm[ 1 ..] ) ?;
142- Ok ( Asset :: Confidential ( Generator :: from_slice ( & comm[ ..] ) ?) )
142+ Ok ( Self :: Confidential ( Generator :: from_slice ( & comm[ ..] ) ?) )
143143 }
144144 p => Err ( encode:: Error :: InvalidConfidentialPrefix ( p) ) ,
145145 }
@@ -152,18 +152,18 @@ impl Serialize for Asset {
152152 use serde:: ser:: SerializeSeq ;
153153
154154 let seq_len = match * self {
155- Asset :: Null => 1 ,
156- Asset :: Explicit ( _) | Asset :: Confidential ( _) => 2 ,
155+ Self :: Null => 1 ,
156+ Self :: Explicit ( _) | Self :: Confidential ( _) => 2 ,
157157 } ;
158158 let mut seq = s. serialize_seq ( Some ( seq_len) ) ?;
159159
160160 match * self {
161- Asset :: Null => seq. serialize_element ( & 0u8 ) ?,
162- Asset :: Explicit ( n) => {
161+ Self :: Null => seq. serialize_element ( & 0u8 ) ?,
162+ Self :: Explicit ( n) => {
163163 seq. serialize_element ( & 1u8 ) ?;
164164 seq. serialize_element ( & n) ?;
165165 }
166- Asset :: Confidential ( commitment) => {
166+ Self :: Confidential ( commitment) => {
167167 seq. serialize_element ( & 2u8 ) ?;
168168 seq. serialize_element ( & commitment) ?;
169169 }
@@ -185,16 +185,16 @@ impl<'de> Deserialize<'de> for Asset {
185185 f. write_str ( "a committed value" )
186186 }
187187
188- fn visit_seq < A : SeqAccess < ' de > > ( self , mut access : A ) -> Result < Asset , A :: Error > {
188+ fn visit_seq < A : SeqAccess < ' de > > ( self , mut access : A ) -> Result < Self :: Value , A :: Error > {
189189 let prefix = access. next_element :: < u8 > ( ) ?;
190190 match prefix {
191- Some ( 0 ) => Ok ( Asset :: Null ) ,
191+ Some ( 0 ) => Ok ( Self :: Value :: Null ) ,
192192 Some ( 1 ) => match access. next_element ( ) ? {
193- Some ( x) => Ok ( Asset :: Explicit ( x) ) ,
193+ Some ( x) => Ok ( Self :: Value :: Explicit ( x) ) ,
194194 None => Err ( A :: Error :: custom ( "missing explicit asset" ) ) ,
195195 } ,
196196 Some ( 2 ) => match access. next_element ( ) ? {
197- Some ( x) => Ok ( Asset :: Confidential ( x) ) ,
197+ Some ( x) => Ok ( Self :: Value :: Confidential ( x) ) ,
198198 None => Err ( A :: Error :: custom ( "missing generator" ) ) ,
199199 } ,
200200 _ => Err ( A :: Error :: custom ( "wrong or missing prefix" ) ) ,
@@ -212,27 +212,27 @@ pub struct AssetBlindingFactor(pub(crate) Tweak);
212212
213213impl AssetBlindingFactor {
214214 /// Generate random asset blinding factor.
215- pub fn new < R : Rng > ( rng : & mut R ) -> Self { AssetBlindingFactor ( Tweak :: new ( rng) ) }
215+ pub fn new < R : Rng > ( rng : & mut R ) -> Self { Self ( Tweak :: new ( rng) ) }
216216
217217 /// Parse a blinding factor from a 64-character hex string.
218218 #[ deprecated( since = "0.27.0" , note = "use s.parse() instead" ) ]
219219 pub fn from_hex ( s : & str ) -> Result < Self , encode:: Error > { s. parse ( ) }
220220
221221 /// Create from bytes.
222222 pub fn from_byte_array ( bytes : [ u8 ; 32 ] ) -> Result < Self , secp256k1_zkp:: Error > {
223- Ok ( AssetBlindingFactor ( Tweak :: from_inner ( bytes) ?) )
223+ Ok ( Self ( Tweak :: from_inner ( bytes) ?) )
224224 }
225225
226226 /// Create from bytes.
227227 pub fn from_slice ( bytes : & [ u8 ] ) -> Result < Self , secp256k1_zkp:: Error > {
228- Ok ( AssetBlindingFactor ( Tweak :: from_slice ( bytes) ?) )
228+ Ok ( Self ( Tweak :: from_slice ( bytes) ?) )
229229 }
230230
231231 /// Returns the inner value.
232232 pub fn into_inner ( self ) -> Tweak { self . 0 }
233233
234234 /// Get a unblinded/zero `AssetBlinding` factor
235- pub fn zero ( ) -> Self { AssetBlindingFactor ( ZERO_TWEAK ) }
235+ pub fn zero ( ) -> Self { Self ( ZERO_TWEAK ) }
236236}
237237
238238impl core:: borrow:: Borrow < [ u8 ] > for AssetBlindingFactor {
@@ -254,7 +254,7 @@ impl str::FromStr for AssetBlindingFactor {
254254 slice. reverse ( ) ;
255255
256256 let inner = Tweak :: from_inner ( slice) ?;
257- Ok ( AssetBlindingFactor ( inner) )
257+ Ok ( Self ( inner) )
258258 }
259259}
260260
@@ -271,7 +271,7 @@ impl Serialize for AssetBlindingFactor {
271271
272272#[ cfg( feature = "serde" ) ]
273273impl < ' de > Deserialize < ' de > for AssetBlindingFactor {
274- fn deserialize < D : Deserializer < ' de > > ( d : D ) -> Result < AssetBlindingFactor , D :: Error > {
274+ fn deserialize < D : Deserializer < ' de > > ( d : D ) -> Result < Self , D :: Error > {
275275 if d. is_human_readable ( ) {
276276 struct HexVisitor ;
277277
0 commit comments