Skip to content

Commit 8b5bcd8

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 1dcc607 + 1b51e3d commit 8b5bcd8

File tree

9 files changed

+71
-19
lines changed

9 files changed

+71
-19
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- rust: nightly
1616
env:
1717
RUSTFMTCHK: false
18-
- rust: 1.41.1
18+
- rust: 1.48.0
1919
env:
2020
RUSTFMTCHK: false
2121
steps:
@@ -27,7 +27,6 @@ jobs:
2727
profile: minimal
2828
toolchain: ${{ matrix.rust }}
2929
override: true
30-
- run: cargo update -p serde --precise 1.0.152
3130
- name: Running test script
3231
env: ${{ matrix.env }}
3332
run: ./contrib/test.sh

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.18.0
2+
3+
- MSRV changed from 1.41.1 to 1.48.0
4+
- Use `bitcoin::Network` in `GetBlockchainInfoResult `.
5+
- Make checksum optional in `GetDescriptorInfoResult`.
6+
- Make `getmempoolinfo` compatible with supported RPC versions.
7+
18
# 0.17.0
29

310
- add `list_wallet_dir` rpc

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ The following versions are officially supported and automatically tested:
3939
* 25.1.0
4040

4141
# Minimum Supported Rust Version (MSRV)
42-
This library should always compile with any combination of features on **Rust 1.41.1**.
42+
This library should always compile with any combination of features on **Rust 1.48.0**.

