Skip to content

Commit 78fee88

Browse files
authored
Merge pull request #3587 from tnull/2025-02-bump-electrum-client
Bump `electrum_client` dependency and add new TLS-backend features
2 parents f67947e + d84a776 commit 78fee88

File tree

5 files changed

+62
-65
lines changed

5 files changed

+62
-65
lines changed

contrib/download_bitcoind_electrs.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
1010
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
1111
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
1212
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
13-
BITCOIND_VERSION="25.1"
13+
BITCOIND_VERSION="28.1"
1414
if [[ "$HOST_PLATFORM" == *linux* ]]; then
1515
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
1616
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
1717
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
18-
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
18+
BITCOIND_DL_HASH="07f77afd326639145b9ba9562912b2ad2ccec47b8a305bd075b4f4cb127b7ed7"
1919
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
2020
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
2121
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
2222
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
23-
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
23+
BITCOIND_DL_HASH="c85d1a0ebedeff43b99db2c906b50f14547b84175a4d0ebb039a9809789af280"
2424
else
2525
printf "\n\n"
2626
echo "Unsupported platform: $HOST_PLATFORM Exiting.."

lightning-transaction-sync/Cargo.toml

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,32 @@ 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.21.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"] }
3543
tokio = { version = "1.35.0", features = ["macros"] }
3644

3745
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
38-
electrsd = { version = "0.28.0", default-features = false, features = ["legacy"] }
46+
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
47+
corepc-node = { version = "0.7.0", default-features = false, features = ["28_0"] }
3948

4049
[lints.rust.unexpected_cfgs]
4150
level = "forbid"

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

+40-52
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;
@@ -17,9 +17,9 @@ use bitcoin::block::Header;
1717
use bitcoin::constants::genesis_block;
1818
use bitcoin::network::Network;
1919
use bitcoin::{Amount, BlockHash, Txid};
20-
use bitcoind::bitcoincore_rpc::RpcApi;
21-
use electrsd::bitcoind::bitcoincore_rpc::bitcoincore_rpc_json::AddressType;
22-
use electrsd::{bitcoind, bitcoind::BitcoinD, ElectrsD};
20+
21+
use electrsd::corepc_node::Node as BitcoinD;
22+
use electrsd::{corepc_node, ElectrsD};
2323

2424
use std::collections::{HashMap, HashSet};
2525
use std::env;
@@ -28,10 +28,10 @@ use std::time::Duration;
2828

2929
pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
3030
let bitcoind_exe =
31-
env::var("BITCOIND_EXE").ok().or_else(|| bitcoind::downloaded_exe_path().ok()).expect(
31+
env::var("BITCOIND_EXE").ok().or_else(|| corepc_node::downloaded_exe_path().ok()).expect(
3232
"you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature",
3333
);
34-
let mut bitcoind_conf = bitcoind::Conf::default();
34+
let mut bitcoind_conf = corepc_node::Conf::default();
3535
bitcoind_conf.network = "regtest";
3636
let bitcoind = BitcoinD::with_conf(bitcoind_exe, &bitcoind_conf).unwrap();
3737

@@ -47,14 +47,15 @@ pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
4747
}
4848

4949
pub fn generate_blocks_and_wait(bitcoind: &BitcoinD, electrsd: &ElectrsD, num: usize) {
50-
let cur_height = bitcoind.client.get_block_count().expect("failed to get current block height");
51-
let address = bitcoind
50+
let cur_height = bitcoind
5251
.client
53-
.get_new_address(Some("test"), Some(AddressType::Legacy))
54-
.expect("failed to get new address")
55-
.assume_checked();
52+
.get_block_count()
53+
.expect("failed to get current block height")
54+
.into_model()
55+
.0;
56+
let address = bitcoind.client.new_address().expect("failed to get new address");
5657
// TODO: expect this Result once the WouldBlock issue is resolved upstream.
57-
let _block_hashes_res = bitcoind.client.generate_to_address(num as u64, &address);
58+
let _block_hashes_res = bitcoind.client.generate_to_address(num, &address);
5859
wait_for_block(electrsd, cur_height as usize + num);
5960
}
6061

