Repository navigation
Conversation
docs: fix lib/coins.py link in environment.rst
to help distinguish logs from kyuupichan/electrumx ref spesmilo/electrumx#306
This prevents the DoS attack vector caused by hitting the max number of sessions. Prior to this change if the max number of sessions was reached, the server would stop listening for new connections until ALL existing connections were closed. Now, the listening port is closed, the existing connections remain live and when the lower threshold is reached, the listening socket is reopened.
…implementation fix: prevent incorrect session limit DoS attack vector
Adds the `mempool.get_info` rpc to fetch mempoolminfee, minrelaytxfee and incrementalrelayfee from the daemons getmempoolinfo rpc for protocol version 1.6. Updates the relayfee comments as the fee returned by `blockchain.relayfee` doesn't guarantee to get into the mempool as previously stated in the docstrings.
The parsing of the version number returned from 'getnetworkinfo' was not adapted to the changed bitcoin core version number scheme since core went from beta to stable. The banner incorrectly showed 0.29.0 instead of 29.0.0.
Checks the daemon version on startup against a minimum allowed daemon version hardcoded in the corresponding `Coin`. This allows ensure that the connected daemon is running a version that supports all the rpc calls electrumx requires.
Guards the new `blockchain.transaction.broadcast_package` and `mempool.get_info` methods of protocol 1.6 behind this versions ptuple in `set_request_handlers` so they are only exposed in protocol versions >= 1.6. Also stops exposing the `blockchain.relayfee` endpoint for version >= 1.6 as it got removed in 1.6.
implements mempool.get_info and clarifies comments of relayfee
check daemon version on startup, fix version in banner
Removes the incorrect and unnecessary txid calculation in `ElectrumX.package_broadcast()`, the daemon will complain anyways if the transactions are invalid.
Make mode uppercase if passed as neither the protocol nor core do specify any requirement here.
session: estimatefee: normalize mode arg
session: broadcast_package: followup #288
session.py: sanitize inputs for tx broadcast RPCs
was just sending back a response with value 1, instead of a jsonrpc error ref spesmilo/electrumx@860ff53
session: fix ReplyAndDisconnect. was broken for PaddedRSTransport
Adds a 1024 (unpadded) byte sending budget to the PaddedRSTransport below which messages are instantly flushed down the socket before the transport will beginn waiting for the buffer to reach MIN_PACKET_SIZE (1024). This allows to get the first couple of messages sent quickly when a wallet connects to improve its ux.
add warmup budget to PaddedRSTransport
We already enforce that server.version must be the first received message in a session, but we also need to ensure that the server finishes processing that message and sets up the correct protocol version before starting to process further messages.
to leave room for future extensions
protocol 1.6: "server.version" must be first msg, must tolerate unknown args
Note that this is a soft fork: the server can apply it even for past
protocol versions.
Previously, with the order being undefined, if an address had multiple
mempool transactions touching it, switching between different servers
could result in a change in address status simply as a result of these
servers ordering mempool txs differently. This would result in the client
re-requesting the whole history of the address.
-----
D/i | interface.[electrum.blockstream.info:60002] | <-- ('blockchain.scripthash.subscribe', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 12)
D/i | interface.[electrum.blockstream.info:60002] | --> 9da27f9df91e3f860212f65b736fa20a539ba6e3d509f6370367ee7f10a4d5b0 (id: 12)
D/i | interface.[electrum.blockstream.info:60002] | <-- ('blockchain.scripthash.get_history', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 13)
D/i | interface.[electrum.blockstream.info:60002] | --> [
{'fee': 200, 'height': 0, 'tx_hash': '3ee6d6e26291ce360127fe039b816470fce6eeea19b5c9d10829a1e4efc2d0c7'},
{'fee': 239, 'height': 0, 'tx_hash': '9e050f09b676b9b0ee26aa02ccee623fae585a85d6a5e24ecedd6f8d6d2d3b1d'},
{'fee': 178, 'height': 0, 'tx_hash': 'fb80adbf8274190418cb3fb0385d82fe9d47a844d9913684fa5fb3d48094b35a'},
{'fee': 200, 'height': 0, 'tx_hash': '713933c50b7c43f606dad5749ea46e3bc6622657e9b13ace9d639697da266e8b'}
] (id: 13)
D/i | interface.[testnet.hsmiths.com:53012] | <-- ('blockchain.scripthash.subscribe', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 12)
D/i | interface.[testnet.hsmiths.com:53012] | --> f7ef7237d2d62a3280acae05616200b96ad9dd85fd0473c29152a4a41e05686c (id: 12)
D/i | interface.[testnet.hsmiths.com:53012] | <-- ('blockchain.scripthash.get_history', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 13)
D/i | interface.[testnet.hsmiths.com:53012] | --> [
{'tx_hash': '9e050f09b676b9b0ee26aa02ccee623fae585a85d6a5e24ecedd6f8d6d2d3b1d', 'height': 0, 'fee': 239},
{'tx_hash': 'fb80adbf8274190418cb3fb0385d82fe9d47a844d9913684fa5fb3d48094b35a', 'height': 0, 'fee': 178},
{'tx_hash': '3ee6d6e26291ce360127fe039b816470fce6eeea19b5c9d10829a1e4efc2d0c7', 'height': 0, 'fee': 200},
{'tx_hash': '713933c50b7c43f606dad5749ea46e3bc6622657e9b13ace9d639697da266e8b', 'height': 0, 'fee': 200}
] (id: 13)
storage: add some type hints
dedupe min python version
utxo db: incrementally clear excess undo infos as we go
mempool: refresh_hashes: log time taken
mempool: partially revert threading _process_mempool
protocol 1.7: revert adding chaintip to responses
session: bump PROTOCOL_MAX to 1.7
also, - don't pin python patch version - use default env var values - "docker stop" seems cleaner, more intuitive, than kill
dockerfile: switch to rocksdb, and show how to build free-threaded python
prepare release 2.0.0
Our fleet runs ElectrumX 1.15.0 (2020). Upstream 2.0.0 moved the tree to
src/, merged the name and AuxPoW mixins into NameIndexAuxPoWMixin (which
carries SESSIONCLS), turned P2SH_VERBYTES and NAME_OPERATIONS into tuples,
added NAME_EXPIRATION, and dropped XPUB/XPRV/WIF entirely -- they have no
remaining use anywhere in the tree.
Values come from the chain and the consensus rules rather than being carried
over unchanged:
RPC_PORT 8339 / 18339 8338 is the P2P port since Core 31, so the old
value pointed ElectrumX at the wrong socket
TX_COUNT 2,742,220 getchaintxstats at height 431,763
NAME_EXPIRATION 36,000 / 30 Consensus::MainNetConsensus::NameExpirationDepth
(36,000 above height 48,000; regtest 30)
Testnet and regtest inherit from Doichain now instead of repeating every
declaration, matching how upstream keeps the Namecoin classes.
Verified with the package installed: ElectrumX resolves all three classes,
with SESSIONCLS NameIndexAuxPoWElectrumX, DESERIALIZER DeserializerAuxPowSegWit,
BLOCK_PROCESSOR NameIndexBlockProcessor, four name operations including
name_doi, and REQUIRED_DAEMON_INDEXES empty -- so no extra daemon index is
required. tests/lib/test_coins.py: 16 passed.
Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 16, 2026
Contributor
Author
|
Superseded by the branch One of the conflicts did not announce itself: git treated Please close this PR in favour of the replacement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrades this fork from ElectrumX 1.15.0 (2020) to upstream 2.0.0 (3 July 2026) and ports the Doichain coin classes onto it. 482 upstream commits plus one of ours; the merge base with
masteris upstream tag1.15.0(835aa49), so this is the whole jump in one branch, including the releases 1.16 through 1.20 that we skipped.Why
aiorpcX < 0.19and runs on Python versions that are past end of life (3.7 on the servers, 3.9 in the container image), so it receives no upstream fixes.RPC_PORTin the coin class was8338. Since Doichain Core 31 that is the P2P port — RPC is 8339 — so aDAEMON_URLwithout an explicit port connected to the wrong socket and ElectrumX never got an answer.What the port had to handle
Upstream did not keep the shape our classes were written against:
NameIndexMixin, AuxPowMixin, CoinNameIndexAuxPoWMixin, Coin(carriesSESSIONCLS)P2SH_VERBYTES,NAME_OPERATIONSNAME_EXPIRATION(new)XPUB_VERBYTES,XPRV_VERBYTES,WIF_BYTEValues are taken from the chain and the consensus rules rather than carried over:
RPC_PORT8339 / 18339 / 18332TX_COUNT2,742,220 at height 431,763 (getchaintxstats),TX_PER_BLOCK2 (4,937 transactions in the last 4,320 blocks)NAME_EXPIRATION36,000, regtest 30 —Consensus::MainNetConsensus::NameExpirationDepth, which returns 36,000 above height 48,000Verification
With the package installed, ElectrumX resolves all three classes itself:
SESSIONCLSNameIndexAuxPoWElectrumX,DESERIALIZERDeserializerAuxPowSegWit,BLOCK_PROCESSORNameIndexBlockProcessorname_doi(OP_10), as a tupleREQUIRED_DAEMON_INDEXESempty — 2.0.0 requirestxospenderindexonly onclass Bitcoin, so no additional index is needed on doichaindtests/lib/test_coins.py: 16 passedtests/lib/test_merkle.pyand fourtest_addresses.pycases (SmartCash among them) fail on the pristine2.0.0tag as well, verified by stashing this change — they are a missingpytest-asyncioand a missing optional hash module, not a regression.For operators, when this is deployed
DB_ENGINEis now mandatory (leveldborrocksdb; RocksDB syncs roughly 25 % faster on SSD).PROTOCOL_MIN = (1, 4).Not in this PR
The container recipe and the compose service live in
Doichain/doichain-installand follow separately.🤖 Generated with Claude Code