diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml
index 1b5b376..b826197 100644
--- a/.github/workflows/cont_integration.yml
+++ b/.github/workflows/cont_integration.yml
@@ -22,6 +22,10 @@ jobs:
features:
- default
- blocking
+ - blocking-https
+ - blocking-https-rustls
+ - blocking-https-native
+ - blocking-https-bundled
- async
- async-https
- async-https-native
@@ -53,7 +57,6 @@ jobs:
run: |
cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5"
cargo update -p time --precise "0.3.20"
- cargo update -p jobserver --precise "0.1.26"
cargo update -p home --precise 0.5.5
- name: Build
run: cargo build --features ${{ matrix.features }} --no-default-features
diff --git a/Cargo.toml b/Cargo.toml
index 54caef3..2fc234b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] }
bitcoin = { version = "0.31.0", features = ["serde", "std"], default-features = false }
hex = { package = "hex-conservative", version = "*" }
log = "^0.4"
-ureq = { version = "2.5.0", features = ["json"], optional = true }
+minreq = { version = "2.11.0", features = ["json-using-serde"], optional = true }
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
[dev-dependencies]
@@ -32,7 +32,11 @@ lazy_static = "1.4.0"
[features]
default = ["blocking", "async", "async-https"]
-blocking = ["ureq", "ureq/socks-proxy"]
+blocking = ["minreq", "minreq/proxy"]
+blocking-https = ["blocking", "minreq/https"]
+blocking-https-rustls = ["blocking", "minreq/https-rustls"]
+blocking-https-native = ["blocking", "minreq/https-native"]
+blocking-https-bundled = ["blocking", "minreq/https-bundled"]
async = ["reqwest", "reqwest/socks"]
async-https = ["async", "reqwest/default-tls"]
async-https-native = ["async", "reqwest/native-tls"]
diff --git a/README.md b/README.md
index 84f62ff..cd94b31 100644
--- a/README.md
+++ b/README.md
@@ -13,10 +13,4 @@ Bitcoin Esplora API client library. Supports plaintext, TLS and Onion servers. B
## Minimum Supported Rust Version (MSRV)
-This library should compile with any combination of features with Rust 1.63.0.
-
-To build with the MSRV you will need to pin dependencies as follows:
-
-```shell
-cargo update -p jobserver --precise "0.1.26"
-```
\ No newline at end of file
+This library should compile with any combination of features with Rust 1.63.0.
\ No newline at end of file
diff --git a/src/api.rs b/src/api.rs
index 2e72337..c700a38 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -4,7 +4,9 @@
pub use bitcoin::consensus::{deserialize, serialize};
pub use bitcoin::hex::FromHex;
-pub use bitcoin::{transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
+pub use bitcoin::{
+ transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness,
+};
use serde::Deserialize;
diff --git a/src/async.rs b/src/async.rs
index caa91fe..683bedb 100644
--- a/src/async.rs
+++ b/src/async.rs
@@ -15,8 +15,8 @@ use std::collections::HashMap;
use std::str::FromStr;
use bitcoin::consensus::{deserialize, serialize};
-use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::hashes::{sha256, Hash};
+use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::{
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
};
@@ -131,16 +131,6 @@ impl AsyncClient {
}
}
- #[deprecated(
- since = "0.2.0",
- note = "Deprecated to improve alignment with Esplora API. Users should use `get_block_hash` and `get_header_by_hash` methods directly."
- )]
- /// Get a [`BlockHeader`] given a particular block height.
- pub async fn get_header(&self, block_height: u32) -> Result {
- let block_hash = self.get_block_hash(block_height).await?;
- self.get_header_by_hash(&block_hash).await
- }
-
/// Get a [`BlockHeader`] given a particular block hash.
pub async fn get_header_by_hash(&self, block_hash: &BlockHash) -> Result {
let resp = self
diff --git a/src/blocking.rs b/src/blocking.rs
index f05136d..bc581dd 100644
--- a/src/blocking.rs
+++ b/src/blocking.rs
@@ -9,22 +9,20 @@
// You may not use this file except in accordance with one or both of these
// licenses.
-//! Esplora by way of `ureq` HTTP client.
+//! Esplora by way of `minreq` HTTP client.
use std::collections::HashMap;
-use std::io;
-use std::io::Read;
+use std::convert::TryFrom;
use std::str::FromStr;
-use std::time::Duration;
#[allow(unused_imports)]
use log::{debug, error, info, trace};
-use ureq::{Agent, Proxy, Response};
+use minreq::{Proxy, Request};
-use bitcoin::consensus::{deserialize, serialize};
-use bitcoin::hex::{DisplayHex, FromHex};
+use bitcoin::consensus::{deserialize, serialize, Decodable};
use bitcoin::hashes::{sha256, Hash};
+use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::{
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
};
@@ -34,52 +32,149 @@ use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus
#[derive(Debug, Clone)]
pub struct BlockingClient {
url: String,
- agent: Agent,
+ /// The proxy is ignored when targeting `wasm32`.
+ pub proxy: Option,
+ /// Socket timeout.
+ pub timeout: Option,
}
impl BlockingClient {
/// build a blocking client from a [`Builder`]
- pub fn from_builder(builder: Builder) -> Result {
- let mut agent_builder = ureq::AgentBuilder::new();
+ pub fn from_builder(builder: Builder) -> Self {
+ Self {
+ url: builder.base_url,
+ proxy: builder.proxy,
+ timeout: builder.timeout,
+ }
+ }
+
+ fn get_request(&self, path: &str) -> Result {
+ let mut request = minreq::get(format!("{}{}", self.url, path));
- if let Some(timeout) = builder.timeout {
- agent_builder = agent_builder.timeout(Duration::from_secs(timeout));
+ if let Some(proxy) = &self.proxy {
+ let proxy = Proxy::new(proxy.as_str())?;
+ request = request.with_proxy(proxy);
}
- if let Some(proxy) = &builder.proxy {
- agent_builder = agent_builder.proxy(Proxy::new(proxy)?);
+ if let Some(timeout) = &self.timeout {
+ request = request.with_timeout(*timeout);
}
- Ok(Self::from_agent(builder.base_url, agent_builder.build()))
+ Ok(request)
}
- /// build a blocking client from an [`Agent`]
- pub fn from_agent(url: String, agent: Agent) -> Self {
- BlockingClient { url, agent }
+ fn get_opt_response(&self, path: &str) -> Result