Skip to content

Expose negotiated protocol version#213

Open
tnull wants to merge 2 commits into
bitcoindevkit:masterfrom
tnull:2026-06-expose-protocol-version
Open

Expose negotiated protocol version#213
tnull wants to merge 2 commits into
bitcoindevkit:masterfrom
tnull:2026-06-expose-protocol-version

Conversation

@tnull

@tnull tnull commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The v1.6 upgrade negotiated and stored the server protocol version during connection setup, but omitted the documented public API for reading it.

Add protocol_version() so callers can reuse the negotiated value. Only fall back to server.version when no cached version exists.

oleonardolima and others added 2 commits July 1, 2026 11:19
The v1.6 upgrade negotiated and stored the server protocol
version during connection setup, but omitted the documented
public API for reading it.

Add protocol_version() so callers can reuse the negotiated value.
Only fall back to server.version when no cached version exists.

Co-Authored-By: HAL 9000
@oleonardolima oleonardolima force-pushed the 2026-06-expose-protocol-version branch from c2a5d17 to f78ed74 Compare July 1, 2026 14:19
@oleonardolima oleonardolima moved this to Needs Review in BDK Chain Jul 1, 2026

@oleonardolima oleonardolima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK f78ed74

Overall it looks good! I pushed a commit fixing the CI, though.

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK fadedd9

I wrote this example to validate:

use electrum_client::{Client, Config, ElectrumApi, Socks5Config};
use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = env::args().nth(1).expect("uso: cargo run --example test_protocol_version -- <url> [socks5_addr]");
    let proxy = env::args().nth(2);

    let config = Config::builder()
        .validate_domain(false)
        .socks5(proxy.map(Socks5Config::new))
        .build();

    let client = Client::from_config(&url, config)?;
    println!("{} -> protocol_version = {}", url, client.protocol_version()?);
    Ok(())
}

and tested using these electrum url's

➜  rust-electrum-client git:(pr-213) - cargo run --example test_protocol_version -- "tcp://5dfr3ossuq3kxyc4zsgwqarh37yzlp7b6jc2j7h2gjq6jp7d7zg6fnid.onion:62001" "127.0.0.1:9050"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/examples/test_protocol_version 'tcp://5dfr3ossuq3kxyc4zsgwqarh37yzlp7b6jc2j7h2gjq6jp7d7zg6fnid.onion:62001' '127.0.0.1:9050'`
tcp://5dfr3ossuq3kxyc4zsgwqarh37yzlp7b6jc2j7h2gjq6jp7d7zg6fnid.onion:62001 -> protocol_version = 1.6
➜  rust-electrum-client git:(pr-213) - cargo run --example test_protocol_version -- "ssl://blackie.c3-soft.com:62002"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/examples/test_protocol_version 'ssl://blackie.c3-soft.com:62002'`
ssl://blackie.c3-soft.com:62002 -> protocol_version = 1.6
➜  rust-electrum-client git:(pr-213) - cargo run --example test_protocol_version -- "ssl://testnet.aranguren.org:51002"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.26s
     Running `target/debug/examples/test_protocol_version 'ssl://testnet.aranguren.org:51002'`
ssl://testnet.aranguren.org:51002 -> protocol_version = 1.6
➜  rust-electrum-client git:(pr-213) - cargo run --example test_protocol_version -- "tcp://blackie.c3-soft.com:57005"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.29s
     Running `target/debug/examples/test_protocol_version 'tcp://blackie.c3-soft.com:57005'`
tcp://blackie.c3-soft.com:57005 -> protocol_version = 1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants