You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extern crate bitcoincore_rpc;
use bitcoincore_rpc::{Client, Error, RpcApi, Auth};
fn main() -> Result<(), Error> {
let auth = Auth::UserPass(
"regtest-username".to_string(),
"incorrect-password".to_string()
);
let rpc = Client::new("http://localhost:18443".to_string(), auth)?;
let info = rpc.get_blockchain_info()?;
println!("info = {:#?}", info);
println!("best block hash = {}", info.best_block_hash);
Ok(())
}
And it produces this error:
Error: JsonRpc(Json(Error("EOF while parsing a value", line: 1, column: 0)))
The error message doesn't mention anything about invalid credentials.
I think what's happening is Bitcoin Core is sending back a HTTP 401 Unauthorized reply, but the rust library still tries to read from the HTTP body. As there's no body it results in a confusing EOF error instead.
I may code a PR myself which fixes this by checking for 401 (I only just started learning rust so this may take a while)
The text was updated successfully, but these errors were encountered:
It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments.
So I don't think HTTP status codes are the correct way to handle errors server-side. It should be a 200 OK with a {"error": { ... }} to specify the error. So this is (per spec) a mistake on Core's side.
This script uses an incorrect password:
And it produces this error:
Error: JsonRpc(Json(Error("EOF while parsing a value", line: 1, column: 0)))
The error message doesn't mention anything about invalid credentials.
I think what's happening is Bitcoin Core is sending back a HTTP 401 Unauthorized reply, but the rust library still tries to read from the HTTP body. As there's no body it results in a confusing EOF error instead.
I may code a PR myself which fixes this by checking for 401 (I only just started learning rust so this may take a while)
The text was updated successfully, but these errors were encountered: