Skip to content

Commit e25d2ff

Browse files
committed
Support HTTPS Esplora endpoints via new feature
To support HTTPS endpoints, the async HTTP library `reqwest` needs one of the `-tls` features enabled. While the users could specify this in their own cargo dependencies, we here provide a new `esplora-async-https` feature for conveinience.
1 parent ccac926 commit e25d2ff

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,21 @@ jobs:
127127
cd lightning-transaction-sync
128128
cargo build --verbose --color always --features esplora-blocking
129129
cargo build --verbose --color always --features esplora-async
130+
cargo build --verbose --color always --features esplora-async-https
130131
- name: Build transaction sync clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
131132
if: "matrix.build-tx-sync && matrix.coverage"
132133
run: |
133134
cd lightning-transaction-sync
134135
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-blocking
135136
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async
137+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async-https
136138
- name: Test transaction sync clients on Rust ${{ matrix.toolchain }} with features
137139
if: "matrix.build-tx-sync"
138140
run: |
139141
cd lightning-transaction-sync
140142
cargo test --verbose --color always --features esplora-blocking
141143
cargo test --verbose --color always --features esplora-async
144+
cargo test --verbose --color always --features esplora-async-https
142145
- name: Test backtrace-debug builds on Rust ${{ matrix.toolchain }}
143146
if: "matrix.toolchain == 'stable'"
144147
shell: bash # Default on Winblows is powershell

lightning-transaction-sync/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1616
[features]
1717
default = []
1818
esplora-async = ["async-interface", "esplora-client/async", "futures"]
19+
esplora-async-https = ["esplora-async", "esplora-client/async-https"]
1920
esplora-blocking = ["esplora-client/blocking"]
2021
async-interface = []
2122

@@ -25,6 +26,7 @@ bitcoin = { version = "0.29.0", default-features = false }
2526
bdk-macros = "0.6"
2627
futures = { version = "0.3", optional = true }
2728
esplora-client = { version = "0.3.0", default-features = false, optional = true }
29+
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
2830

2931
[dev-dependencies]
3032
lightning = { version = "0.0.114", path = "../lightning", features = ["std"] }

lightning-transaction-sync/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
//!
88
//! ## Features and Backend Support
99
//!
10-
//!- `esplora_blocking` enables syncing against an Esplora backend based on a blocking client.
11-
//!- `esplora_async` enables syncing against an Esplora backend based on an async client.
10+
//!- `esplora-blocking` enables syncing against an Esplora backend based on a blocking client.
11+
//!- `esplora-async` enables syncing against an Esplora backend based on an async client.
12+
//!- `esplora-async-https` enables the async Esplora client with support for HTTPS.
1213
//!
1314
//! ## Version Compatibility
1415
//!

lightning-transaction-sync/tests/integration_tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,17 @@ async fn test_esplora_syncs() {
348348
_ => panic!("Unexpected event"),
349349
}
350350
}
351+
352+
#[tokio::test]
353+
#[cfg(feature = "esplora-async-https")]
354+
async fn test_esplora_connects_to_public_server() {
355+
let mut logger = TestLogger {};
356+
let esplora_url = "https://blockstream.info/api".to_string();
357+
let tx_sync = EsploraSyncClient::new(esplora_url, &mut logger);
358+
let confirmable = TestConfirmable::new();
359+
360+
// Check we connect and pick up on new best blocks
361+
assert_eq!(confirmable.best_block.lock().unwrap().1, 0);
362+
tx_sync.sync(vec![&confirmable]).await.unwrap();
363+
assert_ne!(confirmable.best_block.lock().unwrap().1, 0);
364+
}

0 commit comments

Comments
 (0)