clippy patches

This commit is contained in:
c2m 2024-09-29 21:58:46 -04:00
parent ca736c487b
commit 967c903f67
12 changed files with 58 additions and 152 deletions

View file

@ -83,7 +83,7 @@ fn update_expiration(f_auth: &Authorization, address: &String) -> Result<Authori
create_token(String::from(address), time),
);
let db = &DATABASE_LOCK;
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, &u_auth.aid.as_bytes().to_vec())?;
db::DatabaseEnvironment::delete(&db.env, &db.handle, u_auth.aid.as_bytes())?;
let k = u_auth.aid.as_bytes();
let v = bincode::serialize(&u_auth).unwrap_or_default();
db::write_chunks(&db.env, &db.handle, k, &v)?;
@ -128,7 +128,7 @@ pub async fn verify_login(
// update auth with uid
let u_auth = Authorization::update_uid(f_auth, String::from(&u.uid));
let db = &DATABASE_LOCK;
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, &u_auth.aid.as_bytes())?;
db::DatabaseEnvironment::delete(&db.env, &db.handle, u_auth.aid.as_bytes())?;
let v = bincode::serialize(&u_auth).unwrap_or_default();
db::write_chunks(&db.env, &db.handle, u_auth.aid.as_bytes(), &v)?;
monero::close_wallet(&wallet_name, &wallet_password).await;

View file

@ -98,7 +98,7 @@ pub fn delete(cid: &String) -> Result<(), MdbError> {
error!("contact not found");
return Err(MdbError::NotFound);
}
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, cid.as_bytes())?;
db::DatabaseEnvironment::delete(&db.env, &db.handle, cid.as_bytes())?;
Ok(())
}

View file

