Skip to content

Commit b12613e

Browse files
authored
Merge pull request #37 from stevenroose/bitcon-0.23
Update to rust-bitcoin v0.23
2 parents b20b5c1 + 8cfa2cd commit b12613e

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "elements"
3-
version = "0.10.1"
3+
version = "0.11.0"
44
authors = ["Andrew Poelstra <apoelstra@blockstream.com>"]
55
description = "Library with support for de/serialization, parsing and executing on data structures and network messages related to Elements"
66
license = "CC0-1.0"
@@ -16,7 +16,7 @@ documentation = "https://docs.rs/elements/"
1616
"fuzztarget" = []
1717

1818
[dependencies]
19-
bitcoin = "0.20"
19+
bitcoin = "0.23"
2020

2121
[dependencies.serde]
2222
version = "1.0"

src/block.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use std::io;
1919

2020
use bitcoin::blockdata::script::Script;
21-
use bitcoin::BitcoinHash;
21+
use bitcoin::{BitcoinHash, BlockHash};
2222
use bitcoin::hashes::{Hash, sha256d, sha256};
2323
#[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer};
2424
#[cfg(feature = "serde")] use std::fmt;
@@ -313,8 +313,8 @@ impl Decodable for BlockHeader {
313313
}
314314
}
315315

316-
impl BitcoinHash for BlockHeader {
317-
fn bitcoin_hash(&self) -> sha256d::Hash {
316+
impl BitcoinHash<BlockHash> for BlockHeader {
317+
fn bitcoin_hash(&self) -> BlockHash {
318318

319319
let version = if let ExtData::Dynafed { .. } = self.ext {
320320
self.version | 0x8000_0000
@@ -338,7 +338,7 @@ impl BitcoinHash for BlockHeader {
338338
proposed.consensus_encode(&mut enc).unwrap();
339339
},
340340
}
341-
sha256d::Hash::from_engine(enc)
341+
BlockHash::from_engine(enc)
342342
}
343343
}
344344

@@ -353,8 +353,8 @@ pub struct Block {
353353
serde_struct_impl!(Block, header, txdata);
354354
impl_consensus_encoding!(Block, header, txdata);
355355

356-
impl BitcoinHash for Block {
357-
fn bitcoin_hash(&self) -> sha256d::Hash {
356+
impl BitcoinHash<BlockHash> for Block {
357+
fn bitcoin_hash(&self) -> BlockHash {
358358
self.header.bitcoin_hash()
359359
}
360360
}

src/encode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl_upstream!(Vec<Vec<u8>>);
147147
impl_upstream!(btcenc::VarInt);
148148
impl_upstream!(::bitcoin::blockdata::script::Script);
149149
impl_upstream!(::bitcoin::hashes::sha256d::Hash);
150+
impl_upstream!(::bitcoin::Txid);
150151

151152
// Vectors
152153
macro_rules! impl_vec {

src/transaction.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
use std::{io, fmt};
1919

20-
use bitcoin::{self, BitcoinHash, VarInt};
20+
use bitcoin::{self, BitcoinHash, Txid, VarInt};
2121
use bitcoin::blockdata::opcodes;
2222
use bitcoin::blockdata::script::{Script, Instruction};
2323
use bitcoin::hashes::{Hash, sha256d};
@@ -44,7 +44,7 @@ impl_consensus_encoding!(AssetIssuance, asset_blinding_nonce, asset_entropy, amo
4444
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
4545
pub struct OutPoint {
4646
/// The referenced transaction's txid
47-
pub txid: sha256d::Hash,
47+
pub txid: Txid,
4848
/// The index of the referenced output in its transaction's vout
4949
pub vout: u32,
5050
}
@@ -54,7 +54,7 @@ impl Default for OutPoint {
5454
/// Coinbase outpoint
5555
fn default() -> OutPoint {
5656
OutPoint {
57-
txid: sha256d::Hash::default(),
57+
txid: Txid::default(),
5858
vout: 0xffffffff,
5959
}
6060
}
@@ -69,7 +69,7 @@ impl Encodable for OutPoint {
6969

7070
impl Decodable for OutPoint {
7171
fn consensus_decode<D: io::Read>(mut d: D) -> Result<OutPoint, encode::Error> {
72-
let txid = sha256d::Hash::consensus_decode(&mut d)?;
72+
let txid = Txid::consensus_decode(&mut d)?;
7373
let vout = u32::consensus_decode(&mut d)?;
7474
Ok(OutPoint {
7575
txid: txid,
@@ -78,11 +78,11 @@ impl Decodable for OutPoint {
7878
}
7979
}
8080

81-
impl BitcoinHash for OutPoint {
82-
fn bitcoin_hash(&self) -> sha256d::Hash {
81+
impl BitcoinHash<Txid> for OutPoint {
82+
fn bitcoin_hash(&self) -> Txid {
8383
let mut enc = sha256d::Hash::engine();
8484
self.consensus_encode(&mut enc).unwrap();
85-
sha256d::Hash::from_engine(enc)
85+
Txid::from_engine(enc)
8686
}
8787
}
8888

@@ -598,12 +598,12 @@ impl Transaction {
598598
}
599599
}
600600

601-
impl BitcoinHash for Transaction {
601+
impl BitcoinHash<Txid> for Transaction {
602602
/// To get a transaction's txid, which is usually what you want, use the `txid` method.
603-
fn bitcoin_hash(&self) -> sha256d::Hash {
603+
fn bitcoin_hash(&self) -> Txid {
604604
let mut enc = sha256d::Hash::engine();
605605
self.consensus_encode(&mut enc).unwrap();
606-
sha256d::Hash::from_engine(enc)
606+
Txid::from_engine(enc)
607607
}
608608
}
609609

@@ -687,7 +687,7 @@ mod tests {
687687
let txid = "d0a5c455ea7221dead9513596d2f97c09943bad81a386fe61a14a6cda060e422";
688688
let s = format!("{}:42", txid);
689689
let expected = OutPoint {
690-
txid: sha256d::Hash::from_hex(&txid).unwrap(),
690+
txid: Txid::from_hex(&txid).unwrap(),
691691
vout: 42,
692692
};
693693
let op = ::std::str::FromStr::from_str(&s).ok();
@@ -1017,7 +1017,7 @@ mod tests {
10171017
tx.input[0].pegin_data(),
10181018
Some(super::PeginData {
10191019
outpoint: bitcoin::OutPoint {
1020-
txid: sha256d::Hash::from_hex(
1020+
txid: Txid::from_hex(
10211021
"c9d88eb5130365deed045eab11cfd3eea5ba32ad45fa2e156ae6ead5f1fce93f",
10221022
).unwrap(),
10231023
vout: 0,

0 commit comments

Comments
 (0)