add dummy function for random generated Sietch addresses in SDL
This commit is contained in:
@@ -721,6 +721,36 @@ impl Command for NewAddressCommand {
|
||||
}
|
||||
}
|
||||
|
||||
struct NewSietchAddressCommand {}
|
||||
impl Command for NewSietchAddressCommand {
|
||||
fn help(&self) -> String {
|
||||
let mut h = vec![];
|
||||
h.push("New Sietch Address");
|
||||
h.push("Usage:");
|
||||
h.push("sietch [zs]");
|
||||
h.push("");
|
||||
h.push("Example:");
|
||||
h.push("To create a new zdust:");
|
||||
h.push("sietch zs");
|
||||
h.join("\n")
|
||||
}
|
||||
|
||||
fn short_help(&self) -> String {
|
||||
"Create a sietch Address".to_string()
|
||||
}
|
||||
|
||||
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
|
||||
if args.len() != 1 {
|
||||
return format!("No address type specified\n{}", self.help());
|
||||
}
|
||||
|
||||
match lightclient.do_new_sietchaddress(args[0]) {
|
||||
Ok(j) => j,
|
||||
Err(e) => object!{ "error" => e }
|
||||
}.pretty(2)
|
||||
}
|
||||
}
|
||||
|
||||
struct NotesCommand {}
|
||||
impl Command for NotesCommand {
|
||||
fn help(&self) -> String {
|
||||
@@ -831,6 +861,7 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> {
|
||||
map.insert("list".to_string(), Box::new(TransactionsCommand{}));
|
||||
map.insert("notes".to_string(), Box::new(NotesCommand{}));
|
||||
map.insert("new".to_string(), Box::new(NewAddressCommand{}));
|
||||
map.insert("sietch".to_string(), Box::new(NewSietchAddressCommand{}));
|
||||
map.insert("seed".to_string(), Box::new(SeedCommand{}));
|
||||
map.insert("encrypt".to_string(), Box::new(EncryptCommand{}));
|
||||
map.insert("decrypt".to_string(), Box::new(DecryptCommand{}));
|
||||
|
||||
@@ -37,7 +37,7 @@ use crate::ANCHOR_OFFSET;
|
||||
|
||||
mod checkpoints;
|
||||
|
||||
pub const DEFAULT_SERVER: &str = "https://hush-lightwallet.de:443";
|
||||
pub const DEFAULT_SERVER: &str = "https://lite.myhush.org";
|
||||
pub const WALLET_NAME: &str = "silentdragonlite-wallet.dat";
|
||||
pub const LOGFILE_NAME: &str = "silentdragonlite-wallet.debug.log";
|
||||
|
||||
@@ -867,6 +867,31 @@ impl LightClient {
|
||||
Ok(array![new_address])
|
||||
}
|
||||
|
||||
pub fn do_new_sietchaddress(&self, addr_type: &str) -> Result<JsonValue, String> {
|
||||
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
||||
error!("Wallet is locked");
|
||||
return Err("Wallet is locked".to_string());
|
||||
}
|
||||
|
||||
let new_address = {
|
||||
let wallet = self.wallet.write().unwrap();
|
||||
|
||||
match addr_type {
|
||||
"zs" => wallet.add_zaddr(),
|
||||
|
||||
_ => {
|
||||
let e = format!("Unrecognized address type: {}", addr_type);
|
||||
error!("{}", e);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.do_save()?;
|
||||
|
||||
Ok(array![new_address])
|
||||
}
|
||||
|
||||
pub fn clear_state(&self) {
|
||||
// First, clear the state from the wallet
|
||||
self.wallet.read().unwrap().clear_blocks();
|
||||
|
||||
Reference in New Issue
Block a user