diff --git a/Cargo.toml b/Cargo.toml index 3b40dabe..36b5b332 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,18 +18,19 @@ path = "src/lib.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } -bitcoin = { version = "0.30.0", features = ["serde", "std"], default-features = false } +bitcoin = { version = "0.31.1", features = ["serde", "std"], default-features = false } # Temporary dependency on internals until the rust-bitcoin devs release the hex-conservative crate. -bitcoin-internals = { version = "0.1.0", features = ["alloc"] } +bitcoin-internals = { version = "0.2.0", features = ["alloc"] } log = "^0.4" -ureq = { version = "2.5.0", features = ["json"], optional = true } +ureq = { version = "2.9.1", features = ["json"], optional = true } reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] } +hex-conservative = "0.1.1" [dev-dependencies] serde_json = "1.0" -tokio = { version = "1.20.1", features = ["full"] } -electrsd = { version = "0.24.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_22_0"] } -electrum-client = "0.16.0" +tokio = { version = "1.35.1", features = ["full"] } +electrsd = { version = "0.27.1", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] } +electrum-client = "0.19.0" lazy_static = "1.4.0" [features] diff --git a/src/api.rs b/src/api.rs index 1a3d2395..2e6f3b53 100644 --- a/src/api.rs +++ b/src/api.rs @@ -4,8 +4,8 @@ pub use bitcoin::consensus::{deserialize, serialize}; pub use bitcoin::hashes::hex::FromHex; +use bitcoin::{blockdata::transaction::Version, Amount}; pub use bitcoin::{BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness}; - use serde::Deserialize; #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] @@ -93,7 +93,7 @@ pub struct BlockSummary { impl Tx { pub fn to_tx(&self) -> Transaction { Transaction { - version: self.version, + version: Version(self.version), lock_time: bitcoin::absolute::LockTime::from_consensus(self.locktime), input: self .vin @@ -114,7 +114,7 @@ impl Tx { .iter() .cloned() .map(|vout| TxOut { - value: vout.value, + value: Amount::from_int_btc(vout.value), script_pubkey: vout.scriptpubkey, }) .collect(), @@ -140,7 +140,7 @@ impl Tx { .map(|vin| { vin.prevout.map(|po| TxOut { script_pubkey: po.scriptpubkey, - value: po.value, + value: Amount::from_int_btc(po.value), }) }) .collect() diff --git a/src/lib.rs b/src/lib.rs index a5fc3133..56a267a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,7 +64,7 @@ use std::fmt; use std::io; use bitcoin::consensus; - +use hex_conservative::{HexToArrayError, HexToBytesError}; pub mod api; #[cfg(feature = "async")] @@ -171,8 +171,10 @@ pub enum Error { Parsing(std::num::ParseIntError), /// Invalid Bitcoin data returned BitcoinEncoding(bitcoin::consensus::encode::Error), - /// Invalid Hex data returned - Hex(bitcoin::hashes::hex::Error), + /// Invalid Hex Array returned + HexArray(HexToArrayError), + /// Invalid Hex Bytes returned + HexBytes(HexToBytesError), /// Transaction not found TransactionNotFound(Txid), @@ -209,7 +211,8 @@ impl_error!(::reqwest::Error, Reqwest, Error); impl_error!(io::Error, Io, Error); impl_error!(std::num::ParseIntError, Parsing, Error); impl_error!(consensus::encode::Error, BitcoinEncoding, Error); -impl_error!(bitcoin::hashes::hex::Error, Hex, Error); +impl_error!(HexToArrayError, HexArray, Error); +impl_error!(HexToBytesError, HexBytes, Error); #[cfg(test)] mod test {