Repository navigation
fix(rpc): read chunked responses from the bitcoind RPC server - #393
Open
eynhaender wants to merge 1 commit into
Open
eynhaender wants to merge 1 commit into
eynhaender wants to merge 1 commit into
Conversation
`bitcoincore_rpc::Client::new` always uses jsonrpc's `simple_http`
transport, which rejects responses sent with `Transfer-Encoding: chunked`
("The server replied with a chunked response which is not supported").
Servers that stream JSON-RPC responses chunked, such as libbitcoin-server,
cannot be used with `--client-type rpc`.
Build the RPC client over jsonrpc's `minreq_http` transport instead, which
reads chunked and content-length responses. bitcoincore-rpc 0.19 already
enables the `minreq_http` feature of jsonrpc, so no dependency changes.
minreq requires a URL scheme while simple_http defaulted to http, so
`http://` is prepended when the URL has none (e.g. `127.0.0.1:18443`).
This branch has not been deployed
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.
Description
Fixes #392.
--client-type rpcbuilt its client withbitcoincore_rpc::Client::new, which always uses jsonrpc'ssimple_httptransport and fails on any response sent withTransfer-Encoding: chunked.This PR builds the client with
Client::from_jsonrpcover jsonrpc'sminreq_httptransport, which reads both chunked andContent-Lengthresponses. bitcoincore-rpc 0.19 already enablesminreq_http, soCargo.tomlandCargo.lockare unchanged.Notes to the reviewers
minreqrequires a URL scheme, whilesimple_httpassumedhttp.http://is therefore prepended when--urlhas none, so127.0.0.1:18443from the README keeps working.Basic auth (
--basic-auth, and the cookie file viaAuth::get_user_pass) is passed to theminreq_httpbuilder. Transport errors map to the existingError::BitcoinCoreRpcError(bitcoincore_rpc::Error::JsonRpc(..)).Tested manually on regtest with
wallet full_scanand the same wpkh wallet against Bitcoin Core 32.1 and libbitcoin-server masterd09a5c2a(bitcoind endpoint, which sends every response withTransfer-Encoding: chunked):http://)In every run that succeeded, the txid set and the balance were identical.
There is no automated regression test:
bdk_testenv's bitcoind only sendsContent-Lengthresponses. A test would need a mock HTTP server that sends chunked responses; I can add one if wanted.Checklists
All Submissions:
just pre-pushbefore pushingBugfixes: