Skip to content

Commit 5d80b94

Browse files
committed
Merge #177: rename pset::str::Error to ParseError and expose it
ed066af rename pset::str::Error to ParseError and expose it (Riccardo Casatta) Pull request description: Otherwise the pset decoding from string cannot be used downstream fix #175 ACKs for top commit: apoelstra: ACK ed066af sanket1729: ACK ed066af Tree-SHA512: 7ee8346ddea5b6bfa21bdc8fbf0a4fb23ab056821625f0bb67b7b8c271b3c6570f2c431fc0f23f6ee04c025f240d0b7a72a3849e64cd143de4563bfba9634721
2 parents ca1b5c4 + ed066af commit 5d80b94

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/pset/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub mod serialize;
3333
#[cfg(feature = "base64")]
3434
mod str;
3535

36+
#[cfg(feature = "base64")]
37+
pub use self::str::ParseError;
38+
3639
use crate::blind::{BlindAssetProofs, BlindValueProofs};
3740
use crate::confidential;
3841
use crate::encode::{self, Decodable, Encodable};

src/pset/str.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
use super::PartiallySignedTransaction;
22

3+
/// Possible errors when parsing a PSET from a string
34
#[derive(Debug)]
4-
pub enum Error {
5+
pub enum ParseError {
6+
/// Base64 decoding error
57
Base64(bitcoin::base64::DecodeError),
8+
/// PSET binary encoding error
69
Deserialize(crate::encode::Error)
710
}
811

9-
impl core::fmt::Display for Error {
12+
impl core::fmt::Display for ParseError {
1013
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1114
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"),
1417
}
1518
}
1619
}
1720

18-
impl std::error::Error for Error {
21+
impl std::error::Error for ParseError {
1922
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
2023
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),
2326
}
2427
}
2528

2629
}
2730

2831
impl std::str::FromStr for PartiallySignedTransaction {
29-
type Err=Error;
32+
type Err=ParseError;
3033

3134
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)
3437
}
3538
}
3639

0 commit comments

Comments
 (0)