Skip to content

Commit

Permalink
Upgrade bitcoin to 0.32
Browse files Browse the repository at this point in the history
InvalidNetworkError no longer reports address.network() since
that method was removed.
  • Loading branch information
DanGould committed Jul 30, 2024
1 parent 5b41062 commit 989faf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ non-compliant-bytes = ["either"]
[dependencies]
either = { version = "1.6.1", optional = true }
percent-encoding-rfc3986 = "0.1.3"
bitcoin = { version = "0.31.0", default-features = false }
bitcoin = { version = "0.32.0", default-features = false }

[dev-dependencies]
bitcoin = { version = "0.31.0", features = ["std"] }
bitcoin = { version = "0.32.0", features = ["std"] }
24 changes: 8 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ impl<'a, NetVal: NetworkValidation, T> Uri<'a, NetVal, T> {

impl<'a, T> Uri<'a, bitcoin::address::NetworkUnchecked, T> {
/// Checks that the bitcoin network in the URI is `network`.
pub fn require_network(self, network: bitcoin::Network) -> Result<Uri<'a, bitcoin::address::NetworkChecked, T>, InvalidNetworkError> {
if self.address.is_valid_for_network(network) {
Ok(self.assume_checked())
} else {
Err(InvalidNetworkError {
required: network,
found: *self.address.network(),
})
}
pub fn require_network(self, network: bitcoin::Network) -> Result<Uri<'a, bitcoin::address::NetworkChecked, T>, bitcoin::address::ParseError> {
Ok(Uri {
address: self.address.require_network(network)?,
amount: self.amount,
label: self.label,
message: self.message,
extras: self.extras,
})
}

/// Marks URI validated without checks.
Expand All @@ -159,13 +158,6 @@ impl<'a, T> Uri<'a, bitcoin::address::NetworkUnchecked, T> {
}
}

/// An error returned when network validation fails.
#[derive(Debug, Clone)]
pub struct InvalidNetworkError {
required: bitcoin::Network,
found: bitcoin::Network,
}

/// Abstracted stringly parameter in the URI.
///
/// This type abstracts the parameter that may be encoded allowing lazy decoding, possibly even
Expand Down

0 comments on commit 989faf7

Please sign in to comment.