use crate::parameters::Network;
mod orchard;
mod sapling;
use orchard::OrchardViewingKey;
use sapling::SaplingViewingKey;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone)]
pub enum ViewingKey {
Sapling(SaplingViewingKey),
Orchard(OrchardViewingKey),
}
impl ViewingKey {
fn parse_sapling(sapling_key: &str, network: &Network) -> Option<Self> {
SaplingViewingKey::parse(sapling_key, network).map(Self::Sapling)
}
fn parse_orchard(sapling_key: &str, network: &Network) -> Option<Self> {
OrchardViewingKey::parse(sapling_key, network).map(Self::Orchard)
}
pub fn parse(key: &str, network: &Network) -> Option<Self> {
Self::parse_sapling(key, network).or_else(|| Self::parse_orchard(key, network))
}
}