Skip to content

Commit a08ebe3

Browse files
Merge #51: Upgrade bitcoin to v0.30.0
cd497a7 Redundant import (Vladimir Fomene) 8d1f907 Upgrade electrum-client to 0.16.0 (Vladimir Fomene) 73768c5 Add pinning note to electrum-client dependency (Tobin C. Harding) ea1b6d1 Upgrade bitcoin to v0.30.0 (Tobin C. Harding) d48ac22 Pin dependencies in CI for MSRV build (Tobin C. Harding) Pull request description: Upgrade `rust-bitcoin` to v0.30.3, including: - bitcoin - electrsd - electrum-client Also includes addition of a dependency on `bitcoin-internals` for the `DisplayHex` trait. This is a temporary fix while we wait for release of the new [`github.com/rust-bitcoin/hex-conservative`](https://github.com/rust-bitcoin/hex-conservative) crate. Top commit has no ACKs. Tree-SHA512: 6611f3de827bc5ee81d7e3d4b0facef45b9833ced86bc3467942d7817f7fa806b137ef285a7120dc3e591acf9dbecd2a189e3119a2c5c1ff8b04764386e83721
2 parents ff88a70 + cd497a7 commit a08ebe3

File tree

6 files changed

+48
-33
lines changed

6 files changed

+48
-33
lines changed

.github/workflows/cont_integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
run: rustup component add clippy
4949
- name: Update toolchain
5050
run: rustup update
51+
- name: pin dependencies
52+
if: matrix.rust.version == '1.57.0'
53+
run: cargo update -p log --precise 0.4.18 && cargo update -p rustls:0.21.2 --precise 0.21.1 && cargo update -p time:0.3.15 --precise 0.3.13
5154
- name: Build
5255
run: cargo build --features ${{ matrix.features }} --no-default-features
5356
- name: Clippy

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ path = "src/lib.rs"
1717

1818
[dependencies]
1919
serde = { version = "1.0", features = ["derive"] }
20-
bitcoin = { version = "0.29.1", features = ["serde"], default-features = false }
20+
bitcoin = { version = "0.30.0", features = ["serde", "std"], default-features = false }
21+
# Temporary dependency on internals until the rust-bitcoin devs release the hex-conservative crate.
22+
bitcoin-internals = { version = "0.1.0", features = ["alloc"] }
2123
log = "^0.4"
2224
ureq = { version = "2.5.0", features = ["json"], optional = true }
2325
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
2426

2527
[dev-dependencies]
2628
serde_json = "1.0"
2729
tokio = { version = "1.20.1", features = ["full"] }
28-
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_22_0"] }
29-
electrum-client = "0.12.0"
30+
electrsd = { version = "0.24.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_22_0"] }
31+
electrum-client = "0.16.0"
3032
lazy_static = "1.4.0"
3133
# zip versions after 0.6.3 don't work with our MSRV 1.57.0
3234
zip = "=0.6.3"

