Skip to content

Commit e5fb3a3

Browse files
committedFeb 29, 2024··
Merge #79: Upgrade bitcoin
c046047 Upgrade bitcoin (Tobin C. Harding) Pull request description: 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.) ACKs for top commit: notmandatory: utACK c046047 Tree-SHA512: 547902dc645b6b983eebde9eafe290cfec714824549873ef1456264d619c32f52509fdde7e1c5bc7dbc7cb3b47bd7104fba83327f3206c22debf954e0e96872a
2 parents 7faab65 + c046047 commit e5fb3a3

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed
 

‎Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "esplora-client"
3-
version = "0.6.0"
3+
version = "0.7.0"
44
edition = "2018"
55
authors = ["Alekos Filini <alekos.filini@gmail.com>"]
66
license = "MIT"
@@ -18,7 +18,7 @@ path = "src/lib.rs"
1818

1919
[dependencies]
2020
serde = { version = "1.0", features = ["derive"] }
21-
bitcoin = { version = "0.30.0", features = ["serde", "std"], default-features = false }
21+
bitcoin = { version = "0.31.0", features = ["serde", "std"], default-features = false }
2222
hex = { package = "hex-conservative", version = "*" }
2323
log = "^0.4"
2424
ureq = { version = "2.5.0", features = ["json"], optional = true }
@@ -27,7 +27,7 @@ reqwest = { version = "0.11", optional = true, default-features = false, feature
2727
[dev-dependencies]
2828
serde_json = "1.0"
2929
tokio = { version = "1.20.1", features = ["full"] }
30-
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
30+
electrsd = { version = "0.27.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
3131
lazy_static = "1.4.0"
3232

3333
[features]

‎src/api.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//! see: <https://github.com/Blockstream/esplora/blob/master/API.md>
44
55
pub use bitcoin::consensus::{deserialize, serialize};
6-
pub use bitcoin::hashes::hex::FromHex;
7-
pub use bitcoin::{BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
6+
pub use bitcoin::hex::FromHex;
7+
pub use bitcoin::{transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
88

99
use serde::Deserialize;
1010

@@ -93,7 +93,7 @@ pub struct BlockSummary {
9393
impl Tx {
9494
pub fn to_tx(&self) -> Transaction {
9595
Transaction {
96-
version: self.version,
96+
version: transaction::Version::non_standard(self.version),
9797
lock_time: bitcoin::absolute::LockTime::from_consensus(self.locktime),
9898
input: self
9999
.vin
@@ -114,7 +114,7 @@ impl Tx {
114114
.iter()
115115
.cloned()
116116
.map(|vout| TxOut {
117-
value: vout.value,
117+
value: Amount::from_sat(vout.value),
118118
script_pubkey: vout.scriptpubkey,
119119
})
120120
.collect(),
@@ -140,7 +140,7 @@ impl Tx {
140140
.map(|vin| {
141141
vin.prevout.map(|po| TxOut {
142142
script_pubkey: po.scriptpubkey,
143-
value: po.value,
143+
value: Amount::from_sat(po.value),
144144
})
145145
})
146146
.collect()

‎src/async.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ use std::collections::HashMap;
1515
use std::str::FromStr;
1616

1717
use bitcoin::consensus::{deserialize, serialize};
18-
use bitcoin::hashes::hex::FromHex;
18+
use bitcoin::hex::{DisplayHex, FromHex};
1919
use bitcoin::hashes::{sha256, Hash};
2020
use bitcoin::{
2121
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
2222
};
23-
use hex::display::DisplayHex;
2423

2524
#[allow(unused_imports)]
2625
use log::{debug, error, info, trace};

‎src/blocking.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ use log::{debug, error, info, trace};
2323
use ureq::{Agent, Proxy, Response};
2424

2525
use bitcoin::consensus::{deserialize, serialize};
26-
use bitcoin::hashes::hex::FromHex;
26+
use bitcoin::hex::{DisplayHex, FromHex};
2727
use bitcoin::hashes::{sha256, Hash};
2828
use bitcoin::{
2929
block::Header as BlockHeader, Block, BlockHash, MerkleBlock, Script, Transaction, Txid,
3030
};
3131

32-
use hex::display::DisplayHex;
33-
3432
use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus};
3533

3634
#[derive(Debug, Clone)]

‎src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ pub enum Error {
171171
Parsing(std::num::ParseIntError),
172172
/// Invalid Bitcoin data returned
173173
BitcoinEncoding(bitcoin::consensus::encode::Error),
174-
/// Invalid Hex data returned
175-
Hex(bitcoin::hashes::hex::Error),
174+
/// Invalid hex data returned (attempting to create an array)
175+
HexToArray(bitcoin::hex::HexToArrayError),
176+
/// Invalid hex data returned (attempting to create a vector)
177+
HexToBytes(bitcoin::hex::HexToBytesError),
176178

177179
/// Transaction not found
178180
TransactionNotFound(Txid),
@@ -209,7 +211,8 @@ impl_error!(::reqwest::Error, Reqwest, Error);
209211
impl_error!(io::Error, Io, Error);
210212
impl_error!(std::num::ParseIntError, Parsing, Error);
211213
impl_error!(consensus::encode::Error, BitcoinEncoding, Error);
212-
impl_error!(bitcoin::hashes::hex::Error, Hex, Error);
214+
impl_error!(bitcoin::hex::HexToArrayError, HexToArray, Error);
215+
impl_error!(bitcoin::hex::HexToBytesError, HexToBytes, Error);
213216

214217
#[cfg(test)]
215218
mod test {

0 commit comments

Comments
 (0)
Please sign in to comment.