Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 07dddfd

Browse files
committed
Import jsonrpc crate
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.
1 parent 4b0bd28 commit 07dddfd

15 files changed

+2343
-4
lines changed

Cargo-minimal.lock

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ version = "0.3.0"
9090
dependencies = [
9191
"bitcoin",
9292
"bitcoind-json-rpc-types",
93-
"jsonrpc",
93+
"jsonrpc 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
9494
"log",
9595
"serde",
9696
"serde_json",
@@ -106,6 +106,12 @@ dependencies = [
106106
"serde_json",
107107
]
108108

109+
[[package]]
110+
name = "byteorder"
111+
version = "1.5.0"
112+
source = "registry+https://github.com/rust-lang/crates.io-index"
113+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
114+
109115
[[package]]
110116
name = "cc"
111117
version = "1.0.28"
@@ -133,6 +139,17 @@ version = "1.0.11"
133139
source = "registry+https://github.com/rust-lang/crates.io-index"
134140
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
135141

142+
[[package]]
143+
name = "jsonrpc"
144+
version = "0.18.0"
145+
dependencies = [
146+
"base64",
147+
"minreq",
148+
"serde",
149+
"serde_json",
150+
"socks",
151+
]
152+
136153
[[package]]
137154
name = "jsonrpc"
138155
version = "0.18.0"
@@ -145,6 +162,12 @@ dependencies = [
145162
"serde_json",
146163
]
147164

165+
[[package]]
166+
name = "libc"
167+
version = "0.2.158"
168+
source = "registry+https://github.com/rust-lang/crates.io-index"
169+
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
170+
148171
[[package]]
149172
name = "log"
150173
version = "0.4.18"
@@ -237,6 +260,17 @@ dependencies = [
237260
"serde",
238261
]
239262

263+
[[package]]
264+
name = "socks"
265+
version = "0.3.4"
266+
source = "registry+https://github.com/rust-lang/crates.io-index"
267+
checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
268+
dependencies = [
269+
"byteorder",
270+
"libc",
271+
"winapi",
272+
]
273+
240274
[[package]]
241275
name = "syn"
242276
version = "2.0.56"
@@ -253,3 +287,25 @@ name = "unicode-ident"
253287
version = "1.0.8"
254288
source = "registry+https://github.com/rust-lang/crates.io-index"
255289
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
290+
291+
[[package]]
292+
name = "winapi"
293+
version = "0.3.9"
294+
source = "registry+https://github.com/rust-lang/crates.io-index"
295+
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
296+
dependencies = [
297+
"winapi-i686-pc-windows-gnu",
298+
"winapi-x86_64-pc-windows-gnu",
299+
]
300+
301+
[[package]]
302+
name = "winapi-i686-pc-windows-gnu"
303+
version = "0.4.0"
304+
source = "registry+https://github.com/rust-lang/crates.io-index"
305+
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
306+
307+
[[package]]
308+
name = "winapi-x86_64-pc-windows-gnu"
309+
version = "0.4.0"
310+
source = "registry+https://github.com/rust-lang/crates.io-index"
311+
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

Cargo-recent.lock

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ version = "0.3.0"
9090
dependencies = [
9191
"bitcoin",
9292
"bitcoind-json-rpc-types",
93-
"jsonrpc",
93+
"jsonrpc 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
9494
"log",
9595
"serde",
9696
"serde_json",
@@ -106,6 +106,12 @@ dependencies = [
106106
"serde_json",
107107
]
108108

109+
[[package]]
110+
name = "byteorder"
111+
version = "1.5.0"
112+
source = "registry+https://github.com/rust-lang/crates.io-index"
113+
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
114+
109115
[[package]]
110116
name = "cc"
111117
version = "1.0.28"
@@ -133,6 +139,17 @@ version = "1.0.11"
133139
source = "registry+https://github.com/rust-lang/crates.io-index"
134140
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
135141

142+
[[package]]
143+
name = "jsonrpc"
144+
version = "0.18.0"
145+
dependencies = [
146+
"base64",
147+
"minreq",
148+
"serde",
149+
"serde_json",
150+
"socks",
151+
]
152+
136153
[[package]]
137154
name = "jsonrpc"
138155
version = "0.18.0"
@@ -145,6 +162,12 @@ dependencies = [
145162
"serde_json",
146163
]
147164

165+
[[package]]
166+
name = "libc"
167+
version = "0.2.158"
168+
source = "registry+https://github.com/rust-lang/crates.io-index"
169+
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
170+
148171
[[package]]
149172
name = "log"
150173
version = "0.4.18"
@@ -237,6 +260,17 @@ dependencies = [
237260
"serde",
238261
]
239262

263+
[[package]]
264+
name = "socks"
265+
version = "0.3.4"
266+
source = "registry+https://github.com/rust-lang/crates.io-index"
267+
checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
268+
dependencies = [
269+
"byteorder",
270+
"libc",
271+
"winapi",
272+
]
273+
240274
[[package]]
241275
name = "syn"
242276
version = "2.0.56"
@@ -253,3 +287,25 @@ name = "unicode-ident"
253287
version = "1.0.8"
254288
source = "registry+https://github.com/rust-lang/crates.io-index"
255289
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
290+
291+
[[package]]
292+
name = "winapi"
293+
version = "0.3.9"
294+
source = "registry+https://github.com/rust-lang/crates.io-index"
295+
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
296+
dependencies = [
297+
"winapi-i686-pc-windows-gnu",
298+
"winapi-x86_64-pc-windows-gnu",
299+
]
300+
301+
[[package]]
302+
name = "winapi-i686-pc-windows-gnu"
303+
version = "0.4.0"
304+
source = "registry+https://github.com/rust-lang/crates.io-index"
305+
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
306+
307+
[[package]]
308+
name = "winapi-x86_64-pc-windows-gnu"
309+
version = "0.4.0"
310+
source = "registry+https://github.com/rust-lang/crates.io-index"
311+
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["client", "json"]
2+
members = ["client", "json", "jsonrpc"]
33
exclude = ["integration_test", "regtest"]
44
resolver = "2"
55

@@ -8,3 +8,6 @@ path = "client"
88

99
[patch.crates-io.bitcoind-json-rpc-types]
1010
path = "json"
11+
12+
[patch.crates-io.jsonrpc]
13+
path = "jsonrpc"

contrib/crates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# shellcheck disable=SC2148
33

44
# Crates in this workspace to test.
5-
CRATES=("json" "client")
5+
CRATES=("json" "client" "jsonrpc")

jsonrpc/Cargo.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[package]
2+
name = "jsonrpc"
3+
version = "0.18.0"
4+
authors = ["Andrew Poelstra <[email protected]>"]
5+
license = "CC0-1.0"
6+
homepage = "https://github.com/apoelstra/rust-jsonrpc/"
7+
repository = "https://github.com/apoelstra/rust-jsonrpc/"
8+
documentation = "https://docs.rs/jsonrpc/"
9+
description = "Rust support for the JSON-RPC 2.0 protocol"
10+
keywords = [ "protocol", "json", "http", "jsonrpc" ]
11+
readme = "README.md"
12+
edition = "2021"
13+
rust-version = "1.56.1"
14+
exclude = ["tests", "contrib"]
15+
16+
[package.metadata.docs.rs]
17+
all-features = true
18+
rustdoc-args = ["--cfg", "docsrs"]
19+
20+
[features]
21+
default = [ "simple_http", "simple_tcp" ]
22+
# A bare-minimum HTTP transport.
23+
simple_http = [ "base64" ]
24+
# A transport that uses `minreq` as the HTTP client.
25+
minreq_http = [ "base64", "minreq" ]
26+
# Basic transport over a raw TcpListener
27+
simple_tcp = []
28+
# Basic transport over a raw UnixStream
29+
simple_uds = []
30+
# Enable Socks5 Proxy in transport
31+
proxy = ["socks"]
32+
33+
[dependencies]
34+
serde = { version = "1", features = ["derive"] }
35+
serde_json = { version = "1", features = [ "raw_value" ] }
36+
37+
base64 = { version = "0.13.0", optional = true }
38+
minreq = { version = "2.7.0", features = ["json-using-serde"], optional = true }
39+
socks = { version = "0.3.4", optional = true}
40+
41+
[lints.rust]
42+
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(jsonrpc_fuzz)'] }

jsonrpc/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[![Status](https://travis-ci.org/apoelstra/rust-jsonrpc.png?branch=master)](https://travis-ci.org/apoelstra/rust-jsonrpc)
2+
3+
# Rust Version compatibility
4+
5+
This library is compatible with Rust **1.63.0** or higher.
6+
7+
# Rust JSONRPC Client
8+
9+
Rudimentary support for sending JSONRPC 2.0 requests and receiving responses.
10+
11+
As an example, hit a local bitcoind JSON-RPC endpoint and call the `uptime` command.
12+
13+
```rust
14+
use jsonrpc::Client;
15+
use jsonrpc::simple_http::{self, SimpleHttpTransport};
16+
17+
fn client(url: &str, user: &str, pass: &str) -> Result<Client, simple_http::Error> {
18+
let t = SimpleHttpTransport::builder()
19+
.url(url)?
20+
.auth(user, Some(pass))
21+
.build();
22+
23+
Ok(Client::with_transport(t))
24+
}
25+
26+
// Demonstrate an example JSON-RCP call against bitcoind.
27+
fn main() {
28+
let client = client("localhost:18443", "user", "pass").expect("failed to create client");
29+
let request = client.build_request("uptime", None);
30+
let response = client.send_request(request).expect("send_request failed");
31+
32+
// For other commands this would be a struct matching the returned json.
33+
let result: u64 = response.result().expect("response is an error, use check_error");
34+
println!("bitcoind uptime: {}", result);
35+
}
36+
```
37+
38+
## Githooks
39+
40+
To assist devs in catching errors _before_ running CI we provide some githooks. If you do not
41+
already have locally configured githooks you can use the ones in this repository by running, in the
42+
root directory of the repository:
43+
```
44+
git config --local core.hooksPath githooks/
45+
```
46+
47+
Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide.

jsonrpc/contrib/test_vars.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# `rust-jsonrpc` does not have a std feature.
4+
FEATURES_WITH_STD=""
5+
6+
# So this is the var to use for all tests.
7+
FEATURES_WITHOUT_STD="simple_http minreq_http simple_tcp simple_uds proxy"
8+
9+
# Run these examples.
10+
EXAMPLES=""

0 commit comments

Comments
 (0)