@ -134,7 +134,7 @@ pub async fn settle_dispute() -> Result<(), NevekoError> {
if cleared {
// index was created but cleared
info!("terminating dispute auto-settle thread");
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, list_key.as_bytes())
db::DatabaseEnvironment::delete(&db.env, &db.handle, list_key.as_bytes())
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
return Ok(());
}
@ -188,7 +188,7 @@ fn remove_from_auto_settle(did: String) -> Result<(), NevekoError> {
let pre_v_fts = str_r.split(",");
let v: Vec<String> = pre_v_fts
.map(|s| {
if s != &did {
if s != did {
String::from(s)
} else {
String::new()
@ -263,5 +263,5 @@ pub async fn trigger_dispute_request(
error!("failed to create dispute");
return Err(NevekoError::Dispute);
}
Ok(dispute.map_err(|_| NevekoError::Dispute)?)
dispute.map_err(|_| NevekoError::Dispute)
}

View file

@ -116,7 +116,7 @@ pub fn get_destination(st: ServerTunnelType) -> Result<String, NevekoError> {
)
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
let anon_b32_dest: String = bincode::deserialize(&r_anon_b32_dest[..]).unwrap_or_default();
let app_b32_dest: String = bincode::deserialize(&&r_app_b32_dest[..]).unwrap_or_default();
let app_b32_dest: String = bincode::deserialize(&r_app_b32_dest[..]).unwrap_or_default();
match st {
ServerTunnelType::App => Ok(app_b32_dest),
ServerTunnelType::AnonInbound => Ok(anon_b32_dest),

View file

@ -151,7 +151,7 @@ pub async fn rx(m: Json<Message>) -> Result<(), NevekoError> {
async fn parse_multisig_message(mid: String) -> Result<MultisigMessageData, NevekoError> {
let d: reqres::DecipheredMessageBody = decipher_body(mid).await?;
let mut bytes = hex::decode(d.body.into_bytes()).unwrap_or_default();
let decoded = String::from_utf8(bytes).unwrap_or(String::new());
let decoded = String::from_utf8(bytes).unwrap_or_default();
let values = decoded.split(":");
let mut v: Vec<String> = values.map(String::from).collect();
if v.len() != VALID_MSIG_MSG_LENGTH {
@ -374,7 +374,7 @@ pub async fn decipher_body(mid: String) -> Result<reqres::DecipheredMessageBody,
/// Message deletion
pub fn delete(mid: &String) -> Result<(), NevekoError> {
let db = &DATABASE_LOCK;
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, mid.as_bytes())
db::DatabaseEnvironment::delete(&db.env, &db.handle, mid.as_bytes())
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
Ok(())
}
@ -465,7 +465,7 @@ fn remove_from_fts(mid: String) -> Result<(), NevekoError> {
let pre_v_fts = s_r.split(",");
let v: Vec<String> = pre_v_fts
.map(|s| {
if s != &mid {
if s != mid {
String::from(s)
} else {
String::new()
@ -509,8 +509,7 @@ pub async fn retry_fts() -> Result<(), NevekoError> {
if cleared {
// index was created but cleared
info!("terminating retry fts thread");
let _ =
db::DatabaseEnvironment::delete(&db.env, &db.handle, &list_key.as_bytes().to_vec())
db::DatabaseEnvironment::delete(&db.env, &db.handle, list_key.as_bytes())
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
break Err(NevekoError::Database(MdbError::NotFound));
}
@ -689,7 +688,7 @@ pub async fn send_export_info(orid: &String, contact: &String) -> Result<(), Nev
/// multisig info after funding. Once the info is imported
///
/// successfully the order needs to be updated to `MultisigComplete`.
pub async fn send_import_info(orid: &String, info: &Vec<String>) -> Result<(), NevekoError> {
pub async fn send_import_info(orid: &String, info: &[String]) -> Result<(), NevekoError> {
let wallet_name = String::from(orid);
let wallet_password = String::new();
monero::open_wallet(&wallet_name, &wallet_password).await;

View file

@ -328,7 +328,7 @@ fn get_monero_location() -> String {
/// Get monero rpc host from the `--monero-rpc-host` cli arg
fn get_rpc_host() -> String {
let args = args::Args::parse();
let gui_host = std::env::var(crate::MONERO_WALLET_RPC_HOST).unwrap_or(String::new());
let gui_host = std::env::var(crate::MONERO_WALLET_RPC_HOST).unwrap_or_default();
let rpc = if gui_host.is_empty() {
args.monero_rpc_host
} else {
@ -350,7 +350,7 @@ fn get_rpc_creds() -> RpcLogin {
fn get_rpc_daemon() -> String {
let args = args::Args::parse();
let gui_host = std::env::var(crate::MONERO_DAEMON_HOST).unwrap_or(String::new());
let gui_host = std::env::var(crate::MONERO_DAEMON_HOST).unwrap_or_default();
if gui_host.is_empty() {
args.monero_rpc_daemon
} else {
@ -378,10 +378,7 @@ pub async fn get_version() -> reqres::XmrRpcVersionResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcVersionResponse>().await;
debug!("{} response: {:?}", RpcFields::GetVersion.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_e) => Default::default(),
}
@ -417,10 +414,7 @@ pub async fn sign(data: String) -> reqres::XmrRpcSignResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcSignResponse>().await;
debug!("{} response: {:?}", RpcFields::Sign.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_e) => Default::default(),
}
@ -687,10 +681,7 @@ pub async fn get_balance() -> reqres::XmrRpcBalanceResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcBalanceResponse>().await;
debug!("{} response: {:?}", RpcFields::Balance.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -761,10 +752,7 @@ pub async fn validate_address(address: &String) -> reqres::XmrRpcValidateAddress
.json::<reqres::XmrRpcValidateAddressResponse>()
.await;
debug!("{} response: {:?}", RpcFields::ValidateAddress.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -795,10 +783,7 @@ pub async fn prepare_wallet() -> reqres::XmrRpcPrepareResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcPrepareResponse>().await;
debug!("{} response: {:?}", RpcFields::Prepare.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -829,10 +814,7 @@ pub async fn make_wallet(info: Vec<String>) -> reqres::XmrRpcMakeResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcMakeResponse>().await;
debug!("{} response: {:?}", RpcFields::Make.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -857,10 +839,7 @@ pub async fn export_multisig_info() -> reqres::XmrRpcExportResponse {
{
Ok(response) => {
let res = response.json::<reqres::XmrRpcExportResponse>().await;
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -888,10 +867,7 @@ pub async fn import_multisig_info(info: Vec<String>) -> reqres::XmrRpcImportResp
Ok(response) => {
let res = response.json::<reqres::XmrRpcImportResponse>().await;
debug!("{} response: {:?}", RpcFields::Import.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -919,10 +895,7 @@ pub async fn sign_multisig(tx_data_hex: String) -> reqres::XmrRpcSignMultisigRes
Ok(response) => {
let res = response.json::<reqres::XmrRpcSignMultisigResponse>().await;
debug!("{} response: {:?}", RpcFields::SignMultisig.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -952,10 +925,7 @@ pub async fn submit_multisig(tx_data_hex: String) -> reqres::XmrRpcSubmitMultisi
.json::<reqres::XmrRpcSubmitMultisigResponse>()
.await;
debug!("{} response: {:?}", RpcFields::SubmitMultisig.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -997,10 +967,7 @@ pub async fn exchange_multisig_keys(
RpcFields::ExchangeMultisigKeys.value(),
res
);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1034,10 +1001,7 @@ pub async fn check_tx_proof(txp: &proof::TxProof) -> reqres::XmrRpcCheckTxProofR
Ok(response) => {
let res = response.json::<reqres::XmrRpcCheckTxProofResponse>().await;
debug!("{} response: {:?}", RpcFields::CheckTxProof.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1069,10 +1033,7 @@ pub async fn get_tx_proof(ptxp: proof::TxProof) -> reqres::XmrRpcGetTxProofRespo
Ok(response) => {
let res = response.json::<reqres::XmrRpcGetTxProofResponse>().await;
debug!("{} response: {:?}", RpcFields::GetTxProof.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1102,10 +1063,7 @@ pub async fn get_transfer_by_txid(txid: &str) -> reqres::XmrRpcGetTxByIdResponse
Ok(response) => {
let res = response.json::<reqres::XmrRpcGetTxByIdResponse>().await;
debug!("{} response: {:?}", RpcFields::GetTxById.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1116,8 +1074,7 @@ pub async fn transfer(d: reqres::Destination) -> reqres::XmrRpcTransferResponse
info!("executing {}", RpcFields::Transfer.value());
let client = reqwest::Client::new();
let host = get_rpc_host();
let mut destinations: Vec<reqres::Destination> = Vec::new();
destinations.push(d);
let destinations = vec![d];
let params: reqres::XmrRpcTransferParams = reqres::XmrRpcTransferParams {
account_index: 0,
destinations,
@ -1142,10 +1099,7 @@ pub async fn transfer(d: reqres::Destination) -> reqres::XmrRpcTransferResponse
Ok(response) => {
let res = response.json::<reqres::XmrRpcTransferResponse>().await;
debug!("{} response: {:?}", RpcFields::Transfer.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1181,10 +1135,7 @@ pub async fn describe_transfer(multisig_txset: &String) -> reqres::XmrRpcDescrib
RpcFields::DescribeTransfer.value(),
res
);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1212,10 +1163,7 @@ pub async fn sweep_all(address: String) -> reqres::XmrRpcSweepAllResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcSweepAllResponse>().await;
debug!("{} response: {:?}", RpcFields::SweepAll.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1244,10 +1192,7 @@ pub async fn create_address() -> reqres::XmrRpcCreateAddressResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcCreateAddressResponse>().await;
debug!("{} response: {:?}", RpcFields::CreateAddress.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1273,10 +1218,7 @@ pub async fn refresh() -> reqres::XmrRpcRefreshResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcRefreshResponse>().await;
debug!("{} response: {:?}", RpcFields::Refresh.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1302,10 +1244,7 @@ pub async fn is_multisig() -> reqres::XmrRpcIsMultisigResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcIsMultisigResponse>().await;
debug!("{} response: {:?}", RpcFields::IsMultisig.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1331,10 +1270,7 @@ pub async fn get_wallet_height() -> reqres::XmrRpcGetHeightResponse {
Ok(response) => {
let res = response.json::<reqres::XmrRpcGetHeightResponse>().await;
debug!("{} response: {:?}", RpcFields::GetHeight.value(), res);
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1363,10 +1299,7 @@ pub async fn query_view_key() -> reqres::XmrRpcQueryKeyResponse {
{
Ok(response) => {
let res = response.json::<reqres::XmrRpcQueryKeyResponse>().await;
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1389,10 +1322,7 @@ pub async fn get_info() -> reqres::XmrDaemonGetInfoResponse {
Ok(response) => {
let res = response.json::<reqres::XmrDaemonGetInfoResponse>().await;
// add debug log here if needed for adding more info to home screen in gui
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1433,10 +1363,7 @@ pub async fn get_height() -> reqres::XmrDaemonGetHeightResponse {
Ok(response) => {
let res = response.json::<reqres::XmrDaemonGetHeightResponse>().await;
// don't log this one. The fee estimator blows up logs (T_T)
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1479,10 +1406,7 @@ pub async fn get_block(height: u64) -> reqres::XmrDaemonGetBlockResponse {
Ok(response) => {
let res = response.json::<reqres::XmrDaemonGetBlockResponse>().await;
// don't log this one. The fee estimator blows up logs (T_T)
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}
@ -1531,10 +1455,7 @@ pub async fn get_transactions(txs_hashes: Vec<String>) -> reqres::XmrDaemonGetTr
.json::<reqres::XmrDaemonGetTransactionsResponse>()
.await;
// don't log this one. The fee estimator blows up logs (T_T)
match res {
Ok(res) => res,
_ => Default::default(),
}
res.unwrap_or_default()
}
Err(_) => Default::default(),
}

View file

@ -19,6 +19,7 @@ use sha2::{
#[derive(Debug)]
/// Container for the Neveko Message Keys
#[derive(Default)]
pub struct NevekoMessageKeys {
/// Neveko Message Secret Key
pub nmsk: [u8; 32],
@ -30,16 +31,6 @@ pub struct NevekoMessageKeys {
pub hex_nmpk: String,
}
impl Default for NevekoMessageKeys {
fn default() -> Self {
NevekoMessageKeys {
nmpk: [0u8; 32],
nmsk: [0u8; 32],
hex_nmpk: String::new(),
hex_nmsk: String::new(),
}
}
}
/// L value as defined at https://eprint.iacr.org/2008/013.pdf
const CURVE_L: &str = "edd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010";
@ -67,13 +58,11 @@ fn hash_to_scalar(s: Vec<&str>) -> Scalar {
hasher.update(&result);
let hash = hasher.finalize().to_owned();
let mut hash_container: [u8; 32] = [0u8; 32];
let mut index = 0;
for byte in result.as_bytes() {
for (index, byte) in result.as_bytes().iter().enumerate() {
if index == hash_container.len() - 1 {
break;
}
hash_container[index] = *byte;
index += 1;
}
let hash_value = BigInt::from_bytes_le(Sign::Plus, &hash_container);
if hash_value < curve_l_as_big_int() {
@ -92,7 +81,7 @@ fn hash_to_scalar(s: Vec<&str>) -> Scalar {
/// Neveko Message Public Key (NMPK).
pub async fn generate_neveko_message_keys() -> NevekoMessageKeys {
log::info!("generating neveko message keys");
let password = std::env::var(crate::MONERO_WALLET_PASSWORD).unwrap_or(String::new());
let password = std::env::var(crate::MONERO_WALLET_PASSWORD).unwrap_or_default();
let filename = String::from(crate::APP_NAME);
let m_wallet = monero::open_wallet(&filename, &password).await;
if !m_wallet {
@ -126,7 +115,7 @@ pub async fn generate_neveko_message_keys() -> NevekoMessageKeys {
///
/// Pass `None` to encipher parameter to perform deciphering.
pub async fn cipher(hex_nmpk: &String, message: String, encipher: Option<String>) -> String {
let unwrap_encipher: String = encipher.unwrap_or(String::new());
let unwrap_encipher: String = encipher.unwrap_or_default();
let keys: NevekoMessageKeys = generate_neveko_message_keys().await;
// shared secret = nmpk * nmsk
let scalar_nmsk = Scalar::from_bytes_mod_order(keys.nmsk);

View file

@ -267,10 +267,10 @@ pub fn modify(o: Json<Order>) -> Result<Order, NevekoError> {
}
let db = &DATABASE_LOCK;
let u_order = Order::update(String::from(&f_order.orid), &o);
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, &u_order.orid.as_bytes())
db::DatabaseEnvironment::delete(&db.env, &db.handle, u_order.orid.as_bytes())
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
let v = bincode::serialize(&u_order).unwrap_or_default();
let _ = db::write_chunks(&db.env, &db.handle, &u_order.orid.as_bytes(), &v)
db::write_chunks(&db.env, &db.handle, u_order.orid.as_bytes(), &v)
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
Ok(u_order)
}
@ -379,7 +379,7 @@ pub async fn validate_order_for_ship(
let mut j_order: Order = find(orid).map_err(|_| NevekoError::Order)?;
let m_product: Product = product::find(&m_order.pid).map_err(|_| NevekoError::Product)?;
let price = m_product.price;
let total = price * &m_order.quantity;
let total = price * m_order.quantity;
let wallet_password = String::new();
monero::open_wallet(orid, &wallet_password).await;
// check balance and unlock_time

View file

@ -107,7 +107,7 @@ pub fn modify(p: Json<Product>) -> Result<Product, NevekoError> {
}
let u_prod = Product::update(f_prod, &p);
let db = &DATABASE_LOCK;
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, u_prod.pid.as_bytes())
db::DatabaseEnvironment::delete(&db.env, &db.handle, u_prod.pid.as_bytes())
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
let product = bincode::serialize(&u_prod).unwrap_or_default();
let db = &DATABASE_LOCK;

View file

@ -129,12 +129,12 @@ pub async fn prove_payment(contact: String, txp: &TxProof) -> Result<reqres::Jwp
// cache the jwp for for fts
let db = &DATABASE_LOCK;
let k = format!("{}-{}", crate::FTS_JWP_DB_KEY, &contact);
let _ = db::DatabaseEnvironment::delete(&db.env, &db.handle, k.as_bytes())?;
db::DatabaseEnvironment::delete(&db.env, &db.handle, k.as_bytes())?;
db::write_chunks(
&db.env,
&db.handle,
&k.as_bytes(),
&r.jwp.as_bytes().to_vec(),
k.as_bytes(),
r.jwp.as_bytes(),
)
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
Ok(r)

View file

@ -27,7 +27,7 @@ pub fn create(address: &String) -> Result<User, MdbError> {
let db = &DATABASE_LOCK;
let k = &new_user.uid;
let v = bincode::serialize(&new_user).unwrap_or_default();
let _ = db::write_chunks(&db.env, &db.handle, k.as_bytes(), &v)?;
db::write_chunks(&db.env, &db.handle, k.as_bytes(), &v)?;
Ok(new_user)
}

View file

@ -219,7 +219,7 @@ pub fn get_app_port() -> u16 {
/// i2p http proxy
pub fn get_i2p_http_proxy() -> String {
let args = args::Args::parse();
let advanced_proxy = std::env::var(crate::NEVEKO_I2P_PROXY_HOST).unwrap_or(String::new());
let advanced_proxy = std::env::var(crate::NEVEKO_I2P_PROXY_HOST).unwrap_or_default();
if advanced_proxy.is_empty() {
args.i2p_proxy_host
} else {
@ -514,7 +514,7 @@ pub async fn start_up() -> Result<(), NevekoError> {
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
info!("neveko is starting up");
let _ = reset_i2p_status()?;
reset_i2p_status()?;
warn!("monero multisig is experimental and usage of neveko may lead to loss of funds");
let args = args::Args::parse();
if args.clear_fts {
@ -665,7 +665,7 @@ pub async fn estimate_fee() -> u128 {
let mut count: u64 = 1;
let mut v_fee: Vec<u128> = Vec::new();
let mut r_height: reqres::XmrDaemonGetHeightResponse = Default::default();
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or(String::new());
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or_default();
let remote_set = remote_var == *crate::GUI_SET_REMOTE_NODE;
if remote_set {
let p_height = monero::p_get_height().await;
@ -710,16 +710,13 @@ pub async fn estimate_fee() -> u128 {
let fee_split = v1.remove(1);
let post_fee_split = fee_split.split(",");
let mut v2: Vec<String> = post_fee_split.map(String::from).collect();
let fee: u128 = match v2.remove(0).trim().parse::<u128>() {
Ok(n) => n,
Err(_e) => 0,
};
let fee: u128 = v2.remove(0).trim().parse::<u128>().unwrap_or_default();
v_fee.push(fee);
}
}
count += 1;
}
&v_fee.iter().sum::<u128>() / v_fee.len() as u128
v_fee.iter().sum::<u128>() / v_fee.len() as u128
}
/// Combine the results `estimate_fee()` and `get_balance()` to