Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ arbitrary = ["dep:arbitrary", "units/arbitrary", "primitives/arbitrary"]

[dependencies]
base58 = { package = "base58ck", path = "../base58", default-features = false, features = ["alloc"] }
bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] }
bech32 = { git = "https://github.com/braidpool/rust-bech32.git", branch = "cpunet", default-features = false, features = ["alloc"] }
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a git dependency without specifying a commit hash or tag creates reproducibility issues. Consider pinning to a specific commit hash or tag to ensure consistent builds across different environments and times.

Suggested change
bech32 = { git = "https://github.com/braidpool/rust-bech32.git", branch = "cpunet", default-features = false, features = ["alloc"] }
bech32 = { git = "https://github.com/braidpool/rust-bech32.git", rev = "<commit-hash>", default-features = false, features = ["alloc"] }

Copilot uses AI. Check for mistakes.
hashes = { package = "bitcoin_hashes", path = "../hashes", default-features = false, features = ["alloc", "hex"] }
hex = { package = "hex-conservative", version = "0.3.0", default-features = false, features = ["alloc"] }
internals = { package = "bitcoin-internals", path = "../internals", features = ["alloc", "hex"] }
Expand Down
11 changes: 9 additions & 2 deletions bitcoin/src/address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ pub enum KnownHrp {
Testnets,
/// The regtest network.
Regtest,
/// The CPUNet test network.
CPUNet
}

impl KnownHrp {
Expand All @@ -245,8 +247,9 @@ impl KnownHrp {

match network {
Bitcoin => Self::Mainnet,
Testnet(_) | Signet | CPUNet => Self::Testnets,
Testnet(_) | Signet => Self::Testnets,
Regtest => Self::Regtest,
CPUNet => Self::CPUNet
}
}

Expand All @@ -258,6 +261,8 @@ impl KnownHrp {
Ok(Self::Testnets)
} else if hrp == bech32::hrp::BCRT {
Ok(Self::Regtest)
} else if hrp == bech32::hrp::TC {
Ok(Self::CPUNet)
} else {
Err(UnknownHrpError(hrp.to_lowercase()))
}
Expand All @@ -269,6 +274,7 @@ impl KnownHrp {
Self::Mainnet => bech32::hrp::BC,
Self::Testnets => bech32::hrp::TB,
Self::Regtest => bech32::hrp::BCRT,
Self::CPUNet => bech32::hrp::TC
}
}
}
Expand All @@ -283,6 +289,7 @@ impl From<KnownHrp> for NetworkKind {
KnownHrp::Mainnet => NetworkKind::Main,
KnownHrp::Testnets => NetworkKind::Test,
KnownHrp::Regtest => NetworkKind::Test,
KnownHrp::CPUNet => NetworkKind::Test,
}
}
}
Expand Down Expand Up @@ -990,7 +997,7 @@ impl<U: NetworkValidationUnchecked> FromStr for Address<U> {
type Err = ParseError;

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