clippy patches

This commit is contained in:
kn0sys 2024-09-02 11:21:33 -04:00
parent 45b2563f78
commit a4cd1d3624
No known key found for this signature in database
GPG key ID: 3BDB674C95F103FA
22 changed files with 175 additions and 243 deletions

10
Cargo.lock generated
View file

@ -249,6 +249,15 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -1915,6 +1924,7 @@ dependencies = [
name = "neveko_core"
version = "0.1.2-beta"
dependencies = [
"bincode",
"chrono",
"clap",
"curve25519-dalek",

View file

@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bincode = "1.3.3"
chrono = "0.4.23"
clap = { version = "4.1.4", features = ["derive"] }
curve25519-dalek = "4.1.3"

View file

@ -85,7 +85,7 @@ fn update_expiration(f_auth: &Authorization, address: &String) -> Authorization
&u_auth.aid,
&Authorization::to_db(&u_auth),
);
return u_auth;
u_auth
}
/// Performs the signature verfication against stored auth
@ -130,7 +130,7 @@ pub async fn verify_login(aid: String, uid: String, signature: String) -> Author
&Authorization::to_db(&u_auth),
);
monero::close_wallet(&wallet_name, &wallet_password).await;
return u_auth;
u_auth
} else if f_user.xmr_address != utils::empty_string() {
info!("returning user");
let m_access = verify_access(&address, &signature).await;
@ -174,7 +174,7 @@ async fn verify_access(address: &String, signature: &String) -> bool {
return false;
}
info!("auth verified");
return true;
true
}
/// get the auth expiration command line configuration
@ -185,7 +185,7 @@ fn get_auth_expiration() -> i64 {
fn create_token(address: String, created: i64) -> String {
let jwt_secret_key = utils::get_jwt_secret_key();
let key: Hmac<Sha384> = Hmac::new_from_slice(&jwt_secret_key.as_bytes()).expect("hash");
let key: Hmac<Sha384> = Hmac::new_from_slice(jwt_secret_key.as_bytes()).expect("hash");
let header = Header {
algorithm: AlgorithmType::Hs384,
..Default::default()
@ -202,6 +202,13 @@ fn create_token(address: String, created: i64) -> String {
#[derive(Debug)]
pub struct BearerToken(String);
impl BearerToken {
pub fn get_token(self) -> String {
self.0
}
}
#[derive(Debug)]
pub enum BearerTokenError {
Expired,
@ -232,7 +239,7 @@ impl<'r> FromRequest<'r> for BearerToken {
Some(token) => {
// check validity
let jwt_secret_key = utils::get_jwt_secret_key();
let key: Hmac<Sha384> = Hmac::new_from_slice(&jwt_secret_key.as_bytes()).expect("");
let key: Hmac<Sha384> = Hmac::new_from_slice(jwt_secret_key.as_bytes()).expect("");
let jwt: Result<
Token<jwt::Header, BTreeMap<std::string::String, std::string::String>, _>,
jwt::Error,
@ -250,10 +257,7 @@ impl<'r> FromRequest<'r> for BearerToken {
}
// verify expiration
let now: i64 = chrono::offset::Utc::now().timestamp();
let expire = match claims["expiration"].parse::<i64>() {
Ok(n) => n,
Err(_) => 0,
};
let expire = claims["expiration"].parse::<i64>().unwrap_or(0);
if now > expire {
return Outcome::Failure((
Status::Unauthorized,

View file

@ -84,7 +84,7 @@ pub fn find(cid: &String) -> Contact {
pub fn find_by_i2p_address(i2p_address: &String) -> Contact {
let contacts = find_all();
for c in contacts {
if c.i2p_address == String::from(i2p_address) {
if c.i2p_address == *i2p_address {
return c;
}
}
@ -99,7 +99,7 @@ pub fn delete(cid: &String) {
error!("contact not found");
return;
}
db::Interface::delete(&s.env, &s.handle, &cid);
db::Interface::delete(&s.env, &s.handle, cid);
}
/// All contact lookup
@ -113,7 +113,7 @@ pub fn find_all() -> Vec<Contact> {
return Default::default();
}
let v_cid = r.split(",");
let v: Vec<String> = v_cid.map(|s| String::from(s)).collect();
let v: Vec<String> = v_cid.map(String::from).collect();
let mut contacts: Vec<Contact> = Vec::new();
for id in v {
if id != utils::empty_string() {
@ -168,7 +168,7 @@ pub fn exists(from: &String) -> bool {
for c in all {
addresses.push(c.i2p_address);
}
return addresses.contains(from);
addresses.contains(from)
}
/// Get invoice for jwp creation

View file

@ -44,7 +44,7 @@ impl Interface {
// increase map size for writing the multisig txset
.map_size(crate::LMDB_MAPSIZE)
.open(format!("{}/{}", file_path, env_str), 0o777)
.expect(&format!("could not open LMDB at {}", file_path));
.unwrap_or_else(|_| panic!("could not open LMDB at {}", file_path));
let handle = env.get_default_db(DbFlags::empty()).unwrap();
Interface { env, handle }
}
@ -66,16 +66,13 @@ impl Interface {
let txn = e.new_transaction().unwrap();
{
// get a database bound to this transaction
let db = txn.bind(&h);
let pair = vec![(k, v)];
let db = txn.bind(h);
let pair = [(k, v)];
for &(key, value) in pair.iter() {
db.set(&key, &value).unwrap();
}
}
match txn.commit() {
Err(_) => error!("failed to commit!"),
Ok(_) => (),
}
if txn.commit().is_err() { error!("failed to commit!") }
}
pub async fn async_write(e: &Environment, h: &DbHandle, k: &str, v: &str) {
info!("excecuting lmdb async write");
@ -95,8 +92,8 @@ impl Interface {
return utils::empty_string();
}
let reader = e.get_reader().unwrap();
let db = reader.bind(&h);
let value = db.get::<&str>(&k).unwrap_or_else(|_| "");
let db = reader.bind(h);
let value = db.get::<&str>(&k).unwrap_or("");
let r = String::from(value);
{
if r == utils::empty_string() {
@ -125,13 +122,10 @@ impl Interface {
let txn = e.new_transaction().unwrap();
{
// get a database bound to this transaction
let db = txn.bind(&h);
let db = txn.bind(h);
db.del(&k).unwrap_or_else(|_| error!("failed to delete"));
}
match txn.commit() {
Err(_) => error!("failed to commit!"),
Ok(_) => (),
}
if txn.commit().is_err() { error!("failed to commit!") }
}
pub async fn async_delete(e: &Environment, h: &DbHandle, k: &str) {
info!("excecuting lmdb async delete");

View file

@ -70,7 +70,7 @@ pub fn find_all() -> Vec<Dispute> {
error!("dispute index not found");
}
let d_v_did = d_r.split(",");
let d_v: Vec<String> = d_v_did.map(|s| String::from(s)).collect();
let d_v: Vec<String> = d_v_did.map(String::from).collect();
let mut disputes: Vec<Dispute> = Vec::new();
for o in d_v {
let dispute: Dispute = find(&o);
@ -112,7 +112,7 @@ pub async fn settle_dispute() {
info!("dispute index not found");
}
let v_mid = r.split(",");
let d_vec: Vec<String> = v_mid.map(|s| String::from(s)).collect();
let d_vec: Vec<String> = v_mid.map(String::from).collect();
debug!("dispute contents: {:#?}", d_vec);
let cleared = is_dispute_clear(r);
if cleared {
@ -127,7 +127,7 @@ pub async fn settle_dispute() {
let now = chrono::offset::Utc::now().timestamp();
let settle_date = dispute.created + crate::DISPUTE_AUTO_SETTLE as i64;
if settle_date > now {
let wallet_name = String::from(dispute.orid);
let wallet_name = dispute.orid;
let wallet_password = utils::empty_string();
monero::open_wallet(&wallet_name, &wallet_password).await;
let signed = monero::sign_multisig(dispute.tx_set).await;
@ -147,15 +147,15 @@ pub async fn settle_dispute() {
fn is_dispute_clear(r: String) -> bool {
let v_mid = r.split(",");
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
let v: Vec<String> = v_mid.map(String::from).collect();
debug!("dispute index contents: {:#?}", v);
let limit = v.len() <= 1;
if !limit {
return v.len() >= 2
v.len() >= 2
&& v[v.len() - 1] == utils::empty_string()
&& v[0] == utils::empty_string();
&& v[0] == utils::empty_string()
} else {
return limit;
limit
}
}

View file

@ -49,17 +49,11 @@ struct Tunnel {
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Default)]
struct Tunnels {
tunnels: Vec<Tunnel>,
}
impl Default for Tunnels {
fn default() -> Self {
Tunnels {
tunnels: Vec::new(),
}
}
}
/// Looks for the `tunnels-config.json` at /home/$USER/.i2p-zero/config/
///
@ -77,7 +71,7 @@ async fn find_tunnels() {
let proxy_port = get_i2p_proxy_port();
let socks_proxy_port = get_i2p_socks_proxy_port();
let has_http_tunnel = contents.contains(&proxy_port);
let has_socks_proxy_tunnel = contents.contains(&format!("{}", &socks_proxy_port));
let has_socks_proxy_tunnel = contents.contains(&socks_proxy_port.to_string());
let has_anon_inbound_tunnel = contents.contains(&format!("{}", args.anon_inbound_port));
if !has_app_tunnel || !has_http_tunnel || !has_anon_inbound_tunnel || !has_socks_proxy_tunnel {
tokio::time::sleep(Duration::new(120, 0)).await;
@ -112,7 +106,7 @@ pub async fn start() {
Ok(child) => debug!("{:?}", child.stdout),
_ => {
warn!("i2p-zero not installed, manual tunnel creation required");
()
}
}
find_tunnels().await;
@ -150,7 +144,7 @@ fn create_socks_proxy_tunnel() {
let args = args::Args::parse();
let path = args.i2p_zero_dir;
let output = Command::new(format!("{}/router/bin/tunnel-control.sh", path))
.args(["socks.create", &format!("{}", get_i2p_socks_proxy_port())])
.args(["socks.create", &get_i2p_socks_proxy_port().to_string()])
.spawn()
.expect("i2p-zero failed to create a socks proxy tunnel");
debug!("{:?}", output.stdout);
@ -176,18 +170,18 @@ fn create_anon_inbound_tunnel() {
fn get_i2p_proxy_port() -> String {
let proxy_host = utils::get_i2p_http_proxy();
let values = proxy_host.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let port = v.remove(2);
port
let mut v: Vec<String> = values.map(String::from).collect();
v.remove(2)
}
/// Extract i2p socks port from command line arg
fn get_i2p_socks_proxy_port() -> String {
let proxy_host = utils::get_i2p_wallet_proxy_host();
let values = proxy_host.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let port = v.remove(2);
port
let mut v: Vec<String> = values.map(String::from).collect();
v.remove(2)
}
/// Create the http proxy if it doesn't exist
@ -216,7 +210,7 @@ pub fn get_destination(port: Option<u16>) -> String {
let args = args::Args::parse();
let is_advanced_mode =
std::env::var(crate::NEVEKO_I2P_ADVANCED_MODE).unwrap_or(utils::empty_string());
if args.i2p_advanced || is_advanced_mode == String::from("1") {
if args.i2p_advanced || is_advanced_mode == *"1" {
let advanced_tunnel =
std::env::var(crate::NEVEKO_I2P_TUNNELS_JSON).unwrap_or(utils::empty_string());
let manual_tunnel = if advanced_tunnel == utils::empty_string() {
@ -232,7 +226,7 @@ pub fn get_destination(port: Option<u16>) -> String {
_ => utils::empty_string(),
};
if contents != utils::empty_string() {
let input = format!(r#"{contents}"#);
let input = contents.to_string();
let j: Tunnels = serde_json::from_str(&input).unwrap_or(Default::default());
let mut destination: String = utils::empty_string();
let tunnels: Vec<Tunnel> = j.tunnels;

View file

@ -69,7 +69,7 @@ pub const I2P_ZERO_RELEASE_VERSION: &str = "v1.21";
pub const I2P_ZERO_RELEASH_HASH: &str =
"14f34052ad6abb0c24b048816b0ea86b696ae350dd139dd1e90a67ca88e1d07a";
pub const LMDB_MAPSIZE: u64 = 1 * 1024 * 1024 * 1024;
pub const LMDB_MAPSIZE: u64 = 1024 * 1024 * 1024;
pub const I2P_CONNECTIVITY_CHECK_INTERVAL: u32 = 600000;
pub const FTS_RETRY_INTERVAL: u32 = 60000;
/// There is a one week grace period for manual intervention of disputes

View file

@ -133,10 +133,10 @@ pub async fn rx(m: Json<Message>) {
/// Parse the multisig message type and info
async fn parse_multisig_message(mid: String) -> MultisigMessageData {
let d: reqres::DecipheredMessageBody = decipher_body(mid).await;
let mut bytes = hex::decode(d.body.into_bytes()).unwrap_or(Vec::new());
let mut bytes = hex::decode(d.body.into_bytes()).unwrap_or_default();
let decoded = String::from_utf8(bytes).unwrap_or(utils::empty_string());
let values = decoded.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
if v.len() != VALID_MSIG_MSG_LENGTH {
error!("invalid msig message length");
return Default::default();
@ -247,7 +247,7 @@ pub fn find_all() -> Vec<Message> {
error!("message index not found");
}
let i_v_mid = i_r.split(",");
let i_v: Vec<String> = i_v_mid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_mid.map(String::from).collect();
let mut messages: Vec<Message> = Vec::new();
for m in i_v {
let message: Message = find(&m);
@ -262,7 +262,7 @@ pub fn find_all() -> Vec<Message> {
error!("message index not found");
}
let o_v_mid = o_r.split(",");
let o_v: Vec<String> = o_v_mid.map(|s| String::from(s)).collect();
let o_v: Vec<String> = o_v_mid.map(String::from).collect();
for m in o_v {
let message: Message = find(&m);
if message.mid != utils::empty_string() {
@ -286,7 +286,7 @@ async fn send_message(out: &Message, jwp: &str, m_type: MessageType) -> Result<(
.await
.unwrap_or(false);
if is_online {
return match client?
match client?
.post(url)
.header("proof", jwp)
.json(&out)
@ -298,7 +298,7 @@ async fn send_message(out: &Message, jwp: &str, m_type: MessageType) -> Result<(
debug!("send response: {:?}", status.as_str());
if status == StatusCode::OK || status == StatusCode::PAYMENT_REQUIRED {
remove_from_fts(String::from(&out.mid));
return Ok(());
Ok(())
} else {
Ok(())
}
@ -307,7 +307,7 @@ async fn send_message(out: &Message, jwp: &str, m_type: MessageType) -> Result<(
error!("failed to send message due to: {:?}", e);
Ok(())
}
};
}
} else {
send_to_retry(String::from(&out.mid)).await;
Ok(())
@ -385,7 +385,7 @@ async fn send_to_retry(mid: String) {
// restart fts if not empty
let r = db::Interface::read(&s.env, &s.handle, &String::from(list_key));
let v_mid = r.split(",");
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
let v: Vec<String> = v_mid.map(String::from).collect();
debug!("fts contents: {:#?}", v);
let cleared = is_fts_clear(r);
if !cleared {
@ -440,7 +440,7 @@ pub async fn retry_fts() {
break; // terminate fts if no message to send
}
let v_mid = r.split(",");
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
let v: Vec<String> = v_mid.map(String::from).collect();
debug!("fts contents: {:#?}", v);
let cleared = is_fts_clear(r);
if cleared {
@ -482,15 +482,15 @@ fn validate_message(j: &Json<Message>) -> bool {
fn is_fts_clear(r: String) -> bool {
let v_mid = r.split(",");
let v: Vec<String> = v_mid.map(|s| String::from(s)).collect();
let v: Vec<String> = v_mid.map(String::from).collect();
debug!("fts contents: {:#?}", v);
let limit = v.len() <= 1;
if !limit {
return v.len() >= 2
v.len() >= 2
&& v[v.len() - 1] == utils::empty_string()
&& v[0] == utils::empty_string();
&& v[0] == utils::empty_string()
} else {
return limit;
limit
}
}
@ -516,7 +516,7 @@ pub async fn send_prepare_info(orid: &String, contact: &String) {
..Default::default()
};
let j_message: Json<Message> = utils::message_to_json(&message);
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
create(j_message, jwp, MessageType::Multisig).await;
}
@ -539,7 +539,7 @@ pub async fn send_make_info(orid: &String, contact: &String, info: Vec<String>)
..Default::default()
};
let j_message: Json<Message> = utils::message_to_json(&message);
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
create(j_message, jwp, MessageType::Multisig).await;
}
@ -576,7 +576,7 @@ pub async fn send_exchange_info(
..Default::default()
};
let j_message: Json<Message> = utils::message_to_json(&message);
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
create(j_message, jwp, MessageType::Multisig).await;
}
@ -599,7 +599,7 @@ pub async fn send_export_info(orid: &String, contact: &String) {
..Default::default()
};
let j_message: Json<Message> = utils::message_to_json(&message);
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
create(j_message, jwp, MessageType::Multisig).await;
}
@ -613,7 +613,7 @@ pub async fn send_import_info(orid: &String, info: &Vec<String>) {
let wallet_password = utils::empty_string();
monero::open_wallet(&wallet_name, &wallet_password).await;
let pre_import = monero::import_multisig_info(info.to_vec()).await;
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
if pre_import.result.n_outputs == 0 {
error!("unable to import multisig info for order: {}", orid);
return;

View file

@ -40,7 +40,7 @@ impl Authorization {
}
pub fn from_db(k: String, v: String) -> Authorization {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let created_str = v.remove(0);
let created = match created_str.parse::<i64>() {
Ok(n) => n,
@ -117,7 +117,7 @@ impl Contact {
}
pub fn from_db(k: String, v: String) -> Contact {
let values = v.split("!");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let nmpk = v.remove(0);
let i2p_address = v.remove(0);
let is_vendor = match v.remove(0).parse::<bool>() {
@ -165,7 +165,7 @@ impl Message {
}
pub fn from_db(k: String, v: String) -> Message {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let uid = v.remove(0);
let body = v.remove(0);
let created_str = v.remove(0);
@ -210,7 +210,7 @@ impl User {
}
pub fn from_db(k: String, v: String) -> User {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let name = v.remove(0);
let xmr_address = v.remove(0);
User {
@ -264,22 +264,13 @@ impl Product {
}
pub fn from_db(k: String, v: String) -> Product {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let description = v.remove(0);
let image = hex::decode(v.remove(0)).unwrap_or(Vec::new());
let in_stock = match v.remove(0).parse::<bool>() {
Ok(b) => b,
Err(_) => false,
};
let image = hex::decode(v.remove(0)).unwrap_or_default();
let in_stock = v.remove(0).parse::<bool>().unwrap_or(false);
let name = v.remove(0);
let price = match v.remove(0).parse::<u128>() {
Ok(p) => p,
Err(_) => 0,
};
let qty = match v.remove(0).parse::<u128>() {
Ok(q) => q,
Err(_) => 0,
};
let price = v.remove(0).parse::<u128>().unwrap_or(0);
let qty = v.remove(0).parse::<u128>().unwrap_or(0);
Product {
pid: k,
description,
@ -294,7 +285,7 @@ impl Product {
Product {
pid: p.pid,
description: String::from(&jp.description),
image: jp.image.iter().cloned().collect(),
image: jp.image.to_vec(),
in_stock: jp.in_stock,
name: String::from(&jp.name),
price: jp.price,
@ -413,7 +404,7 @@ impl Order {
}
pub fn from_db(k: String, v: String) -> Order {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let orid = k;
let cid = v.remove(0);
let pid = v.remove(0);
@ -423,14 +414,8 @@ impl Order {
let cust_msig_make = v.remove(0);
let cust_msig_prepare = v.remove(0);
let cust_msig_txset = v.remove(0);
let date = match v.remove(0).parse::<i64>() {
Ok(d) => d,
Err(_) => 0,
};
let deliver_date = match v.remove(0).parse::<i64>() {
Ok(d) => d,
Err(_) => 0,
};
let date = v.remove(0).parse::<i64>().unwrap_or(0);
let deliver_date = v.remove(0).parse::<i64>().unwrap_or(0);
let hash = v.remove(0);
let adjudicator_msig_make = v.remove(0);
let adjudicator_msig_prepare = v.remove(0);
@ -438,16 +423,10 @@ impl Order {
let adjudicator_kex_2 = v.remove(0);
let adjudicator_kex_3 = v.remove(0);
let ship_address = v.remove(0);
let ship_date = match v.remove(0).parse::<i64>() {
Ok(d) => d,
Err(_) => 0,
};
let ship_date = v.remove(0).parse::<i64>().unwrap_or(0);
let subaddress = v.remove(0);
let status = v.remove(0);
let quantity = match v.remove(0).parse::<u128>() {
Ok(d) => d,
Err(_) => 0,
};
let quantity = v.remove(0).parse::<u128>().unwrap_or(0);
let vend_kex_1 = v.remove(0);
let vend_kex_2 = v.remove(0);
let vend_kex_3 = v.remove(0);
@ -548,11 +527,8 @@ impl Dispute {
}
pub fn from_db(k: String, v: String) -> Dispute {
let values = v.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let created = match v.remove(0).parse::<i64>() {
Ok(t) => t,
Err(_) => 0,
};
let mut v: Vec<String> = values.map(String::from).collect();
let created = v.remove(0).parse::<i64>().unwrap_or(0);
let orid = v.remove(0);
let tx_set = v.remove(0);
Dispute {

View file

@ -17,11 +17,7 @@ use log::{
};
use std::{
error::Error,
io::Write,
process::{
Command,
Stdio,
},
process::Command,
};
use lazy_static::lazy_static;
@ -184,7 +180,7 @@ pub fn start_daemon() {
let mut socks_proxy_host = utils::get_i2p_wallet_proxy_host();
if socks_proxy_host.contains("http://") {
let values = socks_proxy_host.split("http://");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
socks_proxy_host = v.remove(1);
};
let tx_proxy = format!("i2p,{}", socks_proxy_host);
@ -241,7 +237,7 @@ pub fn start_rpc() {
let mut proxy_host = utils::get_i2p_wallet_proxy_host();
if proxy_host.contains("http://") {
let values = proxy_host.split("http://");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
proxy_host = v.remove(1);
}
let mut args = vec![
@ -281,9 +277,9 @@ pub fn start_rpc() {
fn get_rpc_port() -> String {
let args = args::Args::parse();
let rpc = String::from(args.monero_rpc_host);
let rpc = args.monero_rpc_host;
let values = rpc.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let port = v.remove(2);
debug!("monero-wallet-rpc port: {}", port);
port
@ -291,28 +287,22 @@ fn get_rpc_port() -> String {
pub fn get_daemon_port() -> u16 {
let args = args::Args::parse();
let rpc = String::from(args.monero_rpc_daemon);
let rpc = args.monero_rpc_daemon;
let values = rpc.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let port = v.remove(2);
debug!("monerod port: {}", port);
match port.parse::<u16>() {
Ok(p) => p,
Err(_) => 0,
}
port.parse::<u16>().unwrap_or(0)
}
pub fn get_tx_proxy_port() -> u16 {
let args = args::Args::parse();
let rpc = String::from(args.i2p_socks_proxy_host);
let rpc = args.i2p_socks_proxy_host;
let values = rpc.split(":");
let mut v: Vec<String> = values.map(|s| String::from(s)).collect();
let mut v: Vec<String> = values.map(String::from).collect();
let port = v.remove(2);
debug!("i2p socks port: {}", port);
match port.parse::<u16>() {
Ok(p) => p,
Err(_) => 0,
}
port.parse::<u16>().unwrap_or(0)
}
pub fn get_anon_inbound_port() -> u16 {
@ -323,7 +313,7 @@ pub fn get_anon_inbound_port() -> u16 {
/// Get monero rpc host from command line argument
fn get_blockchain_dir() -> String {
let args = args::Args::parse();
String::from(args.monero_blockchain_dir)
args.monero_blockchain_dir
}
/// Get monero download location
@ -338,7 +328,7 @@ fn get_rpc_host() -> String {
let args = args::Args::parse();
let gui_host = std::env::var(crate::MONERO_WALLET_RPC_HOST).unwrap_or(utils::empty_string());
let rpc = if gui_host == utils::empty_string() {
String::from(args.monero_rpc_host)
args.monero_rpc_host
} else {
gui_host
};
@ -348,8 +338,8 @@ fn get_rpc_host() -> String {
/// Get creds from the `--monero-rpc-daemon` cli arg
fn get_rpc_creds() -> RpcLogin {
let args = args::Args::parse();
let username = String::from(args.monero_rpc_username);
let credential = String::from(args.monero_rpc_cred);
let username = args.monero_rpc_username;
let credential = args.monero_rpc_cred;
RpcLogin {
username,
credential,
@ -360,7 +350,7 @@ fn get_rpc_daemon() -> String {
let args = args::Args::parse();
let gui_host = std::env::var(crate::MONERO_DAEMON_HOST).unwrap_or(utils::empty_string());
if gui_host == utils::empty_string() {
String::from(args.monero_rpc_daemon)
args.monero_rpc_daemon
} else {
gui_host
}
@ -396,7 +386,7 @@ pub async fn get_version() -> reqres::XmrRpcVersionResponse {
}
/// Helper function for checking xmr rpc online during app startup
pub async fn check_rpc_connection() -> () {
pub async fn check_rpc_connection() {
let res: reqres::XmrRpcVersionResponse = get_version().await;
if res.result.version == INVALID_VERSION {
error!("failed to connect to monero-wallet-rpc");
@ -531,10 +521,10 @@ fn update_wallet_lock(filename: &String, closing: bool) -> bool {
}
if !closing {
*IS_WALLET_BUSY.lock().unwrap() = true;
return true;
true
} else {
*IS_WALLET_BUSY.lock().unwrap() = false;
return true;
true
}
}
@ -576,7 +566,7 @@ pub async fn open_wallet(filename: &String, password: &String) -> bool {
if r.contains("-1") {
return false;
}
return true;
true
}
_ => false,
}
@ -615,10 +605,7 @@ pub async fn close_wallet(filename: &String, password: &String) -> bool {
// The result from wallet operation is empty
let res = response.text().await;
debug!("{} response: {:?}", RpcFields::Close.value(), res);
match res {
Ok(_) => true,
_ => false,
}
res.is_ok()
}
Err(_) => false,
}
@ -662,7 +649,7 @@ pub async fn change_wallet_password(new_password: &String) -> bool {
if r.contains("-1") {
return false;
}
return true;
true
}
_ => false,
}

View file

@ -54,7 +54,7 @@ fn curve_l_as_big_int() -> BigInt {
}
fn big_int_to_string(b: &BigInt) -> String {
String::from(String::from_utf8(b.to_signed_bytes_le()).unwrap_or_default())
String::from_utf8(b.to_signed_bytes_le()).unwrap_or_default()
}
/// Hash string input to scalar
@ -110,8 +110,8 @@ pub async fn generate_neveko_message_keys() -> NevekoMessageKeys {
let point_nmpk = EdwardsPoint::mul_base(&scalar_nmsk);
let nmsk = *scalar_nmsk.as_bytes();
let nmpk: [u8; 32] = *point_nmpk.compress().as_bytes();
let hex_nmpk = hex::encode(&nmpk);
let hex_nmsk = hex::encode(&nmsk);
let hex_nmpk = hex::encode(nmpk);
let hex_nmsk = hex::encode(nmsk);
NevekoMessageKeys {
nmpk,
nmsk,
@ -143,15 +143,15 @@ pub async fn cipher(hex_nmpk: &String, message: String, encipher: Option<String>
// x = m + h or x = m - h'
let h = hash_to_scalar(vec![&ss_hex[..]]);
let h_bi = BigInt::from_bytes_le(Sign::Plus, h.as_bytes());
if unwrap_encipher == String::from(ENCIPHER) {
let msg_bi = BigInt::from_bytes_le(Sign::Plus, &message.as_bytes());
if unwrap_encipher == *ENCIPHER {
let msg_bi = BigInt::from_bytes_le(Sign::Plus, message.as_bytes());
let x = msg_bi + h_bi;
return hex::encode(x.to_bytes_le().1);
hex::encode(x.to_bytes_le().1)
} else {
let msg_bi = BigInt::from_bytes_le(Sign::Plus, &hex::decode(&message).unwrap_or_default());
let x = msg_bi - h_bi;
return big_int_to_string(&x);
};
big_int_to_string(&x)
}
}
// Tests

View file

@ -98,7 +98,7 @@ pub fn backup(order: &Order) {
let s = db::Interface::open();
let k = &order.orid;
db::Interface::delete(&s.env, &s.handle, k);
db::Interface::write(&s.env, &s.handle, k, &Order::to_db(&order));
db::Interface::write(&s.env, &s.handle, k, &Order::to_db(order));
// in order to retrieve all orders, write keys to with col
let list_key = crate::CUSTOMER_ORDER_LIST_DB_KEY;
let r = db::Interface::read(&s.env, &s.handle, &String::from(list_key));
@ -135,7 +135,7 @@ pub fn find_all() -> Vec<Order> {
error!("order index not found");
}
let i_v_oid = i_r.split(",");
let i_v: Vec<String> = i_v_oid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_oid.map(String::from).collect();
let mut orders: Vec<Order> = Vec::new();
for o in i_v {
let order: Order = find(&o);
@ -155,7 +155,7 @@ pub fn find_all_backup() -> Vec<Order> {
error!("customer order index not found");
}
let i_v_oid = i_r.split(",");
let i_v: Vec<String> = i_v_oid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_oid.map(String::from).collect();
let mut orders: Vec<Order> = Vec::new();
for o in i_v {
let order: Order = find(&o);
@ -179,7 +179,7 @@ pub async fn find_all_customer_orders(cid: String) -> Vec<Order> {
error!("order index not found");
}
let i_v_oid = i_r.split(",");
let i_v: Vec<String> = i_v_oid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_oid.map(String::from).collect();
let mut orders: Vec<Order> = Vec::new();
for o in i_v {
let order: Order = find(&o);
@ -200,7 +200,7 @@ pub fn find_all_vendor_orders() -> Vec<Order> {
error!("order index not found");
}
let i_v_oid = i_r.split(",");
let i_v: Vec<String> = i_v_oid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_oid.map(String::from).collect();
let mut orders: Vec<Order> = Vec::new();
let vendor_b32: String = i2p::get_destination(None);
for o in i_v {
@ -229,7 +229,7 @@ pub fn modify(o: Json<Order>) -> Order {
let s = db::Interface::open();
db::Interface::delete(&s.env, &s.handle, &u_order.orid);
db::Interface::write(&s.env, &s.handle, &u_order.orid, &Order::to_db(&u_order));
return u_order;
u_order
}
/// Sign and submit multisig
@ -239,12 +239,12 @@ pub async fn sign_and_submit_multisig(
) -> reqres::XmrRpcSubmitMultisigResponse {
info!("signing and submitting multisig");
let wallet_password = utils::empty_string();
monero::open_wallet(&orid, &wallet_password).await;
monero::open_wallet(orid, &wallet_password).await;
let r_sign: reqres::XmrRpcSignMultisigResponse =
monero::sign_multisig(String::from(tx_data_hex)).await;
let r_submit: reqres::XmrRpcSubmitMultisigResponse =
monero::submit_multisig(r_sign.result.tx_data_hex).await;
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
if r_submit.result.tx_hash_list.is_empty() {
error!("unable to submit payment for order: {}", orid);
}
@ -262,7 +262,7 @@ pub async fn sign_and_submit_multisig(
pub async fn secure_retrieval(orid: &String, signature: &String) -> Order {
info!("secure order retrieval for {}", orid);
// get customer address for NEVEKO NOT order wallet
let m_order: Order = find(&orid);
let m_order: Order = find(orid);
let mut xmr_address: String = String::new();
let a_customers: Vec<Contact> = contact::find_all();
for customer in a_customers {
@ -292,7 +292,7 @@ pub async fn secure_retrieval(orid: &String, signature: &String) -> Order {
pub async fn cancel_order(orid: &String, signature: &String) -> Order {
info!("cancel order {}", orid);
// get customer address for NEVEKO NOT order wallet
let mut m_order: Order = find(&orid);
let mut m_order: Order = find(orid);
let mut xmr_address: String = String::new();
let a_customers: Vec<Contact> = contact::find_all();
for customer in a_customers {
@ -316,7 +316,7 @@ pub async fn cancel_order(orid: &String, signature: &String) -> Order {
// update the order status and send to customer
m_order.status = order::StatusType::Cancelled.value();
order::modify(Json(m_order));
order::find(&orid)
order::find(orid)
}
/// Check for import multisig info, validate block time and that the
@ -335,10 +335,10 @@ pub async fn validate_order_for_ship(orid: &String) -> reqres::FinalizeOrderResp
let price = m_product.price;
let total = price * &m_order.quantity;
let wallet_password = utils::empty_string();
monero::open_wallet(&orid, &wallet_password).await;
monero::open_wallet(orid, &wallet_password).await;
// check balance and unlock_time
let r_balance = monero::get_balance().await;
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
// update the order status to multisig complete
let ready_to_ship: bool = r_balance.result.balance >= total as u128
&& r_balance.result.blocks_to_unlock < monero::LockTimeLimit::Blocks.value();
@ -421,11 +421,11 @@ pub async fn upload_delivery_info(
}
// get draft payment txset
let wallet_password = utils::empty_string();
monero::open_wallet(&orid, &wallet_password).await;
monero::open_wallet(orid, &wallet_password).await;
monero::refresh().await;
let sweep: reqres::XmrRpcSweepAllResponse =
monero::sweep_all(String::from(&lookup.subaddress)).await;
monero::close_wallet(&orid, &wallet_password).await;
monero::close_wallet(orid, &wallet_password).await;
if sweep.result.multisig_txset.is_empty() {
error!("unable to create draft txset");
return Default::default();
@ -439,7 +439,7 @@ pub async fn upload_delivery_info(
// order
let s = db::Interface::async_open().await;
let k = String::from(crate::DELIVERY_INFO_DB_KEY);
db::Interface::async_write(&s.env, &s.handle, &k, &hex::encode(&delivery_info)).await;
db::Interface::async_write(&s.env, &s.handle, &k, &hex::encode(delivery_info)).await;
modify(Json(m_order));
// trigger nasr, this will cause the customer's neveko instance to request the
// txset
@ -560,7 +560,7 @@ pub async fn trigger_finalize_request(
return Default::default();
}
let unwrap: reqres::FinalizeOrderResponse = finalize.unwrap();
let mut m_order: Order = order::find(&orid);
let mut m_order: Order = order::find(orid);
m_order.status = order::StatusType::Delivered.value();
backup(&m_order);
unwrap
@ -578,7 +578,7 @@ pub async fn d_trigger_finalize_request(
let jwp = db::Interface::async_read(&s.env, &s.handle, &k).await;
info!("executing d_trigger_finalize_request");
// request finalize if the order status is shipped
let order: Order = order::find(&orid);
let order: Order = order::find(orid);
if order.status != order::StatusType::Shipped.value() {
let trigger = trigger_finalize_request(contact, &jwp, orid).await;
if trigger.vendor_update_success {
@ -808,7 +808,7 @@ pub async fn d_trigger_cancel_request(contact: &String, orid: &String) -> Order
let jwp = db::Interface::async_read(&s.env, &s.handle, &k).await;
info!("executing d_trigger_cancel_request");
// request cancel if the order status is not MultisigComplete
let order: Order = order::find(&orid);
let order: Order = order::find(orid);
if order.status != order::StatusType::MulitsigComplete.value() {
let trigger = trigger_cancel_request(contact, &jwp, orid).await;
if trigger.status == order::StatusType::Cancelled.value() {
@ -824,5 +824,5 @@ pub async fn init_adjudicator_wallet(orid: &String) {
if !m_wallet {
log::error!("failed to create adjudicator wallet");
}
monero::close_wallet(&orid, &password).await;
monero::close_wallet(orid, &password).await;
}

View file

@ -23,7 +23,7 @@ pub fn create(d: Json<Product>) -> Product {
let new_product = Product {
pid: String::from(&pid),
description: String::from(&d.description),
image: d.image.iter().cloned().collect(),
image: d.image.to_vec(),
in_stock: d.in_stock,
name: String::from(&d.name),
price: d.price,
@ -68,7 +68,7 @@ pub fn find_all() -> Vec<Product> {
error!("product index not found");
}
let i_v_pid = i_r.split(",");
let i_v: Vec<String> = i_v_pid.map(|s| String::from(s)).collect();
let i_v: Vec<String> = i_v_pid.map(String::from).collect();
let mut products: Vec<Product> = Vec::new();
for p in i_v {
let mut product: Product = find(&p);
@ -94,7 +94,7 @@ pub fn modify(p: Json<Product>) -> Product {
let s = db::Interface::open();
db::Interface::delete(&s.env, &s.handle, &u_prod.pid);
db::Interface::write(&s.env, &s.handle, &u_prod.pid, &Product::to_db(&u_prod));
return u_prod;
u_prod
}
/// check product field lengths to prevent db spam

View file

@ -94,7 +94,7 @@ pub async fn create_jwp(proof: &TxProof) -> String {
return utils::empty_string();
}
let jwp_secret_key = utils::get_jwp_secret_key();
let key: Hmac<Sha512> = Hmac::new_from_slice(&jwp_secret_key.as_bytes()).expect("hash");
let key: Hmac<Sha512> = Hmac::new_from_slice(jwp_secret_key.as_bytes()).expect("hash");
let header = Header {
algorithm: AlgorithmType::Hs512,
..Default::default()
@ -193,7 +193,7 @@ impl<'r> FromRequest<'r> for PaymentProof {
Some(proof) => {
// check validity of address, payment amount and tx confirmations
let jwp_secret_key = utils::get_jwp_secret_key();
let key: Hmac<Sha512> = Hmac::new_from_slice(&jwp_secret_key.as_bytes()).expect("");
let key: Hmac<Sha512> = Hmac::new_from_slice(jwp_secret_key.as_bytes()).expect("");
let jwp: Result<
Token<jwt::Header, BTreeMap<std::string::String, std::string::String>, _>,
jwt::Error,
@ -301,5 +301,5 @@ async fn validate_subaddress(subaddress: &String) -> bool {
for s_address in all_address {
address_list.push(s_address.address);
}
return address_list.contains(&subaddress);
address_list.contains(subaddress)
}

View file

@ -473,16 +473,12 @@ pub struct XmrRpcGetTxProofResult {
}
#[derive(Deserialize, Serialize, Debug)]
#[derive(Default)]
pub struct SubAddressIndex {
pub major: u64,
pub minor: u64,
}
impl Default for SubAddressIndex {
fn default() -> Self {
SubAddressIndex { major: 0, minor: 0 }
}
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Transfer {
@ -809,17 +805,11 @@ impl Default for XmrDaemonGetBlockResponse {
/// Only extract the json string. TODO(c2m): map to a struct
#[derive(Serialize, Deserialize, Debug)]
#[derive(Default)]
pub struct XmrDaemonGetTransactionsResponse {
pub txs_as_json: Vec<String>,
}
impl Default for XmrDaemonGetTransactionsResponse {
fn default() -> Self {
XmrDaemonGetTransactionsResponse {
txs_as_json: Vec::new(),
}
}
}
#[derive(Deserialize, Debug)]
pub struct XmrRpcSignResponse {
@ -1380,12 +1370,8 @@ impl Default for FinalizeOrderResponse {
/// Response for the vendor mode
#[derive(Serialize, Deserialize, Debug)]
#[serde(crate = "rocket::serde")]
#[derive(Default)]
pub struct VendorModeResponse {
pub mode: bool,
}
impl Default for VendorModeResponse {
fn default() -> Self {
VendorModeResponse { mode: false }
}
}

View file

@ -68,19 +68,12 @@ enum ExternalSoftware {
}
/// Handles the state for the installation manager popup
#[derive(Default)]
pub struct Installations {
pub xmr: bool,
pub i2p_zero: bool,
}
impl Default for Installations {
fn default() -> Self {
Installations {
xmr: false,
i2p_zero: false,
}
}
}
/// Handles the state for the connection manager popup
pub struct Connections {
@ -191,16 +184,16 @@ pub fn start_core(conn: &Connections) {
];
if conn.is_i2p_advanced {
// set the i2p proxy host for advanced user re-use
std::env::set_var(crate::NEVEKO_I2P_PROXY_HOST, &conn.i2p_proxy_host.clone());
std::env::set_var(crate::NEVEKO_I2P_PROXY_HOST, conn.i2p_proxy_host.clone());
std::env::set_var(
crate::NEVEKO_I2P_TUNNELS_JSON,
&conn.i2p_tunnels_json.clone(),
conn.i2p_tunnels_json.clone(),
);
std::env::set_var(crate::NEVEKO_I2P_ADVANCED_MODE, String::from("1"));
}
if conn.is_remote_node {
std::env::set_var(crate::MONERO_DAEMON_HOST, &conn.daemon_host.clone());
std::env::set_var(crate::MONERO_WALLET_RPC_HOST, &conn.rpc_host.clone());
std::env::set_var(crate::MONERO_DAEMON_HOST, conn.daemon_host.clone());
std::env::set_var(crate::MONERO_WALLET_RPC_HOST, conn.rpc_host.clone());
std::env::set_var(crate::GUI_REMOTE_NODE, crate::GUI_SET_REMOTE_NODE)
}
let output = std::process::Command::new("./neveko")
@ -230,11 +223,11 @@ pub fn generate_rnd() -> String {
/// Helper for separation of dev and prod concerns
pub fn get_release_env() -> ReleaseEnvironment {
let args = args::Args::parse();
let env = String::from(args.release_env);
let env = args.release_env;
if env == "prod" {
return ReleaseEnvironment::Production;
ReleaseEnvironment::Production
} else {
return ReleaseEnvironment::Development;
ReleaseEnvironment::Development
}
}
@ -327,7 +320,7 @@ pub fn product_to_json(m: &models::Product) -> Json<models::Product> {
let r_product: models::Product = models::Product {
pid: String::from(&m.pid),
description: String::from(&m.description),
image: m.image.iter().cloned().collect(),
image: m.image.to_vec(),
in_stock: m.in_stock,
name: String::from(&m.name),
price: m.price,
@ -675,7 +668,7 @@ fn validate_installation_hash(sw: ExternalSoftware, filename: &String) -> bool {
.expect("hash validation failed");
let str_sha = String::from_utf8(sha_output.stdout).unwrap();
let split1 = str_sha.split(" ");
let mut v: Vec<String> = split1.map(|s| String::from(s)).collect();
let mut v: Vec<String> = split1.map(String::from).collect();
let actual_hash = v.remove(0);
debug!("actual hash: {}", actual_hash);
debug!("expected hash: {}", expected_hash);
@ -708,7 +701,7 @@ pub async fn estimate_fee() -> u128 {
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(utils::empty_string());
let remote_set = remote_var == String::from(crate::GUI_SET_REMOTE_NODE);
let remote_set = remote_var == *crate::GUI_SET_REMOTE_NODE;
if remote_set {
let p_height = monero::p_get_height().await;
r_height = p_height.unwrap_or(r_height);
@ -726,12 +719,12 @@ pub async fn estimate_fee() -> u128 {
}
// TODO(?): determine a more effecient fix than this for slow fee estimation
// over i2p
if v_fee.len() >= 1 && remote_set {
if !v_fee.is_empty() && remote_set {
break;
}
height = r_height.height - count;
let mut block: reqres::XmrDaemonGetBlockResponse = Default::default();
if remote_var == String::from(crate::GUI_SET_REMOTE_NODE) {
if remote_var == *crate::GUI_SET_REMOTE_NODE {
let p_block = monero::p_get_block(height).await;
block = p_block.unwrap_or(block);
} else {
@ -748,10 +741,10 @@ pub async fn estimate_fee() -> u128 {
}
for tx in transactions.txs_as_json {
let pre_fee_split = tx.split("txnFee\":");
let mut v1: Vec<String> = pre_fee_split.map(|s| String::from(s)).collect();
let mut v1: Vec<String> = pre_fee_split.map(String::from).collect();
let fee_split = v1.remove(1);
let post_fee_split = fee_split.split(",");
let mut v2: Vec<String> = post_fee_split.map(|s| String::from(s)).collect();
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,
@ -797,7 +790,7 @@ pub fn toggle_vendor_enabled() -> bool {
contact::NEVEKO_VENDOR_ENABLED,
contact::NEVEKO_VENDOR_MODE_ON,
);
return true;
true
} else {
info!("neveko vendor mode disabled");
db::Interface::write(
@ -806,7 +799,7 @@ pub fn toggle_vendor_enabled() -> bool {
contact::NEVEKO_VENDOR_ENABLED,
contact::NEVEKO_VENDOR_MODE_OFF,
);
return false;
false
}
}

View file

@ -13,7 +13,7 @@ use egui_winit::winit;
use crate::{epi, Result};
use super::epi_integration::{self, EpiIntegration};
use super::epi_integration::{self};
// ----------------------------------------------------------------------------
@ -58,10 +58,6 @@ enum EventResult {
}
trait WinitApp {
fn is_focused(&self) -> bool;
fn integration(&self) -> Option<&EpiIntegration>;
fn window(&self) -> Option<&winit::window::Window>;
fn save_and_destroy(&mut self);
@ -736,14 +732,6 @@ mod glow_integration {
}
impl WinitApp for GlowWinitApp {
fn is_focused(&self) -> bool {
self.is_focused
}
fn integration(&self) -> Option<&EpiIntegration> {
self.running.as_ref().map(|r| &r.integration)
}
fn window(&self) -> Option<&winit::window::Window> {
self.running.as_ref().map(|r| r.gl_window.window())
}

View file

@ -16,7 +16,7 @@ pub struct WindowSettings {
impl WindowSettings {
pub fn from_display(window: &winit::window::Window) -> Self {
let inner_size_points = window.inner_size().to_logical::<f32>(window.scale_factor());
let position = if cfg!(macos) {
let position = if cfg!(unix) || cfg!(windows) {
// MacOS uses inner position when positioning windows.
window
.inner_position()

View file

@ -217,8 +217,6 @@ impl TextureAtlas {
if required_height > self.max_height() {
// This is a bad place to be - we need to start reusing space :/
#[cfg(feature = "tracing")]
tracing::wan!("epaint texture atlas overflowed!");
self.cursor = (0, self.image.height() / 3); // Restart a bit down - the top of the atlas has too many important things in it
self.overflowed = true; // this will signal the user that we need to recreate the texture atlas next frame.

View file

@ -7,6 +7,7 @@ use std::sync::mpsc::{
Sender,
};
#[allow(dead_code)]
pub struct MultisigManagement {
pub completed_kex_init: bool,
pub completed_kex_final: bool,

View file

@ -135,18 +135,18 @@ pub async fn get_multisig_info(
r_info: Json<reqres::MultisigInfoRequest>,
_jwp: proof::PaymentProof,
) -> Custom<Json<models::Order>> {
let info: Vec<String> = r_info.info.iter().cloned().collect();
if r_info.msig_type == String::from(message::PREPARE_MSIG) {
let info: Vec<String> = r_info.info.to_vec();
if r_info.msig_type == *message::PREPARE_MSIG {
// adjudicator won't have wallet for order yet do that first
if r_info.init_adjudicator {
order::init_adjudicator_wallet(&r_info.orid).await;
}
message::send_prepare_info(&r_info.orid, &r_info.contact).await;
} else if r_info.msig_type == String::from(message::MAKE_MSIG) {
} else if r_info.msig_type == *message::MAKE_MSIG {
message::send_make_info(&r_info.orid, &r_info.contact, info).await;
} else if r_info.msig_type == String::from(message::EXPORT_MSIG) {
} else if r_info.msig_type == *message::EXPORT_MSIG {
message::send_export_info(&r_info.orid, &r_info.contact).await;
} else if r_info.msig_type == String::from(message::IMPORT_MSIG) {
} else if r_info.msig_type == *message::IMPORT_MSIG {
message::send_import_info(&r_info.orid, &r_info.info).await;
} else {
message::send_exchange_info(&r_info.orid, &r_info.contact, info, r_info.kex_init).await;