From 09b9505e35e7ced92e61f89962a17b956421e814 Mon Sep 17 00:00:00 2001 From: creating2morrow Date: Sat, 30 Mar 2024 19:29:03 -0400 Subject: [PATCH] update terminology to adjudicator update pre-commit.sample --- neveko-core/src/lib.rs | 2 +- neveko-core/src/message.rs | 6 +- neveko-core/src/models.rs | 60 ++++----- neveko-core/src/order.rs | 13 +- neveko-core/src/reqres.rs | 10 +- neveko-core/src/utils.rs | 2 +- neveko-gui/src/apps/market.rs | 240 +++++++++++++++++++--------------- neveko-gui/src/lib.rs | 2 +- neveko-market/README.md | 4 +- scripts/pre-commit.sample | 3 + src/controller.rs | 6 +- 11 files changed, 188 insertions(+), 160 deletions(-) diff --git a/neveko-core/src/lib.rs b/neveko-core/src/lib.rs index 8945e29..c93eecd 100644 --- a/neveko-core/src/lib.rs +++ b/neveko-core/src/lib.rs @@ -36,7 +36,7 @@ pub const RX_MESSAGE_DB_KEY: &str = "rx"; pub const DISPUTE_LAST_CHECK_DB_KEY: &str = "dlc"; pub const FTS_DB_KEY: &str = "fts"; pub const CUSTOMER_ORDER_LIST_DB_KEY: &str = "olc"; -pub const MEDIATOR_DB_KEY: &str = "med8"; +pub const ADJUDICATOR_DB_KEY: &str = "med8"; pub const MSIG_MESSAGE_DB_KEY: &str = "msig"; pub const MSIG_MESSAGE_LIST_DB_KEY: &str = "msigl"; pub const FTS_JWP_DB_KEY: &str = "fts-jwp"; diff --git a/neveko-core/src/message.rs b/neveko-core/src/message.rs index 4b81dfe..2d41b2f 100644 --- a/neveko-core/src/message.rs +++ b/neveko-core/src/message.rs @@ -162,7 +162,7 @@ fn parse_multisig_message(mid: String) -> MultisigMessageData { /// /// decrypted for convenience sake. The client must determine which /// -/// .b32.i2p address belongs to the vendor / mediator. +/// .b32.i2p address belongs to the vendor / adjudicator. /// /// The result should be a string that needs to be decomposed into a /// @@ -622,7 +622,7 @@ pub async fn send_import_info(orid: &String, info: &Vec) { /// Customer begins multisig orchestration by requesting the prepare info /// -/// from the mediator and the vendor. In response they create an encrypted +/// from the adjudicator and the vendor. In response they create an encrypted /// /// multisig message with the requested data. Customer manages multisig by /// @@ -673,7 +673,7 @@ pub async fn d_trigger_msig_info( let d_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: String::from(&request.contact), info: request.info.clone(), - init_mediator: request.init_mediator, + init_adjudicator: request.init_adjudicator, kex_init: request.kex_init, msig_type: String::from(&request.msig_type), orid: String::from(&request.orid), diff --git a/neveko-core/src/models.rs b/neveko-core/src/models.rs index 4425346..89a0b62 100644 --- a/neveko-core/src/models.rs +++ b/neveko-core/src/models.rs @@ -320,11 +320,11 @@ pub struct Order { pub deliver_date: i64, /// Transaction hash from vendor or customer signed txset pub hash: String, - pub mediator_kex_1: String, - pub mediator_kex_2: String, - pub mediator_kex_3: String, - pub mediator_msig_make: String, - pub mediator_msig_prepare: String, + pub adjudicator_kex_1: String, + pub adjudicator_kex_2: String, + pub adjudicator_kex_3: String, + pub adjudicator_msig_make: String, + pub adjudicator_msig_prepare: String, /// Address gpg key encrypted bytes pub ship_address: Vec, pub ship_date: i64, @@ -357,11 +357,11 @@ impl Default for Order { date: 0, deliver_date: 0, hash: utils::empty_string(), - mediator_kex_1: utils::empty_string(), - mediator_kex_2: utils::empty_string(), - mediator_kex_3: utils::empty_string(), - mediator_msig_make: utils::empty_string(), - mediator_msig_prepare: utils::empty_string(), + adjudicator_kex_1: utils::empty_string(), + adjudicator_kex_2: utils::empty_string(), + adjudicator_kex_3: utils::empty_string(), + adjudicator_msig_make: utils::empty_string(), + adjudicator_msig_prepare: utils::empty_string(), ship_address: Vec::new(), ship_date: 0, subaddress: utils::empty_string(), @@ -393,11 +393,11 @@ impl Order { o.date, o.deliver_date, o.hash, - o.mediator_msig_make, - o.mediator_msig_prepare, - o.mediator_kex_1, - o.mediator_kex_2, - o.mediator_kex_3, + o.adjudicator_msig_make, + o.adjudicator_msig_prepare, + o.adjudicator_kex_1, + o.adjudicator_kex_2, + o.adjudicator_kex_3, ship_address, o.ship_date, o.subaddress, @@ -433,11 +433,11 @@ impl Order { Err(_) => 0, }; let hash = v.remove(0); - let mediator_msig_make = v.remove(0); - let mediator_msig_prepare = v.remove(0); - let mediator_kex_1 = v.remove(0); - let mediator_kex_2 = v.remove(0); - let mediator_kex_3 = v.remove(0); + let adjudicator_msig_make = v.remove(0); + let adjudicator_msig_prepare = v.remove(0); + let adjudicator_kex_1 = v.remove(0); + let adjudicator_kex_2 = v.remove(0); + let adjudicator_kex_3 = v.remove(0); let ship_address = hex::decode(v.remove(0)).unwrap_or(Vec::new()); let ship_date = match v.remove(0).parse::() { Ok(d) => d, @@ -469,11 +469,11 @@ impl Order { date, deliver_date, hash, - mediator_kex_1, - mediator_kex_2, - mediator_kex_3, - mediator_msig_make, - mediator_msig_prepare, + adjudicator_kex_1, + adjudicator_kex_2, + adjudicator_kex_3, + adjudicator_msig_make, + adjudicator_msig_prepare, ship_address, ship_date, subaddress, @@ -502,11 +502,11 @@ impl Order { date: o.date, deliver_date: o.deliver_date, hash: String::from(&o.hash), - mediator_kex_1: String::from(&o.mediator_kex_1), - mediator_kex_2: String::from(&o.mediator_kex_2), - mediator_kex_3: String::from(&o.mediator_kex_3), - mediator_msig_make: String::from(&o.mediator_msig_make), - mediator_msig_prepare: String::from(&o.mediator_msig_prepare), + adjudicator_kex_1: String::from(&o.adjudicator_kex_1), + adjudicator_kex_2: String::from(&o.adjudicator_kex_2), + adjudicator_kex_3: String::from(&o.adjudicator_kex_3), + adjudicator_msig_make: String::from(&o.adjudicator_msig_make), + adjudicator_msig_prepare: String::from(&o.adjudicator_msig_prepare), ship_address: o.ship_address.iter().cloned().collect(), ship_date: o.ship_date, subaddress: String::from(&o.subaddress), diff --git a/neveko-core/src/order.rs b/neveko-core/src/order.rs index 174c6b0..a36b6a0 100644 --- a/neveko-core/src/order.rs +++ b/neveko-core/src/order.rs @@ -75,9 +75,9 @@ pub async fn create(j_order: Json) -> Order { monero::enable_experimental_multisig(&orid); debug!("insert order: {:?}", &new_order); let s = db::Interface::async_open().await; - // inject mediator separately, modifying the order model is mendokusai - let mediator_k = format!("{}-{}", crate::MEDIATOR_DB_KEY, &orid); - db::Interface::async_write(&s.env, &s.handle, &mediator_k, &j_order.mediator).await; + // inject adjudicator separately, modifying the order model is mendokusai + let adjudicator_k = format!("{}-{}", crate::ADJUDICATOR_DB_KEY, &orid); + db::Interface::async_write(&s.env, &s.handle, &adjudicator_k, &j_order.adjudicator).await; let k = &new_order.orid; db::Interface::async_write(&s.env, &s.handle, k, &Order::to_db(&new_order)).await; // in order to retrieve all orders, write keys to with ol @@ -255,7 +255,8 @@ pub async fn sign_and_submit_multisig( /// /// they must sign the order id with their NEVEKO wallet instance. This means /// -/// that the mediator can see order id for disputes without being able to access +/// that the adjudicator can see order id for disputes without being able to +/// access /// /// the details of said order. pub async fn secure_retrieval(orid: &String, signature: &String) -> Order { @@ -803,11 +804,11 @@ pub async fn d_trigger_cancel_request(contact: &String, orid: &String) -> Order Default::default() } -pub async fn init_mediator_wallet(orid: &String) { +pub async fn init_adjudicator_wallet(orid: &String) { let password = utils::empty_string(); let m_wallet = monero::create_wallet(orid, &password).await; if !m_wallet { - log::error!("failed to create mediator wallet"); + log::error!("failed to create adjudicator wallet"); } // enable multisig monero::close_wallet(&orid, &password).await; diff --git a/neveko-core/src/reqres.rs b/neveko-core/src/reqres.rs index 6cbef47..988b48b 100644 --- a/neveko-core/src/reqres.rs +++ b/neveko-core/src/reqres.rs @@ -1244,7 +1244,7 @@ impl Default for ErrorResponse { #[serde(crate = "rocket::serde")] pub struct OrderRequest { pub cid: String, - pub mediator: String, + pub adjudicator: String, pub pid: String, pub ship_address: Vec, pub quantity: u128, @@ -1254,7 +1254,7 @@ impl Default for OrderRequest { fn default() -> Self { OrderRequest { cid: utils::empty_string(), - mediator: utils::empty_string(), + adjudicator: utils::empty_string(), pid: utils::empty_string(), ship_address: Vec::new(), quantity: 0, @@ -1269,8 +1269,8 @@ pub struct MultisigInfoRequest { pub contact: String, /// Send empty array on prepare info request pub info: Vec, - /// flag for mediator to create create multisig wallet for order - pub init_mediator: bool, + /// flag for adjudicator to create create multisig wallet for order + pub init_adjudicator: bool, /// We need to know when the first kex round occurs pub kex_init: bool, /// valid values are found in lines 21-26 of market.rs @@ -1283,7 +1283,7 @@ impl Default for MultisigInfoRequest { MultisigInfoRequest { contact: utils::empty_string(), info: Vec::new(), - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: utils::empty_string(), orid: utils::empty_string(), diff --git a/neveko-core/src/utils.rs b/neveko-core/src/utils.rs index da2b18d..efc7f73 100644 --- a/neveko-core/src/utils.rs +++ b/neveko-core/src/utils.rs @@ -341,7 +341,7 @@ pub fn product_to_json(m: &models::Product) -> Json { pub fn order_to_json(o: &reqres::OrderRequest) -> Json { let r_order: reqres::OrderRequest = reqres::OrderRequest { cid: String::from(&o.cid), - mediator: String::from(&o.mediator), + adjudicator: String::from(&o.adjudicator), pid: String::from(&o.pid), ship_address: o.ship_address.iter().cloned().collect(), quantity: o.quantity, diff --git a/neveko-gui/src/apps/market.rs b/neveko-gui/src/apps/market.rs index b13aa8d..e1e2d2b 100644 --- a/neveko-gui/src/apps/market.rs +++ b/neveko-gui/src/apps/market.rs @@ -18,11 +18,11 @@ pub struct MultisigManagement { pub completed_make: bool, pub exchange_multisig_keys: String, pub export_info: String, - pub has_mediator: bool, + pub has_adjudicator: bool, pub make_info: String, - pub mediator: String, + pub adjudicator: String, pub prepare_info: String, - pub query_mediator: bool, + pub query_adjudicator: bool, pub signed_txset: String, pub vendor: String, } @@ -40,11 +40,11 @@ impl Default for MultisigManagement { completed_make: false, exchange_multisig_keys: utils::empty_string(), export_info: utils::empty_string(), - has_mediator: false, + has_adjudicator: false, make_info: utils::empty_string(), - mediator: utils::empty_string(), + adjudicator: utils::empty_string(), prepare_info: utils::empty_string(), - query_mediator: false, + query_adjudicator: false, signed_txset: utils::empty_string(), vendor: utils::empty_string(), } @@ -437,36 +437,36 @@ impl eframe::App for MarketApp { ui.label("msig request in progress..."); } ui.horizontal(|ui| { - let mediator = ui.label("Mediator: "); - let prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); - if !self.msig.query_mediator { - let mediator_db = + let adjudicator = ui.label("Mediator: "); + let prefix = String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); + if !self.msig.query_adjudicator { + let adjudicator_db = utils::search_gui_db(String::from(&prefix), self.m_order.orid.clone()); - log::debug!("mediator db: {}", mediator_db); - self.msig.has_mediator = mediator_db != utils::empty_string(); - self.msig.mediator = mediator_db; - self.msig.query_mediator = true; - } else if self.msig.query_mediator && !self.msig.has_mediator { - ui.text_edit_singleline(&mut self.msig.mediator) - .labelled_by(mediator.id); + log::debug!("adjudicator db: {}", adjudicator_db); + self.msig.has_adjudicator = adjudicator_db != utils::empty_string(); + self.msig.adjudicator = adjudicator_db; + self.msig.query_adjudicator = true; + } else if self.msig.query_adjudicator && !self.msig.has_adjudicator { + ui.text_edit_singleline(&mut self.msig.adjudicator) + .labelled_by(adjudicator.id); ui.label("\t"); if ui.button("Set Mediator").clicked() { utils::write_gui_db( prefix, self.m_order.orid.clone(), - self.msig.mediator.clone(), + self.msig.adjudicator.clone(), ); - self.msig.has_mediator = true; + self.msig.has_adjudicator = true; } } else { - ui.label(self.msig.mediator.clone()); + ui.label(self.msig.adjudicator.clone()); ui.label("\t"); if !self.msig.completed_prepare { if ui.button("Clear Mediator").clicked() { utils::clear_gui_db(prefix, self.m_order.orid.clone()); - self.msig.mediator = utils::empty_string(); - self.msig.has_mediator = false; - self.msig.query_mediator = false; + self.msig.adjudicator = utils::empty_string(); + self.msig.has_adjudicator = false; + self.msig.query_adjudicator = false; } } } @@ -477,32 +477,34 @@ impl eframe::App for MarketApp { ui.label("Prepare: \t\t\t\t\t"); if ui.button("Prepare").clicked() { self.is_loading = true; - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); - // get prepare multisig info from vendor and mediator + // get prepare multisig info from vendor and adjudicator // call prepare multisig and save to db send_prepare_info_req( self.our_prepare_info_tx.clone(), ctx.clone(), - mediator, + adjudicator, &self.m_order.orid.clone(), vendor, ) } if ui.button("Check").clicked() { - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); let sub_type = String::from(message::PREPARE_MSIG); let is_prepared = validate_msig_step( - &mediator, + &adjudicator, &self.m_order.orid, &vendor, &sub_type, @@ -516,32 +518,34 @@ impl eframe::App for MarketApp { ui.label("Make: \t\t\t\t\t\t"); if ui.button("Make").clicked() { self.is_loading = true; - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); - // get make multisig info from vendor and mediator + // get make multisig info from vendor and adjudicator // call make multisig and save to db send_make_info_req( self.our_make_info_tx.clone(), ctx.clone(), - mediator, + adjudicator, &self.m_order.orid.clone(), vendor, ) } if ui.button("Check").clicked() { - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); let sub_type = String::from(message::MAKE_MSIG); let is_made = validate_msig_step( - &mediator, + &adjudicator, &self.m_order.orid, &vendor, &sub_type, @@ -555,32 +559,34 @@ impl eframe::App for MarketApp { ui.label("Key Exchange Initial: \t\t\t"); if ui.button("KEX-INIT").clicked() { self.is_loading = true; - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); - // get kex round one info from vendor and mediator + // get kex round one info from vendor and adjudicator // call make multisig and save to db send_kex_initial_req( self.our_make_info_tx.clone(), ctx.clone(), - mediator, + adjudicator, &self.m_order.orid.clone(), vendor, ) } if ui.button("Check").clicked() { - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); let sub_type = String::from(message::KEX_ONE_MSIG); let is_made = validate_msig_step( - &mediator, + &adjudicator, &self.m_order.orid, &vendor, &sub_type, @@ -594,32 +600,34 @@ impl eframe::App for MarketApp { ui.label("Key Exchange Final: \t\t\t"); if ui.button("KEX-FINAL").clicked() { self.is_loading = true; - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); - // get kex round two info from vendor and mediator + // get kex round two info from vendor and adjudicator // call make multisig and save to db send_kex_final_req( self.our_make_info_tx.clone(), ctx.clone(), - mediator, + adjudicator, &self.m_order.orid.clone(), vendor, ) } if ui.button("Check").clicked() { - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); + let adjudicator_prefix = + String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY); - let mediator = - utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); let vendor = utils::search_gui_db(vendor_prefix, self.m_order.orid.clone()); let sub_type = String::from(message::KEX_TWO_MSIG); let is_made = validate_msig_step( - &mediator, + &adjudicator, &self.m_order.orid, &vendor, &sub_type, @@ -952,10 +960,11 @@ impl eframe::App for MarketApp { ui.add(egui::Spinner::new()); ui.label("loading..."); } - let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY); - let mediator = utils::search_gui_db(mediator_prefix, self.m_order.orid.clone()); + let adjudicator_prefix = String::from(crate::GUI_MSIG_ADJUDICATOR_DB_KEY); + let adjudicator = + utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone()); ui.label(format!("customer id: {}", self.new_order.cid)); - ui.label(format!("mediator id: {}", mediator)); + ui.label(format!("adjudicator id: {}", adjudicator)); ui.label(format!("product id: {}", self.new_order.pid)); ui.horizontal(|ui| { let shipping_name = ui.label("shipping address: "); @@ -986,7 +995,7 @@ impl eframe::App for MarketApp { gpg::encrypt(self.vendor_status.i2p.clone(), &address_bytes); let new_order = reqres::OrderRequest { cid: String::from(&self.new_order.cid), - mediator: String::from(&mediator), + adjudicator: String::from(&adjudicator), pid: String::from(&self.new_order.pid), ship_address: encrypted_shipping_address.unwrap_or(Vec::new()), quantity: qty, @@ -1813,7 +1822,7 @@ fn submit_order_req( fn send_prepare_info_req( tx: Sender, ctx: egui::Context, - mediator: String, + adjudicator: String, orid: &String, vendor: String, ) { @@ -1821,8 +1830,10 @@ fn send_prepare_info_req( let v_orid: String = String::from(orid); let w_orid: String = String::from(orid); tokio::spawn(async move { - let m_jwp: String = - utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator)); + let m_jwp: String = utils::search_gui_db( + String::from(crate::GUI_JWP_DB_KEY), + String::from(&adjudicator), + ); let v_jwp: String = utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor)); let wallet_password = utils::empty_string(); @@ -1845,14 +1856,14 @@ fn send_prepare_info_req( String::from(&w_orid), String::from(ref_prepare_info), ); - // Request mediator and vendor while we're at it + // Request adjudicator and vendor while we're at it // Will coordinating send this on make requests next let s = db::Interface::async_open().await; let m_msig_key = format!( "{}-{}-{}", message::PREPARE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -1870,7 +1881,7 @@ fn send_prepare_info_req( let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: Vec::new(), - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::PREPARE_MSIG), orid: String::from(v_orid), @@ -1879,18 +1890,19 @@ fn send_prepare_info_req( } if m_prepare == utils::empty_string() { log::debug!( - "constructing mediator {} msig messages", + "constructing adjudicator {} msig messages", message::PREPARE_MSIG ); let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: Vec::new(), - init_mediator: true, + init_adjudicator: true, kex_init: false, msig_type: String::from(message::PREPARE_MSIG), orid: String::from(m_orid), }; - let _m_result = message::d_trigger_msig_info(&mediator, &m_jwp, &m_msig_request).await; + let _m_result = + message::d_trigger_msig_info(&adjudicator, &m_jwp, &m_msig_request).await; } let _ = tx.send(String::from(ref_prepare_info)); }); @@ -1900,7 +1912,7 @@ fn send_prepare_info_req( fn send_make_info_req( tx: Sender, ctx: egui::Context, - mediator: String, + adjudicator: String, orid: &String, vendor: String, ) { @@ -1908,8 +1920,10 @@ fn send_make_info_req( let v_orid: String = String::from(orid); let w_orid: String = String::from(orid); tokio::spawn(async move { - let m_jwp: String = - utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator)); + let m_jwp: String = utils::search_gui_db( + String::from(crate::GUI_JWP_DB_KEY), + String::from(&adjudicator), + ); let v_jwp: String = utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor)); let wallet_password = utils::empty_string(); @@ -1923,7 +1937,7 @@ fn send_make_info_req( let mut prepare_info_prep = Vec::new(); let mut m_prepare_info_send = Vec::new(); let mut v_prepare_info_send = Vec::new(); - // we need to send our info to mediator and vendor so they can perform + // we need to send our info to adjudicator and vendor so they can perform // make_multisig and send the reponse (String) back let c_prepare = utils::search_gui_db( String::from(crate::GUI_MSIG_PREPARE_DB_KEY), @@ -1934,7 +1948,7 @@ fn send_make_info_req( "{}-{}-{}", message::PREPARE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -1966,7 +1980,7 @@ fn send_make_info_req( ); } } - // Request mediator and vendor while we're at it + // Request adjudicator and vendor while we're at it // Will coordinating send this on make requests next let s = db::Interface::async_open().await; @@ -1974,7 +1988,7 @@ fn send_make_info_req( "{}-{}-{}", message::MAKE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -1989,7 +2003,7 @@ fn send_make_info_req( let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: v_prepare_info_send, - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::MAKE_MSIG), orid: String::from(v_orid), @@ -1997,16 +2011,20 @@ fn send_make_info_req( let _v_result = message::d_trigger_msig_info(&vendor, &v_jwp, &v_msig_request).await; } if m_make == utils::empty_string() { - log::debug!("constructing mediator {} msig messages", message::MAKE_MSIG); + log::debug!( + "constructing adjudicator {} msig messages", + message::MAKE_MSIG + ); let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: m_prepare_info_send, - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::MAKE_MSIG), orid: String::from(m_orid), }; - let _m_result = message::d_trigger_msig_info(&mediator, &m_jwp, &m_msig_request).await; + let _m_result = + message::d_trigger_msig_info(&adjudicator, &m_jwp, &m_msig_request).await; } let _ = tx.send(String::from(&local_make)); }); @@ -2016,7 +2034,7 @@ fn send_make_info_req( fn send_kex_initial_req( tx: Sender, ctx: egui::Context, - mediator: String, + adjudicator: String, orid: &String, vendor: String, ) { @@ -2024,8 +2042,10 @@ fn send_kex_initial_req( let v_orid: String = String::from(orid); let w_orid: String = String::from(orid); tokio::spawn(async move { - let m_jwp: String = - utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator)); + let m_jwp: String = utils::search_gui_db( + String::from(crate::GUI_JWP_DB_KEY), + String::from(&adjudicator), + ); let v_jwp: String = utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor)); let wallet_password = utils::empty_string(); @@ -2039,7 +2059,7 @@ fn send_kex_initial_req( let mut kex_init_prep = Vec::new(); let mut m_kex_init_send = Vec::new(); let mut v_kex_init_send = Vec::new(); - // we need to send our info to mediator and vendor so they can perform + // we need to send our info to adjudicator and vendor so they can perform // kex final one and send the reponse (info) back let c_kex_init = utils::search_gui_db( String::from(crate::GUI_MSIG_MAKE_DB_KEY), @@ -2050,7 +2070,7 @@ fn send_kex_initial_req( "{}-{}-{}", message::MAKE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -2083,14 +2103,14 @@ fn send_kex_initial_req( ); } } - // Request mediator and vendor while we're at it + // Request adjudicator and vendor while we're at it // Will coordinating send this on kex round two next let s = db::Interface::async_open().await; let m_msig_key = format!( "{}-{}-{}", message::KEX_ONE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -2108,7 +2128,7 @@ fn send_kex_initial_req( let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: v_kex_init_send, - init_mediator: false, + init_adjudicator: false, kex_init: true, msig_type: String::from(message::KEX_ONE_MSIG), orid: String::from(v_orid), @@ -2117,18 +2137,19 @@ fn send_kex_initial_req( } if m_kex_init == utils::empty_string() { log::debug!( - "constructing mediator {} msig messages", + "constructing adjudicator {} msig messages", message::KEX_ONE_MSIG ); let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: m_kex_init_send, - init_mediator: false, + init_adjudicator: false, kex_init: true, msig_type: String::from(message::KEX_ONE_MSIG), orid: String::from(m_orid), }; - let _m_result = message::d_trigger_msig_info(&mediator, &m_jwp, &m_msig_request).await; + let _m_result = + message::d_trigger_msig_info(&adjudicator, &m_jwp, &m_msig_request).await; } let _ = tx.send(String::from(&local_kex_init)); }); @@ -2138,7 +2159,7 @@ fn send_kex_initial_req( fn send_kex_final_req( tx: Sender, ctx: egui::Context, - mediator: String, + adjudicator: String, orid: &String, vendor: String, ) { @@ -2146,8 +2167,10 @@ fn send_kex_final_req( let v_orid: String = String::from(orid); let w_orid: String = String::from(orid); tokio::spawn(async move { - let m_jwp: String = - utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator)); + let m_jwp: String = utils::search_gui_db( + String::from(crate::GUI_JWP_DB_KEY), + String::from(&adjudicator), + ); let v_jwp: String = utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor)); let wallet_password = utils::empty_string(); @@ -2170,7 +2193,7 @@ fn send_kex_final_req( "{}-{}-{}", message::KEX_ONE_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -2209,7 +2232,7 @@ fn send_kex_final_req( "{}-{}-{}", message::KEX_TWO_MSIG, String::from(&m_orid), - mediator + adjudicator ); let v_msig_key = format!( "{}-{}-{}", @@ -2227,7 +2250,7 @@ fn send_kex_final_req( let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: v_kex_final_send, - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::KEX_TWO_MSIG), orid: String::from(v_orid), @@ -2236,18 +2259,19 @@ fn send_kex_final_req( } if m_kex_final == utils::empty_string() { log::debug!( - "constructing mediator {} msig messages", + "constructing adjudicator {} msig messages", message::KEX_TWO_MSIG ); let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info: m_kex_final_send, - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::KEX_TWO_MSIG), orid: String::from(m_orid), }; - let _m_result = message::d_trigger_msig_info(&mediator, &m_jwp, &m_msig_request).await; + let _m_result = + message::d_trigger_msig_info(&adjudicator, &m_jwp, &m_msig_request).await; } let _ = tx.send(String::from(&local_kex_final)); }); @@ -2347,7 +2371,7 @@ fn send_import_info_req(tx: Sender, ctx: egui::Context, orid: &String, v let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest { contact: i2p::get_destination(None), info, - init_mediator: false, + init_adjudicator: false, kex_init: false, msig_type: String::from(message::IMPORT_MSIG), orid: String::from(v_orid), @@ -2398,17 +2422,17 @@ fn cancel_order_req( // End Async fn requests fn validate_msig_step( - mediator: &String, + adjudicator: &String, orid: &String, vendor: &String, sub_type: &String, ) -> bool { let s = db::Interface::open(); - let m_msig_key = format!("{}-{}-{}", sub_type, orid, mediator); + let m_msig_key = format!("{}-{}-{}", sub_type, orid, adjudicator); let v_msig_key = format!("{}-{}-{}", sub_type, orid, vendor); let m_info = db::Interface::read(&s.env, &s.handle, &m_msig_key); let v_info = db::Interface::read(&s.env, &s.handle, &v_msig_key); - log::debug!("{} mediator info: {}", sub_type, &m_info); + log::debug!("{} adjudicator info: {}", sub_type, &m_info); log::debug!("{} vendor info: {}", sub_type, &v_info); m_info != utils::empty_string() && v_info != utils::empty_string() } @@ -2457,7 +2481,7 @@ fn create_dispute_req( monero::open_wallet(&wallet_name, &wallet_password).await; let address_res = monero::get_address().await; monero::close_wallet(&wallet_name, &wallet_password).await; - // generate a txset for the mediator + // generate a txset for the adjudicator let wallet_password = utils::empty_string(); monero::open_wallet(&d_orid, &wallet_password).await; let transfer = monero::sweep_all(String::from(address_res.result.address)).await; diff --git a/neveko-gui/src/lib.rs b/neveko-gui/src/lib.rs index f6c63c8..02624db 100644 --- a/neveko-gui/src/lib.rs +++ b/neveko-gui/src/lib.rs @@ -22,7 +22,7 @@ pub const GUI_MSIG_KEX_TWO_DB_KEY: &str = "gui-kex-2"; pub const GUI_MSIG_EXPORT_DB_KEY: &str = "gui-export"; pub const GUI_MSIG_IMPORT_DB_KEY: &str = "gui-import"; pub const GUI_MSIG_MAKE_DB_KEY: &str = "gui-make"; -pub const GUI_MSIG_MEDIATOR_DB_KEY: &str = "gui-mediator"; +pub const GUI_MSIG_ADJUDICATOR_DB_KEY: &str = "gui-adjudicator"; pub const GUI_MSIG_PREPARE_DB_KEY: &str = "gui-prepare"; pub const GUI_MSIG_TXSET_DB_KEY: &str = "gui-txset"; // End LMDB keys diff --git a/neveko-market/README.md b/neveko-market/README.md index 0a7e717..2395a72 100755 --- a/neveko-market/README.md +++ b/neveko-market/README.md @@ -22,7 +22,7 @@ |cust | X | | | |med | x | | | -* customer makes and sends both prepare infos to mediator and vendor +* customer makes and sends both prepare infos to adjudicator and vendor * participants all make_info | | prepare | make | exchange | @@ -54,7 +54,7 @@ * vendor drafts the multisig txset and sends to customer with tracking/delivery info * order arrives, customer releases signed txset to vendor * vendor signs and submits signed txset -* in case of dispute the mediator can sign multisig txset for customer refund +* in case of dispute the adjudicator can sign multisig txset for customer refund or if the customer doesn't release payment after delivery Reference: https://resilience365.com/monero-multisig-how-to/ diff --git a/scripts/pre-commit.sample b/scripts/pre-commit.sample index 47ea91e..547adbc 100755 --- a/scripts/pre-commit.sample +++ b/scripts/pre-commit.sample @@ -1,5 +1,8 @@ #!/usr/bin/env bash # Run the formatter and linter before commits +# TODO: automatically squash in formatting changes +# For now if there formatting changes just undo the +# previous commit and commit again. # If any command fails exit immediately with that code set -eo pipefail diff --git a/src/controller.rs b/src/controller.rs index c2fa66d..3d5d13d 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -148,9 +148,9 @@ pub async fn get_multisig_info( ) -> Custom> { let info: Vec = r_info.info.iter().cloned().collect(); if r_info.msig_type == String::from(message::PREPARE_MSIG) { - // mediator won't have wallet for order yet do that first - if r_info.init_mediator { - order::init_mediator_wallet(&r_info.orid).await; + // 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) {