diff --git a/Cargo.toml b/Cargo.toml index a49716b..a199dc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dash-evo-tool" -version = "0.2.0" +version = "0.3.0" license = "MIT" edition = "2021" default-run = "dash-evo-tool" diff --git a/src/database/identities.rs b/src/database/identities.rs index 6148349..8c83ae7 100644 --- a/src/database/identities.rs +++ b/src/database/identities.rs @@ -17,11 +17,15 @@ impl Database { let id = identifier.to_vec(); let conn = self.conn.lock().unwrap(); - conn.execute( + let rows_updated = conn.execute( "UPDATE identity SET alias = ? WHERE id = ?", params![new_alias, id], )?; + if rows_updated == 0 { + return Err(rusqlite::Error::QueryReturnedNoRows); + } + Ok(()) } pub fn insert_local_qualified_identity( @@ -164,11 +168,13 @@ impl Database { let conn = self.conn.lock().unwrap(); let mut stmt = conn.prepare( - "SELECT data FROM identity WHERE is_local = 1 AND network = ? AND data IS NOT NULL", + "SELECT data, alias FROM identity WHERE is_local = 1 AND network = ? AND data IS NOT NULL", )?; let identity_iter = stmt.query_map(params![network], |row| { let data: Vec = row.get(0)?; + let alias: Option = row.get(1)?; let mut identity: QualifiedIdentity = QualifiedIdentity::from_bytes(&data); + identity.alias = alias; identity.associated_wallets = wallets .iter() diff --git a/src/ui/identities/identities_screen.rs b/src/ui/identities/identities_screen.rs index c19d4a5..046cb76 100644 --- a/src/ui/identities/identities_screen.rs +++ b/src/ui/identities/identities_screen.rs @@ -87,13 +87,15 @@ impl IdentitiesScreen { } else { identity_to_update.alias = Some(alias); } - self.app_context - .db - .set_alias( - &identity_to_update.identity.id(), - identity_to_update.alias.as_ref().map(|s| s.as_str()), - ) - .ok(); + match self.app_context.db.set_alias( + &identity_to_update.identity.id(), + identity_to_update.alias.as_ref().map(|s| s.as_str()), + ) { + Ok(_) => {} + Err(e) => { + eprintln!("{}", e) + } + } } } diff --git a/src/ui/identities/withdraw_from_identity_screen.rs b/src/ui/identities/withdraw_from_identity_screen.rs index 3126a75..f51738e 100644 --- a/src/ui/identities/withdraw_from_identity_screen.rs +++ b/src/ui/identities/withdraw_from_identity_screen.rs @@ -105,7 +105,7 @@ impl WithdrawalScreen { ui.text_edit_singleline(&mut self.withdrawal_amount); if ui.button("Max").clicked() { - let expected_max_amount = self.max_amount.saturating_sub(30000) as f64 * 1e-8; + let expected_max_amount = self.max_amount.saturating_sub(5000000) as f64 * 1e-8; // Use flooring and format the result with 4 decimal places let floored_amount = (expected_max_amount * 10_000.0).floor() / 10_000.0;