Skip to content

Complete a handshake upon channel stop. - #1233

Merged
evoskuil merged 1 commit into
libbitcoin:masterfrom
echennells:fix/handshake-stop
Nov 27, 2026
Merged

evoskuil merged 1 commit into
libbitcoin:masterfrom
echennells:fix/handshake-stop

Conversation

@echennells

Copy link
Copy Markdown
Contributor

A handshake protocol must invoke its handler one time, but protocol_electrum_version, protocol_bitcoind_version and protocol_stratum_v2_setup do so only from finished, which returns if the channel is stopped. A channel that stops before its opener never completes its handshake, so the session never unpends it, and it is retained with its request buffer until shutdown. This affects electrum, sparrow, bitcoind, btcd and stratum v2.

protocol_version_106 completes from stopping. This does the same.

Regtest on the November 25 masters, 200 connections closed before sending, per service: 7.65 MB retained per connection on electrum, sparrow, bitcoind and btcd, 24 KB on stratum v2, and none on esplora (no handshake). With this change growth stops within the first 100 connections on electrum and sparrow, and there is none on the others.

Depends on libbitcoin/libbitcoin-network#1065. Otherwise the second stop, by session::handle_handshake, resets a client that is still sending when a pending handshake is stopped with an answer (e.g. 413).

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.946% (+0.03%) from 93.919% — echennells:fix/handshake-stop into libbitcoin:master

@evoskuil
evoskuil merged commit cb4fad3 into libbitcoin:master Nov 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants