rustywallet_import/
types.rs1use rustywallet_keys::prelude::PrivateKey;
4use rustywallet_hd::Network;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum ImportFormat {
9 Wif,
11 Hex,
13 Mnemonic,
15 ElectrumSeed,
17 Bip38,
19 MiniKey,
21}
22
23impl std::fmt::Display for ImportFormat {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 match self {
26 ImportFormat::Wif => write!(f, "WIF"),
27 ImportFormat::Hex => write!(f, "Hex"),
28 ImportFormat::Mnemonic => write!(f, "Mnemonic"),
29 ImportFormat::ElectrumSeed => write!(f, "Electrum Seed"),
30 ImportFormat::Bip38 => write!(f, "BIP38"),
31 ImportFormat::MiniKey => write!(f, "Mini Key"),
32 }
33 }
34}
35
36#[derive(Debug)]
38pub struct ImportResult {
39 pub private_key: PrivateKey,
41 pub format: ImportFormat,
43 pub network: Option<Network>,
45 pub compressed: bool,
47 pub metadata: ImportMetadata,
49}
50
51#[derive(Debug, Default)]
53pub struct ImportMetadata {
54 pub derivation_path: Option<String>,
56 pub word_count: Option<usize>,
58 pub has_passphrase: bool,
60}
61
62impl ImportResult {
63 pub fn new(private_key: PrivateKey, format: ImportFormat) -> Self {
65 Self {
66 private_key,
67 format,
68 network: None,
69 compressed: true,
70 metadata: ImportMetadata::default(),
71 }
72 }
73
74 pub fn with_network(mut self, network: Network) -> Self {
76 self.network = Some(network);
77 self
78 }
79
80 pub fn with_compressed(mut self, compressed: bool) -> Self {
82 self.compressed = compressed;
83 self
84 }
85
86 pub fn with_metadata(mut self, metadata: ImportMetadata) -> Self {
88 self.metadata = metadata;
89 self
90 }
91}