mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
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.
This commit is contained in:
parent
ccac926671
commit
7a30f3e118
4 changed files with 25 additions and 2 deletions
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
@ -127,18 +127,21 @@ jobs:
|
|||
cd lightning-transaction-sync
|
||||
cargo build --verbose --color always --features esplora-blocking
|
||||
cargo build --verbose --color always --features esplora-async
|
||||
cargo build --verbose --color always --features esplora-async-https
|
||||
- name: Build transaction sync clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
|
||||
if: "matrix.build-tx-sync && matrix.coverage"
|
||||
run: |
|
||||
cd lightning-transaction-sync
|
||||
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-blocking
|
||||
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async
|
||||
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async-https
|
||||
- name: Test transaction sync clients on Rust ${{ matrix.toolchain }} with features
|
||||
if: "matrix.build-tx-sync"
|
||||
run: |
|
||||
cd lightning-transaction-sync
|
||||
cargo test --verbose --color always --features esplora-blocking
|
||||
cargo test --verbose --color always --features esplora-async
|
||||
cargo test --verbose --color always --features esplora-async-https
|
||||
- name: Test backtrace-debug builds on Rust ${{ matrix.toolchain }}
|
||||
if: "matrix.toolchain == 'stable'"
|
||||
shell: bash # Default on Winblows is powershell
|
||||
|
|
|
@ -16,6 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||
[features]
|
||||
default = []
|
||||
esplora-async = ["async-interface", "esplora-client/async", "futures"]
|
||||
esplora-async-https = ["esplora-async", "reqwest/rustls-tls"]
|
||||
esplora-blocking = ["esplora-client/blocking"]
|
||||
async-interface = []
|
||||
|
||||
|
@ -25,6 +26,7 @@ bitcoin = { version = "0.29.0", default-features = false }
|
|||
bdk-macros = "0.6"
|
||||
futures = { version = "0.3", optional = true }
|
||||
esplora-client = { version = "0.3.0", default-features = false, optional = true }
|
||||
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
|
||||
|
||||
[dev-dependencies]
|
||||
lightning = { version = "0.0.114", path = "../lightning", features = ["std"] }
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
//!
|
||||
//! ## Features and Backend Support
|
||||
//!
|
||||
//!- `esplora_blocking` enables syncing against an Esplora backend based on a blocking client.
|
||||
//!- `esplora_async` enables syncing against an Esplora backend based on an async client.
|
||||
//!- `esplora-blocking` enables syncing against an Esplora backend based on a blocking client.
|
||||
//!- `esplora-async` enables syncing against an Esplora backend based on an async client.
|
||||
//!- `esplora-async-https` enables the async Esplora client with support for HTTPS.
|
||||
//!
|
||||
//! ## Version Compatibility
|
||||
//!
|
||||
|
|
|
@ -348,3 +348,20 @@ async fn test_esplora_syncs() {
|
|||
_ => panic!("Unexpected event"),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(any(feature = "esplora-async-https", feature = "esplora-blocking"))]
|
||||
async fn test_esplora_connects_to_public_server() {
|
||||
let mut logger = TestLogger {};
|
||||
let esplora_url = "https://blockstream.info/api".to_string();
|
||||
let tx_sync = EsploraSyncClient::new(esplora_url, &mut logger);
|
||||
let confirmable = TestConfirmable::new();
|
||||
|
||||
// Check we connect and pick up on new best blocks
|
||||
assert_eq!(confirmable.best_block.lock().unwrap().1, 0);
|
||||
#[cfg(feature = "esplora-async-https")]
|
||||
tx_sync.sync(vec![&confirmable]).await.unwrap();
|
||||
#[cfg(feature = "esplora-blocking")]
|
||||
tx_sync.sync(vec![&confirmable]).unwrap();
|
||||
assert_ne!(confirmable.best_block.lock().unwrap().1, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue