fixup tx proxy args

This commit is contained in:
creating2morrow 2023-06-04 12:44:44 -04:00
parent ffee9de424
commit 348725ad4c
6 changed files with 45 additions and 30 deletions

View file

@ -87,9 +87,14 @@ async fn find_tunnels() {
debug!("creating http tunnel"); debug!("creating http tunnel");
create_http_proxy(); create_http_proxy();
} }
let env = utils::get_release_env();
// only use tx proxy on mainnet
if env == utils::ReleaseEnvironment::Production {
if !has_tx_proxy_tunnel && !utils::is_using_remote_node() { if !has_tx_proxy_tunnel && !utils::is_using_remote_node() {
debug!("creating tx proxy tunnel");
create_tx_proxy_tunnel(); create_tx_proxy_tunnel();
} }
}
} }
/// Called on application startup for i2p tunnel creation, /// Called on application startup for i2p tunnel creation,

View file

@ -1,8 +1,9 @@
use crate::{ use crate::{
args, args,
i2p,
proof, proof,
reqres, reqres,
utils, i2p, utils,
}; };
use clap::Parser; use clap::Parser;
use diqwest::WithDigestAuth; use diqwest::WithDigestAuth;
@ -124,7 +125,7 @@ pub fn start_daemon() {
let tx_proxy = format!("i2p,{}", utils::get_i2p_http_proxy()); let tx_proxy = format!("i2p,{}", utils::get_i2p_http_proxy());
let port = get_daemon_port(); let port = get_daemon_port();
let destination = i2p::get_destination(Some(port)); let destination = i2p::get_destination(Some(port));
let anon_inbound = format!("{}:{},8", destination, port); let anon_inbound = format!("{},127.0.0.1:{},8", destination, port);
if release_env == utils::ReleaseEnvironment::Development { if release_env == utils::ReleaseEnvironment::Development {
let args = ["--data-dir", &blockchain_dir, "--stagenet", "--detach"]; let args = ["--data-dir", &blockchain_dir, "--stagenet", "--detach"];
let output = Command::new(format!("{}/monerod", bin_dir)) let output = Command::new(format!("{}/monerod", bin_dir))
@ -133,7 +134,8 @@ pub fn start_daemon() {
.expect("monerod failed to start"); .expect("monerod failed to start");
debug!("{:?}", output.stdout); debug!("{:?}", output.stdout);
} else { } else {
let args = [" let args = [
"
--data-dir", --data-dir",
&blockchain_dir, &blockchain_dir,
"--tx-proxy", "--tx-proxy",
@ -736,7 +738,9 @@ pub async fn submit_multisig(tx_data_hex: String) -> reqres::XmrRpcSubmitMultisi
.await .await
{ {
Ok(response) => { Ok(response) => {
let res = response.json::<reqres::XmrRpcSubmitMultisigResponse>().await; let res = response
.json::<reqres::XmrRpcSubmitMultisigResponse>()
.await;
debug!("{} response: {:?}", RpcFields::SubmitMultisig.value(), res); debug!("{} response: {:?}", RpcFields::SubmitMultisig.value(), res);
match res { match res {
Ok(res) => res, Ok(res) => res,

View file

@ -12,16 +12,13 @@ use log::{
}; };
use rocket::serde::json::Json; use rocket::serde::json::Json;
/* /*
TODOs(c2m): TODOs(c2m):
- API to validate payment and import multisig info - API to validate payment and import multisig info, update to multisig complete
- API to upload gpg encrypted tracking number - API to upload gpg encrypted tracking number, update order to shipped
release tracking (locker code?) when txset is released release tracking (locker code?) when txset is released, update to delivered
- update order status
*/ */
enum StatusType { enum StatusType {
_Delivered, _Delivered,
MultisigMissing, MultisigMissing,
@ -157,7 +154,8 @@ pub fn modify(o: Json<Order>) -> Order {
/// Sign and submit multisig /// Sign and submit multisig
pub async fn sign_and_submit_multisig( pub async fn sign_and_submit_multisig(
orid: &String, orid: &String,
tx_data_hex: &String) -> reqres::XmrRpcSubmitMultisigResponse { tx_data_hex: &String,
) -> reqres::XmrRpcSubmitMultisigResponse {
info!("signing and submitting multisig"); info!("signing and submitting multisig");
let r_sign: reqres::XmrRpcSignMultisigResponse = let r_sign: reqres::XmrRpcSignMultisigResponse =
monero::sign_multisig(String::from(tx_data_hex)).await; monero::sign_multisig(String::from(tx_data_hex)).await;
@ -168,3 +166,13 @@ pub async fn sign_and_submit_multisig(
} }
r_submit r_submit
} }
pub async fn validate_order_for_ship() -> bool {
info!("validating order for shipment");
// import multisig info
// check balance and unlock_time
// update the order status to multisig complete
return false;
}

View file

@ -24,7 +24,8 @@ async fn rocket() -> _ {
routes![ routes![
controller::get_order, controller::get_order,
controller::sign_and_submit_multisig, controller::sign_and_submit_multisig,
controller::update_order], controller::update_order
],
) )
.mount("/orders", routes![controller::get_orders]) .mount("/orders", routes![controller::get_orders])
.mount("/products", routes![controller::get_products]) .mount("/products", routes![controller::get_products])

View file

@ -98,7 +98,7 @@ pub async fn create_order(
Custom(Status::Created, Json(m_order)) Custom(Status::Created, Json(m_order))
} }
/// TODO: Customer order retreival. Must send `signature` /// TODO(c2m): Customer order retreival. Must send `signature`
/// ///
/// which is the order id signed by the wallet. /// which is the order id signed by the wallet.
/// ///
@ -157,11 +157,8 @@ pub async fn rx_multisig_message(
/// multisig info, check balance and sanity check `unlock_time`. /// multisig info, check balance and sanity check `unlock_time`.
/// ///
/// Protected: true /// Protected: true
#[post("/", data = "<message>")] #[post("/")]
pub async fn request_shipment( pub async fn request_shipment(_jwp: proof::PaymentProof) -> Custom<Json<models::Message>> {
_jwp: proof::PaymentProof, order::validate_order_for_ship().await;
message: Json<models::Message>,
) -> Custom<Json<models::Message>> {
//validate_order_for_ship();
Custom(Status::Ok, Json(Default::default())) Custom(Status::Ok, Json(Default::default()))
} }