src/api.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
55
pub use bitcoin::consensus::{deserialize, serialize};
66
pub use bitcoin::hashes::hex::FromHex;
7-
pub use bitcoin::{BlockHash, OutPoint, Script, Transaction, TxIn, TxOut, Txid, Witness};
7+
pub use bitcoin::{BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
88

99
use serde::Deserialize;
1010

1111
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
1212
pub struct PrevOut {
1313
pub value: u64,
14-
pub scriptpubkey: Script,
14+
pub scriptpubkey: ScriptBuf,
1515
}
1616

1717
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -20,7 +20,7 @@ pub struct Vin {
2020
pub vout: u32,
2121
// None if coinbase
2222
pub prevout: Option<PrevOut>,
23-
pub scriptsig: Script,
23+
pub scriptsig: ScriptBuf,
2424
#[serde(deserialize_with = "deserialize_witness", default)]
2525
pub witness: Vec<Vec<u8>>,
2626
pub sequence: u32,
@@ -30,7 +30,7 @@ pub struct Vin {
3030
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
3131
pub struct Vout {
3232
pub value: u64,
33-
pub scriptpubkey: Script,
33+
pub scriptpubkey: ScriptBuf,
3434
}
3535

3636
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -87,14 +87,14 @@ pub struct BlockSummary {
8787
pub time: BlockTime,
8888
/// Hash of the previous block, will be `None` for the genesis block.
8989
pub previousblockhash: Option<bitcoin::BlockHash>,
90-
pub merkle_root: bitcoin::TxMerkleNode,
90+
pub merkle_root: bitcoin::hash_types::TxMerkleNode,
9191
}
9292

9393
impl Tx {
9494
pub fn to_tx(&self) -> Transaction {
9595
Transaction {
9696
version: self.version,
97-
lock_time: bitcoin::PackedLockTime(self.locktime),
97+
lock_time: bitcoin::absolute::LockTime::from_consensus(self.locktime),
9898
input: self
9999
.vin
100100
.iter()
@@ -106,7 +106,7 @@ impl Tx {
106106
},
107107
script_sig: vin.scriptsig,
108108
sequence: bitcoin::Sequence(vin.sequence),
109-
witness: Witness::from_vec(vin.witness),
109+
witness: Witness::from_slice(&vin.witness),
110110
})
111111
.collect(),
112112
output: self

src/async.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ use std::collections::HashMap;
1515
use std::str::FromStr;
1616

1717
use bitcoin::consensus::{deserialize, serialize};
18-
use bitcoin::hashes::hex::{FromHex, ToHex};
18+
use bitcoin::hashes::hex::FromHex;
1919
use bitcoin::hashes::{sha256, Hash};
20-
use bitcoin::{Block, BlockHash, BlockHeader, MerkleBlock, Script, Transaction, Txid};
20+
use bitcoin::{Block, BlockHash, block::Header as BlockHeader, MerkleBlock, Script, Transaction, Txid};
21+
use bitcoin_internals::hex::display::DisplayHex;
2122

2223
#[allow(unused_imports)]
2324
use log::{debug, error, info, trace};
@@ -212,7 +213,7 @@ impl AsyncClient {
212213
pub async fn broadcast(&self, transaction: &Transaction) -> Result<(), Error> {
213214
self.client
214215
.post(&format!("{}/tx", self.url))
215-
.body(serialize(transaction).to_hex())
216+
.body(serialize(transaction).to_lower_hex_string())
216217
.send()
217218
.await?
218219
.error_for_status()?;
@@ -269,13 +270,13 @@ impl AsyncClient {
269270
script: &Script,
270271
last_seen: Option<Txid>,
271272
) -> Result<Vec<Tx>, Error> {
272-
let script_hash = sha256::Hash::hash(script.as_bytes()).into_inner().to_hex();
273+
let script_hash = sha256::Hash::hash(script.as_bytes());
273274
let url = match last_seen {
274275
Some(last_seen) => format!(
275-
"{}/scripthash/{}/txs/chain/{}",
276+
"{}/scripthash/{:x}/txs/chain/{}",
276277
self.url, script_hash, last_seen
277278
),
278-
None => format!("{}/scripthash/{}/txs", self.url, script_hash),
279+
None => format!("{}/scripthash/{:x}/txs", self.url, script_hash),
279280
};
280281
Ok(self
281282
.client

src/blocking.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ 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, ToHex};
26+
use bitcoin::hashes::hex::FromHex;
2727
use bitcoin::hashes::{sha256, Hash};
28-
use bitcoin::{Block, BlockHash, BlockHeader, MerkleBlock, Script, Transaction, Txid};
28+
use bitcoin::{Block, BlockHash, block::Header as BlockHeader, MerkleBlock, Script, Transaction, Txid};
29+
30+
use bitcoin_internals::hex::display::DisplayHex;
2931

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

@@ -244,7 +246,7 @@ impl BlockingClient {
244246
let resp = self
245247
.agent
246248
.post(&format!("{}/tx", self.url))
247-
.send_string(&serialize(transaction).to_hex());
249+
.send_string(&serialize(transaction).to_lower_hex_string());
248250

249251
match resp {
250252
Ok(_) => Ok(()), // We do not return the txid?
@@ -329,13 +331,13 @@ impl BlockingClient {
329331
script: &Script,
330332
last_seen: Option<Txid>,
331333
) -> Result<Vec<Tx>, Error> {
332-
let script_hash = sha256::Hash::hash(script.as_bytes()).into_inner().to_hex();
334+
let script_hash = sha256::Hash::hash(script.as_bytes());
333335
let url = match last_seen {
334336
Some(last_seen) => format!(
335-
"{}/scripthash/{}/txs/chain/{}",
337+
"{}/scripthash/{:x}/txs/chain/{}",
336338
self.url, script_hash, last_seen
337339
),
338-
None => format!("{}/scripthash/{}/txs", self.url, script_hash),
340+
None => format!("{}/scripthash/{:x}/txs", self.url, script_hash),
339341
};
340342
Ok(self.agent.get(&url).call()?.into_json()?)
341343
}

src/lib.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ use std::fmt;
6464
use std::io;
6565

6666
use bitcoin::consensus;
67-
use bitcoin::{BlockHash, Txid};
6867

6968
pub mod api;
7069

@@ -224,10 +223,10 @@ mod test {
224223
bitcoin::hashes::Hash,
225224
bitcoin::Amount,
226225
electrsd::{
227-
bitcoind::bitcoincore_rpc::bitcoincore_rpc_json::AddressType,
226+
bitcoind::bitcoincore_rpc::json::AddressType,
228227
bitcoind::bitcoincore_rpc::RpcApi,
228+
electrum_client::ElectrumApi,
229229
},
230-
electrum_client::ElectrumApi,
231230
std::time::Duration,
232231
tokio::sync::OnceCell,
233232
};
@@ -292,7 +291,8 @@ mod test {
292291
let address = BITCOIND
293292
.client
294293
.get_new_address(Some("test"), Some(AddressType::Legacy))
295-
.unwrap();
294+
.unwrap()
295+
.assume_checked();
296296
let _block_hashes = BITCOIND
297297
.client
298298
.generate_to_address(num as u64, &address)
@@ -383,7 +383,8 @@ mod test {
383383
let address = BITCOIND
384384
.client
385385
.get_new_address(Some("test"), Some(AddressType::Legacy))
386-
.unwrap();
386+
.unwrap()
387+
.assume_checked();
387388
let txid = BITCOIND
388389
.client
389390
.send_to_address(
@@ -413,7 +414,8 @@ mod test {
413414
let address = BITCOIND
414415
.client
415416
.get_new_address(Some("test"), Some(AddressType::Legacy))
416-
.unwrap();
417+
.unwrap()
418+
.assume_checked();
417419
let txid = BITCOIND
418420
.client
419421
.send_to_address(
@@ -443,7 +445,8 @@ mod test {
443445
let address = BITCOIND
444446
.client
445447
.get_new_address(Some("test"), Some(AddressType::Legacy))
446-
.unwrap();
448+
.unwrap()
449+
.assume_checked();
447450
let txid = BITCOIND
448451
.client
449452
.send_to_address(
@@ -572,7 +575,8 @@ mod test {
572575
let address = BITCOIND
573576
.client
574577
.get_new_address(Some("test"), Some(AddressType::Legacy))
575-
.unwrap();
578+
.unwrap()
579+
.assume_checked();
576580
let txid = BITCOIND
577581
.client
578582
.send_to_address(
@@ -603,7 +607,8 @@ mod test {
603607
let address = BITCOIND
604608
.client
605609
.get_new_address(Some("test"), Some(AddressType::Legacy))
606-
.unwrap();
610+
.unwrap()
611+
.assume_checked();
607612
let txid = BITCOIND
608613
.client
609614
.send_to_address(
@@ -643,7 +648,8 @@ mod test {
643648
let address = BITCOIND
644649
.client
645650
.get_new_address(Some("test"), Some(AddressType::Legacy))
646-
.unwrap();
651+
.unwrap()
652+
.assume_checked();
647653
let txid = BITCOIND
648654
.client
649655
.send_to_address(
@@ -741,7 +747,8 @@ mod test {
741747
let address = BITCOIND
742748
.client
743749
.get_new_address(Some("test"), Some(AddressType::Legacy))
744-
.unwrap();
750+
.unwrap()
751+
.assume_checked();
745752
let txid = BITCOIND
746753
.client
747754
.send_to_address(

0 commit comments

Comments
 (0)