Skip to content

Commit c56fdd0

Browse files
committed
upgrade bitcoin 0.31 -> 0.32
1 parent c08382c commit c56fdd0

File tree

8 files changed

+27
-29
lines changed

8 files changed

+27
-29
lines changed

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ json-contract = ["serde_json"]
2222
base64 = ["bitcoin/base64"]
2323

2424
[dependencies]
25-
bitcoin = "0.31.0"
26-
secp256k1-zkp = { version = "0.10.0", features = ["global-context", "hashes"] }
25+
bech32 = "0.11.0"
26+
bitcoin = "0.32.2"
27+
secp256k1-zkp = { version = "0.11.0", features = ["global-context", "hashes"] }
2728

2829
# Used for ContractHash::from_json_contract.
2930
serde_json = { version = "1.0", optional = true }

src/address.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ mod test {
908908
"ert130xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqqu2tys".parse();
909909
assert_eq!(
910910
address.err().unwrap().to_string(),
911-
"bech32 error: invalid segwit witness version: 3", // FIXME https://github.com/rust-bitcoin/rust-bech32/issues/162 should be 17
911+
"bech32 error: invalid segwit witness version: 17 (bech32 character: '3')",
912912
);
913913

914914
let address: Result<Address, _> = "el1pq0umk3pez693jrrlxz9ndlkuwne93gdu9g83mhhzuyf46e3mdzfpva0w48gqgzgrklncnm0k5zeyw8my2ypfsqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpe9jfn0gypaj".parse();
@@ -920,10 +920,7 @@ mod test {
920920
// "invalid prefix" gives a weird error message because we do
921921
// a dumb prefix check before even attempting bech32 decoding
922922
let address: Result<Address, _> = "rrr1qq0umk3pez693jrrlxz9ndlkuwne93gdu9g83mhhzuyf46e3mdzfpva0w48gqgzgrklncnm0k5zeyw8my2ypfs2d9rp7meq4kg".parse();
923-
assert_eq!(
924-
address.err().unwrap().to_string(),
925-
"base58 error: invalid base58 character 0x30",
926-
);
923+
assert_eq!(address.err().unwrap().to_string(), "base58 error: decode",);
927924
}
928925

929926
#[test]

src/blech32/decode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'s> UncheckedHrpstring<'s> {
150150
}
151151

152152
let mut checksum_eng = checksum::Engine::<Ck>::new();
153-
checksum_eng.input_hrp(&self.hrp());
153+
checksum_eng.input_hrp(self.hrp());
154154

155155
// Unwrap ok since we checked all characters in our constructor.
156156
for fe in self.data.iter().map(|&b| Fe32::from_char(b.into()).unwrap()) {

src/blech32/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ impl crate::bech32::Checksum for Blech32 {
3737
0x7093e5a608865b,
3838
];
3939
const TARGET_RESIDUE: u64 = 1;
40+
41+
const CODE_LENGTH: usize = 9999; // TODO
4042
}
4143

4244
/// The blech32m checksum algorithm.
@@ -54,5 +56,6 @@ impl crate::bech32::Checksum for Blech32m {
5456
0x7093e5a608865b,
5557
];
5658
const TARGET_RESIDUE: u64 = 0x455972a3350f7a1;
57-
}
5859

60+
const CODE_LENGTH: usize = 9999; // TODO
61+
}

src/blind.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ mod tests {
13751375
use crate::encode::deserialize;
13761376
use crate::hex::FromHex;
13771377
use crate::Script;
1378-
use bitcoin::{Network, PrivateKey, PublicKey};
1378+
use bitcoin::{PrivateKey, PublicKey};
13791379
use rand::thread_rng;
13801380
use secp256k1_zkp::SECP256K1;
13811381
use std::str::FromStr;
@@ -1466,7 +1466,7 @@ mod tests {
14661466
SECP256K1,
14671467
&PrivateKey {
14681468
compressed: true,
1469-
network: Network::Regtest,
1469+
network: bitcoin::NetworkKind::Test,
14701470
inner: sk,
14711471
},
14721472
);
@@ -1475,7 +1475,7 @@ mod tests {
14751475
SECP256K1,
14761476
&PrivateKey {
14771477
compressed: true,
1478-
network: Network::Regtest,
1478+
network: bitcoin::NetworkKind::Test,
14791479
inner: blinding_sk,
14801480
},
14811481
);

src/hash_types.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,39 @@
1616
//! to avoid mixing data of the same hash format (like SHA256d) but of different meaning
1717
//! (transaction id, block hash etc).
1818
19-
use crate:: hashes::{hash_newtype, hash160, sha256, sha256d, Hash};
20-
use bitcoin::secp256k1::ThirtyTwoByteHash;
19+
use crate::hashes::{hash160, hash_newtype, sha256, sha256d, Hash};
2120

2221
macro_rules! impl_hashencode {
2322
($hashtype:ident) => {
2423
impl $crate::encode::Encodable for $hashtype {
25-
fn consensus_encode<W: std::io::Write>(&self, w: W) -> Result<usize, crate::encode::Error> {
24+
fn consensus_encode<W: std::io::Write>(
25+
&self,
26+
w: W,
27+
) -> Result<usize, crate::encode::Error> {
2628
self.0.consensus_encode(w)
2729
}
2830
}
2931

3032
impl $crate::encode::Decodable for $hashtype {
3133
fn consensus_decode<R: std::io::Read>(r: R) -> Result<Self, $crate::encode::Error> {
32-
Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?))
34+
Ok(Self::from_byte_array(
35+
<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?,
36+
))
3337
}
3438
}
3539
};
3640
}
3741

3842
hash_newtype! {
3943
/// An elements transaction ID
40-
pub struct Txid(sha256d::Hash);
44+
pub struct Txid(sha256d::Hash);
4145
/// An elements witness transaction ID
42-
pub struct Wtxid(sha256d::Hash);
46+
pub struct Wtxid(sha256d::Hash);
4347
/// An elements blockhash
44-
pub struct BlockHash(sha256d::Hash);
48+
pub struct BlockHash(sha256d::Hash);
4549

4650
/// "Hash of the transaction according to the signature algorithm"
47-
pub struct Sighash(sha256d::Hash);
51+
pub struct Sighash(sha256d::Hash);
4852

4953
/// A hash of a public key.
5054
pub struct PubkeyHash(hash160::Hash);
@@ -59,15 +63,8 @@ hash_newtype! {
5963
pub struct TxMerkleNode(sha256d::Hash);
6064
}
6165

62-
6366
impl_hashencode!(Txid);
6467
impl_hashencode!(Wtxid);
6568
impl_hashencode!(Sighash);
6669
impl_hashencode!(BlockHash);
6770
impl_hashencode!(TxMerkleNode);
68-
69-
impl ThirtyTwoByteHash for Sighash {
70-
fn into_32(self) -> [u8; 32] {
71-
self.0.to_byte_array()
72-
}
73-
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mod transaction;
7373
// consider making upstream public
7474
mod endian;
7575
// re-export bitcoin deps which we re-use
76-
pub use bitcoin::bech32;
76+
pub(crate) use bech32;
7777
pub use bitcoin::hashes;
7878
// export everything at the top level so it can be used as `elements::Transaction` etc.
7979
pub use crate::address::{Address, AddressError, AddressParams};

src/pset/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub enum Error {
117117

118118
impl fmt::Display for Error {
119119
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
120-
match *self {
120+
match self {
121121
Error::InvalidKey(ref rkey) => write!(f, "invalid key: {}", rkey),
122122
Error::InvalidProprietaryKey => write!(
123123
f,

0 commit comments

Comments
 (0)