@@ -175,36 +176,20 @@ macro_rules! test_syncing {
175176
assert_eq!(events.len(), 1);
176177

177178
// Check registered confirmed transactions are marked confirmed
178-
let new_address = $bitcoind
179-
.client
180-
.get_new_address(Some("test"), Some(AddressType::Legacy))
181-
.unwrap()
182-
.assume_checked();
179+
let new_address = $bitcoind.client.new_address().unwrap();
183180
let txid = $bitcoind
184181
.client
185-
.send_to_address(
186-
&new_address,
187-
Amount::from_sat(5000),
188-
None,
189-
None,
190-
None,
191-
None,
192-
None,
193-
None,
194-
)
182+
.send_to_address(&new_address, Amount::from_sat(5000))
183+
.unwrap()
184+
.0
185+
.parse()
195186
.unwrap();
196187
let second_txid = $bitcoind
197188
.client
198-
.send_to_address(
199-
&new_address,
200-
Amount::from_sat(5000),
201-
None,
202-
None,
203-
None,
204-
None,
205-
None,
206-
None,
207-
)
189+
.send_to_address(&new_address, Amount::from_sat(5000))
190+
.unwrap()
191+
.0
192+
.parse()
208193
.unwrap();
209194
$tx_sync.register_tx(&txid, &new_address.script_pubkey());
210195

@@ -224,16 +209,12 @@ macro_rules! test_syncing {
224209
assert!($confirmable.unconfirmed_txs.lock().unwrap().is_empty());
225210

226211
// Now take an arbitrary output of the second transaction and check we'll confirm its spend.
227-
let tx_res = $bitcoind.client.get_transaction(&second_txid, None).unwrap();
228-
let block_hash = tx_res.info.blockhash.unwrap();
229-
let tx = tx_res.transaction().unwrap();
212+
let tx_res = $bitcoind.client.get_transaction(second_txid).unwrap().into_model().unwrap();
213+
let block_hash = tx_res.block_hash.unwrap();
214+
let tx = tx_res.tx;
230215
let prev_outpoint = tx.input.first().unwrap().previous_output;
231-
let prev_tx = $bitcoind
232-
.client
233-
.get_transaction(&prev_outpoint.txid, None)
234-
.unwrap()
235-
.transaction()
236-
.unwrap();
216+
let prev_tx =
217+
$bitcoind.client.get_transaction(prev_outpoint.txid).unwrap().into_model().unwrap().tx;
237218
let prev_script_pubkey = prev_tx.output[prev_outpoint.vout as usize].script_pubkey.clone();
238219
let output = WatchedOutput {
239220
block_hash: Some(block_hash),
@@ -251,19 +232,26 @@ macro_rules! test_syncing {
251232
assert!($confirmable.unconfirmed_txs.lock().unwrap().is_empty());
252233

253234
// Check previously confirmed transactions are marked unconfirmed when they are reorged.
254-
let best_block_hash = $bitcoind.client.get_best_block_hash().unwrap();
255-
$bitcoind.client.invalidate_block(&best_block_hash).unwrap();
235+
let best_block_hash =
236+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0;
237+
$bitcoind.client.invalidate_block(best_block_hash).unwrap();
256238

257239
// We're getting back to the previous height with a new tip, but best block shouldn't change.
258240
generate_blocks_and_wait(&$bitcoind, &$electrsd, 1);
259-
assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash);
241+
assert_ne!(
242+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0,
243+
best_block_hash
244+
);
260245
maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap();
261246
let events = std::mem::take(&mut *$confirmable.events.lock().unwrap());
262247
assert_eq!(events.len(), 0);
263248

264249
// Now we're surpassing previous height, getting new tip.
265250
generate_blocks_and_wait(&$bitcoind, &$electrsd, 1);
266-
assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash);
251+
assert_ne!(
252+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0,
253+
best_block_hash
254+
);
267255
maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap();
268256

269257
// Transactions still confirmed but under new tip.
@@ -344,7 +332,7 @@ async fn test_esplora_syncs() {
344332
}
345333

346334
#[test]
347-
#[cfg(feature = "electrum")]
335+
#[cfg(feature = "_electrum")]
348336
fn test_electrum_syncs() {
349337
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
350338
generate_blocks_and_wait(&bitcoind, &electrsd, 101);

0 commit comments

Comments
 (0)