@@ -236,6 +236,8 @@ pub enum KnownHrp {
236236 Testnets ,
237237 /// The regtest network.
238238 Regtest ,
239+ /// The CPUNet test network.
240+ CPUNet
239241}
240242
241243impl KnownHrp {
@@ -245,8 +247,9 @@ impl KnownHrp {
245247
246248 match network {
247249 Bitcoin => Self :: Mainnet ,
248- Testnet ( _) | Signet | CPUNet => Self :: Testnets ,
250+ Testnet ( _) | Signet => Self :: Testnets ,
249251 Regtest => Self :: Regtest ,
252+ CPUNet => Self :: CPUNet
250253 }
251254 }
252255
@@ -258,6 +261,8 @@ impl KnownHrp {
258261 Ok ( Self :: Testnets )
259262 } else if hrp == bech32:: hrp:: BCRT {
260263 Ok ( Self :: Regtest )
264+ } else if hrp == bech32:: hrp:: TC {
265+ Ok ( Self :: CPUNet )
261266 } else {
262267 Err ( UnknownHrpError ( hrp. to_lowercase ( ) ) )
263268 }
@@ -269,6 +274,7 @@ impl KnownHrp {
269274 Self :: Mainnet => bech32:: hrp:: BC ,
270275 Self :: Testnets => bech32:: hrp:: TB ,
271276 Self :: Regtest => bech32:: hrp:: BCRT ,
277+ Self :: CPUNet => bech32:: hrp:: TC
272278 }
273279 }
274280}
@@ -283,6 +289,7 @@ impl From<KnownHrp> for NetworkKind {
283289 KnownHrp :: Mainnet => NetworkKind :: Main ,
284290 KnownHrp :: Testnets => NetworkKind :: Test ,
285291 KnownHrp :: Regtest => NetworkKind :: Test ,
292+ KnownHrp :: CPUNet => NetworkKind :: Test ,
286293 }
287294 }
288295}
@@ -990,7 +997,7 @@ impl<U: NetworkValidationUnchecked> FromStr for Address<U> {
990997 type Err = ParseError ;
991998
992999 fn from_str ( s : & str ) -> Result < Self , ParseError > {
993- if [ "bc1" , "bcrt1" , "tb1" ] . iter ( ) . any ( |& prefix| s. to_lowercase ( ) . starts_with ( prefix) ) {
1000+ if [ "bc1" , "bcrt1" , "tb1" , "tc1" ] . iter ( ) . any ( |& prefix| s. to_lowercase ( ) . starts_with ( prefix) ) {
9941001 let address = Address :: from_bech32_str ( s) ?;
9951002 // We know that `U` is only ever `NetworkUnchecked` but the compiler does not.
9961003 Ok ( Address :: from_inner ( address. into_inner ( ) ) )
0 commit comments