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,8 +87,13 @@ async fn find_tunnels() {
debug!("creating http tunnel");
create_http_proxy();
}
if !has_tx_proxy_tunnel && !utils::is_using_remote_node() {
create_tx_proxy_tunnel();
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() {
debug!("creating tx proxy tunnel");
create_tx_proxy_tunnel();
}
}
}
@ -176,7 +181,7 @@ fn create_http_proxy() {
/// This is the `dest` value of the app i2p tunnels
///
/// in `tunnels-config.json`.
///
///
/// `port` - the port of the tunnel (e.g. `utils::get_app_port()`)
pub fn get_destination(port: Option<u16>) -> String {
let file_path = format!(

View file

@ -153,9 +153,9 @@ fn parse_multisig_message(mid: String) -> MultisigMessageData {
/// decrypted for convenience sake. The client must determine which
///
/// .b32.i2p address belongs to the vendor / mediator.
///
///
/// The result should be a string that needs to be decomposed into a
///
///
/// vector.
/// ### Example
///

View file

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

View file

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

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

View file

@ -98,7 +98,7 @@ pub async fn create_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.
///
@ -151,17 +151,14 @@ pub async fn rx_multisig_message(
}
/// Customer can request shipment after the wallet is funded
///
///
/// with the amount of the order. The vendor will then request export
///
///
/// multisig info, check balance and sanity check `unlock_time`.
///
/// Protected: true
#[post("/", data = "<message>")]
pub async fn request_shipment(
_jwp: proof::PaymentProof,
message: Json<models::Message>,
) -> Custom<Json<models::Message>> {
//validate_order_for_ship();
#[post("/")]
pub async fn request_shipment(_jwp: proof::PaymentProof) -> Custom<Json<models::Message>> {
order::validate_order_for_ship().await;
Custom(Status::Ok, Json(Default::default()))
}