Compare commits

..

12 Commits

Author SHA1 Message Date
merge-script
b2fdc5ccf8
Merge bitcoindevkit/rust-electrum-client#195: feat(ci): add justfile
Some checks failed
CI / Test (stable) (push) Has been cancelled
CI / Rust fmt (push) Has been cancelled
CI / Rust clippy (push) Has been cancelled
CI / Test (1.75.0) (push) Has been cancelled
df6675dc09 fix(docs): fix `bitcoin::block::Header` link (Luis Schwab)
4b98565ee2 feat(ci): add justfile (Luis Schwab)

Pull request description:

  This PR adds a `justfile` stolen from `rust-esplora-client`.

ACKs for top commit:
  oleonardolima:
    tACK df6675dc09

Tree-SHA512: 8d8f43c27631d7dc1c0eac28e01828510118a0600c762e9459b779a6423ceb6b1e3000f5c797d065a2ef6e511e2c47f6ad7bcf0182a515e573fc097e74f9e04b
2026-01-20 20:58:18 -03:00
Luis Schwab
df6675dc09
fix(docs): fix bitcoin::block::Header link 2026-01-19 17:13:06 -03:00
Luis Schwab
4b98565ee2
feat(ci): add justfile 2026-01-19 17:10:29 -03:00
merge-script
5d7be37136
Merge bitcoindevkit/rust-electrum-client#180: feat!: Change ConfigBuilder::timeout to accept Option<Duration>
5dc4bb6360 ci: bump clippy to 1.90.0 (valued mammal)
e31cf4773b feat!: Change ConfigBuilder::timeout to accept Option<Duration> (valued mammal)

Pull request description:

  Change `ConfigBuilder::timeout` to accept `Option<Duration>`. This makes the API more explicit and less error prone, as the caller no longer needs to assume the units of the given duration.

  Also updated the code to run clippy check in CI using rust 1.90.0.

  BREAKING:

  The `timeout` method on `ConfigBuilder` is changed to accept a `timeout: Option<Duration>`. Previously it was `Option<u8>`.

  fix #151
  fix #175
  Supersedes #179

ACKs for top commit:
  oleonardolima:
    ACK 5dc4bb6360

Tree-SHA512: cd6ca6fdd91dcf6f193327ca40f6d37ea8b1b548102f080d0b72a0df509f6455aa50ee43148e4746ca6b295a30a78cb7d786fb0e90c050448e96e122a5b8c92d
2025-11-10 21:32:04 -05:00
merge-script
761796c94a
Merge bitcoindevkit/rust-electrum-client#185: Release 0.24.1
Some checks failed
CI / Test (1.75.0) (push) Has been cancelled
CI / Test (stable) (push) Has been cancelled
CI / Rust fmt (push) Has been cancelled
CI / Rust clippy (push) Has been cancelled
c2656995fc chore: Bump version to 0.24.1 (valued mammal)

Pull request description:

  Bump version to `0.24.1`.

  Update CHANGELOG.md.

ACKs for top commit:
  oleonardolima:
    ACK c2656995fc

Tree-SHA512: 1e73dc9268f0c09224df758cd84620d591f0b0b82e114dfda07507ede5c58b0c43d99d1935b301db46a162e71de35bde56c9f8d36b4d9451f90f56890b48cc07
2025-11-04 14:38:42 -05:00
valued mammal
5dc4bb6360
ci: bump clippy to 1.90.0
- Fixed hidden lifetime in `Batch::iter`
- Use `io::Error::other` in place of `io::Error::new`
when the error kind is `ErrorKind::Other`.
2025-11-03 10:10:26 -05:00
valued mammal
e31cf4773b
feat!: Change ConfigBuilder::timeout to accept Option<Duration> 2025-11-03 10:10:26 -05:00
valued mammal
c2656995fc
chore: Bump version to 0.24.1
Update CHANGELOG.md.
2025-11-03 10:06:12 -05:00
merge-script
b185259561
Merge bitcoindevkit/rust-electrum-client#183: Default to ring if multiple rustls features are set
80bf744a70 test: don't assert the value returned by `relay_fee` (valued mammal)
0e28021b3e Check in CI that we compile if all `rustls` features are set (Elias Rohrer)
980fa4afd6 Default to `ring` if multiple `rustls` features are set (Elias Rohrer)

