Skip to content

Commit a568e4e

Browse files
committed
Use CPUNet-modified bech32 library
1 parent 7d32028 commit a568e4e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bitcoin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ arbitrary = ["dep:arbitrary", "units/arbitrary", "primitives/arbitrary"]
2626

2727
[dependencies]
2828
base58 = { package = "base58ck", path = "../base58", default-features = false, features = ["alloc"] }
29-
bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] }
29+
bech32 = { git = "https://github.com/braidpool/rust-bech32.git", branch = "cpunet", default-features = false, features = ["alloc"] }
3030
hashes = { package = "bitcoin_hashes", path = "../hashes", default-features = false, features = ["alloc", "hex"] }
3131
hex = { package = "hex-conservative", version = "0.3.0", default-features = false, features = ["alloc"] }
3232
internals = { package = "bitcoin-internals", path = "../internals", features = ["alloc", "hex"] }

bitcoin/src/address/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ pub enum KnownHrp {
236236
Testnets,
237237
/// The regtest network.
238238
Regtest,
239+
/// The CPUNet test network.
240+
CPUNet
239241
}
240242

241243
impl KnownHrp {
@@ -258,6 +260,8 @@ impl KnownHrp {
258260
Ok(Self::Testnets)
259261
} else if hrp == bech32::hrp::BCRT {
260262
Ok(Self::Regtest)
263+
} else if hrp == bech32::hrp::TC {
264+
Ok(Self::CPUNet)
261265
} else {
262266
Err(UnknownHrpError(hrp.to_lowercase()))
263267
}
@@ -269,6 +273,7 @@ impl KnownHrp {
269273
Self::Mainnet => bech32::hrp::BC,
270274
Self::Testnets => bech32::hrp::TB,
271275
Self::Regtest => bech32::hrp::BCRT,
276+
Self::CPUNet => bech32::hrp::TC
272277
}
273278
}
274279
}
@@ -283,6 +288,7 @@ impl From<KnownHrp> for NetworkKind {
283288
KnownHrp::Mainnet => NetworkKind::Main,
284289
KnownHrp::Testnets => NetworkKind::Test,
285290
KnownHrp::Regtest => NetworkKind::Test,
291+
KnownHrp::CPUNet => NetworkKind::Test,
286292
}
287293
}
288294
}
@@ -990,7 +996,7 @@ impl<U: NetworkValidationUnchecked> FromStr for Address<U> {
990996
type Err = ParseError;
991997

992998
fn from_str(s: &str) -> Result<Self, ParseError> {
993-
if ["bc1", "bcrt1", "tb1"].iter().any(|&prefix| s.to_lowercase().starts_with(prefix)) {
999+
if ["bc1", "bcrt1", "tb1", "tc1"].iter().any(|&prefix| s.to_lowercase().starts_with(prefix)) {
9941000
let address = Address::from_bech32_str(s)?;
9951001
// We know that `U` is only ever `NetworkUnchecked` but the compiler does not.
9961002
Ok(Address::from_inner(address.into_inner()))

0 commit comments

Comments
 (0)