@@ -133,10 +133,13 @@ impl<'a> InternalInputPair<'a> {
133
133
}
134
134
}
135
135
136
- pub fn validate_utxo ( & self , treat_missing_as_error : bool ) -> Result < ( ) , PsbtInputError > {
136
+ pub fn validate_utxo (
137
+ & self ,
138
+ treat_missing_as_error : bool ,
139
+ ) -> Result < ( ) , InternalPsbtInputError > {
137
140
match ( & self . psbtin . non_witness_utxo , & self . psbtin . witness_utxo ) {
138
141
( None , None ) if treat_missing_as_error =>
139
- Err ( PsbtInputError :: PrevTxOut ( PrevTxOutError :: MissingUtxoInformation ) ) ,
142
+ Err ( InternalPsbtInputError :: PrevTxOut ( PrevTxOutError :: MissingUtxoInformation ) ) ,
140
143
( None , None ) => Ok ( ( ) ) ,
141
144
( Some ( tx) , None ) if tx. compute_txid ( ) == self . txin . previous_output . txid => tx
142
145
. output
@@ -154,7 +157,7 @@ impl<'a> InternalInputPair<'a> {
154
157
. into ( )
155
158
} )
156
159
. map ( drop) ,
157
- ( Some ( _) , None ) => Err ( PsbtInputError :: UnequalTxid ) ,
160
+ ( Some ( _) , None ) => Err ( InternalPsbtInputError :: UnequalTxid ) ,
158
161
( None , Some ( _) ) => Ok ( ( ) ) ,
159
162
( Some ( tx) , Some ( witness_txout) )
160
163
if tx. compute_txid ( ) == self . txin . previous_output . txid =>
@@ -174,10 +177,10 @@ impl<'a> InternalInputPair<'a> {
174
177
if witness_txout == non_witness_txout {
175
178
Ok ( ( ) )
176
179
} else {
177
- Err ( PsbtInputError :: SegWitTxOutMismatch )
180
+ Err ( InternalPsbtInputError :: SegWitTxOutMismatch )
178
181
}
179
182
}
180
- ( Some ( _) , Some ( _) ) => Err ( PsbtInputError :: UnequalTxid ) ,
183
+ ( Some ( _) , Some ( _) ) => Err ( InternalPsbtInputError :: UnequalTxid ) ,
181
184
}
182
185
}
183
186
@@ -227,7 +230,7 @@ impl<'a> InternalInputPair<'a> {
227
230
}
228
231
229
232
#[ derive( Debug ) ]
230
- pub enum PrevTxOutError {
233
+ pub ( crate ) enum PrevTxOutError {
231
234
MissingUtxoInformation ,
232
235
IndexOutOfBounds { output_count : usize , index : u32 } ,
233
236
}
@@ -246,7 +249,7 @@ impl fmt::Display for PrevTxOutError {
246
249
impl std:: error:: Error for PrevTxOutError { }
247
250
248
251
#[ derive( Debug ) ]
249
- pub enum PsbtInputError {
252
+ pub ( crate ) enum InternalPsbtInputError {
250
253
PrevTxOut ( PrevTxOutError ) ,
251
254
UnequalTxid ,
252
255
/// TxOut provided in `segwit_utxo` doesn't match the one in `non_segwit_utxo`
@@ -255,7 +258,7 @@ pub enum PsbtInputError {
255
258
NoRedeemScript ,
256
259
}
257
260
258
- impl fmt:: Display for PsbtInputError {
261
+ impl fmt:: Display for InternalPsbtInputError {
259
262
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
260
263
match self {
261
264
Self :: PrevTxOut ( _) => write ! ( f, "invalid previous transaction output" ) ,
@@ -267,7 +270,7 @@ impl fmt::Display for PsbtInputError {
267
270
}
268
271
}
269
272
270
- impl std:: error:: Error for PsbtInputError {
273
+ impl std:: error:: Error for InternalPsbtInputError {
271
274
fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
272
275
match self {
273
276
Self :: PrevTxOut ( error) => Some ( error) ,
@@ -279,18 +282,33 @@ impl std::error::Error for PsbtInputError {
279
282
}
280
283
}
281
284
282
- impl From < PrevTxOutError > for PsbtInputError {
283
- fn from ( value : PrevTxOutError ) -> Self { PsbtInputError :: PrevTxOut ( value) }
285
+ impl From < PrevTxOutError > for InternalPsbtInputError {
286
+ fn from ( value : PrevTxOutError ) -> Self { InternalPsbtInputError :: PrevTxOut ( value) }
284
287
}
285
288
286
- impl From < AddressTypeError > for PsbtInputError {
289
+ impl From < AddressTypeError > for InternalPsbtInputError {
287
290
fn from ( value : AddressTypeError ) -> Self { Self :: AddressType ( value) }
288
291
}
289
292
293
+ #[ derive( Debug ) ]
294
+ pub struct PsbtInputError ( crate :: psbt:: InternalPsbtInputError ) ;
295
+
296
+ impl From < crate :: psbt:: InternalPsbtInputError > for PsbtInputError {
297
+ fn from ( e : crate :: psbt:: InternalPsbtInputError ) -> Self { PsbtInputError ( e) }
298
+ }
299
+
300
+ impl fmt:: Display for PsbtInputError {
301
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result { write ! ( f, "{}" , self . 0 ) }
302
+ }
303
+
304
+ impl std:: error:: Error for PsbtInputError {
305
+ fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > { Some ( & self . 0 ) }
306
+ }
307
+
290
308
#[ derive( Debug ) ]
291
309
pub struct PsbtInputsError {
292
310
index : usize ,
293
- error : PsbtInputError ,
311
+ error : InternalPsbtInputError ,
294
312
}
295
313
296
314
impl fmt:: Display for PsbtInputsError {
@@ -304,7 +322,7 @@ impl std::error::Error for PsbtInputsError {
304
322
}
305
323
306
324
#[ derive( Debug ) ]
307
- pub enum AddressTypeError {
325
+ pub ( crate ) enum AddressTypeError {
308
326
PrevTxOut ( PrevTxOutError ) ,
309
327
InvalidScript ( FromScriptError ) ,
310
328
UnknownAddressType ,
0 commit comments