@@ -82,7 +82,16 @@ impl fmt::Display for Error {
8282 }
8383}
8484
85- impl error:: Error for Error { }
85+ impl error:: Error for Error {
86+ fn cause ( & self ) -> Option < & dyn error:: Error > {
87+ use self :: Error :: * ;
88+
89+ match self {
90+ InputError ( e, _) => Some ( e) ,
91+ WrongInputCount { .. } | InputIdxOutofBounds { .. } => None ,
92+ }
93+ }
94+ }
8695
8796/// Error type for Pbst Input
8897#[ derive( Debug ) ]
@@ -148,6 +157,32 @@ pub enum InputError {
148157 } ,
149158}
150159
160+ impl error:: Error for InputError {
161+ fn cause ( & self ) -> Option < & dyn error:: Error > {
162+ use self :: InputError :: * ;
163+
164+ match self {
165+ CouldNotSatisfyTr
166+ | InvalidRedeemScript { .. }
167+ | InvalidWitnessScript { .. }
168+ | InvalidSignature { .. }
169+ | MissingRedeemScript
170+ | MissingWitness
171+ | MissingPubkey
172+ | MissingWitnessScript
173+ | MissingUtxo
174+ | NonEmptyWitnessScript
175+ | NonEmptyRedeemScript
176+ | NonStandardSighashType ( _)
177+ | WrongSighashFlag { .. } => None ,
178+ SecpErr ( e) => Some ( e) ,
179+ KeyErr ( e) => Some ( e) ,
180+ Interpreter ( e) => Some ( e) ,
181+ MiniscriptError ( e) => Some ( e) ,
182+ }
183+ }
184+ }
185+
151186impl fmt:: Display for InputError {
152187 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
153188 match * self {
@@ -1069,7 +1104,16 @@ impl fmt::Display for UtxoUpdateError {
10691104 }
10701105}
10711106
1072- impl error:: Error for UtxoUpdateError { }
1107+ impl error:: Error for UtxoUpdateError {
1108+ fn cause ( & self ) -> Option < & dyn error:: Error > {
1109+ use self :: UtxoUpdateError :: * ;
1110+
1111+ match self {
1112+ IndexOutOfBounds ( _, _) | MissingInputUtxo | UtxoCheck | MismatchedScriptPubkey => None ,
1113+ DerivationError ( e) => Some ( e) ,
1114+ }
1115+ }
1116+ }
10731117
10741118/// Return error type for [`PsbtExt::sighash_msg`]
10751119#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy ) ]
@@ -1110,7 +1154,21 @@ impl fmt::Display for SighashError {
11101154 }
11111155}
11121156
1113- impl error:: Error for SighashError { }
1157+ impl error:: Error for SighashError {
1158+ fn cause ( & self ) -> Option < & dyn error:: Error > {
1159+ use self :: SighashError :: * ;
1160+
1161+ match self {
1162+ IndexOutOfBounds ( _, _)
1163+ | MissingInputUtxo
1164+ | MissingSpendUtxos
1165+ | InvalidSighashType
1166+ | MissingWitnessScript
1167+ | MissingRedeemScript => None ,
1168+ SighashComputationError ( e) => Some ( e) ,
1169+ }
1170+ }
1171+ }
11141172
11151173impl From < bitcoin:: util:: sighash:: Error > for SighashError {
11161174 fn from ( e : bitcoin:: util:: sighash:: Error ) -> Self {
0 commit comments