@@ -109,16 +109,21 @@ impl Deserialize for EcdsaSig {
109
109
// also has a field sighash_u32 (See BIP141). For example, when signing with non-standard
110
110
// 0x05, the sighash message would have the last field as 0x05u32 while, the verification
111
111
// would use check the signature assuming sighash_u32 as `0x01`.
112
- match EcdsaSig :: from_slice ( & bytes) {
113
- Ok ( sig) => Ok ( sig) ,
114
- Err ( EcdsaSigError :: EmptySignature ) =>
115
- Err ( encode:: Error :: ParseFailed ( "Empty partial signature data" ) ) ,
116
- Err ( EcdsaSigError :: NonStandardSigHashType ( flag) ) =>
117
- Err ( encode:: Error :: from ( psbt:: Error :: NonStandardSigHashType ( flag) ) ) ,
118
- Err ( EcdsaSigError :: Secp256k1 ( ..) ) =>
119
- Err ( encode:: Error :: ParseFailed ( "Invalid Ecdsa signature" ) ) ,
120
- Err ( EcdsaSigError :: HexEncoding ( ..) ) => unreachable ! ( "Decoding from slice, not hex" )
121
- }
112
+ EcdsaSig :: from_slice ( & bytes)
113
+ . map_err ( |e| match e {
114
+ EcdsaSigError :: EmptySignature => {
115
+ encode:: Error :: ParseFailed ( "Empty partial signature data" )
116
+ }
117
+ EcdsaSigError :: NonStandardSigHashType ( flag) => {
118
+ encode:: Error :: from ( psbt:: Error :: NonStandardSigHashType ( flag) )
119
+ }
120
+ EcdsaSigError :: Secp256k1 ( ..) => {
121
+ encode:: Error :: ParseFailed ( "Invalid Ecdsa signature" )
122
+ }
123
+ EcdsaSigError :: HexEncoding ( ..) => {
124
+ unreachable ! ( "Decoding from slice, not hex" )
125
+ }
126
+ } )
122
127
}
123
128
}
124
129
@@ -205,16 +210,18 @@ impl Serialize for schnorr::SchnorrSig {
205
210
206
211
impl Deserialize for schnorr:: SchnorrSig {
207
212
fn deserialize ( bytes : & [ u8 ] ) -> Result < Self , encode:: Error > {
208
- match schnorr:: SchnorrSig :: from_slice ( & bytes) {
209
- Ok ( sig) => Ok ( sig) ,
210
- Err ( schnorr:: SchnorrSigError :: InvalidSighashType ( flag) ) => {
211
- Err ( encode:: Error :: from ( psbt:: Error :: NonStandardSigHashType ( flag as u32 ) ) )
212
- }
213
- Err ( schnorr:: SchnorrSigError :: InvalidSchnorrSigSize ( _) ) =>
214
- Err ( encode:: Error :: ParseFailed ( "Invalid Schnorr signature length" ) ) ,
215
- Err ( schnorr:: SchnorrSigError :: Secp256k1 ( ..) ) =>
216
- Err ( encode:: Error :: ParseFailed ( "Invalid Schnorr signature" ) ) ,
217
- }
213
+ schnorr:: SchnorrSig :: from_slice ( & bytes)
214
+ . map_err ( |e| match e {
215
+ schnorr:: SchnorrSigError :: InvalidSighashType ( flag) => {
216
+ encode:: Error :: from ( psbt:: Error :: NonStandardSigHashType ( flag as u32 ) )
217
+ }
218
+ schnorr:: SchnorrSigError :: InvalidSchnorrSigSize ( _) => {
219
+ encode:: Error :: ParseFailed ( "Invalid Schnorr signature length" )
220
+ }
221
+ schnorr:: SchnorrSigError :: Secp256k1 ( ..) => {
222
+ encode:: Error :: ParseFailed ( "Invalid Schnorr signature" )
223
+ }
224
+ } )
218
225
}
219
226
}
220
227
0 commit comments