Skip to content

Commit

Permalink
Upgrade bitcoin
Browse files Browse the repository at this point in the history
Upgrade dependencies to use the latest `rust-bitcoin v0.31`.

While we are at it, bump the crate version ready for release.

(Includes pinning dependencies for MSRV build in CI.)
  • Loading branch information
tcharding committed Feb 7, 2024
1 parent ac2fd86 commit e41b360
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
- name: pin dependencies
if: matrix.rust.version == '1.63.0'
run: |
cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5"
cargo update -p zstd-sys --precise "2.0.6+zstd.1.5.2"
cargo update -p zstd --precise 0.11.2+zstd.1.5.2
cargo update -p time --precise "0.3.20"
cargo update -p jobserver --precise "0.1.26"
cargo update -p home --precise 0.5.5
Expand Down
6 changes: 3 additions & 3 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,7 +18,7 @@ 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.0", features = ["serde", "std"], default-features = false }
hex = { package = "hex-conservative", version = "*" }
log = "^0.4"
ureq = { version = "2.5.0", features = ["json"], optional = true }
Expand All @@ -27,7 +27,7 @@ reqwest = { version = "0.11", optional = true, default-features = false, feature
[dev-dependencies]
serde_json = "1.0"
tokio = { version = "1.20.1", features = ["full"] }
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.27.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_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
3 changes: 1 addition & 2 deletions src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ 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 hex::display::DisplayHex;

#[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 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

0 comments on commit e41b360

Please sign in to comment.