From 700b3b6097886d0ee1c81472a6b9111236eac691 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Fri, 24 Apr 2026 22:03:09 -0300 Subject: [PATCH 01/13] chore: update lockfiles for electrsd --- Cargo-minimal.lock | 166 ++++++++++++++++++++++++++++++++++++++++++--- Cargo-recent.lock | 166 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 314 insertions(+), 18 deletions(-) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index 5cfd5da3..f8ae71da 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -17,6 +17,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.95" @@ -147,7 +156,7 @@ dependencies = [ "bitcoin_hashes", "bitreq", "corepc-client", - "env_logger", + "env_logger 0.9.3", "flate2", "log", "serde_json", @@ -157,6 +166,12 @@ dependencies = [ "zip", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.11.1" @@ -300,6 +315,33 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "electrsd" +version = "0.38.0" +dependencies = [ + "bitcoin_hashes", + "bitcoind", + "bitreq", + "corepc-client", + "electrum-client", + "env_logger 0.10.2", + "log", + "nix", + "zip", +] + +[[package]] +name = "electrum-client" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5059f13888a90486e7268bbce59b175f5f76b1c55e5b9c568ceaa42d2b8507c" +dependencies = [ + "bitcoin", + "log", + "serde", + "serde_json", +] + [[package]] name = "env_logger" version = "0.9.3" @@ -309,6 +351,19 @@ dependencies = [ "log", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "errno" version = "0.3.10" @@ -494,6 +549,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "hex-conservative" version = "0.2.1" @@ -527,6 +588,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" + [[package]] name = "idna" version = "1.1.0" @@ -558,6 +625,17 @@ dependencies = [ "unicode-joining-type", ] +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi 0.5.2", + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "itoa" version = "1.0.11" @@ -604,7 +682,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.11.1", "libc", "redox_syscall", ] @@ -636,6 +714,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.8.4" @@ -651,7 +738,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -674,6 +761,20 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -704,7 +805,7 @@ version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ - "bitflags", + "bitflags 2.11.1", "cfg-if", "foreign-types", "libc", @@ -760,6 +861,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.31" @@ -790,7 +897,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bb0be07becd10686a0bb407298fb425360a5c44a663774406340c59a22de4ce" dependencies = [ - "bitflags", + "bitflags 2.11.1", "lazy_static", "num-traits", "rand", @@ -859,7 +966,30 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags", + "bitflags 2.11.1", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] @@ -903,7 +1033,7 @@ version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags", + "bitflags 2.11.1", "errno", "libc", "linux-raw-sys", @@ -997,7 +1127,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags", + "bitflags 2.11.1", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -1010,7 +1140,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags", + "bitflags 2.11.1", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -1144,6 +1274,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "tiny_http" version = "0.12.0" @@ -1330,6 +1469,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 5cfd5da3..f8ae71da 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -17,6 +17,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.95" @@ -147,7 +156,7 @@ dependencies = [ "bitcoin_hashes", "bitreq", "corepc-client", - "env_logger", + "env_logger 0.9.3", "flate2", "log", "serde_json", @@ -157,6 +166,12 @@ dependencies = [ "zip", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.11.1" @@ -300,6 +315,33 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "electrsd" +version = "0.38.0" +dependencies = [ + "bitcoin_hashes", + "bitcoind", + "bitreq", + "corepc-client", + "electrum-client", + "env_logger 0.10.2", + "log", + "nix", + "zip", +] + +[[package]] +name = "electrum-client" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5059f13888a90486e7268bbce59b175f5f76b1c55e5b9c568ceaa42d2b8507c" +dependencies = [ + "bitcoin", + "log", + "serde", + "serde_json", +] + [[package]] name = "env_logger" version = "0.9.3" @@ -309,6 +351,19 @@ dependencies = [ "log", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "errno" version = "0.3.10" @@ -494,6 +549,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "hex-conservative" version = "0.2.1" @@ -527,6 +588,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" + [[package]] name = "idna" version = "1.1.0" @@ -558,6 +625,17 @@ dependencies = [ "unicode-joining-type", ] +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi 0.5.2", + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "itoa" version = "1.0.11" @@ -604,7 +682,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.11.1", "libc", "redox_syscall", ] @@ -636,6 +714,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "miniz_oxide" version = "0.8.4" @@ -651,7 +738,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -674,6 +761,20 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -704,7 +805,7 @@ version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ - "bitflags", + "bitflags 2.11.1", "cfg-if", "foreign-types", "libc", @@ -760,6 +861,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.31" @@ -790,7 +897,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bb0be07becd10686a0bb407298fb425360a5c44a663774406340c59a22de4ce" dependencies = [ - "bitflags", + "bitflags 2.11.1", "lazy_static", "num-traits", "rand", @@ -859,7 +966,30 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags", + "bitflags 2.11.1", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] @@ -903,7 +1033,7 @@ version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags", + "bitflags 2.11.1", "errno", "libc", "linux-raw-sys", @@ -997,7 +1127,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags", + "bitflags 2.11.1", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -1010,7 +1140,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags", + "bitflags 2.11.1", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -1144,6 +1274,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "tiny_http" version = "0.12.0" @@ -1330,6 +1469,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" From bf34015e74e6b677ccf3ad5b980c47abe9dfc3b9 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Wed, 29 Apr 2026 13:11:58 -0300 Subject: [PATCH 02/13] electrsd: apply rustfmt cleanup --- electrsd/build.rs | 24 +++++-------- electrsd/src/error.rs | 20 +++-------- electrsd/src/ext.rs | 23 +++++-------- electrsd/src/lib.rs | 74 ++++++++++++---------------------------- electrsd/src/versions.rs | 4 +-- 5 files changed, 44 insertions(+), 101 deletions(-) diff --git a/electrsd/build.rs b/electrsd/build.rs index ee31ddf5..6cd6025d 100644 --- a/electrsd/build.rs +++ b/electrsd/build.rs @@ -2,19 +2,18 @@ fn main() {} #[cfg(feature = "download")] -fn main() { - download::download() -} +fn main() { download::download() } #[cfg(feature = "download")] mod download { - use bitcoin_hashes::{sha256, Hash}; use std::fs::File; use std::io::{BufRead, BufReader, Cursor}; use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::str::FromStr; + use bitcoin_hashes::{sha256, Hash}; + include!("src/versions.rs"); const GITHUB_URL: &str = @@ -45,17 +44,13 @@ mod download { let expected_hash = get_expected_sha256(&download_filename).unwrap(); let out_dir = std::env::var_os("OUT_DIR").unwrap(); let electrs_exe_home = Path::new(&out_dir).join("electrs"); - let destination_filename = electrs_exe_home - .join(&download_filename_without_extension) - .join("electrs"); + let destination_filename = + electrs_exe_home.join(&download_filename_without_extension).join("electrs"); dbg!(&destination_filename); if !destination_filename.exists() { - println!( - "filename:{} version:{} hash:{}", - download_filename, VERSION, expected_hash - ); + println!("filename:{} version:{} hash:{}", download_filename, VERSION, expected_hash); let download_endpoint = std::env::var("ELECTRSD_DOWNLOAD_ENDPOINT").unwrap_or(GITHUB_URL.to_string()); @@ -73,11 +68,8 @@ mod download { let mut outfile = std::fs::File::create(&destination_filename).unwrap(); std::io::copy(&mut file, &mut outfile).unwrap(); - std::fs::set_permissions( - &destination_filename, - std::fs::Permissions::from_mode(0o755), - ) - .unwrap(); + std::fs::set_permissions(&destination_filename, std::fs::Permissions::from_mode(0o755)) + .unwrap(); } } } diff --git a/electrsd/src/error.rs b/electrsd/src/error.rs index ff0188ea..aa2abf83 100644 --- a/electrsd/src/error.rs +++ b/electrsd/src/error.rs @@ -44,32 +44,22 @@ impl std::error::Error for Error { } impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self) - } + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", self) } } impl From for Error { - fn from(e: std::io::Error) -> Self { - Error::Io(e) - } + fn from(e: std::io::Error) -> Self { Error::Io(e) } } impl From for Error { - fn from(e: bitcoind::Error) -> Self { - Error::Bitcoind(e) - } + fn from(e: bitcoind::Error) -> Self { Error::Bitcoind(e) } } impl From for Error { - fn from(e: electrum_client::Error) -> Self { - Error::ElectrumClient(e) - } + fn from(e: electrum_client::Error) -> Self { Error::ElectrumClient(e) } } #[cfg(not(target_os = "windows"))] impl From for Error { - fn from(e: nix::Error) -> Self { - Error::Nix(e) - } + fn from(e: nix::Error) -> Self { Error::Nix(e) } } diff --git a/electrsd/src/ext.rs b/electrsd/src/ext.rs index 147bd413..6320bde8 100644 --- a/electrsd/src/ext.rs +++ b/electrsd/src/ext.rs @@ -4,7 +4,8 @@ use std::thread; use std::time::Duration; -use electrum_client::{bitcoin::Txid, ElectrumApi}; +use electrum_client::bitcoin::Txid; +use electrum_client::ElectrumApi; use crate::ElectrsD; @@ -28,10 +29,8 @@ impl ElectrsD { // having the raw tx doesn't mean the scripts has been indexed let txid = tx.compute_txid(); if let Some(output) = tx.output.first() { - let history = self - .client - .script_get_history(&output.script_pubkey) - .unwrap(); + let history = + self.client.script_get_history(&output.script_pubkey).unwrap(); for el in history { if el.tx_hash == txid { // the tx has to be updated atomically, so founding one is enough @@ -52,8 +51,10 @@ impl ElectrsD { #[cfg(test)] mod test { + use electrum_client::bitcoin::Amount; + use electrum_client::ElectrumApi; + use crate::test::setup_nodes; - use electrum_client::{bitcoin::Amount, ElectrumApi}; #[cfg(not(feature = "electrs_0_8_10"))] #[test] @@ -74,10 +75,7 @@ mod test { let header = electrsd.client.block_headers_subscribe().unwrap(); assert_eq!(header.height, 1); let generate_address = bitcoind.client.new_address().unwrap(); - bitcoind - .client - .generate_to_address(100, &generate_address) - .unwrap(); + bitcoind.client.generate_to_address(100, &generate_address).unwrap(); let address = bitcoind.client.new_address().unwrap(); let txid = bitcoind @@ -88,10 +86,7 @@ mod test { .unwrap(); electrsd.wait_tx(&txid); - let history = electrsd - .client - .script_get_history(&address.script_pubkey()) - .unwrap(); + let history = electrsd.client.script_get_history(&address.script_pubkey()).unwrap(); assert_eq!(history.len(), 1); } } diff --git a/electrsd/src/lib.rs b/electrsd/src/lib.rs index 68d97f68..b68166d6 100644 --- a/electrsd/src/lib.rs +++ b/electrsd/src/lib.rs @@ -10,13 +10,6 @@ mod error; mod ext; mod versions; -use bitcoind::anyhow::Context; -use bitcoind::get_available_port; -use bitcoind::serde_json::Value; -use bitcoind::tempfile::TempDir; -use bitcoind::{anyhow, BitcoinD}; -use electrum_client::raw_client::{ElectrumPlaintextStream, RawClient}; -use log::{debug, error, warn}; use std::env; use std::ffi::OsStr; use std::path::PathBuf; @@ -25,12 +18,17 @@ use std::time::Duration; // re-export bitcoind pub use bitcoind; +use bitcoind::anyhow::Context; +use bitcoind::serde_json::Value; +use bitcoind::tempfile::TempDir; +use bitcoind::{anyhow, get_available_port, BitcoinD}; // re-export corepc_client pub use corepc_client; // re-export electrum_client because calling RawClient methods requires the ElectrumApi trait pub use electrum_client; - +use electrum_client::raw_client::{ElectrumPlaintextStream, RawClient}; pub use error::Error; +use log::{debug, error, warn}; /// Electrs configuration parameters, implements a convenient [Default] for most common use. /// @@ -153,18 +151,11 @@ impl ElectrsD { conf: &Conf, ) -> anyhow::Result { let response = bitcoind.client.call::("getblockchaininfo", &[])?; - if response - .get("initialblockdownload") - .and_then(|v| v.as_bool()) - .unwrap_or(false) - { + if response.get("initialblockdownload").and_then(|v| v.as_bool()).unwrap_or(false) { // electrum will remain idle until bitcoind is in IBD // bitcoind will remain in IBD if doesn't see a block from a long time, thus adding a block let node_address = bitcoind.client.call::("getnewaddress", &[])?; - bitcoind - .client - .call::("generatetoaddress", &[1.into(), node_address]) - .unwrap(); + bitcoind.client.call::("generatetoaddress", &[1.into(), node_address]).unwrap(); } let mut args = conf.args.clone(); @@ -250,11 +241,7 @@ impl ElectrsD { None }; - let view_stderr = if conf.view_stderr { - Stdio::inherit() - } else { - Stdio::null() - }; + let view_stderr = if conf.view_stderr { Stdio::inherit() } else { Stdio::null() }; debug!("args: {:?}", args); let mut process = Command::new(&exe) @@ -282,13 +269,7 @@ impl ElectrsD { } }; - Ok(ElectrsD { - process, - client, - work_dir, - electrum_url, - esplora_url, - }) + Ok(ElectrsD { process, client, work_dir, electrum_url, esplora_url }) } /// triggers electrs sync by sending the `SIGUSR1` signal, useful to call after a block for example @@ -301,14 +282,10 @@ impl ElectrsD { } #[cfg(target_os = "windows")] - pub fn trigger(&self) -> anyhow::Result<()> { - Ok(()) - } + pub fn trigger(&self) -> anyhow::Result<()> { Ok(()) } /// Return the current workdir path of the running electrs - pub fn workdir(&self) -> PathBuf { - self.work_dir.path() - } + pub fn workdir(&self) -> PathBuf { self.work_dir.path() } /// terminate the electrs process pub fn kill(&mut self) -> anyhow::Result<()> { @@ -335,25 +312,17 @@ impl ElectrsD { } #[cfg(target_os = "windows")] - fn inner_kill(&mut self) -> anyhow::Result<()> { - Ok(self.process.kill()?) - } + fn inner_kill(&mut self) -> anyhow::Result<()> { Ok(self.process.kill()?) } } impl Drop for ElectrsD { - fn drop(&mut self) { - let _ = self.kill(); - } + fn drop(&mut self) { let _ = self.kill(); } } /// Provide the electrs executable path if a version feature has been specified and `ELECTRSD_SKIP_DOWNLOAD` is not set. pub fn downloaded_exe_path() -> Option { if versions::HAS_FEATURE && std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_none() { - Some(format!( - "{}/electrs/{}/electrs", - env!("OUT_DIR"), - versions::electrs_name(), - )) + Some(format!("{}/electrs/{}/electrs", env!("OUT_DIR"), versions::electrs_name(),)) } else { None } @@ -420,12 +389,13 @@ pub fn exe_path() -> anyhow::Result { #[cfg(test)] mod test { - use crate::exe_path; - use crate::ElectrsD; + use std::env; + use bitcoind::P2P; use electrum_client::ElectrumApi; use log::{debug, log_enabled, Level}; - use std::env; + + use crate::{exe_path, ElectrsD}; #[test] #[ignore] // launch singularly since env are globals @@ -483,10 +453,8 @@ mod test { conf.p2p = P2P::Yes; } let bitcoind = bitcoind::BitcoinD::with_conf(&bitcoind_exe, &conf).unwrap(); - let electrs_conf = crate::Conf { - view_stderr: log_enabled!(Level::Debug), - ..Default::default() - }; + let electrs_conf = + crate::Conf { view_stderr: log_enabled!(Level::Debug), ..Default::default() }; let electrsd = ElectrsD::with_conf(&electrs_exe, &bitcoind, &electrs_conf).unwrap(); (electrs_exe, bitcoind, electrsd) } diff --git a/electrsd/src/versions.rs b/electrsd/src/versions.rs index 999c39d6..504da5c1 100644 --- a/electrsd/src/versions.rs +++ b/electrsd/src/versions.rs @@ -39,6 +39,4 @@ pub const HAS_FEATURE: bool = cfg!(any( feature = "esplora_a33e97e1", )); -pub fn electrs_name() -> String { - format!("electrs_{}_{}", OS, VERSION) -} +pub fn electrs_name() -> String { format!("electrs_{}_{}", OS, VERSION) } From 2f57ea88592af082073b277bf1381d89cccd3263 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Wed, 29 Apr 2026 13:19:32 -0300 Subject: [PATCH 03/13] electrsd: apply clippy lint error fix --- electrsd/build.rs | 2 +- electrsd/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/electrsd/build.rs b/electrsd/build.rs index 6cd6025d..1c320b95 100644 --- a/electrsd/build.rs +++ b/electrsd/build.rs @@ -21,7 +21,7 @@ mod download { fn get_expected_sha256(filename: &str) -> Result { let file = File::open("sha256").map_err(|_| ())?; - for line in BufReader::new(file).lines().flatten() { + for line in BufReader::new(file).lines().map_while(Result::ok) { let tokens: Vec<_> = line.split(" ").collect(); if tokens.len() == 2 && filename == tokens[1] { return sha256::Hash::from_str(tokens[0]).map_err(|_| ()); diff --git a/electrsd/src/lib.rs b/electrsd/src/lib.rs index b68166d6..ed46f989 100644 --- a/electrsd/src/lib.rs +++ b/electrsd/src/lib.rs @@ -437,7 +437,7 @@ mod test { fn test_kill() { let (_, bitcoind, mut electrsd) = setup_nodes(); let _ = bitcoind.client.get_network_info().unwrap(); // without using bitcoind, it is dropped and all the rest fails. - let _ = electrsd.client.ping().unwrap(); + electrsd.client.ping().unwrap(); assert!(electrsd.client.ping().is_ok()); electrsd.kill().unwrap(); assert!(electrsd.client.ping().is_err()); From a8ad1b30e6f3d9926dff84766f2749b90e98c279 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Wed, 29 Apr 2026 13:19:44 -0300 Subject: [PATCH 04/13] electrsd: add rbmt lint configuration --- electrsd/Cargo.toml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index 07b5ee9e..a67fafea 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -61,3 +61,19 @@ bitcoind_0_20_2 = ["bitcoind/0_20_2"] bitcoind_0_19_1 = ["bitcoind/0_19_1"] bitcoind_0_18_1 = ["bitcoind/0_18_1"] bitcoind_0_17_2 = ["bitcoind/0_17_2"] + +[package.metadata.rbmt.lint] +# The electrsd crate requires a version feature to compile +features = ["electrs_0_10_6"] +# Duplicates from build-dep/dep splits, --target=all, or upstream version conflicts. +allowed_duplicates = [ + "anyhow", # build-dep and regular dep, same version + "base64", # upstream version conflicts + "bitcoin_hashes", # build-dep (download) and transitive dep, same version + "bitflags", # upstream version conflicts + "bitreq", # build-dep (download) and regular dep, same version + "libc", # same version, appears twice under --target=all + "linux-raw-sys", # same version, appears twice under --target=all + "rustix", # same version, appears twice under --target=all + "windows-sys", # upstream version conflicts +] From 4483c4b533c9737ffd41ffd2fac8dd3e7136444a Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Fri, 24 Apr 2026 17:33:51 -0300 Subject: [PATCH 05/13] electrsd: handle esplora electrs cookie and remove legacy flag When running `--all-features`, both `electrs_0_8_10` and `esplora_a33e97e1` features are enabled. This PR handles such case by enabling the legacy cookie handling when `esplora_a33e97e1` is enabled. The `legacy` flag is semantically meaningless, therefore it was dropped. --- .github/workflows/rust.yaml | 2 +- electrsd/Cargo.toml | 4 +--- electrsd/src/lib.rs | 33 ++++++++++----------------------- electrsd/src/versions.rs | 4 ++++ 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index a41a1bdf..a9c2192f 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -194,7 +194,7 @@ jobs: CARGO_TERM_COLOR: always strategy: matrix: - features: ["bitcoind_22_1,bitcoind_download,legacy,esplora_a33e97e1"] + features: ["bitcoind_22_1,bitcoind_download,esplora_a33e97e1"] steps: - uses: actions/checkout@v3 diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index a67fafea..f82c0f83 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -34,12 +34,10 @@ bitreq = { version = "0.3.5", path = "../bitreq", default-features = false, opti ] } [features] -legacy = [] - # download is not supposed to be used directly only through selecting one of the version feature download = ["bitcoin_hashes", "zip", "bitreq"] -esplora_a33e97e1 = ["download", "legacy"] +esplora_a33e97e1 = ["download"] electrs_0_8_10 = ["download"] electrs_0_9_1 = ["download"] electrs_0_9_11 = ["download"] diff --git a/electrsd/src/lib.rs b/electrsd/src/lib.rs index ed46f989..29f43226 100644 --- a/electrsd/src/lib.rs +++ b/electrsd/src/lib.rs @@ -86,7 +86,6 @@ impl Default for Conf<'_> { let args = if cfg!(feature = "electrs_0_9_1") || cfg!(feature = "electrs_0_8_10") || cfg!(feature = "esplora_a33e97e1") - || cfg!(feature = "legacy") { vec!["-vvv"] } else { @@ -180,36 +179,24 @@ impl ElectrsD { args.push("--network"); args.push(conf.network); - #[cfg(not(feature = "legacy"))] - let cookie_file; - #[cfg(not(feature = "legacy"))] - { - args.push("--cookie-file"); - cookie_file = format!("{}", bitcoind.params.cookie_file.display()); - args.push(&cookie_file); - } - - #[cfg(feature = "legacy")] - let mut cookie_value; - #[cfg(feature = "legacy")] - { + let cookie_value = if versions::USE_LEGACY_COOKIE { use std::io::Read; args.push("--cookie"); - let mut cookie = std::fs::File::open(&bitcoind.params.cookie_file)?; - cookie_value = String::new(); - cookie.read_to_string(&mut cookie_value)?; - args.push(&cookie_value); - } + let mut cookie = String::new(); + std::fs::File::open(&bitcoind.params.cookie_file)?.read_to_string(&mut cookie)?; + cookie + } else { + args.push("--cookie-file"); + bitcoind.params.cookie_file.display().to_string() + }; + args.push(&cookie_value); args.push("--daemon-rpc-addr"); let rpc_socket = bitcoind.params.rpc_socket.to_string(); args.push(&rpc_socket); let p2p_socket; - if cfg!(feature = "electrs_0_8_10") - || cfg!(feature = "esplora_a33e97e1") - || cfg!(feature = "legacy") - { + if cfg!(feature = "electrs_0_8_10") || cfg!(feature = "esplora_a33e97e1") { args.push("--jsonrpc-import"); } else { args.push("--daemon-p2p-addr"); diff --git a/electrsd/src/versions.rs b/electrsd/src/versions.rs index 504da5c1..182109f8 100644 --- a/electrsd/src/versions.rs +++ b/electrsd/src/versions.rs @@ -31,6 +31,10 @@ const VERSION: &str = "v0.10.6"; )))] const VERSION: &str = "NA"; +#[allow(unused)] // this is not used in `build.rs` +pub const USE_LEGACY_COOKIE: bool = + cfg!(all(feature = "esplora_a33e97e1", not(feature = "electrs_0_8_10"))); + pub const HAS_FEATURE: bool = cfg!(any( feature = "electrs_0_8_10", feature = "electrs_0_9_1", From 7065ee6f5765a8389e97a403a487b9ad76cdedb4 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Fri, 24 Apr 2026 17:34:03 -0300 Subject: [PATCH 06/13] electrsd: fix mempool tx compatibility for 0.8.10 --- electrsd/src/ext.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/electrsd/src/ext.rs b/electrsd/src/ext.rs index 6320bde8..896c62c2 100644 --- a/electrsd/src/ext.rs +++ b/electrsd/src/ext.rs @@ -85,6 +85,13 @@ mod test { .txid() .unwrap(); + #[cfg(feature = "electrs_0_8_10")] + { + // the 0.8.10 version doesn't have a mempool, so we need to mine the tx + bitcoind.client.generate_to_address(1, &generate_address).unwrap(); + electrsd.trigger().unwrap(); + } + electrsd.wait_tx(&txid); let history = electrsd.client.script_get_history(&address.script_pubkey()).unwrap(); assert_eq!(history.len(), 1); From 4ab10da9df80df962cb92160eb6fe32779ed9e95 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Fri, 24 Apr 2026 21:40:04 -0300 Subject: [PATCH 07/13] electrsd: pin default electrsd version `std` was included in bitreq for the download `get()` function. --- electrsd/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index f82c0f83..f891191c 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -31,9 +31,11 @@ zip = { version = "0.6", default-features = false, optional = true, features = [ ] } bitreq = { version = "0.3.5", path = "../bitreq", default-features = false, optional = true, features = [ "https", + "std" ] } [features] +default = ["electrs_0_10_6", "download"] # download is not supposed to be used directly only through selecting one of the version feature download = ["bitcoin_hashes", "zip", "bitreq"] From 7dd79b6f8857600d19e9b0b2479361b196a5b9b0 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Fri, 24 Apr 2026 21:37:27 -0300 Subject: [PATCH 08/13] ci: pin electrsd version on no download ci check It tested an unsuported version 0.11.x. --- .github/workflows/rust.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index a9c2192f..4a4d195d 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -208,6 +208,7 @@ jobs: env: CARGO_TERM_COLOR: always ELECTRS_EXEC: "/home/runner/.cargo-install/electrs/bin/electrs" + ELECTRSD_SKIP_DOWNLOAD: "1" steps: - uses: dtolnay/rust-toolchain@stable - name: Install LLVM and Clang @@ -232,8 +233,9 @@ jobs: uses: baptiste0928/cargo-install@v2 with: crate: electrs - - run: "echo $ELECTRS_EXEC" + version: 0.10.6 + locked: true - name: Checkout Crate uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - - run: cd electrsd && cargo test --features 'bitcoind_25_2,bitcoind_download' + - run: cd electrsd && cargo test --no-default-features --features 'bitcoind_25_2,electrs_0_10_6,bitcoind_download' From 065c16a97aa3269967ebd96d527ca3972dc776b9 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Tue, 28 Apr 2026 15:37:26 -0300 Subject: [PATCH 09/13] ci: add electrs logs for error context --- .github/workflows/rust.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 4a4d195d..bd09d4f6 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -184,7 +184,7 @@ jobs: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - uses: dtolnay/rust-toolchain@stable - - run: cd electrsd && cargo test --features ${{ matrix.features }} + - run: cd electrsd && RUST_LOG=debug cargo test --features ${{ matrix.features }} test-electrs-esplora: @@ -200,7 +200,7 @@ jobs: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - uses: dtolnay/rust-toolchain@stable - - run: cd electrsd && cargo test --features ${{ matrix.features }} + - run: cd electrsd && RUST_LOG=debug cargo test --features ${{ matrix.features }} test-electrs-no-download: name: Test Electrs no auto-download features @@ -238,4 +238,4 @@ jobs: - name: Checkout Crate uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - - run: cd electrsd && cargo test --no-default-features --features 'bitcoind_25_2,electrs_0_10_6,bitcoind_download' + - run: cd electrsd && RUST_LOG=debug cargo test --no-default-features --features 'bitcoind_25_2,electrs_0_10_6,bitcoind_download' From 4a5423d5ac46712f57af48c571efbae86299591b Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Tue, 28 Apr 2026 16:09:14 -0300 Subject: [PATCH 10/13] ci: ensure electrs job runs esplora --- .github/workflows/rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index bd09d4f6..f7f4d1a6 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -200,7 +200,7 @@ jobs: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - uses: dtolnay/rust-toolchain@stable - - run: cd electrsd && RUST_LOG=debug cargo test --features ${{ matrix.features }} + - run: cd electrsd && RUST_LOG=debug cargo test --no-default-features --features ${{ matrix.features }} test-electrs-no-download: name: Test Electrs no auto-download features From d165d9d6bd63b8e05a1f7d99c594278cbb1c2e2d Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Tue, 28 Apr 2026 16:32:56 -0300 Subject: [PATCH 11/13] electrsd: fix bitcoind version 23.2 mismatch --- electrsd/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index f891191c..b01cc22e 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -54,7 +54,7 @@ bitcoind_27_2 = ["bitcoind/27_2"] bitcoind_26_2 = ["bitcoind/26_2"] bitcoind_25_2 = ["bitcoind/25_2"] bitcoind_24_2 = ["bitcoind/24_2"] -bitcoind_23_1 = ["bitcoind/23_2"] +bitcoind_23_2 = ["bitcoind/23_2"] bitcoind_22_1 = ["bitcoind/22_1"] bitcoind_0_21_2 = ["bitcoind/0_21_2"] bitcoind_0_20_2 = ["bitcoind/0_20_2"] From d4e07c01300ff6e9546abe135712a1de88029223 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Thu, 23 Apr 2026 15:10:56 -0300 Subject: [PATCH 12/13] electrsd: include electrsd in workspace Mirrors bitcoind solution. It also removes default electrs download for non-esplora paths. --- .github/workflows/rust.yaml | 3 +++ Cargo.toml | 12 +++++++-- electrsd/Cargo.toml | 16 +++++------- electrsd/src/ext.rs | 7 +++-- electrsd/src/lib.rs | 13 +++------- electrsd/src/versions.rs | 52 +++++++++++++++++++++++++++---------- 6 files changed, 65 insertions(+), 38 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index f7f4d1a6..6415f060 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -36,6 +36,7 @@ jobs: runs-on: ubuntu-latest env: BITCOIND_SKIP_DOWNLOAD: "1" + ELECTRSD_SKIP_DOWNLOAD: "1" strategy: fail-fast: false matrix: @@ -61,6 +62,7 @@ jobs: runs-on: ubuntu-latest env: BITCOIND_SKIP_DOWNLOAD: "1" + ELECTRSD_SKIP_DOWNLOAD: "1" strategy: fail-fast: false matrix: @@ -78,6 +80,7 @@ jobs: runs-on: ubuntu-latest env: BITCOIND_SKIP_DOWNLOAD: "1" + ELECTRSD_SKIP_DOWNLOAD: "1" strategy: fail-fast: false matrix: diff --git a/Cargo.toml b/Cargo.toml index 50ef533c..3dd2b37d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,14 @@ [workspace] -members = ["bitcoind", "bitreq", "client", "fuzz", "jsonrpc", "types"] -exclude = ["integration_test", "verify", "electrsd"] +members = [ + "bitcoind", + "bitreq", + "client", + "electrsd", + "fuzz", + "jsonrpc", + "types", +] +exclude = ["integration_test", "verify"] resolver = "2" [workspace.metadata.rbmt.toolchains] diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index b01cc22e..9824c6c0 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -35,17 +35,15 @@ bitreq = { version = "0.3.5", path = "../bitreq", default-features = false, opti ] } [features] -default = ["electrs_0_10_6", "download"] -# download is not supposed to be used directly only through selecting one of the version feature download = ["bitcoin_hashes", "zip", "bitreq"] - -esplora_a33e97e1 = ["download"] -electrs_0_8_10 = ["download"] -electrs_0_9_1 = ["download"] -electrs_0_9_11 = ["download"] -electrs_0_10_6 = ["download"] - bitcoind_download = ["bitcoind/download", "download"] +default = ["electrs_0_10_6", "download"] + +electrs_0_10_6 = ["electrs_0_9_11"] +electrs_0_9_11 = ["electrs_0_9_1"] +electrs_0_9_1 = ["electrs_0_8_10"] +electrs_0_8_10 = ["esplora_a33e97e1"] +esplora_a33e97e1 = [] bitcoind_30_2 = ["bitcoind/30_2"] bitcoind_29_0 = ["bitcoind/29_0"] diff --git a/electrsd/src/ext.rs b/electrsd/src/ext.rs index 896c62c2..7ca61918 100644 --- a/electrsd/src/ext.rs +++ b/electrsd/src/ext.rs @@ -10,7 +10,7 @@ use electrum_client::ElectrumApi; use crate::ElectrsD; impl ElectrsD { - #[cfg(not(feature = "electrs_0_8_10"))] + #[cfg(any(feature = "electrs_0_9_1", not(feature = "electrs_0_8_10")))] /// wait up to a minute the electrum server has indexed up to the given height. pub fn wait_height(&self, height: usize) { for _ in 0..600 { @@ -56,7 +56,7 @@ mod test { use crate::test::setup_nodes; - #[cfg(not(feature = "electrs_0_8_10"))] + #[cfg(any(feature = "electrs_0_9_1", not(feature = "electrs_0_8_10")))] #[test] fn test_wait_height() { let (_, bitcoind, electrsd) = setup_nodes(); @@ -85,8 +85,7 @@ mod test { .txid() .unwrap(); - #[cfg(feature = "electrs_0_8_10")] - { + if crate::versions::IS_ELECTRS_0_8_10 { // the 0.8.10 version doesn't have a mempool, so we need to mine the tx bitcoind.client.generate_to_address(1, &generate_address).unwrap(); electrsd.trigger().unwrap(); diff --git a/electrsd/src/lib.rs b/electrsd/src/lib.rs index 29f43226..86f607cf 100644 --- a/electrsd/src/lib.rs +++ b/electrsd/src/lib.rs @@ -83,14 +83,7 @@ pub struct Conf<'a> { impl Default for Conf<'_> { fn default() -> Self { - let args = if cfg!(feature = "electrs_0_9_1") - || cfg!(feature = "electrs_0_8_10") - || cfg!(feature = "esplora_a33e97e1") - { - vec!["-vvv"] - } else { - vec![] - }; + let args = if versions::USE_VERBOSE_ARG { vec!["-vvv"] } else { vec![] }; Conf { args, @@ -196,7 +189,7 @@ impl ElectrsD { args.push(&rpc_socket); let p2p_socket; - if cfg!(feature = "electrs_0_8_10") || cfg!(feature = "esplora_a33e97e1") { + if versions::USE_JSONRPC_IMPORT { args.push("--jsonrpc-import"); } else { args.push("--daemon-p2p-addr"); @@ -436,7 +429,7 @@ mod test { debug!("electrs: {}", &electrs_exe); let mut conf = bitcoind::Conf::default(); conf.view_stdout = log_enabled!(Level::Debug); - if !cfg!(feature = "electrs_0_8_10") && !cfg!(feature = "esplora_a33e97e1") { + if !crate::versions::USE_JSONRPC_IMPORT { conf.p2p = P2P::Yes; } let bitcoind = bitcoind::BitcoinD::with_conf(&bitcoind_exe, &conf).unwrap(); diff --git a/electrsd/src/versions.rs b/electrsd/src/versions.rs index 182109f8..a1a7849e 100644 --- a/electrsd/src/versions.rs +++ b/electrsd/src/versions.rs @@ -7,21 +7,34 @@ const OS: &str = "linux"; #[cfg(not(any(target_os = "linux", target_os = "macos")))] const OS: &str = "undefined"; -#[cfg(feature = "electrs_0_8_10")] -const VERSION: &str = "v0.8.10"; +// An explicit version of Electrs must be selected by enabling some feature. +// We check this here instead of in `lib.rs` because this file is included in `build.rs`. +#[cfg(all( + not(feature = "electrs_0_8_10"), + not(feature = "electrs_0_9_1"), + not(feature = "electrs_0_9_11"), + not(feature = "electrs_0_10_6"), + not(feature = "esplora_a33e97e1"), +))] +compile_error!("enable a feature in order to select the version of Electrs to use"); -#[cfg(feature = "esplora_a33e97e1")] -const VERSION: &str = "esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"; +#[cfg(feature = "electrs_0_10_6")] +const VERSION: &str = "v0.10.6"; + +#[cfg(all(feature = "electrs_0_9_11", not(feature = "electrs_0_10_6")))] +const VERSION: &str = "v0.9.11"; -#[cfg(feature = "electrs_0_9_1")] +#[cfg(all(feature = "electrs_0_9_1", not(feature = "electrs_0_9_11")))] const VERSION: &str = "v0.9.1"; -#[cfg(feature = "electrs_0_9_11")] -const VERSION: &str = "v0.9.11"; +#[cfg(all(feature = "electrs_0_8_10", not(feature = "electrs_0_9_1")))] +const VERSION: &str = "v0.8.10"; -#[cfg(feature = "electrs_0_10_6")] -const VERSION: &str = "v0.10.6"; +#[cfg(all(feature = "esplora_a33e97e1", not(feature = "electrs_0_8_10")))] +const VERSION: &str = "esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"; +/// This is meaningless but we need it otherwise we can't get far enough into +/// the build process to trigger the `compile_error!` above. #[cfg(not(any( feature = "electrs_0_8_10", feature = "electrs_0_9_1", @@ -31,10 +44,6 @@ const VERSION: &str = "v0.10.6"; )))] const VERSION: &str = "NA"; -#[allow(unused)] // this is not used in `build.rs` -pub const USE_LEGACY_COOKIE: bool = - cfg!(all(feature = "esplora_a33e97e1", not(feature = "electrs_0_8_10"))); - pub const HAS_FEATURE: bool = cfg!(any( feature = "electrs_0_8_10", feature = "electrs_0_9_1", @@ -44,3 +53,20 @@ pub const HAS_FEATURE: bool = cfg!(any( )); pub fn electrs_name() -> String { format!("electrs_{}_{}", OS, VERSION) } + +pub(crate) const IS_ELECTRS_0_8_10: bool = + cfg!(all(feature = "electrs_0_8_10", not(feature = "electrs_0_9_1"))); + +pub(crate) const IS_ELECTRS_0_9_1: bool = + cfg!(all(feature = "electrs_0_9_1", not(feature = "electrs_0_9_11"))); + +const IS_ESPLORA: bool = cfg!(all(feature = "esplora_a33e97e1", not(feature = "electrs_0_8_10"))); + +#[allow(unused)] // this is not used in `build.rs` +pub const USE_LEGACY_COOKIE: bool = IS_ESPLORA; + +#[allow(unused)] // this is not used in `build.rs` +pub const USE_JSONRPC_IMPORT: bool = IS_ELECTRS_0_8_10 || IS_ESPLORA; + +#[allow(unused)] // this is not used in `build.rs` +pub const USE_VERBOSE_ARG: bool = IS_ELECTRS_0_8_10 || IS_ELECTRS_0_9_1 || IS_ESPLORA; From cd0ddfe2c47955c3211695c588e8426432488c75 Mon Sep 17 00:00:00 2001 From: Renato Britto Date: Wed, 29 Apr 2026 16:20:57 -0300 Subject: [PATCH 13/13] electrsd: fix cargo.toml documentation typo --- electrsd/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrsd/Cargo.toml b/electrsd/Cargo.toml index 9824c6c0..21c9e7fe 100644 --- a/electrsd/Cargo.toml +++ b/electrsd/Cargo.toml @@ -4,7 +4,7 @@ version = "0.38.0" authors = ["Riccardo Casatta "] description = "Utility to run a regtest electrs process, useful in integration testing environment" repository = "https://github.com/rust-bitcoin/corepc" -documentation = "https://docs.rs/elecrtsd/" +documentation = "https://docs.rs/electrsd/" license = "MIT" edition = "2021" rust-version = "1.75.0"