Pull request description:

  Fixes #181

  We default to use `ring` if multiple features are set, ensuring the features are additive. To that end, we also add a check to CI that asserts we succeed to build with both features set.

  Would be cool to get a patch release for this, as it's currently breaking our docs.rs builds in `lightning-liquidity`.

ACKs for top commit:
  ValuedMammal:
    ACK 80bf744a70.
  oleonardolima:
    cACK 80bf744a70

Tree-SHA512: 0b1bacb0f3a57fd8c666e1ece14b9a733f9d5dfdec7efd6461b400d58ef0e302c286597531381e417b5fdf1b97659ed36266d2cf89f8a0c4cab5e4d9b3fdeed7
2025-11-03 09:55:26 -05:00
valued mammal
80bf744a70
test: don't assert the value returned by relay_fee
Changed `test_relay_fee` to no longer assert the value of min
relay fee, and instead assert that the value is non-zero.
This fixes a test failure likely due to some nodes now having a
smaller default min relay fee (100sat).
2025-11-03 08:04:32 -05:00
Elias Rohrer
0e28021b3e
Check in CI that we compile if all rustls features are set
We assert that we still succeed compilation if multiple `rustls`
features are set.
2025-11-03 10:49:30 +01:00
Elias Rohrer
980fa4afd6
Default to ring if multiple rustls features are set 2025-11-03 10:49:01 +01:00
11 changed files with 67 additions and 60 deletions

View File

@ -41,6 +41,7 @@ jobs:
- run: cargo check --verbose --no-default-features --features=proxy,use-openssl
- run: cargo check --verbose --no-default-features --features=proxy,use-rustls
- run: cargo check --verbose --no-default-features --features=proxy,use-rustls-ring
- run: cargo check --verbose --no-default-features --features=proxy,use-rustls,use-rustls-ring
fmt:
name: Rust fmt
@ -61,13 +62,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: 1.84.0
toolchain: 1.90.0
components: clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.1
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings
- run: cargo clippy --all-features --all-targets -- -D warnings

View File

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.24.1]
- Default to `ring` if multiple `rustls` features are set #183
## [0.24.0]
- Use default `CryptoProvider` if available, otherwise install `rustls`'s `CryptoProvider` based on features #171
- Add a new batch method for `blockchain.transaction.get_merkle` #170
@ -59,4 +62,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.23.0]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.22.0...0.23.0
[0.23.1]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.23.0...0.23.1
[0.24.0]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.23.1...0.24.0
[Unreleased]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.24.0...HEAD
[0.24.1]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.24.0...0.24.1
[Unreleased]: https://github.com/bitcoindevkit/rust-electrum-client/compare/0.24.1...HEAD

View File

@ -1,6 +1,6 @@
[package]
name = "electrum-client"
version = "0.24.0"
version = "0.24.1"
authors = ["Alekos Filini <alekos.filini@gmail.com>"]
license = "MIT"
homepage = "https://github.com/bitcoindevkit/rust-electrum-client"

34
justfile Normal file
View File

@ -0,0 +1,34 @@
alias b := build
alias c := check
alias f := fmt
alias t := test
alias p := pre-push
_default:
@just --list
# Build the project
build:
cargo build
# Check code: formatting, compilation, linting, doc comments, and commit signature
check:
cargo +nightly fmt --all -- --check
cargo check --all-features --all-targets
cargo clippy --all-features --all-targets -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps
@[ "$(git log --pretty='format:%G?' -1 HEAD)" = "N" ] && \
echo "\n⚠ Unsigned commit: BDK requires that commits be signed." || \
true
# Format all code
fmt:
cargo +nightly fmt
# Run all tests on the workspace with all features
test:
cargo test --all-features -- --test-threads=1
# Run pre-push suite: format, check, and test
pre-push: fmt check test

View File

