Skip to content

Commit e61e15a

Browse files
committed
Impl From<Network> for &str
1 parent 542788f commit e61e15a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/utils/common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ pub enum Network {
3636
Regtest,
3737
}
3838

39+
impl From<Network> for &str {
40+
fn from(value: Network) -> Self {
41+
match value {
42+
Network::Mainnet => "bitcoin", // we use the same string as rust-bitcoin for compatibility
43+
Network::Regtest => "regtest",
44+
Network::Testnet => "testnet",
45+
}
46+
}
47+
}
48+
3949
/// A silent payment address struct that can be used to deserialize a silent payment address string.
4050
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
4151
pub struct SilentPaymentAddress {

0 commit comments

Comments
 (0)