Drop (non-test/serde) hex dep in favor of bitcoin_hashes' fn's
This commit is contained in:
parent
6ce582bed6
commit
f1f7718b6c
|
@ -17,8 +17,8 @@ path = "src/lib.rs"
|
||||||
[features]
|
[features]
|
||||||
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]
|
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]
|
||||||
unstable = []
|
unstable = []
|
||||||
use-serde = ["serde", "bitcoin_hashes/serde", "secp256k1/serde"]
|
|
||||||
rand = ["secp256k1/rand"]
|
rand = ["secp256k1/rand"]
|
||||||
|
use-serde = ["hex", "serde", "bitcoin_hashes/serde", "secp256k1/serde"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bech32 = "0.7.1"
|
bech32 = "0.7.1"
|
||||||
|
@ -26,10 +26,11 @@ byteorder = "1.2"
|
||||||
bitcoin_hashes = "0.7"
|
bitcoin_hashes = "0.7"
|
||||||
bitcoinconsensus = { version = "0.17", optional = true }
|
bitcoinconsensus = { version = "0.17", optional = true }
|
||||||
serde = { version = "1", optional = true }
|
serde = { version = "1", optional = true }
|
||||||
|
hex = { version = "=0.3.2", optional = true }
|
||||||
secp256k1 = "0.15"
|
secp256k1 = "0.15"
|
||||||
hex = "=0.3.2"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
hex = "=0.3.2"
|
||||||
serde_derive = "<1.0.99"
|
serde_derive = "<1.0.99"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
serde_test = "1"
|
serde_test = "1"
|
||||||
|
|
|
@ -36,7 +36,7 @@ use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{Cursor, Read, Write};
|
use std::io::{Cursor, Read, Write};
|
||||||
use byteorder::{LittleEndian, WriteBytesExt, ReadBytesExt};
|
use byteorder::{LittleEndian, WriteBytesExt, ReadBytesExt};
|
||||||
use hex::encode as hex_encode;
|
use hashes::hex::ToHex;
|
||||||
|
|
||||||
use hashes::{sha256d, Hash as HashTrait};
|
use hashes::{sha256d, Hash as HashTrait};
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
|
@ -104,7 +104,7 @@ impl fmt::Display for Error {
|
||||||
Error::Psbt(ref e) => fmt::Display::fmt(e, f),
|
Error::Psbt(ref e) => fmt::Display::fmt(e, f),
|
||||||
Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e, a),
|
Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e, a),
|
||||||
Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, "{}: requested {}, maximum {}", error::Error::description(self), r, m),
|
Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, "{}: requested {}, maximum {}", error::Error::description(self), r, m),
|
||||||
Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), hex_encode(e), hex_encode(a)),
|
Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, "{}: expected {}, actual {}", error::Error::description(self), e[..].to_hex(), a[..].to_hex()),
|
||||||
Error::UnknownNetworkMagic(ref m) => write!(f, "{}: {}", error::Error::description(self), m),
|
Error::UnknownNetworkMagic(ref m) => write!(f, "{}: {}", error::Error::description(self), m),
|
||||||
Error::ParseFailed(ref e) => write!(f, "{}: {}", error::Error::description(self), e),
|
Error::ParseFailed(ref e) => write!(f, "{}: {}", error::Error::description(self), e),
|
||||||
Error::UnsupportedSegwitFlag(ref swflag) => write!(f, "{}: {}", error::Error::description(self), swflag),
|
Error::UnsupportedSegwitFlag(ref swflag) => write!(f, "{}: {}", error::Error::description(self), swflag),
|
||||||
|
@ -189,7 +189,7 @@ pub fn serialize<T: Encodable + ?Sized>(data: &T) -> Vec<u8> {
|
||||||
|
|
||||||
/// Encode an object into a hex-encoded string
|
/// Encode an object into a hex-encoded string
|
||||||
pub fn serialize_hex<T: Encodable + ?Sized>(data: &T) -> String {
|
pub fn serialize_hex<T: Encodable + ?Sized>(data: &T) -> String {
|
||||||
hex_encode(serialize(data))
|
serialize(data)[..].to_hex()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize an object from a vector, will error if said deserialization
|
/// Deserialize an object from a vector, will error if said deserialization
|
||||||
|
|
|
@ -51,8 +51,8 @@ pub extern crate bitcoin_hashes as hashes;
|
||||||
pub extern crate secp256k1;
|
pub extern crate secp256k1;
|
||||||
pub extern crate bech32;
|
pub extern crate bech32;
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "serde"))] extern crate hex;
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate hex;
|
|
||||||
#[cfg(feature = "serde")] extern crate serde;
|
#[cfg(feature = "serde")] extern crate serde;
|
||||||
#[cfg(all(test, feature = "serde"))] #[macro_use] extern crate serde_derive; // for 1.22.0 compat
|
#[cfg(all(test, feature = "serde"))] #[macro_use] extern crate serde_derive; // for 1.22.0 compat
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_json;
|
#[cfg(all(test, feature = "serde"))] extern crate serde_json;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
||||||
|
|
||||||
use consensus::encode::{self, Decodable, Encodable, VarInt, MAX_VEC_SIZE};
|
use consensus::encode::{self, Decodable, Encodable, VarInt, MAX_VEC_SIZE};
|
||||||
|
use hashes::hex::ToHex;
|
||||||
use util::psbt::Error;
|
use util::psbt::Error;
|
||||||
|
|
||||||
/// A PSBT key in its raw byte form.
|
/// A PSBT key in its raw byte form.
|
||||||
|
@ -46,7 +47,7 @@ impl fmt::Display for Key {
|
||||||
f,
|
f,
|
||||||
"type: {:#x}, key: {}",
|
"type: {:#x}, key: {}",
|
||||||
self.type_value,
|
self.type_value,
|
||||||
::hex::encode(&self.key)
|
self.key[..].to_hex()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue