This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import the `rust-jsonrpc` crate from https://github.com/apoelstra/rust-jsonrpc using current tip of master `59646e6 Merge apoelstra/rust-jsonrpc#119: Use rust-bitcoin-maintainer-tools and re-write CI` Full commit hash: 59646e6e6ac95f07998133b1709e4a1fa2dbc7bd Do so using the following commands: mkdir jsonrpc mkdir jsonrpc/contrib rsync -avz ../../rust-jsonrpc/master/README.md jsonrpc rsync -avz ../../rust-jsonrpc/master/src jsonrpc rsync -avz ../../rust-jsonrpc/master/contrib/test_vars.sh jsonrpc/contrib Then: - Update `contrib/crates.sh` to include `jsonrpc`. - Remove workspaces from `jsonrpc/Cargo.toml`. - Add `jsonrpc` to repository workspace (and add patch section). Note, this PR does not bring over the `fuzz` directory, that will be done separately. Also we do not copy the integration testing because we get sufficient coverage from the current integration tests.
- Loading branch information
Showing
15 changed files
with
2,321 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[package] | ||
name = "jsonrpc" | ||
version = "0.18.0" | ||
authors = ["Andrew Poelstra <[email protected]>"] | ||
license = "CC0-1.0" | ||
homepage = "https://github.com/apoelstra/rust-jsonrpc/" | ||
repository = "https://github.com/apoelstra/rust-jsonrpc/" | ||
documentation = "https://docs.rs/jsonrpc/" | ||
description = "Rust support for the JSON-RPC 2.0 protocol" | ||
keywords = [ "protocol", "json", "http", "jsonrpc" ] | ||
readme = "README.md" | ||
edition = "2021" | ||
rust-version = "1.56.1" | ||
exclude = ["tests", "contrib"] | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[features] | ||
default = [ "simple_http", "simple_tcp" ] | ||
# A bare-minimum HTTP transport. | ||
simple_http = [ "base64" ] | ||
# A transport that uses `minreq` as the HTTP client. | ||
minreq_http = [ "base64", "minreq" ] | ||
# Basic transport over a raw TcpListener | ||
simple_tcp = [] | ||
# Basic transport over a raw UnixStream | ||
simple_uds = [] | ||
# Enable Socks5 Proxy in transport | ||
proxy = ["socks"] | ||
|
||
[dependencies] | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = { version = "1", features = [ "raw_value" ] } | ||
|
||
base64 = { version = "0.13.0", optional = true } | ||
minreq = { version = "2.7.0", features = ["json-using-serde"], optional = true } | ||
socks = { version = "0.3.4", optional = true} | ||
|
||
[lints.rust] | ||
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(jsonrpc_fuzz)'] } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[![Status](https://travis-ci.org/apoelstra/rust-jsonrpc.png?branch=master)](https://travis-ci.org/apoelstra/rust-jsonrpc) | ||
|
||
# Rust Version compatibility | ||
|
||
This library is compatible with Rust **1.63.0** or higher. | ||
|
||
# Rust JSONRPC Client | ||
|
||
Rudimentary support for sending JSONRPC 2.0 requests and receiving responses. | ||
|
||
As an example, hit a local bitcoind JSON-RPC endpoint and call the `uptime` command. | ||
|
||
```rust | ||
use jsonrpc::Client; | ||
use jsonrpc::simple_http::{self, SimpleHttpTransport}; | ||
|
||
fn client(url: &str, user: &str, pass: &str) -> Result<Client, simple_http::Error> { | ||
let t = SimpleHttpTransport::builder() | ||
.url(url)? | ||
.auth(user, Some(pass)) | ||
.build(); | ||
|
||
Ok(Client::with_transport(t)) | ||
} | ||
|
||
// Demonstrate an example JSON-RCP call against bitcoind. | ||
fn main() { | ||
let client = client("localhost:18443", "user", "pass").expect("failed to create client"); | ||
let request = client.build_request("uptime", None); | ||
let response = client.send_request(request).expect("send_request failed"); | ||
|
||
// For other commands this would be a struct matching the returned json. | ||
let result: u64 = response.result().expect("response is an error, use check_error"); | ||
println!("bitcoind uptime: {}", result); | ||
} | ||
``` | ||
|
||
## Githooks | ||
|
||
To assist devs in catching errors _before_ running CI we provide some githooks. If you do not | ||
already have locally configured githooks you can use the ones in this repository by running, in the | ||
root directory of the repository: | ||
``` | ||
git config --local core.hooksPath githooks/ | ||
``` | ||
|
||
Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
# `rust-jsonrpc` does not have a std feature. | ||
FEATURES_WITH_STD="" | ||
|
||
# So this is the var to use for all tests. | ||
FEATURES_WITHOUT_STD="simple_http minreq_http simple_tcp simple_uds proxy" | ||
|
||
# Run these examples. | ||
EXAMPLES="" |
Oops, something went wrong.