Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update bitcoin to 0.31 #74

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esplora-client"
version = "0.6.0"
version = "0.7.0"
edition = "2018"
authors = ["Alekos Filini <[email protected]>"]
license = "MIT"
Expand All @@ -18,18 +18,16 @@ path = "src/lib.rs"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
bitcoin = { version = "0.30.0", 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 = { version = "0.31.0", features = ["serde", "std"], default-features = false }
log = "^0.4"
ureq = { version = "2.5.0", features = ["json"], optional = true }
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }

[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"
electrsd = { version = "0.27.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_22_1"] }
electrum-client = "0.19.0"
lazy_static = "1.4.0"

[features]
Expand Down
10 changes: 5 additions & 5 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! see: <https://github.com/Blockstream/esplora/blob/master/API.md>

pub use bitcoin::consensus::{deserialize, serialize};
pub use bitcoin::hashes::hex::FromHex;
pub use bitcoin::{BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
pub use bitcoin::hex::FromHex;
pub use bitcoin::{transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};

use serde::Deserialize;

Expand Down Expand Up @@ -93,7 +93,7 @@ pub struct BlockSummary {
impl Tx {
pub fn to_tx(&self) -> Transaction {
Transaction {
version: self.version,
version: transaction::Version::non_standard(self.version),
lock_time: bitcoin::absolute::LockTime::from_consensus(self.locktime),
input: self
.vin
Expand All @@ -114,7 +114,7 @@ impl Tx {
.iter()
.cloned()
.map(|vout| TxOut {
value: vout.value,
value: Amount::from_sat(vout.value),
script_pubkey: vout.scriptpubkey,
})
.collect(),
Expand All @@ -140,7 +140,7 @@ impl Tx {
.map(|vin| {
vin.prevout.map(|po| TxOut {
script_pubkey: po.scriptpubkey,
value: po.value,
value: Amount::from_sat(po.value),
})
})
.collect()
Expand Down
7 changes: 2 additions & 5 deletions src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ use std::collections::HashMap;
use std::str::FromStr;

use bitcoin::consensus::{deserialize, serialize};
use bitcoin::hashes::hex::FromHex;
use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::hashes::{sha256, Hash};
use bitcoin::{
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
};
use bitcoin_internals::hex::display::DisplayHex;
use bitcoin::{Block, BlockHash, block::Header as BlockHeader, MerkleBlock, Script, Transaction, Txid};

#[allow(unused_imports)]
use log::{debug, error, info, trace};
Expand Down
4 changes: 1 addition & 3 deletions src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ use log::{debug, error, info, trace};
use ureq::{Agent, Proxy, Response};

use bitcoin::consensus::{deserialize, serialize};
use bitcoin::hashes::hex::FromHex;
use bitcoin::hex::{DisplayHex, FromHex};
use bitcoin::hashes::{sha256, Hash};
use bitcoin::{
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
};

use bitcoin_internals::hex::display::DisplayHex;

use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus};

#[derive(Debug, Clone)]
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 data returned (attempting to create an array)
HexToArray(bitcoin::hex::HexToArrayError),
/// Invalid hex data returned (attempting to create a vector)
HexToBytes(bitcoin::hex::HexToBytesError),

/// Transaction not found
TransactionNotFound(Txid),
Expand Down Expand Up @@ -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!(bitcoin::hex::HexToArrayError, HexToArray, Error);
impl_error!(bitcoin::hex::HexToBytesError, HexToBytes, Error);

#[cfg(test)]
mod test {
Expand Down