1414
1515use  std:: { error,  fmt} ; 
1616
17- use  crate :: Txid ; 
1817use  crate :: encode; 
18+ use  crate :: Txid ; 
1919
2020use  super :: raw; 
2121
22- use  crate :: hashes; 
2322use  crate :: blind:: ConfidentialTxOutError ; 
23+ use  crate :: hashes; 
2424use  secp256k1_zkp; 
2525
2626#[ derive( Copy ,  Clone ,  PartialEq ,  Eq ,  Debug ) ]  
@@ -119,52 +119,94 @@ impl fmt::Display for Error {
119119    fn  fmt ( & self ,  f :  & mut  fmt:: Formatter )  -> fmt:: Result  { 
120120        match  * self  { 
121121            Error :: InvalidKey ( ref  rkey)  => write ! ( f,  "invalid key: {}" ,  rkey) , 
122-             Error :: InvalidProprietaryKey  => write ! ( f,  "non-proprietary key type found when proprietary key was expected" ) , 
122+             Error :: InvalidProprietaryKey  => write ! ( 
123+                 f, 
124+                 "non-proprietary key type found when proprietary key was expected" 
125+             ) , 
123126            Error :: DuplicateKey ( ref  rkey)  => write ! ( f,  "duplicate key: {}" ,  rkey) , 
124127            Error :: LocktimeConflict  => write ! ( f,  "conflicting locktime requirements" ) , 
125-             Error :: UniqueIdMismatch  {  expected :  ref  e,  actual :  ref  a }  => write ! ( f,  "different id: expected {}, actual {}" ,  e,  a) , 
126-             Error :: NonStandardSigHashType ( ref  sht)  => write ! ( f,  "non-standard sighash type: {}" ,  sht) , 
128+             Error :: UniqueIdMismatch  { 
129+                 expected :  ref  e, 
130+                 actual :  ref  a, 
131+             }  => write ! ( f,  "different id: expected {}, actual {}" ,  e,  a) , 
132+             Error :: NonStandardSigHashType ( ref  sht)  => { 
133+                 write ! ( f,  "non-standard sighash type: {}" ,  sht) 
134+             } 
127135            Error :: InvalidMagic  => f. write_str ( "invalid magic" ) , 
128136            Error :: InvalidSeparator  => f. write_str ( "invalid separator" ) , 
129-             Error :: UnsignedTxHasScriptSigs  => f. write_str ( "the unsigned transaction has script sigs" ) , 
130-             Error :: UnsignedTxHasScriptWitnesses  => f. write_str ( "the unsigned transaction has script witnesses" ) , 
137+             Error :: UnsignedTxHasScriptSigs  => { 
138+                 f. write_str ( "the unsigned transaction has script sigs" ) 
139+             } 
140+             Error :: UnsignedTxHasScriptWitnesses  => { 
141+                 f. write_str ( "the unsigned transaction has script witnesses" ) 
142+             } 
131143            Error :: MustHaveUnsignedTx  => { 
132144                f. write_str ( "partially signed transactions must have an unsigned transaction" ) 
133145            } 
134146            Error :: NoMorePairs  => f. write_str ( "no more key-value pairs for this pset map" ) , 
135147            Error :: HashParseError ( e)  => write ! ( f,  "Hash Parse Error: {}" ,  e) , 
136-             Error :: InvalidPreimageHashPair { ref  preimage,  ref  hash,  ref  hash_type}  => { 
148+             Error :: InvalidPreimageHashPair  { 
149+                 ref  preimage, 
150+                 ref  hash, 
151+                 ref  hash_type, 
152+             }  => { 
137153                // directly using debug forms of psethash enums 
138-                 write ! ( f,  "Preimage {:?} does not match {:?} hash {:?}" ,  preimage,  hash_type,  hash ) 
154+                 write ! ( 
155+                     f, 
156+                     "Preimage {:?} does not match {:?} hash {:?}" , 
157+                     preimage,  hash_type,  hash
158+                 ) 
159+             } 
160+             Error :: MergeConflict ( ref  s)  => { 
161+                 write ! ( f,  "Merge conflict: {}" ,  s) 
139162            } 
140-             Error :: MergeConflict ( ref  s)  => {  write ! ( f,  "Merge conflict: {}" ,  s)  } 
141163            Error :: ConsensusEncoding  => f. write_str ( "bitcoin consensus encoding error" ) , 
142164            Error :: TooLargePset  => { 
143165                write ! ( f,  "Psets with 10_000 or more inputs/outputs unsupported" ) 
144166            } 
145-             Error :: ExpiredPsbtv0Field  => f. write_str ( "psbt v0 field specified in pset(based on pset)" ) , 
167+             Error :: ExpiredPsbtv0Field  => { 
168+                 f. write_str ( "psbt v0 field specified in pset(based on pset)" ) 
169+             } 
146170            Error :: IncorrectPsetVersion  => f. write_str ( "Pset version must be 2" ) , 
147171            Error :: MissingTxVersion  => f. write_str ( "PSET missing global transaction version" ) , 
148172            Error :: MissingInputCount  => f. write_str ( "PSET missing input count" ) , 
149173            Error :: MissingOutputCount  => f. write_str ( "PSET missing output count" ) , 
150174            Error :: MissingInputPrevTxId  => f. write_str ( "PSET input missing previous txid" ) , 
151175            Error :: MissingInputPrevVout  => f. write_str ( "PSET input missing previous output index" ) , 
152176            Error :: SecpScalarSizeError ( actual)  => { 
153-                 write ! ( f,  "PSET blinding scalars must be 32 bytes. Found {} bytes" ,  actual) 
154-             } 
155-             Error :: MissingOutputValue  => f. write_str ( "PSET output missing value. Must have \  
156- ) , 
157-             Error :: MissingOutputAsset  => f. write_str ( "PSET output missing asset. Must have \  
158- ) , 
159-             Error :: MissingBlinderIndex  => f. write_str ( "Output is blinded but does not have a blinder index" ) , 
160-             Error :: MissingBlindingInfo  => f. write_str ( "Output marked for blinding, but missing \  
161- ) , 
162-             Error :: MissingOutputSpk  => f. write_str ( "PSET output missing script pubkey. Must have \  
163- ) , 
164-             Error :: InputCountMismatch  => f. write_str ( "PSET input count global field must \  
165- ) , 
166-             Error :: OutputCountMismatch  => f. write_str ( "PSET output count global field must \  
167- ) , 
177+                 write ! ( 
178+                     f, 
179+                     "PSET blinding scalars must be 32 bytes. Found {} bytes" , 
180+                     actual
181+                 ) 
182+             } 
183+             Error :: MissingOutputValue  => f. write_str ( 
184+                 "PSET output missing value. Must have \  
185+ , 
186+             ) , 
187+             Error :: MissingOutputAsset  => f. write_str ( 
188+                 "PSET output missing asset. Must have \  
189+ , 
190+             ) , 
191+             Error :: MissingBlinderIndex  => { 
192+                 f. write_str ( "Output is blinded but does not have a blinder index" ) 
193+             } 
194+             Error :: MissingBlindingInfo  => f. write_str ( 
195+                 "Output marked for blinding, but missing \  
196+ , 
197+             ) , 
198+             Error :: MissingOutputSpk  => f. write_str ( 
199+                 "PSET output missing script pubkey. Must have \  
200+ , 
201+             ) , 
202+             Error :: InputCountMismatch  => f. write_str ( 
203+                 "PSET input count global field must \  
204+ , 
205+             ) , 
206+             Error :: OutputCountMismatch  => f. write_str ( 
207+                 "PSET output count global field must \  
208+ , 
209+             ) , 
168210        } 
169211    } 
170212} 
@@ -223,8 +265,12 @@ impl fmt::Display for PsetBlindError {
223265                write ! ( f,  "Atleast one output secrets should be provided" ) 
224266            } 
225267            PsetBlindError :: BlinderIndexOutOfBounds ( i,  bl)  => { 
226-                 write ! ( f,  "Blinder index {} for output index {} must be less \  
227- ,  bl,  i) 
268+                 write ! ( 
269+                     f, 
270+                     "Blinder index {} for output index {} must be less \  
271+ , 
272+                     bl,  i
273+                 ) 
228274            } 
229275            PsetBlindError :: MissingInputBlinds ( i,  bl)  => { 
230276                write ! ( f,  "Output index {} expects blinding input index {}" ,  i,  bl) 
@@ -239,9 +285,13 @@ impl fmt::Display for PsetBlindError {
239285                write ! ( f,  "Blinding error {} at output index {}" ,  e,  i) 
240286            } 
241287            PsetBlindError :: BlindingProofsCreationError ( i,  e)  => { 
242-                 write ! ( f,  "Blinding proof creation error {} at output index {}" ,  e,  i) 
288+                 write ! ( 
289+                     f, 
290+                     "Blinding proof creation error {} at output index {}" , 
291+                     e,  i
292+                 ) 
243293            } 
244294        } 
245295    } 
246296} 
247- impl  error:: Error  for  PsetBlindError  { } 
297+ impl  error:: Error  for  PsetBlindError  { } 
0 commit comments