use rustywallet_keys::prelude::PrivateKey;
use rustywallet_hd::Network;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImportFormat {
Wif,
Hex,
Mnemonic,
ElectrumSeed,
Bip38,
MiniKey,
}
impl std::fmt::Display for ImportFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ImportFormat::Wif => write!(f, "WIF"),
ImportFormat::Hex => write!(f, "Hex"),
ImportFormat::Mnemonic => write!(f, "Mnemonic"),
ImportFormat::ElectrumSeed => write!(f, "Electrum Seed"),
ImportFormat::Bip38 => write!(f, "BIP38"),
ImportFormat::MiniKey => write!(f, "Mini Key"),
}
}
}
#[derive(Debug)]
pub struct ImportResult {
pub private_key: PrivateKey,
pub format: ImportFormat,
pub network: Option<Network>,
pub compressed: bool,
pub metadata: ImportMetadata,
}
#[derive(Debug, Default)]
pub struct ImportMetadata {
pub derivation_path: Option<String>,
pub word_count: Option<usize>,
pub has_passphrase: bool,
}
impl ImportResult {
pub fn new(private_key: PrivateKey, format: ImportFormat) -> Self {
Self {
private_key,
format,
network: None,
compressed: true,
metadata: ImportMetadata::default(),
}
}
pub fn with_network(mut self, network: Network) -> Self {
self.network = Some(network);
self
}
pub fn with_compressed(mut self, compressed: bool) -> Self {
self.compressed = compressed;
self
}
pub fn with_metadata(mut self, metadata: ImportMetadata) -> Self {
self.metadata = metadata;
self
}
}