14
14
15
15
use std:: { error, fmt} ;
16
16
17
- use crate :: Txid ;
18
17
use crate :: encode;
18
+ use crate :: Txid ;
19
19
20
20
use super :: raw;
21
21
22
- use crate :: hashes;
23
22
use crate :: blind:: ConfidentialTxOutError ;
23
+ use crate :: hashes;
24
24
use secp256k1_zkp;
25
25
26
26
#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
@@ -119,52 +119,94 @@ impl fmt::Display for Error {
119
119
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
120
120
match * self {
121
121
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
+ ) ,
123
126
Error :: DuplicateKey ( ref rkey) => write ! ( f, "duplicate key: {}" , rkey) ,
124
127
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
+ }
127
135
Error :: InvalidMagic => f. write_str ( "invalid magic" ) ,
128
136
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
+ }
131
143
Error :: MustHaveUnsignedTx => {
132
144
f. write_str ( "partially signed transactions must have an unsigned transaction" )
133
145
}
134
146
Error :: NoMorePairs => f. write_str ( "no more key-value pairs for this pset map" ) ,
135
147
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
+ } => {
137
153
// 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)
139
162
}
140
- Error :: MergeConflict ( ref s) => { write ! ( f, "Merge conflict: {}" , s) }
141
163
Error :: ConsensusEncoding => f. write_str ( "bitcoin consensus encoding error" ) ,
142
164
Error :: TooLargePset => {
143
165
write ! ( f, "Psets with 10_000 or more inputs/outputs unsupported" )
144
166
}
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
+ }
146
170
Error :: IncorrectPsetVersion => f. write_str ( "Pset version must be 2" ) ,
147
171
Error :: MissingTxVersion => f. write_str ( "PSET missing global transaction version" ) ,
148
172
Error :: MissingInputCount => f. write_str ( "PSET missing input count" ) ,
149
173
Error :: MissingOutputCount => f. write_str ( "PSET missing output count" ) ,
150
174
Error :: MissingInputPrevTxId => f. write_str ( "PSET input missing previous txid" ) ,
151
175
Error :: MissingInputPrevVout => f. write_str ( "PSET input missing previous output index" ) ,
152
176
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
- at least one of explicit/confidential value set") ,
157
- Error :: MissingOutputAsset => f. write_str ( "PSET output missing asset. Must have \
158
- at least one of explicit/confidential asset set") ,
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
- some blinding information") ,
162
- Error :: MissingOutputSpk => f. write_str ( "PSET output missing script pubkey. Must have \
163
- exactly one of explicit/confidential script pubkey set") ,
164
- Error :: InputCountMismatch => f. write_str ( "PSET input count global field must \
165
- match the number of inputs") ,
166
- Error :: OutputCountMismatch => f. write_str ( "PSET output count global field must \
167
- match the number of outputs") ,
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
+ at least one of explicit/confidential value set",
186
+ ) ,
187
+ Error :: MissingOutputAsset => f. write_str (
188
+ "PSET output missing asset. Must have \
189
+ at least one of explicit/confidential asset set",
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
+ some blinding information",
197
+ ) ,
198
+ Error :: MissingOutputSpk => f. write_str (
199
+ "PSET output missing script pubkey. Must have \
200
+ exactly one of explicit/confidential script pubkey set",
201
+ ) ,
202
+ Error :: InputCountMismatch => f. write_str (
203
+ "PSET input count global field must \
204
+ match the number of inputs",
205
+ ) ,
206
+ Error :: OutputCountMismatch => f. write_str (
207
+ "PSET output count global field must \
208
+ match the number of outputs",
209
+ ) ,
168
210
}
169
211
}
170
212
}
@@ -223,8 +265,12 @@ impl fmt::Display for PsetBlindError {
223
265
write ! ( f, "Atleast one output secrets should be provided" )
224
266
}
225
267
PsetBlindError :: BlinderIndexOutOfBounds ( i, bl) => {
226
- write ! ( f, "Blinder index {} for output index {} must be less \
227
- than total input count", bl, i)
268
+ write ! (
269
+ f,
270
+ "Blinder index {} for output index {} must be less \
271
+ than total input count",
272
+ bl, i
273
+ )
228
274
}
229
275
PsetBlindError :: MissingInputBlinds ( i, bl) => {
230
276
write ! ( f, "Output index {} expects blinding input index {}" , i, bl)
@@ -239,9 +285,13 @@ impl fmt::Display for PsetBlindError {
239
285
write ! ( f, "Blinding error {} at output index {}" , e, i)
240
286
}
241
287
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
+ )
243
293
}
244
294
}
245
295
}
246
296
}
247
- impl error:: Error for PsetBlindError { }
297
+ impl error:: Error for PsetBlindError { }
0 commit comments