Contractless/src/wallets/structures.rs

37 lines
1.3 KiB
Rust
Raw Normal View History

2026-05-24 17:56:57 +00:00
use crate::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SavedWallet {
pub short_address: String,
pub vanity_address: Option<String>,
pub public_key: String,
pub private_key: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Wallet {
pub saved: SavedWallet,
pub encryption_key: String,
}
impl Wallet {
pub const FN_DSA_LOGN: u32 = 9;
2026-06-22 16:37:46 +00:00
pub const REQUIRED_PUBLIC_KEY_HASH_BYTE: u8 = 239;
2026-05-24 17:56:57 +00:00
pub const PUBLIC_KEY_LENGTH: usize = 897;
pub const PRIVATE_KEY_LENGTH: usize = 1281;
pub const SIGNATURE_LENGTH: usize = 666;
pub const ADDRESS_BYTES_LENGTH: usize = 1 + Self::PUBLIC_KEY_LENGTH;
pub const ADDRESS_HEX_LENGTH: usize = Self::PUBLIC_KEY_LENGTH * 2;
pub const SHORT_ADDRESS_HASH_BYTES_LENGTH: usize = 20;
pub const SHORT_ADDRESS_BYTES_LENGTH: usize = Self::SHORT_ADDRESS_HASH_BYTES_LENGTH + 2;
pub const SHORT_ADDRESS_SEPARATOR: u8 = b'.';
pub fn display_wallet(&self) -> String {
2026-06-04 16:18:55 +00:00
let mut output = format!("Short Address: {}", self.saved.short_address);
2026-05-24 17:56:57 +00:00
if let Some(vanity_address) = &self.saved.vanity_address {
output.push_str(&format!("\nVanity Address: {vanity_address}"));
}
output.push_str(&format!("\nPublic Key: {}", self.saved.public_key));
output
}
}