client/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blackcoinmore-rpc"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
authors = [
55
"Steven Roose <steven@stevenroose.org>",
66
"Jean Pierre Dudey <jeandudey@hotmail.com>",
@@ -20,11 +20,15 @@ name = "blackcoinmore_rpc"
2020
path = "src/lib.rs"
2121

2222
[dependencies]
23-
blackcoinmore-rpc-json = { version = "0.17.0", path = "../json" }
23+
blackcoinmore-rpc-json = { version = "0.18.0", path = "../json" }
2424

2525
log = "0.4.5"
2626
jsonrpc = "0.14.0"
2727

2828
# Used for deserialization of JSON.
2929
serde = "1"
3030
serde_json = "1"
31+
32+
[dev-dependencies]
33+
tempfile = "3.3.0"
34+

client/src/client.rs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::collections::HashMap;
1212
use std::fs::File;
13+
use std::io::{BufRead, BufReader};
1314
use std::iter::FromIterator;
1415
use std::path::PathBuf;
1516
use std::{fmt, result};
@@ -201,19 +202,16 @@ pub enum Auth {
201202
impl Auth {
202203
/// Convert into the arguments that jsonrpc::Client needs.
203204
pub fn get_user_pass(self) -> Result<(Option<String>, Option<String>)> {
204-
use std::io::Read;
205205
match self {
206206
Auth::None => Ok((None, None)),
207207
Auth::UserPass(u, p) => Ok((Some(u), Some(p))),
208208
Auth::CookieFile(path) => {
209-
let mut file = File::open(path)?;
210-
let mut contents = String::new();
211-
file.read_to_string(&mut contents)?;
212-
let mut split = contents.splitn(2, ":");
213-
Ok((
214-
Some(split.next().ok_or(Error::InvalidCookieFile)?.into()),
215-
Some(split.next().ok_or(Error::InvalidCookieFile)?.into()),
216-
))
209+
let line = BufReader::new(File::open(path)?)
210+
.lines()
211+
.next()
212+
.ok_or(Error::InvalidCookieFile)??;
213+
let colon = line.find(':').ok_or(Error::InvalidCookieFile)?;
214+
Ok((Some(line[..colon].into()), Some(line[colon + 1..].into())))
217215
}
218216
}
219217
}
@@ -1440,4 +1438,34 @@ mod tests {
14401438
fn test_handle_defaults() {
14411439
test_handle_defaults_inner().unwrap();
14421440
}
1441+
1442+
#[test]
1443+
fn auth_cookie_file_ignores_newline() {
1444+
let tempdir = tempfile::tempdir().unwrap();
1445+
let path = tempdir.path().join("cookie");
1446+
std::fs::write(&path, "foo:bar\n").unwrap();
1447+
assert_eq!(
1448+
Auth::CookieFile(path).get_user_pass().unwrap(),
1449+
(Some("foo".into()), Some("bar".into())),
1450+
);
1451+
}
1452+
1453+
#[test]
1454+
fn auth_cookie_file_ignores_additional_lines() {
1455+
let tempdir = tempfile::tempdir().unwrap();
1456+
let path = tempdir.path().join("cookie");
1457+
std::fs::write(&path, "foo:bar\nbaz").unwrap();
1458+
assert_eq!(
1459+
Auth::CookieFile(path).get_user_pass().unwrap(),
1460+
(Some("foo".into()), Some("bar".into())),
1461+
);
1462+
}
1463+
1464+
#[test]
1465+
fn auth_cookie_file_fails_if_colon_isnt_present() {
1466+
let tempdir = tempfile::tempdir().unwrap();
1467+
let path = tempdir.path().join("cookie");
1468+
std::fs::write(&path, "foobar").unwrap();
1469+
assert!(matches!(Auth::CookieFile(path).get_user_pass(), Err(Error::InvalidCookieFile)));
1470+
}
14431471
}

contrib/test.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
set -xe
33

4+
MSRV="1\.48"
5+
46
# Just echo all the relevant env vars to help debug Travis.
57
echo "RUSTFMTCHECK: \"$RUSTFMTCHECK\""
68
echo "BITCOINVERSION: \"$BITCOINVERSION\""
@@ -11,6 +13,16 @@ if [ -n "$RUSTFMTCHECK" ]; then
1113
cargo fmt --all -- --check
1214
fi
1315

16+
# Test pinned versions (these are from rust-bitcoin pinning for 1.48).
17+
if cargo --version | grep ${MSRV}; then
18+
cargo update -p tempfile --precise 3.3.0
19+
cargo update -p log --precise 0.4.18
20+
cargo update -p serde_json --precise 1.0.99
21+
cargo update -p serde --precise 1.0.156
22+
cargo update -p quote --precise 1.0.30
23+
cargo update -p proc-macro2 --precise 1.0.63
24+
fi
25+
1426
# Integration test.
1527
if [ -n "$BITCOINVERSION" ]; then
1628
wget https://bitcoincore.org/bin/bitcoin-core-$BITCOINVERSION/bitcoin-$BITCOINVERSION-x86_64-linux-gnu.tar.gz
@@ -25,4 +37,3 @@ else
2537
cargo test --verbose
2638
cargo build --verbose --examples
2739
fi
28-

integration_test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ edition = "2018"
66

77
[dependencies]
88
blackcoinmore-rpc = { path = "../client" }
9-
bitcoin = { version = "0.31.0-rc2", features = ["serde", "rand", "rand-std"], git = "http://github.com/CoinBlack/rust-blackcoin", branch = "develop" }
9+
bitcoin = { version = "0.31.0", features = ["serde", "rand", "rand-std"], git = "http://github.com/CoinBlack/rust-blackcoin" }
1010
lazy_static = "1.4.0"
1111
log = "0.4"

integration_test/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,10 @@ fn test_add_multisig_address(cl: &Client) {
14061406
#[rustfmt::skip]
14071407
fn test_derive_addresses(cl: &Client) {
14081408
let descriptor = r"pkh(02e96fe52ef0e22d2f131dd425ce1893073a3c6ad20e8cac36726393dfb4856a4c)#62k9sn4x";
1409-
assert_eq!(cl.derive_addresses(descriptor, None).unwrap(), vec!["mrkwtj5xpYQjHeJe5wsweNjVeTKkvR5fCr".parse::<Address<NetworkUnchecked>>().unwrap()]);
1409+
assert_eq!(
1410+
cl.derive_addresses(descriptor, None).unwrap(),
1411+
vec!["mrkwtj5xpYQjHeJe5wsweNjVeTKkvR5fCr".parse::<Address<NetworkUnchecked>>().unwrap()]
1412+
);
14101413
assert!(cl.derive_addresses(descriptor, Some([0, 1])).is_err()); // Range should not be specified for an unranged descriptor
14111414

14121415
let descriptor = std::concat!(

json/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blackcoinmore-rpc-json"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
authors = [
55
"Steven Roose <steven@stevenroose.org>",
66
"Jean Pierre Dudey <jeandudey@hotmail.com>",
@@ -23,4 +23,4 @@ path = "src/lib.rs"
2323
serde = { version = "1", features = [ "derive" ] }
2424
serde_json = "1"
2525

26-
bitcoin = { version = "0.31.0-rc2", features = ["serde", "rand", "rand-std"], git = "http://github.com/CoinBlack/rust-blackcoin", branch = "develop" }
26+
bitcoin = { version = "0.31.0", features = ["serde", "rand", "rand-std"], git = "http://github.com/CoinBlack/rust-blackcoin" }

0 commit comments

Comments
 (0)