Skip to content

Commit 91228df

Browse files
committed
Merge bitcoindevkit#121: Upgrade bitcoin
dd3c171 Upgrade bitcoin (Tobin C. Harding) Pull request description: Upgrade bitcoin dependency to `rust-bitcoin v0.31.0-rc1`: Allows us to remove the dependency on `bitcoin-private` because the `hex` stuff is exposed by `bitcoin` now. ACKs for top commit: notmandatory: ACK dd3c171 Tree-SHA512: 9082d3c2136445230bb23669f83fed58c90d1baf28d35527fc3dea1d40c9d3bdebeddbc44b3bdbc8e79c9b701e09cb453c018af0bc4ac8bcd1c4a14d11c90e39
2 parents e4d2b1d + dd3c171 commit 91228df

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ path = "src/lib.rs"
1818

1919
[dependencies]
2020
log = "^0.4"
21-
bitcoin = { version = "^0.30", features = ["serde"] }
22-
bitcoin-private = "0.1.0"
21+
bitcoin = { version = "0.31.0", features = ["serde"] }
2322
serde = { version = "^1.0", features = ["derive"] }
2423
serde_json = { version = "^1.0" }
2524

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
//! ```
2121
2222
pub extern crate bitcoin;
23-
extern crate bitcoin_private;
2423
extern crate core;
2524
extern crate log;
2625
#[cfg(feature = "use-openssl")]

src/raw_client.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use std::time::Duration;
1616
use log::{debug, error, info, trace, warn};
1717

1818
use bitcoin::consensus::encode::deserialize;
19-
use bitcoin::hashes::hex::FromHex;
19+
use bitcoin::hex::{DisplayHex, FromHex};
2020
use bitcoin::{Script, Txid};
21-
use bitcoin_private::hex::exts::DisplayHex;
2221

2322
#[cfg(feature = "use-openssl")]
2423
use openssl::ssl::{SslConnector, SslMethod, SslStream, SslVerifyMode};
@@ -1181,10 +1180,10 @@ mod test {
11811180
let client = RawClient::new(get_test_server(), None).unwrap();
11821181

11831182
// Mt.Gox hack address
1184-
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF").unwrap();
1185-
let resp = client
1186-
.script_get_history(&addr.payload.script_pubkey())
1187-
.unwrap();
1183+
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF")
1184+
.unwrap()
1185+
.assume_checked();
1186+
let resp = client.script_get_history(&addr.script_pubkey()).unwrap();
11881187

11891188
assert!(resp.len() >= 328);
11901189
assert_eq!(
@@ -1202,10 +1201,10 @@ mod test {
12021201
let client = RawClient::new(get_test_server(), None).unwrap();
12031202

12041203
// Peter todd's sha256 bounty address https://bitcointalk.org/index.php?topic=293382.0
1205-
let addr = bitcoin::Address::from_str("35Snmmy3uhaer2gTboc81ayCip4m9DT4ko").unwrap();
1206-
let resp = client
1207-
.script_list_unspent(&addr.payload.script_pubkey())
1208-
.unwrap();
1204+
let addr = bitcoin::Address::from_str("35Snmmy3uhaer2gTboc81ayCip4m9DT4ko")
1205+
.unwrap()
1206+
.assume_checked();
1207+
let resp = client.script_list_unspent(&addr.script_pubkey()).unwrap();
12091208

12101209
assert!(resp.len() >= 9);
12111210
let txid = "397f12ee15f8a3d2ab25c0f6bb7d3c64d2038ca056af10dd8251b98ae0f076b0";
@@ -1226,7 +1225,7 @@ mod test {
12261225
// Peter todd's sha256 bounty address https://bitcointalk.org/index.php?topic=293382.0
12271226
let script_1 = bitcoin::Address::from_str("35Snmmy3uhaer2gTboc81ayCip4m9DT4ko")
12281227
.unwrap()
1229-
.payload
1228+
.assume_checked()
12301229
.script_pubkey();
12311230

12321231
let resp = client
@@ -1248,7 +1247,7 @@ mod test {
12481247

12491248
#[test]
12501249
fn test_transaction_get() {
1251-
use bitcoin::Txid;
1250+
use bitcoin::{transaction, Txid};
12521251

12531252
let client = RawClient::new(get_test_server(), None).unwrap();
12541253

@@ -1258,7 +1257,7 @@ mod test {
12581257
.unwrap(),
12591258
)
12601259
.unwrap();
1261-
assert_eq!(resp.version, 1);
1260+
assert_eq!(resp.version, transaction::Version::ONE);
12621261
assert_eq!(resp.lock_time.to_consensus_u32(), 0);
12631262
}
12641263

@@ -1362,12 +1361,12 @@ mod test {
13621361
let client = RawClient::new(get_test_server(), None).unwrap();
13631362

13641363
// Mt.Gox hack address
1365-
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF").unwrap();
1364+
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF")
1365+
.unwrap()
1366+
.assume_checked();
13661367

13671368
// Just make sure that the call returns Ok(something)
1368-
client
1369-
.script_subscribe(&addr.payload.script_pubkey())
1370-
.unwrap();
1369+
client.script_subscribe(&addr.script_pubkey()).unwrap();
13711370
}
13721371

13731372
#[test]

src/types.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ use std::sync::Arc;
99

1010
use bitcoin::blockdata::block;
1111
use bitcoin::consensus::encode::deserialize;
12-
use bitcoin::hashes::hex::FromHex;
1312
use bitcoin::hashes::{sha256, Hash};
13+
use bitcoin::hex::{DisplayHex, FromHex};
1414
use bitcoin::{Script, Txid};
1515

16-
use bitcoin_private::hex::exts::DisplayHex;
1716
use serde::{de, Deserialize, Serialize};
1817

1918
static JSONRPC_2_0: &str = "2.0";
@@ -288,8 +287,8 @@ pub enum Error {
288287
IOError(std::io::Error),
289288
/// Wraps `serde_json::error::Error`
290289
JSON(serde_json::error::Error),
291-
/// Wraps `bitcoin::hashes::hex::Error`
292-
Hex(bitcoin::hashes::hex::Error),
290+
/// Wraps `bitcoin::hex::HexToBytesError`
291+
Hex(bitcoin::hex::HexToBytesError),
293292
/// Error returned by the Electrum server
294293
Protocol(serde_json::Value),
295294
/// Error during the deserialization of a Bitcoin data structure
@@ -382,7 +381,7 @@ macro_rules! impl_error {
382381

383382
impl_error!(std::io::Error, IOError);
384383
impl_error!(serde_json::Error, JSON);
385-
impl_error!(bitcoin::hashes::hex::Error, Hex);
384+
impl_error!(bitcoin::hex::HexToBytesError, Hex);
386385
impl_error!(bitcoin::consensus::encode::Error, Bitcoin);
387386

388387
impl<T> From<std::sync::PoisonError<T>> for Error {

0 commit comments

Comments
 (0)