mirror of
https://github.com/creating2morrow/neveko.git
synced 2025-01-03 01:19:44 +00:00
update terminology to adjudicator
This commit is contained in:
parent
8ea1740965
commit
80e44400f7
9 changed files with 175 additions and 158 deletions
|
@ -162,7 +162,7 @@ fn parse_multisig_message(mid: String) -> MultisigMessageData {
|
||||||
///
|
///
|
||||||
/// decrypted for convenience sake. The client must determine which
|
/// 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
|
/// 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<String>) {
|
||||||
|
|
||||||
/// Customer begins multisig orchestration by requesting the prepare info
|
/// 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
|
/// 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 {
|
let d_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: String::from(&request.contact),
|
contact: String::from(&request.contact),
|
||||||
info: request.info.clone(),
|
info: request.info.clone(),
|
||||||
init_mediator: request.init_mediator,
|
init_adjudicator: request.init_adjudicator,
|
||||||
kex_init: request.kex_init,
|
kex_init: request.kex_init,
|
||||||
msig_type: String::from(&request.msig_type),
|
msig_type: String::from(&request.msig_type),
|
||||||
orid: String::from(&request.orid),
|
orid: String::from(&request.orid),
|
||||||
|
|
|
@ -320,11 +320,11 @@ pub struct Order {
|
||||||
pub deliver_date: i64,
|
pub deliver_date: i64,
|
||||||
/// Transaction hash from vendor or customer signed txset
|
/// Transaction hash from vendor or customer signed txset
|
||||||
pub hash: String,
|
pub hash: String,
|
||||||
pub mediator_kex_1: String,
|
pub adjudicator_kex_1: String,
|
||||||
pub mediator_kex_2: String,
|
pub adjudicator_kex_2: String,
|
||||||
pub mediator_kex_3: String,
|
pub adjudicator_kex_3: String,
|
||||||
pub mediator_msig_make: String,
|
pub adjudicator_msig_make: String,
|
||||||
pub mediator_msig_prepare: String,
|
pub adjudicator_msig_prepare: String,
|
||||||
/// Address gpg key encrypted bytes
|
/// Address gpg key encrypted bytes
|
||||||
pub ship_address: Vec<u8>,
|
pub ship_address: Vec<u8>,
|
||||||
pub ship_date: i64,
|
pub ship_date: i64,
|
||||||
|
@ -357,11 +357,11 @@ impl Default for Order {
|
||||||
date: 0,
|
date: 0,
|
||||||
deliver_date: 0,
|
deliver_date: 0,
|
||||||
hash: utils::empty_string(),
|
hash: utils::empty_string(),
|
||||||
mediator_kex_1: utils::empty_string(),
|
adjudicator_kex_1: utils::empty_string(),
|
||||||
mediator_kex_2: utils::empty_string(),
|
adjudicator_kex_2: utils::empty_string(),
|
||||||
mediator_kex_3: utils::empty_string(),
|
adjudicator_kex_3: utils::empty_string(),
|
||||||
mediator_msig_make: utils::empty_string(),
|
adjudicator_msig_make: utils::empty_string(),
|
||||||
mediator_msig_prepare: utils::empty_string(),
|
adjudicator_msig_prepare: utils::empty_string(),
|
||||||
ship_address: Vec::new(),
|
ship_address: Vec::new(),
|
||||||
ship_date: 0,
|
ship_date: 0,
|
||||||
subaddress: utils::empty_string(),
|
subaddress: utils::empty_string(),
|
||||||
|
@ -393,11 +393,11 @@ impl Order {
|
||||||
o.date,
|
o.date,
|
||||||
o.deliver_date,
|
o.deliver_date,
|
||||||
o.hash,
|
o.hash,
|
||||||
o.mediator_msig_make,
|
o.adjudicator_msig_make,
|
||||||
o.mediator_msig_prepare,
|
o.adjudicator_msig_prepare,
|
||||||
o.mediator_kex_1,
|
o.adjudicator_kex_1,
|
||||||
o.mediator_kex_2,
|
o.adjudicator_kex_2,
|
||||||
o.mediator_kex_3,
|
o.adjudicator_kex_3,
|
||||||
ship_address,
|
ship_address,
|
||||||
o.ship_date,
|
o.ship_date,
|
||||||
o.subaddress,
|
o.subaddress,
|
||||||
|
@ -433,11 +433,11 @@ impl Order {
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
};
|
};
|
||||||
let hash = v.remove(0);
|
let hash = v.remove(0);
|
||||||
let mediator_msig_make = v.remove(0);
|
let adjudicator_msig_make = v.remove(0);
|
||||||
let mediator_msig_prepare = v.remove(0);
|
let adjudicator_msig_prepare = v.remove(0);
|
||||||
let mediator_kex_1 = v.remove(0);
|
let adjudicator_kex_1 = v.remove(0);
|
||||||
let mediator_kex_2 = v.remove(0);
|
let adjudicator_kex_2 = v.remove(0);
|
||||||
let mediator_kex_3 = v.remove(0);
|
let adjudicator_kex_3 = v.remove(0);
|
||||||
let ship_address = hex::decode(v.remove(0)).unwrap_or(Vec::new());
|
let ship_address = hex::decode(v.remove(0)).unwrap_or(Vec::new());
|
||||||
let ship_date = match v.remove(0).parse::<i64>() {
|
let ship_date = match v.remove(0).parse::<i64>() {
|
||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
|
@ -469,11 +469,11 @@ impl Order {
|
||||||
date,
|
date,
|
||||||
deliver_date,
|
deliver_date,
|
||||||
hash,
|
hash,
|
||||||
mediator_kex_1,
|
adjudicator_kex_1,
|
||||||
mediator_kex_2,
|
adjudicator_kex_2,
|
||||||
mediator_kex_3,
|
adjudicator_kex_3,
|
||||||
mediator_msig_make,
|
adjudicator_msig_make,
|
||||||
mediator_msig_prepare,
|
adjudicator_msig_prepare,
|
||||||
ship_address,
|
ship_address,
|
||||||
ship_date,
|
ship_date,
|
||||||
subaddress,
|
subaddress,
|
||||||
|
@ -502,11 +502,11 @@ impl Order {
|
||||||
date: o.date,
|
date: o.date,
|
||||||
deliver_date: o.deliver_date,
|
deliver_date: o.deliver_date,
|
||||||
hash: String::from(&o.hash),
|
hash: String::from(&o.hash),
|
||||||
mediator_kex_1: String::from(&o.mediator_kex_1),
|
adjudicator_kex_1: String::from(&o.adjudicator_kex_1),
|
||||||
mediator_kex_2: String::from(&o.mediator_kex_2),
|
adjudicator_kex_2: String::from(&o.adjudicator_kex_2),
|
||||||
mediator_kex_3: String::from(&o.mediator_kex_3),
|
adjudicator_kex_3: String::from(&o.adjudicator_kex_3),
|
||||||
mediator_msig_make: String::from(&o.mediator_msig_make),
|
adjudicator_msig_make: String::from(&o.adjudicator_msig_make),
|
||||||
mediator_msig_prepare: String::from(&o.mediator_msig_prepare),
|
adjudicator_msig_prepare: String::from(&o.adjudicator_msig_prepare),
|
||||||
ship_address: o.ship_address.iter().cloned().collect(),
|
ship_address: o.ship_address.iter().cloned().collect(),
|
||||||
ship_date: o.ship_date,
|
ship_date: o.ship_date,
|
||||||
subaddress: String::from(&o.subaddress),
|
subaddress: String::from(&o.subaddress),
|
||||||
|
|
|
@ -75,9 +75,9 @@ pub async fn create(j_order: Json<reqres::OrderRequest>) -> Order {
|
||||||
monero::enable_experimental_multisig(&orid);
|
monero::enable_experimental_multisig(&orid);
|
||||||
debug!("insert order: {:?}", &new_order);
|
debug!("insert order: {:?}", &new_order);
|
||||||
let s = db::Interface::async_open().await;
|
let s = db::Interface::async_open().await;
|
||||||
// inject mediator separately, modifying the order model is mendokusai
|
// inject adjudicator separately, modifying the order model is mendokusai
|
||||||
let mediator_k = format!("{}-{}", crate::MEDIATOR_DB_KEY, &orid);
|
let adjudicator_k = format!("{}-{}", crate::MEDIATOR_DB_KEY, &orid);
|
||||||
db::Interface::async_write(&s.env, &s.handle, &mediator_k, &j_order.mediator).await;
|
db::Interface::async_write(&s.env, &s.handle, &adjudicator_k, &j_order.adjudicator).await;
|
||||||
let k = &new_order.orid;
|
let k = &new_order.orid;
|
||||||
db::Interface::async_write(&s.env, &s.handle, k, &Order::to_db(&new_order)).await;
|
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
|
// 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
|
/// 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.
|
/// the details of said order.
|
||||||
pub async fn secure_retrieval(orid: &String, signature: &String) -> 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()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init_mediator_wallet(orid: &String) {
|
pub async fn init_adjudicator_wallet(orid: &String) {
|
||||||
let password = utils::empty_string();
|
let password = utils::empty_string();
|
||||||
let m_wallet = monero::create_wallet(orid, &password).await;
|
let m_wallet = monero::create_wallet(orid, &password).await;
|
||||||
if !m_wallet {
|
if !m_wallet {
|
||||||
log::error!("failed to create mediator wallet");
|
log::error!("failed to create adjudicator wallet");
|
||||||
}
|
}
|
||||||
// enable multisig
|
// enable multisig
|
||||||
monero::close_wallet(&orid, &password).await;
|
monero::close_wallet(&orid, &password).await;
|
||||||
|
|
|
@ -1244,7 +1244,7 @@ impl Default for ErrorResponse {
|
||||||
#[serde(crate = "rocket::serde")]
|
#[serde(crate = "rocket::serde")]
|
||||||
pub struct OrderRequest {
|
pub struct OrderRequest {
|
||||||
pub cid: String,
|
pub cid: String,
|
||||||
pub mediator: String,
|
pub adjudicator: String,
|
||||||
pub pid: String,
|
pub pid: String,
|
||||||
pub ship_address: Vec<u8>,
|
pub ship_address: Vec<u8>,
|
||||||
pub quantity: u128,
|
pub quantity: u128,
|
||||||
|
@ -1254,7 +1254,7 @@ impl Default for OrderRequest {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
OrderRequest {
|
OrderRequest {
|
||||||
cid: utils::empty_string(),
|
cid: utils::empty_string(),
|
||||||
mediator: utils::empty_string(),
|
adjudicator: utils::empty_string(),
|
||||||
pid: utils::empty_string(),
|
pid: utils::empty_string(),
|
||||||
ship_address: Vec::new(),
|
ship_address: Vec::new(),
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
|
@ -1269,8 +1269,8 @@ pub struct MultisigInfoRequest {
|
||||||
pub contact: String,
|
pub contact: String,
|
||||||
/// Send empty array on prepare info request
|
/// Send empty array on prepare info request
|
||||||
pub info: Vec<String>,
|
pub info: Vec<String>,
|
||||||
/// flag for mediator to create create multisig wallet for order
|
/// flag for adjudicator to create create multisig wallet for order
|
||||||
pub init_mediator: bool,
|
pub init_adjudicator: bool,
|
||||||
/// We need to know when the first kex round occurs
|
/// We need to know when the first kex round occurs
|
||||||
pub kex_init: bool,
|
pub kex_init: bool,
|
||||||
/// valid values are found in lines 21-26 of market.rs
|
/// valid values are found in lines 21-26 of market.rs
|
||||||
|
@ -1283,7 +1283,7 @@ impl Default for MultisigInfoRequest {
|
||||||
MultisigInfoRequest {
|
MultisigInfoRequest {
|
||||||
contact: utils::empty_string(),
|
contact: utils::empty_string(),
|
||||||
info: Vec::new(),
|
info: Vec::new(),
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: utils::empty_string(),
|
msig_type: utils::empty_string(),
|
||||||
orid: utils::empty_string(),
|
orid: utils::empty_string(),
|
||||||
|
|
|
@ -341,7 +341,7 @@ pub fn product_to_json(m: &models::Product) -> Json<models::Product> {
|
||||||
pub fn order_to_json(o: &reqres::OrderRequest) -> Json<reqres::OrderRequest> {
|
pub fn order_to_json(o: &reqres::OrderRequest) -> Json<reqres::OrderRequest> {
|
||||||
let r_order: reqres::OrderRequest = reqres::OrderRequest {
|
let r_order: reqres::OrderRequest = reqres::OrderRequest {
|
||||||
cid: String::from(&o.cid),
|
cid: String::from(&o.cid),
|
||||||
mediator: String::from(&o.mediator),
|
adjudicator: String::from(&o.adjudicator),
|
||||||
pid: String::from(&o.pid),
|
pid: String::from(&o.pid),
|
||||||
ship_address: o.ship_address.iter().cloned().collect(),
|
ship_address: o.ship_address.iter().cloned().collect(),
|
||||||
quantity: o.quantity,
|
quantity: o.quantity,
|
||||||
|
|
|
@ -18,11 +18,11 @@ pub struct MultisigManagement {
|
||||||
pub completed_make: bool,
|
pub completed_make: bool,
|
||||||
pub exchange_multisig_keys: String,
|
pub exchange_multisig_keys: String,
|
||||||
pub export_info: String,
|
pub export_info: String,
|
||||||
pub has_mediator: bool,
|
pub has_adjudicator: bool,
|
||||||
pub make_info: String,
|
pub make_info: String,
|
||||||
pub mediator: String,
|
pub adjudicator: String,
|
||||||
pub prepare_info: String,
|
pub prepare_info: String,
|
||||||
pub query_mediator: bool,
|
pub query_adjudicator: bool,
|
||||||
pub signed_txset: String,
|
pub signed_txset: String,
|
||||||
pub vendor: String,
|
pub vendor: String,
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ impl Default for MultisigManagement {
|
||||||
completed_make: false,
|
completed_make: false,
|
||||||
exchange_multisig_keys: utils::empty_string(),
|
exchange_multisig_keys: utils::empty_string(),
|
||||||
export_info: utils::empty_string(),
|
export_info: utils::empty_string(),
|
||||||
has_mediator: false,
|
has_adjudicator: false,
|
||||||
make_info: utils::empty_string(),
|
make_info: utils::empty_string(),
|
||||||
mediator: utils::empty_string(),
|
adjudicator: utils::empty_string(),
|
||||||
prepare_info: utils::empty_string(),
|
prepare_info: utils::empty_string(),
|
||||||
query_mediator: false,
|
query_adjudicator: false,
|
||||||
signed_txset: utils::empty_string(),
|
signed_txset: utils::empty_string(),
|
||||||
vendor: utils::empty_string(),
|
vendor: utils::empty_string(),
|
||||||
}
|
}
|
||||||
|
@ -437,36 +437,36 @@ impl eframe::App for MarketApp {
|
||||||
ui.label("msig request in progress...");
|
ui.label("msig request in progress...");
|
||||||
}
|
}
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let mediator = ui.label("Mediator: ");
|
let adjudicator = ui.label("Mediator: ");
|
||||||
let prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
if !self.msig.query_mediator {
|
if !self.msig.query_adjudicator {
|
||||||
let mediator_db =
|
let adjudicator_db =
|
||||||
utils::search_gui_db(String::from(&prefix), self.m_order.orid.clone());
|
utils::search_gui_db(String::from(&prefix), self.m_order.orid.clone());
|
||||||
log::debug!("mediator db: {}", mediator_db);
|
log::debug!("adjudicator db: {}", adjudicator_db);
|
||||||
self.msig.has_mediator = mediator_db != utils::empty_string();
|
self.msig.has_adjudicator = adjudicator_db != utils::empty_string();
|
||||||
self.msig.mediator = mediator_db;
|
self.msig.adjudicator = adjudicator_db;
|
||||||
self.msig.query_mediator = true;
|
self.msig.query_adjudicator = true;
|
||||||
} else if self.msig.query_mediator && !self.msig.has_mediator {
|
} else if self.msig.query_adjudicator && !self.msig.has_adjudicator {
|
||||||
ui.text_edit_singleline(&mut self.msig.mediator)
|
ui.text_edit_singleline(&mut self.msig.adjudicator)
|
||||||
.labelled_by(mediator.id);
|
.labelled_by(adjudicator.id);
|
||||||
ui.label("\t");
|
ui.label("\t");
|
||||||
if ui.button("Set Mediator").clicked() {
|
if ui.button("Set Mediator").clicked() {
|
||||||
utils::write_gui_db(
|
utils::write_gui_db(
|
||||||
prefix,
|
prefix,
|
||||||
self.m_order.orid.clone(),
|
self.m_order.orid.clone(),
|
||||||
self.msig.mediator.clone(),
|
self.msig.adjudicator.clone(),
|
||||||
);
|
);
|
||||||
self.msig.has_mediator = true;
|
self.msig.has_adjudicator = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui.label(self.msig.mediator.clone());
|
ui.label(self.msig.adjudicator.clone());
|
||||||
ui.label("\t");
|
ui.label("\t");
|
||||||
if !self.msig.completed_prepare {
|
if !self.msig.completed_prepare {
|
||||||
if ui.button("Clear Mediator").clicked() {
|
if ui.button("Clear Mediator").clicked() {
|
||||||
utils::clear_gui_db(prefix, self.m_order.orid.clone());
|
utils::clear_gui_db(prefix, self.m_order.orid.clone());
|
||||||
self.msig.mediator = utils::empty_string();
|
self.msig.adjudicator = utils::empty_string();
|
||||||
self.msig.has_mediator = false;
|
self.msig.has_adjudicator = false;
|
||||||
self.msig.query_mediator = false;
|
self.msig.query_adjudicator = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,32 +477,32 @@ impl eframe::App for MarketApp {
|
||||||
ui.label("Prepare: \t\t\t\t\t");
|
ui.label("Prepare: \t\t\t\t\t");
|
||||||
if ui.button("Prepare").clicked() {
|
if ui.button("Prepare").clicked() {
|
||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
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
|
// call prepare multisig and save to db
|
||||||
send_prepare_info_req(
|
send_prepare_info_req(
|
||||||
self.our_prepare_info_tx.clone(),
|
self.our_prepare_info_tx.clone(),
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
mediator,
|
adjudicator,
|
||||||
&self.m_order.orid.clone(),
|
&self.m_order.orid.clone(),
|
||||||
vendor,
|
vendor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ui.button("Check").clicked() {
|
if ui.button("Check").clicked() {
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
||||||
let sub_type = String::from(message::PREPARE_MSIG);
|
let sub_type = String::from(message::PREPARE_MSIG);
|
||||||
let is_prepared = validate_msig_step(
|
let is_prepared = validate_msig_step(
|
||||||
&mediator,
|
&adjudicator,
|
||||||
&self.m_order.orid,
|
&self.m_order.orid,
|
||||||
&vendor,
|
&vendor,
|
||||||
&sub_type,
|
&sub_type,
|
||||||
|
@ -516,32 +516,32 @@ impl eframe::App for MarketApp {
|
||||||
ui.label("Make: \t\t\t\t\t\t");
|
ui.label("Make: \t\t\t\t\t\t");
|
||||||
if ui.button("Make").clicked() {
|
if ui.button("Make").clicked() {
|
||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
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
|
// call make multisig and save to db
|
||||||
send_make_info_req(
|
send_make_info_req(
|
||||||
self.our_make_info_tx.clone(),
|
self.our_make_info_tx.clone(),
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
mediator,
|
adjudicator,
|
||||||
&self.m_order.orid.clone(),
|
&self.m_order.orid.clone(),
|
||||||
vendor,
|
vendor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ui.button("Check").clicked() {
|
if ui.button("Check").clicked() {
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
||||||
let sub_type = String::from(message::MAKE_MSIG);
|
let sub_type = String::from(message::MAKE_MSIG);
|
||||||
let is_made = validate_msig_step(
|
let is_made = validate_msig_step(
|
||||||
&mediator,
|
&adjudicator,
|
||||||
&self.m_order.orid,
|
&self.m_order.orid,
|
||||||
&vendor,
|
&vendor,
|
||||||
&sub_type,
|
&sub_type,
|
||||||
|
@ -555,32 +555,32 @@ impl eframe::App for MarketApp {
|
||||||
ui.label("Key Exchange Initial: \t\t\t");
|
ui.label("Key Exchange Initial: \t\t\t");
|
||||||
if ui.button("KEX-INIT").clicked() {
|
if ui.button("KEX-INIT").clicked() {
|
||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
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
|
// call make multisig and save to db
|
||||||
send_kex_initial_req(
|
send_kex_initial_req(
|
||||||
self.our_make_info_tx.clone(),
|
self.our_make_info_tx.clone(),
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
mediator,
|
adjudicator,
|
||||||
&self.m_order.orid.clone(),
|
&self.m_order.orid.clone(),
|
||||||
vendor,
|
vendor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ui.button("Check").clicked() {
|
if ui.button("Check").clicked() {
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
||||||
let sub_type = String::from(message::KEX_ONE_MSIG);
|
let sub_type = String::from(message::KEX_ONE_MSIG);
|
||||||
let is_made = validate_msig_step(
|
let is_made = validate_msig_step(
|
||||||
&mediator,
|
&adjudicator,
|
||||||
&self.m_order.orid,
|
&self.m_order.orid,
|
||||||
&vendor,
|
&vendor,
|
||||||
&sub_type,
|
&sub_type,
|
||||||
|
@ -594,32 +594,32 @@ impl eframe::App for MarketApp {
|
||||||
ui.label("Key Exchange Final: \t\t\t");
|
ui.label("Key Exchange Final: \t\t\t");
|
||||||
if ui.button("KEX-FINAL").clicked() {
|
if ui.button("KEX-FINAL").clicked() {
|
||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
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
|
// call make multisig and save to db
|
||||||
send_kex_final_req(
|
send_kex_final_req(
|
||||||
self.our_make_info_tx.clone(),
|
self.our_make_info_tx.clone(),
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
mediator,
|
adjudicator,
|
||||||
&self.m_order.orid.clone(),
|
&self.m_order.orid.clone(),
|
||||||
vendor,
|
vendor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ui.button("Check").clicked() {
|
if ui.button("Check").clicked() {
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
||||||
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
let vendor_prefix = String::from(crate::GUI_OVL_DB_KEY);
|
||||||
let mediator =
|
let adjudicator =
|
||||||
utils::search_gui_db(mediator_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(adjudicator_prefix, self.m_order.orid.clone());
|
||||||
let vendor =
|
let vendor =
|
||||||
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
utils::search_gui_db(vendor_prefix, self.m_order.orid.clone());
|
||||||
let sub_type = String::from(message::KEX_TWO_MSIG);
|
let sub_type = String::from(message::KEX_TWO_MSIG);
|
||||||
let is_made = validate_msig_step(
|
let is_made = validate_msig_step(
|
||||||
&mediator,
|
&adjudicator,
|
||||||
&self.m_order.orid,
|
&self.m_order.orid,
|
||||||
&vendor,
|
&vendor,
|
||||||
&sub_type,
|
&sub_type,
|
||||||
|
@ -952,10 +952,11 @@ impl eframe::App for MarketApp {
|
||||||
ui.add(egui::Spinner::new());
|
ui.add(egui::Spinner::new());
|
||||||
ui.label("loading...");
|
ui.label("loading...");
|
||||||
}
|
}
|
||||||
let mediator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_DB_KEY);
|
let adjudicator_prefix = String::from(crate::GUI_MSIG_MEDIATOR_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());
|
||||||
ui.label(format!("customer id: {}", self.new_order.cid));
|
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.label(format!("product id: {}", self.new_order.pid));
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let shipping_name = ui.label("shipping address: ");
|
let shipping_name = ui.label("shipping address: ");
|
||||||
|
@ -986,7 +987,7 @@ impl eframe::App for MarketApp {
|
||||||
gpg::encrypt(self.vendor_status.i2p.clone(), &address_bytes);
|
gpg::encrypt(self.vendor_status.i2p.clone(), &address_bytes);
|
||||||
let new_order = reqres::OrderRequest {
|
let new_order = reqres::OrderRequest {
|
||||||
cid: String::from(&self.new_order.cid),
|
cid: String::from(&self.new_order.cid),
|
||||||
mediator: String::from(&mediator),
|
adjudicator: String::from(&adjudicator),
|
||||||
pid: String::from(&self.new_order.pid),
|
pid: String::from(&self.new_order.pid),
|
||||||
ship_address: encrypted_shipping_address.unwrap_or(Vec::new()),
|
ship_address: encrypted_shipping_address.unwrap_or(Vec::new()),
|
||||||
quantity: qty,
|
quantity: qty,
|
||||||
|
@ -1813,7 +1814,7 @@ fn submit_order_req(
|
||||||
fn send_prepare_info_req(
|
fn send_prepare_info_req(
|
||||||
tx: Sender<String>,
|
tx: Sender<String>,
|
||||||
ctx: egui::Context,
|
ctx: egui::Context,
|
||||||
mediator: String,
|
adjudicator: String,
|
||||||
orid: &String,
|
orid: &String,
|
||||||
vendor: String,
|
vendor: String,
|
||||||
) {
|
) {
|
||||||
|
@ -1821,8 +1822,10 @@ fn send_prepare_info_req(
|
||||||
let v_orid: String = String::from(orid);
|
let v_orid: String = String::from(orid);
|
||||||
let w_orid: String = String::from(orid);
|
let w_orid: String = String::from(orid);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let m_jwp: String =
|
let m_jwp: String = utils::search_gui_db(
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator));
|
String::from(crate::GUI_JWP_DB_KEY),
|
||||||
|
String::from(&adjudicator),
|
||||||
|
);
|
||||||
let v_jwp: String =
|
let v_jwp: String =
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
||||||
let wallet_password = utils::empty_string();
|
let wallet_password = utils::empty_string();
|
||||||
|
@ -1845,14 +1848,14 @@ fn send_prepare_info_req(
|
||||||
String::from(&w_orid),
|
String::from(&w_orid),
|
||||||
String::from(ref_prepare_info),
|
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
|
// Will coordinating send this on make requests next
|
||||||
let s = db::Interface::async_open().await;
|
let s = db::Interface::async_open().await;
|
||||||
let m_msig_key = format!(
|
let m_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::PREPARE_MSIG,
|
message::PREPARE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -1870,7 +1873,7 @@ fn send_prepare_info_req(
|
||||||
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: Vec::new(),
|
info: Vec::new(),
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::PREPARE_MSIG),
|
msig_type: String::from(message::PREPARE_MSIG),
|
||||||
orid: String::from(v_orid),
|
orid: String::from(v_orid),
|
||||||
|
@ -1879,18 +1882,19 @@ fn send_prepare_info_req(
|
||||||
}
|
}
|
||||||
if m_prepare == utils::empty_string() {
|
if m_prepare == utils::empty_string() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"constructing mediator {} msig messages",
|
"constructing adjudicator {} msig messages",
|
||||||
message::PREPARE_MSIG
|
message::PREPARE_MSIG
|
||||||
);
|
);
|
||||||
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: Vec::new(),
|
info: Vec::new(),
|
||||||
init_mediator: true,
|
init_adjudicator: true,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::PREPARE_MSIG),
|
msig_type: String::from(message::PREPARE_MSIG),
|
||||||
orid: String::from(m_orid),
|
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));
|
let _ = tx.send(String::from(ref_prepare_info));
|
||||||
});
|
});
|
||||||
|
@ -1900,7 +1904,7 @@ fn send_prepare_info_req(
|
||||||
fn send_make_info_req(
|
fn send_make_info_req(
|
||||||
tx: Sender<String>,
|
tx: Sender<String>,
|
||||||
ctx: egui::Context,
|
ctx: egui::Context,
|
||||||
mediator: String,
|
adjudicator: String,
|
||||||
orid: &String,
|
orid: &String,
|
||||||
vendor: String,
|
vendor: String,
|
||||||
) {
|
) {
|
||||||
|
@ -1908,8 +1912,10 @@ fn send_make_info_req(
|
||||||
let v_orid: String = String::from(orid);
|
let v_orid: String = String::from(orid);
|
||||||
let w_orid: String = String::from(orid);
|
let w_orid: String = String::from(orid);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let m_jwp: String =
|
let m_jwp: String = utils::search_gui_db(
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator));
|
String::from(crate::GUI_JWP_DB_KEY),
|
||||||
|
String::from(&adjudicator),
|
||||||
|
);
|
||||||
let v_jwp: String =
|
let v_jwp: String =
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
||||||
let wallet_password = utils::empty_string();
|
let wallet_password = utils::empty_string();
|
||||||
|
@ -1923,7 +1929,7 @@ fn send_make_info_req(
|
||||||
let mut prepare_info_prep = Vec::new();
|
let mut prepare_info_prep = Vec::new();
|
||||||
let mut m_prepare_info_send = Vec::new();
|
let mut m_prepare_info_send = Vec::new();
|
||||||
let mut v_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
|
// make_multisig and send the reponse (String) back
|
||||||
let c_prepare = utils::search_gui_db(
|
let c_prepare = utils::search_gui_db(
|
||||||
String::from(crate::GUI_MSIG_PREPARE_DB_KEY),
|
String::from(crate::GUI_MSIG_PREPARE_DB_KEY),
|
||||||
|
@ -1934,7 +1940,7 @@ fn send_make_info_req(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::PREPARE_MSIG,
|
message::PREPARE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -1966,7 +1972,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
|
// Will coordinating send this on make requests next
|
||||||
|
|
||||||
let s = db::Interface::async_open().await;
|
let s = db::Interface::async_open().await;
|
||||||
|
@ -1974,7 +1980,7 @@ fn send_make_info_req(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::MAKE_MSIG,
|
message::MAKE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -1989,7 +1995,7 @@ fn send_make_info_req(
|
||||||
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: v_prepare_info_send,
|
info: v_prepare_info_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::MAKE_MSIG),
|
msig_type: String::from(message::MAKE_MSIG),
|
||||||
orid: String::from(v_orid),
|
orid: String::from(v_orid),
|
||||||
|
@ -1997,16 +2003,20 @@ fn send_make_info_req(
|
||||||
let _v_result = message::d_trigger_msig_info(&vendor, &v_jwp, &v_msig_request).await;
|
let _v_result = message::d_trigger_msig_info(&vendor, &v_jwp, &v_msig_request).await;
|
||||||
}
|
}
|
||||||
if m_make == utils::empty_string() {
|
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 {
|
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: m_prepare_info_send,
|
info: m_prepare_info_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::MAKE_MSIG),
|
msig_type: String::from(message::MAKE_MSIG),
|
||||||
orid: String::from(m_orid),
|
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));
|
let _ = tx.send(String::from(&local_make));
|
||||||
});
|
});
|
||||||
|
@ -2016,7 +2026,7 @@ fn send_make_info_req(
|
||||||
fn send_kex_initial_req(
|
fn send_kex_initial_req(
|
||||||
tx: Sender<String>,
|
tx: Sender<String>,
|
||||||
ctx: egui::Context,
|
ctx: egui::Context,
|
||||||
mediator: String,
|
adjudicator: String,
|
||||||
orid: &String,
|
orid: &String,
|
||||||
vendor: String,
|
vendor: String,
|
||||||
) {
|
) {
|
||||||
|
@ -2024,8 +2034,10 @@ fn send_kex_initial_req(
|
||||||
let v_orid: String = String::from(orid);
|
let v_orid: String = String::from(orid);
|
||||||
let w_orid: String = String::from(orid);
|
let w_orid: String = String::from(orid);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let m_jwp: String =
|
let m_jwp: String = utils::search_gui_db(
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator));
|
String::from(crate::GUI_JWP_DB_KEY),
|
||||||
|
String::from(&adjudicator),
|
||||||
|
);
|
||||||
let v_jwp: String =
|
let v_jwp: String =
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
||||||
let wallet_password = utils::empty_string();
|
let wallet_password = utils::empty_string();
|
||||||
|
@ -2039,7 +2051,7 @@ fn send_kex_initial_req(
|
||||||
let mut kex_init_prep = Vec::new();
|
let mut kex_init_prep = Vec::new();
|
||||||
let mut m_kex_init_send = Vec::new();
|
let mut m_kex_init_send = Vec::new();
|
||||||
let mut v_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
|
// kex final one and send the reponse (info) back
|
||||||
let c_kex_init = utils::search_gui_db(
|
let c_kex_init = utils::search_gui_db(
|
||||||
String::from(crate::GUI_MSIG_MAKE_DB_KEY),
|
String::from(crate::GUI_MSIG_MAKE_DB_KEY),
|
||||||
|
@ -2050,7 +2062,7 @@ fn send_kex_initial_req(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::MAKE_MSIG,
|
message::MAKE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -2083,14 +2095,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
|
// Will coordinating send this on kex round two next
|
||||||
let s = db::Interface::async_open().await;
|
let s = db::Interface::async_open().await;
|
||||||
let m_msig_key = format!(
|
let m_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::KEX_ONE_MSIG,
|
message::KEX_ONE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -2108,7 +2120,7 @@ fn send_kex_initial_req(
|
||||||
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: v_kex_init_send,
|
info: v_kex_init_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: true,
|
kex_init: true,
|
||||||
msig_type: String::from(message::KEX_ONE_MSIG),
|
msig_type: String::from(message::KEX_ONE_MSIG),
|
||||||
orid: String::from(v_orid),
|
orid: String::from(v_orid),
|
||||||
|
@ -2117,18 +2129,19 @@ fn send_kex_initial_req(
|
||||||
}
|
}
|
||||||
if m_kex_init == utils::empty_string() {
|
if m_kex_init == utils::empty_string() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"constructing mediator {} msig messages",
|
"constructing adjudicator {} msig messages",
|
||||||
message::KEX_ONE_MSIG
|
message::KEX_ONE_MSIG
|
||||||
);
|
);
|
||||||
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: m_kex_init_send,
|
info: m_kex_init_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: true,
|
kex_init: true,
|
||||||
msig_type: String::from(message::KEX_ONE_MSIG),
|
msig_type: String::from(message::KEX_ONE_MSIG),
|
||||||
orid: String::from(m_orid),
|
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));
|
let _ = tx.send(String::from(&local_kex_init));
|
||||||
});
|
});
|
||||||
|
@ -2138,7 +2151,7 @@ fn send_kex_initial_req(
|
||||||
fn send_kex_final_req(
|
fn send_kex_final_req(
|
||||||
tx: Sender<String>,
|
tx: Sender<String>,
|
||||||
ctx: egui::Context,
|
ctx: egui::Context,
|
||||||
mediator: String,
|
adjudicator: String,
|
||||||
orid: &String,
|
orid: &String,
|
||||||
vendor: String,
|
vendor: String,
|
||||||
) {
|
) {
|
||||||
|
@ -2146,8 +2159,10 @@ fn send_kex_final_req(
|
||||||
let v_orid: String = String::from(orid);
|
let v_orid: String = String::from(orid);
|
||||||
let w_orid: String = String::from(orid);
|
let w_orid: String = String::from(orid);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let m_jwp: String =
|
let m_jwp: String = utils::search_gui_db(
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&mediator));
|
String::from(crate::GUI_JWP_DB_KEY),
|
||||||
|
String::from(&adjudicator),
|
||||||
|
);
|
||||||
let v_jwp: String =
|
let v_jwp: String =
|
||||||
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
utils::search_gui_db(String::from(crate::GUI_JWP_DB_KEY), String::from(&vendor));
|
||||||
let wallet_password = utils::empty_string();
|
let wallet_password = utils::empty_string();
|
||||||
|
@ -2170,7 +2185,7 @@ fn send_kex_final_req(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::KEX_ONE_MSIG,
|
message::KEX_ONE_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -2209,7 +2224,7 @@ fn send_kex_final_req(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
message::KEX_TWO_MSIG,
|
message::KEX_TWO_MSIG,
|
||||||
String::from(&m_orid),
|
String::from(&m_orid),
|
||||||
mediator
|
adjudicator
|
||||||
);
|
);
|
||||||
let v_msig_key = format!(
|
let v_msig_key = format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
|
@ -2227,7 +2242,7 @@ fn send_kex_final_req(
|
||||||
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: v_kex_final_send,
|
info: v_kex_final_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::KEX_TWO_MSIG),
|
msig_type: String::from(message::KEX_TWO_MSIG),
|
||||||
orid: String::from(v_orid),
|
orid: String::from(v_orid),
|
||||||
|
@ -2236,18 +2251,19 @@ fn send_kex_final_req(
|
||||||
}
|
}
|
||||||
if m_kex_final == utils::empty_string() {
|
if m_kex_final == utils::empty_string() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"constructing mediator {} msig messages",
|
"constructing adjudicator {} msig messages",
|
||||||
message::KEX_TWO_MSIG
|
message::KEX_TWO_MSIG
|
||||||
);
|
);
|
||||||
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let m_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info: m_kex_final_send,
|
info: m_kex_final_send,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::KEX_TWO_MSIG),
|
msig_type: String::from(message::KEX_TWO_MSIG),
|
||||||
orid: String::from(m_orid),
|
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));
|
let _ = tx.send(String::from(&local_kex_final));
|
||||||
});
|
});
|
||||||
|
@ -2347,7 +2363,7 @@ fn send_import_info_req(tx: Sender<String>, ctx: egui::Context, orid: &String, v
|
||||||
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
let v_msig_request: reqres::MultisigInfoRequest = reqres::MultisigInfoRequest {
|
||||||
contact: i2p::get_destination(None),
|
contact: i2p::get_destination(None),
|
||||||
info,
|
info,
|
||||||
init_mediator: false,
|
init_adjudicator: false,
|
||||||
kex_init: false,
|
kex_init: false,
|
||||||
msig_type: String::from(message::IMPORT_MSIG),
|
msig_type: String::from(message::IMPORT_MSIG),
|
||||||
orid: String::from(v_orid),
|
orid: String::from(v_orid),
|
||||||
|
@ -2398,17 +2414,17 @@ fn cancel_order_req(
|
||||||
// End Async fn requests
|
// End Async fn requests
|
||||||
|
|
||||||
fn validate_msig_step(
|
fn validate_msig_step(
|
||||||
mediator: &String,
|
adjudicator: &String,
|
||||||
orid: &String,
|
orid: &String,
|
||||||
vendor: &String,
|
vendor: &String,
|
||||||
sub_type: &String,
|
sub_type: &String,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let s = db::Interface::open();
|
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 v_msig_key = format!("{}-{}-{}", sub_type, orid, vendor);
|
||||||
let m_info = db::Interface::read(&s.env, &s.handle, &m_msig_key);
|
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);
|
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);
|
log::debug!("{} vendor info: {}", sub_type, &v_info);
|
||||||
m_info != utils::empty_string() && v_info != utils::empty_string()
|
m_info != utils::empty_string() && v_info != utils::empty_string()
|
||||||
}
|
}
|
||||||
|
@ -2457,7 +2473,7 @@ fn create_dispute_req(
|
||||||
monero::open_wallet(&wallet_name, &wallet_password).await;
|
monero::open_wallet(&wallet_name, &wallet_password).await;
|
||||||
let address_res = monero::get_address().await;
|
let address_res = monero::get_address().await;
|
||||||
monero::close_wallet(&wallet_name, &wallet_password).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();
|
let wallet_password = utils::empty_string();
|
||||||
monero::open_wallet(&d_orid, &wallet_password).await;
|
monero::open_wallet(&d_orid, &wallet_password).await;
|
||||||
let transfer = monero::sweep_all(String::from(address_res.result.address)).await;
|
let transfer = monero::sweep_all(String::from(address_res.result.address)).await;
|
||||||
|
|
|
@ -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_EXPORT_DB_KEY: &str = "gui-export";
|
||||||
pub const GUI_MSIG_IMPORT_DB_KEY: &str = "gui-import";
|
pub const GUI_MSIG_IMPORT_DB_KEY: &str = "gui-import";
|
||||||
pub const GUI_MSIG_MAKE_DB_KEY: &str = "gui-make";
|
pub const GUI_MSIG_MAKE_DB_KEY: &str = "gui-make";
|
||||||
pub const GUI_MSIG_MEDIATOR_DB_KEY: &str = "gui-mediator";
|
pub const GUI_MSIG_MEDIATOR_DB_KEY: &str = "gui-adjudicator";
|
||||||
pub const GUI_MSIG_PREPARE_DB_KEY: &str = "gui-prepare";
|
pub const GUI_MSIG_PREPARE_DB_KEY: &str = "gui-prepare";
|
||||||
pub const GUI_MSIG_TXSET_DB_KEY: &str = "gui-txset";
|
pub const GUI_MSIG_TXSET_DB_KEY: &str = "gui-txset";
|
||||||
// End LMDB keys
|
// End LMDB keys
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|cust | X | | |
|
|cust | X | | |
|
||||||
|med | 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
|
* participants all make_info
|
||||||
|
|
||||||
| | prepare | make | exchange |
|
| | prepare | make | exchange |
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
* vendor drafts the multisig txset and sends to customer with tracking/delivery info
|
* vendor drafts the multisig txset and sends to customer with tracking/delivery info
|
||||||
* order arrives, customer releases signed txset to vendor
|
* order arrives, customer releases signed txset to vendor
|
||||||
* vendor signs and submits signed txset
|
* 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
|
or if the customer doesn't release payment after delivery
|
||||||
|
|
||||||
Reference: https://resilience365.com/monero-multisig-how-to/
|
Reference: https://resilience365.com/monero-multisig-how-to/
|
||||||
|
|
|
@ -148,9 +148,9 @@ pub async fn get_multisig_info(
|
||||||
) -> Custom<Json<models::Order>> {
|
) -> Custom<Json<models::Order>> {
|
||||||
let info: Vec<String> = r_info.info.iter().cloned().collect();
|
let info: Vec<String> = r_info.info.iter().cloned().collect();
|
||||||
if r_info.msig_type == String::from(message::PREPARE_MSIG) {
|
if r_info.msig_type == String::from(message::PREPARE_MSIG) {
|
||||||
// mediator won't have wallet for order yet do that first
|
// adjudicator won't have wallet for order yet do that first
|
||||||
if r_info.init_mediator {
|
if r_info.init_adjudicator {
|
||||||
order::init_mediator_wallet(&r_info.orid).await;
|
order::init_adjudicator_wallet(&r_info.orid).await;
|
||||||
}
|
}
|
||||||
message::send_prepare_info(&r_info.orid, &r_info.contact).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 == String::from(message::MAKE_MSIG) {
|
||||||
|
|
Loading…
Reference in a new issue