Skip to content

Commit d84a776

Browse files
committed
Allow users to the rustls crypto provider used by electrum-client
Recently `rustls` introduced a new default crypto provider, `aws-lc-rc`. While it generally works fine, it doesn't seem to build properly on `aarch64-apple-ios`. Here, we therefore allow the users to decide which crypto provider the `electrum-client` client should use for its `rustls` TLS backend. To this end, we disable default features while keeping the `proxy` enabled, as it's a prerequisite for the `electrum_client::Client` to be exposed / usable (also see bitcoindevkit/rust-electrum-client#91).
1 parent c257589 commit d84a776

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

lightning-transaction-sync/Cargo.toml

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ time = []
1919
esplora-async = ["async-interface", "esplora-client/async", "esplora-client/tokio", "futures"]
2020
esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"]
2121
esplora-blocking = ["esplora-client/blocking"]
22-
electrum = ["electrum-client"]
2322
async-interface = []
2423

24+
# dummy feature to enable the common codepaths for electrum
25+
_electrum = []
26+
# the 'default' electrum feature, enabling `rustls` with the `aws-lc-rs` crypto provider
27+
electrum = ["_electrum", "electrum-client/use-rustls"]
28+
electrum-rustls = ["electrum"]
29+
30+
# this feature enables `rustls` with the `ring` crypto provider
31+
electrum-rustls-ring = ["_electrum", "electrum-client/use-rustls-ring"]
32+
2533
[dependencies]
2634
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std"] }
2735
lightning-macros = { version = "0.2", path = "../lightning-macros", default-features = false }
2836
bitcoin = { version = "0.32.2", default-features = false }
2937
futures = { version = "0.3", optional = true }
3038
esplora-client = { version = "0.11", default-features = false, optional = true }
31-
electrum-client = { version = "0.22.0", optional = true }
39+
electrum-client = { version = "0.22.0", optional = true, default-features = false, features = ["proxy"] }
3240

3341
[dev-dependencies]
3442
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std", "_test_utils"] }

lightning-transaction-sync/src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ impl From<esplora_client::Error> for InternalError {
6565
}
6666
}
6767

68-
#[cfg(feature = "electrum")]
68+
#[cfg(feature = "_electrum")]
6969
impl From<electrum_client::Error> for InternalError {
7070
fn from(_e: electrum_client::Error) -> Self {
7171
Self::Failed
7272
}
7373
}
7474

75-
#[cfg(feature = "electrum")]
75+
#[cfg(feature = "_electrum")]
7676
impl From<electrum_client::Error> for TxSyncError {
7777
fn from(_e: electrum_client::Error) -> Self {
7878
Self::Failed

lightning-transaction-sync/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@
7474
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
7575
mod esplora;
7676

77-
#[cfg(any(feature = "electrum"))]
77+
#[cfg(any(feature = "_electrum"))]
7878
mod electrum;
7979

80-
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
80+
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
8181
mod common;
82-
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
82+
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
8383
mod error;
84-
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
84+
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum"))]
8585
pub use error::TxSyncError;
8686

87-
#[cfg(feature = "electrum")]
87+
#[cfg(feature = "_electrum")]
8888
pub use electrum::ElectrumSyncClient;
8989
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
9090
pub use esplora::EsploraSyncClient;

lightning-transaction-sync/tests/integration_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#![cfg(all(
22
not(target_os = "windows"),
3-
any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum")
3+
any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum")
44
))]
55

66
use lightning::chain::transaction::{OutPoint, TransactionData};
77
use lightning::chain::{Confirm, Filter, WatchedOutput};
88
use lightning::util::test_utils::TestLogger;
9-
#[cfg(feature = "electrum")]
9+
#[cfg(feature = "_electrum")]
1010
use lightning_transaction_sync::ElectrumSyncClient;
1111
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
1212
use lightning_transaction_sync::EsploraSyncClient;
@@ -332,7 +332,7 @@ async fn test_esplora_syncs() {
332332
}
333333

334334
#[test]
335-
#[cfg(feature = "electrum")]
335+
#[cfg(feature = "_electrum")]
336336
fn test_electrum_syncs() {
337337
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
338338
generate_blocks_and_wait(&bitcoind, &electrsd, 101);

0 commit comments

Comments
 (0)