Drop archived bitcoincore-rpc dependency#1288
Open
PeterXMR wants to merge 1 commit into
Open
Conversation
The `rust-bitcoincore-rpc` crate was archived upstream on 2025-11-25 (see rust-bitcoin/rust-bitcoincore-rpc@92cad27). Replace it with a small local `rpc` module that implements only the subset electrs actually uses, layered directly on top of the still-maintained `jsonrpc` crate — already pulled in transitively and used directly for `batch_request`. The new module covers: - `Auth` (None, UserPass, CookieFile) and a thin `Client` wrapper. - The eight RPC methods `Daemon` invokes: `get_network_info`, `get_blockchain_info`, `estimate_smart_fee`, `send_raw_transaction`, `get_raw_transaction`, `get_block_info`, `get_mempool_info`, `get_raw_mempool`, plus the generic `call` and a `get_jsonrpc_client` accessor used for batch requests. - Local `Deserialize` response types holding only the fields electrs reads from the corresponding bitcoind responses (subset of `bitcoincore_rpc::json::*`). - An `Error` enum mirroring the two-layer `JsonRpc | Decode` shape callers already pattern-match against. Verified against Bitcoin Core 31 on regtest: every replaced RPC path round-trips successfully (relayfee, estimatefee, transaction.get hex+verbose, fee_histogram covering mempool sync, broadcast of a fresh signed tx), and the error-extraction path returns structured `DaemonError`s through the Electrum protocol. Closes romanz#1254 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49b643d to
f40c609
Compare
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.
Closes #1254.
The upstream
rust-bitcoincore-rpccrate was archived on 2025-11-25. This PR removes it from electrs in favor of a small in-treerpcmodule that calls bitcoind directly via the still-maintainedjsonrpccrate (which electrs was already pulling in transitively and using directly inbatch_request).Approach
I noticed
bitcoincore-rpcwas mostly a thin typed wrapper overjsonrpc::Client, and electrs uses only ~10 of its methods — so the replacement is narrow:Auth— local enum mirroring the three variantsconfig.rsconstructs.Client— wrapsjsonrpc::Clientand exposes the eight typed methodsDaemoncalls (get_network_info,get_blockchain_info,estimate_smart_fee,send_raw_transaction,get_raw_transaction,get_block_info,get_mempool_info,get_raw_mempool) plus the genericcall()andget_jsonrpc_client()used for batch requests.#[derive(Deserialize)]structs containing only the fields electrs actually reads, matching the JSON-field renames bitcoind uses (networkactive,initialblockdownload,relayfee,feerate).Error— two-variant enum (JsonRpc | Decode) mirroring the nested shape callers already pattern-match against, so the changes indaemon.rsandelectrum.rsare nearly mechanical.Diff
Testing
cargo build --all-targets— cleancargo clippy --all-targets -- -D warnings— zero warningscargo test --lib— 21/21 pass (includingconfig::tests::test_auth_debug, which exercises the localAuthenum'sDebugformatting)blockchain.relayfee→get_network_info::relay_fee(BTC↔Amountserde)blockchain.estimatefee→estimate_smart_fee(correctly maps missingfeeratetoOption<Amount>::Noneon regtest)blockchain.transaction.get(hex) →get_raw_transaction(hex + consensus decode)blockchain.transaction.get(verbose) → genericClient::callmempool.get_fee_histogram→ mempool sync exercisingget_mempool_info+get_raw_mempool+ batchgetmempoolentry(incl.fees.base,vsize,depends) + batchgetrawtransactionblockchain.transaction.broadcast(fresh signed tx) →send_raw_transaction{"code": 2, ...}, confirmingextract_bitcoind_errorand thedowncast_ref::<crate::rpc::Error>()inelectrum.rswork as before.get_blockchain_info(rpc_poll),get_block_info(indexing 111 blocks),get_mempool_info.Notes
Auth::Nonein place (marked#[allow(dead_code)]) for API completeness —daemon.rsmatches it but no current code path constructs it. Easy to remove if you'd prefer.EstimateModeenum (the oldbitcoincore_rpc_json::EstimateMode) since electrs always passesNonefor it. The newestimate_smart_feetakesOption<&str>instead, which avoids dead variants. Happy to add the enum back if you'd rather keep the API surface.bindex#1252 (bindex) — if that's expected to land soon and will rewrite most ofdaemon.rsanyway, this PR could be deferred or closed. It's a tidy interim cleanup either way.