|
1 | 1 | use super::PartiallySignedTransaction; |
2 | 2 |
|
| 3 | +/// Possible errors when parsing a PSET from a string |
3 | 4 | #[derive(Debug)] |
4 | | -pub enum Error { |
| 5 | +pub enum ParseError { |
| 6 | + /// Base64 decoding error |
5 | 7 | Base64(bitcoin::base64::DecodeError), |
| 8 | + /// PSET binary encoding error |
6 | 9 | Deserialize(crate::encode::Error) |
7 | 10 | } |
8 | 11 |
|
9 | | -impl core::fmt::Display for Error { |
| 12 | +impl core::fmt::Display for ParseError { |
10 | 13 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
11 | 14 | match self { |
12 | | - Error::Base64(_) => write!(f, "Base64 error"), |
13 | | - Error::Deserialize(_) => write!(f, "Deserialize error"), |
| 15 | + ParseError::Base64(_) => write!(f, "Base64 error"), |
| 16 | + ParseError::Deserialize(_) => write!(f, "Deserialize error"), |
14 | 17 | } |
15 | 18 | } |
16 | 19 | } |
17 | 20 |
|
18 | | -impl std::error::Error for Error { |
| 21 | +impl std::error::Error for ParseError { |
19 | 22 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
20 | 23 | match self { |
21 | | - Error::Base64(e) => Some(e), |
22 | | - Error::Deserialize(e) => Some(e), |
| 24 | + ParseError::Base64(e) => Some(e), |
| 25 | + ParseError::Deserialize(e) => Some(e), |
23 | 26 | } |
24 | 27 | } |
25 | 28 |
|
26 | 29 | } |
27 | 30 |
|
28 | 31 | impl std::str::FromStr for PartiallySignedTransaction { |
29 | | - type Err=Error; |
| 32 | + type Err=ParseError; |
30 | 33 |
|
31 | 34 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
32 | | - let bytes = bitcoin::base64::decode(s).map_err(Error::Base64)?; |
33 | | - crate::encode::deserialize(&bytes).map_err(Error::Deserialize) |
| 35 | + let bytes = bitcoin::base64::decode(s).map_err(ParseError::Base64)?; |
| 36 | + crate::encode::deserialize(&bytes).map_err(ParseError::Deserialize) |
34 | 37 | } |
35 | 38 | } |
36 | 39 |
|
|
0 commit comments