@ -88,7 +88,7 @@ impl Batch {
}
/// Returns an iterator on the batch
pub fn iter(&self) -> BatchIter {
pub fn iter(&self) -> BatchIter<'_> {
BatchIter {
batch: self,
index: 0,

View File

@ -448,7 +448,9 @@ mod tests {
let now = Instant::now();
let client = Client::from_config(
&endpoint,
crate::config::ConfigBuilder::new().timeout(Some(5)).build(),
crate::config::ConfigBuilder::new()
.timeout(Some(Duration::from_secs(5)))
.build(),
);
let elapsed = now.elapsed();

View File

@ -55,8 +55,8 @@ impl ConfigBuilder {
}
/// Sets the timeout
pub fn timeout(mut self, timeout: Option<u8>) -> Self {
self.config.timeout = timeout.map(|t| Duration::from_secs(t as u64));
pub fn timeout(mut self, timeout: Option<Duration>) -> Self {
self.config.timeout = timeout;
self
}

View File

@ -408,7 +408,7 @@ impl RawClient<ElectrumSslStream> {
if rustls::crypto::CryptoProvider::get_default().is_none() {
// We install a crypto provider depending on the set feature.
#[cfg(feature = "use-rustls")]
#[cfg(all(feature = "use-rustls", not(feature = "use-rustls-ring")))]
rustls::crypto::CryptoProvider::install_default(
rustls::crypto::aws_lc_rs::default_provider(),
)
@ -449,7 +449,7 @@ impl RawClient<ElectrumSslStream> {
builder
.dangerous()
.with_custom_certificate_verifier(std::sync::Arc::new(
#[cfg(feature = "use-rustls")]
#[cfg(all(feature = "use-rustls", not(feature = "use-rustls-ring")))]
danger::NoCertificateVerification::new(rustls::crypto::aws_lc_rs::default_provider()),
#[cfg(feature = "use-rustls-ring")]
danger::NoCertificateVerification::new(rustls::crypto::ring::default_provider()),
@ -1249,7 +1249,7 @@ mod test {
let client = RawClient::new(get_test_server(), None).unwrap();
let resp = client.relay_fee().unwrap();
assert_eq!(resp, 0.00001);
assert!(resp > 0.0);
}
#[test]

View File

@ -18,12 +18,7 @@ fn read_response(socket: &mut TcpStream) -> io::Result<SocketAddrV4> {
match response.read_u8()? {
90 => {}
91 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"request rejected or failed",
))
}
91 => return Err(io::Error::other("request rejected or failed")),
92 => {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,

View File

@ -37,10 +37,7 @@ fn read_addr<R: Read>(socket: &mut R) -> io::Result<TargetAddr> {
ip, port, 0, 0,
))))
}
_ => Err(io::Error::new(
io::ErrorKind::Other,
"unsupported address type",
)),
_ => Err(io::Error::other("unsupported address type")),
}
}
@ -54,35 +51,15 @@ fn read_response(socket: &mut TcpStream) -> io::Result<TargetAddr> {
match socket.read_u8()? {
0 => {}
1 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"general SOCKS server failure",
))
}
2 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"connection not allowed by ruleset",
))
}
3 => return Err(io::Error::new(io::ErrorKind::Other, "network unreachable")),
4 => return Err(io::Error::new(io::ErrorKind::Other, "host unreachable")),
5 => return Err(io::Error::new(io::ErrorKind::Other, "connection refused")),
6 => return Err(io::Error::new(io::ErrorKind::Other, "TTL expired")),
7 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"command not supported",
))
}
8 => {
return Err(io::Error::new(
io::ErrorKind::Other,
"address kind not supported",
))
}
_ => return Err(io::Error::new(io::ErrorKind::Other, "unknown error")),
1 => return Err(io::Error::other("general SOCKS server failure")),
2 => return Err(io::Error::other("connection not allowed by ruleset")),
3 => return Err(io::Error::other("network unreachable")),
4 => return Err(io::Error::other("host unreachable")),
5 => return Err(io::Error::other("connection refused")),
6 => return Err(io::Error::other("TTL expired")),
7 => return Err(io::Error::other("command not supported")),
8 => return Err(io::Error::other("address kind not supported")),
_ => return Err(io::Error::other("unknown error")),
}
if socket.read_u8()? != 0 {
@ -227,14 +204,11 @@ impl Socks5Stream {
}
if selected_method == 0xff {
return Err(io::Error::new(
io::ErrorKind::Other,
"no acceptable auth methods",
));
return Err(io::Error::other("no acceptable auth methods"));
}
if selected_method != auth.id() && selected_method != Authentication::None.id() {
return Err(io::Error::new(io::ErrorKind::Other, "unknown auth method"));
return Err(io::Error::other("unknown auth method"));
}
match *auth {

View File

@ -13,7 +13,7 @@ use bitcoin::Txid;
/// otherwise.
///
/// [`transaction_get_merkle`]: crate::ElectrumApi::transaction_get_merkle
/// [`BlockHeader`]: bitcoin::BlockHeader
/// [`BlockHeader`]: bitcoin::block::Header
pub fn validate_merkle_proof(
txid: &Txid,
merkle_root: &TxMerkleNode,