Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ path = "src/lib.rs"

[dependencies]
log = "^0.4"
bitcoin = { version = "^0.30", features = ["serde"] }
bitcoin-private = "0.1.0"
bitcoin = { version = "0.31.0", features = ["serde"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1.0" }

Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
//! ```

pub extern crate bitcoin;
extern crate bitcoin_private;
extern crate core;
extern crate log;
#[cfg(feature = "use-openssl")]
Expand Down
33 changes: 16 additions & 17 deletions src/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ use std::time::Duration;
use log::{debug, error, info, trace, warn};

use bitcoin::consensus::encode::deserialize;
use bitcoin::hashes::hex::FromHex;
use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::{Script, Txid};
use bitcoin_private::hex::exts::DisplayHex;

#[cfg(feature = "use-openssl")]
use openssl::ssl::{SslConnector, SslMethod, SslStream, SslVerifyMode};
Expand Down Expand Up @@ -1179,10 +1178,10 @@ mod test {
let client = RawClient::new(get_test_server(), None).unwrap();

// Mt.Gox hack address
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF").unwrap();
let resp = client
.script_get_history(&addr.payload.script_pubkey())
.unwrap();
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF")
.unwrap()
.assume_checked();
let resp = client.script_get_history(&addr.script_pubkey()).unwrap();

assert!(resp.len() >= 328);
assert_eq!(
Expand All @@ -1200,10 +1199,10 @@ mod test {
let client = RawClient::new(get_test_server(), None).unwrap();

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

assert!(resp.len() >= 9);
let txid = "397f12ee15f8a3d2ab25c0f6bb7d3c64d2038ca056af10dd8251b98ae0f076b0";
Expand All @@ -1224,7 +1223,7 @@ mod test {
// Peter todd's sha256 bounty address https://bitcointalk.org/index.php?topic=293382.0
let script_1 = bitcoin::Address::from_str("35Snmmy3uhaer2gTboc81ayCip4m9DT4ko")
.unwrap()
.payload
.assume_checked()
.script_pubkey();

let resp = client
Expand All @@ -1246,7 +1245,7 @@ mod test {

#[test]
fn test_transaction_get() {
use bitcoin::Txid;
use bitcoin::{transaction, Txid};

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

Expand All @@ -1256,7 +1255,7 @@ mod test {
.unwrap(),
)
.unwrap();
assert_eq!(resp.version, 1);
assert_eq!(resp.version, transaction::Version::ONE);
assert_eq!(resp.lock_time.to_consensus_u32(), 0);
}

Expand Down Expand Up @@ -1340,12 +1339,12 @@ mod test {
let client = RawClient::new(get_test_server(), None).unwrap();

// Mt.Gox hack address
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF").unwrap();
let addr = bitcoin::Address::from_str("1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF")
.unwrap()
.assume_checked();

// Just make sure that the call returns Ok(something)
client
.script_subscribe(&addr.payload.script_pubkey())
.unwrap();
client.script_subscribe(&addr.script_pubkey()).unwrap();
}

#[test]
Expand Down
9 changes: 4 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use std::sync::Arc;

use bitcoin::blockdata::block;
use bitcoin::consensus::encode::deserialize;
use bitcoin::hashes::hex::FromHex;
use bitcoin::hashes::{sha256, Hash};
use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::{Script, Txid};

use bitcoin_private::hex::exts::DisplayHex;
use serde::{de, Deserialize, Serialize};

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

impl_error!(std::io::Error, IOError);
impl_error!(serde_json::Error, JSON);
impl_error!(bitcoin::hashes::hex::Error, Hex);
impl_error!(bitcoin::hex::HexToBytesError, Hex);
impl_error!(bitcoin::consensus::encode::Error, Bitcoin);

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