Adds `is_regtest()` methods
This commit is contained in:
parent
9b41cba5a3
commit
b38dbfd252
|
@ -180,6 +180,15 @@ impl Network {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if the network is Regtest, or false otherwise.
|
||||
pub fn is_regtest(&self) -> bool {
|
||||
if let Self::Testnet(params) = self {
|
||||
params.is_regtest()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the [`NetworkKind`] for this network.
|
||||
pub fn kind(&self) -> NetworkKind {
|
||||
match self {
|
||||
|
|
|
@ -291,6 +291,22 @@ impl Parameters {
|
|||
self == &Self::default()
|
||||
}
|
||||
|
||||
/// Returns true if the instance of [`Parameters`] represents Regtest.
|
||||
pub fn is_regtest(&self) -> bool {
|
||||
let Self {
|
||||
network_name,
|
||||
hrp_sapling_extended_spending_key,
|
||||
hrp_sapling_extended_full_viewing_key,
|
||||
hrp_sapling_payment_address,
|
||||
..
|
||||
} = Self::new_regtest(ConfiguredActivationHeights::default());
|
||||
|
||||
self.network_name == network_name
|
||||
&& self.hrp_sapling_extended_spending_key == hrp_sapling_extended_spending_key
|
||||
&& self.hrp_sapling_extended_full_viewing_key == hrp_sapling_extended_full_viewing_key
|
||||
&& self.hrp_sapling_payment_address == hrp_sapling_payment_address
|
||||
}
|
||||
|
||||
/// Returns the network name
|
||||
pub fn network_name(&self) -> &str {
|
||||
&self.network_name
|
||||
|
|
Loading…
Reference in New Issue