mirror of
https://github.com/creating2morrow/neveko.git
synced 2025-01-03 17:39:55 +00:00
patches for daemon proxy request
This commit is contained in:
parent
c5bd5c407f
commit
b1800617d8
3 changed files with 32 additions and 37 deletions
|
@ -334,12 +334,11 @@ fn get_rpc_creds() -> RpcLogin {
|
||||||
fn get_rpc_daemon() -> String {
|
fn get_rpc_daemon() -> String {
|
||||||
let args = args::Args::parse();
|
let args = args::Args::parse();
|
||||||
let gui_host = std::env::var(crate::MONERO_DAEMON_HOST).unwrap_or(utils::empty_string());
|
let gui_host = std::env::var(crate::MONERO_DAEMON_HOST).unwrap_or(utils::empty_string());
|
||||||
let daemon = if gui_host == utils::empty_string() {
|
if gui_host == utils::empty_string() {
|
||||||
String::from(args.monero_rpc_daemon)
|
String::from(args.monero_rpc_daemon)
|
||||||
} else {
|
} else {
|
||||||
gui_host
|
gui_host
|
||||||
};
|
}
|
||||||
format!("{}/json_rpc", daemon)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs rpc 'get_version' method
|
/// Performs rpc 'get_version' method
|
||||||
|
@ -1158,7 +1157,7 @@ pub async fn create_address() -> reqres::XmrRpcCreateAddressResponse {
|
||||||
pub async fn get_info() -> reqres::XmrDaemonGetInfoResponse {
|
pub async fn get_info() -> reqres::XmrDaemonGetInfoResponse {
|
||||||
info!("fetching daemon info");
|
info!("fetching daemon info");
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let host = get_rpc_daemon();
|
let host = format!("{}/json_rpc", get_rpc_daemon());
|
||||||
let req = reqres::XmrRpcRequest {
|
let req = reqres::XmrRpcRequest {
|
||||||
jsonrpc: DaemonFields::Version.value(),
|
jsonrpc: DaemonFields::Version.value(),
|
||||||
id: DaemonFields::Id.value(),
|
id: DaemonFields::Id.value(),
|
||||||
|
@ -1183,7 +1182,7 @@ pub async fn p_get_info() -> Result<reqres::XmrDaemonGetInfoResponse, Box<dyn Er
|
||||||
let host = utils::get_i2p_http_proxy();
|
let host = utils::get_i2p_http_proxy();
|
||||||
let proxy = reqwest::Proxy::http(&host)?;
|
let proxy = reqwest::Proxy::http(&host)?;
|
||||||
let client = reqwest::Client::builder().proxy(proxy).build();
|
let client = reqwest::Client::builder().proxy(proxy).build();
|
||||||
let host = get_rpc_daemon();
|
let host = format!("{}/json_rpc", get_rpc_daemon());
|
||||||
let req = reqres::XmrRpcRequest {
|
let req = reqres::XmrRpcRequest {
|
||||||
jsonrpc: DaemonFields::Version.value(),
|
jsonrpc: DaemonFields::Version.value(),
|
||||||
id: DaemonFields::Id.value(),
|
id: DaemonFields::Id.value(),
|
||||||
|
@ -1206,8 +1205,7 @@ pub async fn p_get_info() -> Result<reqres::XmrDaemonGetInfoResponse, Box<dyn Er
|
||||||
pub async fn get_height() -> reqres::XmrDaemonGetHeightResponse {
|
pub async fn get_height() -> reqres::XmrDaemonGetHeightResponse {
|
||||||
info!("fetching daemon height");
|
info!("fetching daemon height");
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let args = args::Args::parse();
|
let daemon = get_rpc_daemon();
|
||||||
let daemon = String::from(args.monero_rpc_daemon);
|
|
||||||
let req = format!("{}/{}", daemon, DaemonFields::GetHeight.value());
|
let req = format!("{}/{}", daemon, DaemonFields::GetHeight.value());
|
||||||
match client.post(req).send().await {
|
match client.post(req).send().await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
@ -1228,8 +1226,7 @@ pub async fn p_get_height() -> Result<reqres::XmrDaemonGetHeightResponse, Box<dy
|
||||||
let host = utils::get_i2p_http_proxy();
|
let host = utils::get_i2p_http_proxy();
|
||||||
let proxy = reqwest::Proxy::http(&host)?;
|
let proxy = reqwest::Proxy::http(&host)?;
|
||||||
let client = reqwest::Client::builder().proxy(proxy).build();
|
let client = reqwest::Client::builder().proxy(proxy).build();
|
||||||
let args = args::Args::parse();
|
let daemon = get_rpc_daemon();
|
||||||
let daemon = String::from(args.monero_rpc_daemon);
|
|
||||||
let req = format!("{}/{}", daemon, DaemonFields::GetHeight.value());
|
let req = format!("{}/{}", daemon, DaemonFields::GetHeight.value());
|
||||||
match client?.post(req).send().await {
|
match client?.post(req).send().await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
@ -1248,7 +1245,7 @@ pub async fn p_get_height() -> Result<reqres::XmrDaemonGetHeightResponse, Box<dy
|
||||||
pub async fn get_block(height: u64) -> reqres::XmrDaemonGetBlockResponse {
|
pub async fn get_block(height: u64) -> reqres::XmrDaemonGetBlockResponse {
|
||||||
info!("fetching block at height: {}", height);
|
info!("fetching block at height: {}", height);
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let host = get_rpc_daemon();
|
let host = format!("{}/json_rpc", get_rpc_daemon());
|
||||||
let params: reqres::XmrDaemonGetBlockParams = reqres::XmrDaemonGetBlockParams { height };
|
let params: reqres::XmrDaemonGetBlockParams = reqres::XmrDaemonGetBlockParams { height };
|
||||||
let req = reqres::XmrDaemonGetBlockRequest {
|
let req = reqres::XmrDaemonGetBlockRequest {
|
||||||
jsonrpc: DaemonFields::Version.value(),
|
jsonrpc: DaemonFields::Version.value(),
|
||||||
|
@ -1275,7 +1272,7 @@ pub async fn p_get_block(height: u64) -> Result<reqres::XmrDaemonGetBlockRespons
|
||||||
let host = utils::get_i2p_http_proxy();
|
let host = utils::get_i2p_http_proxy();
|
||||||
let proxy = reqwest::Proxy::http(&host)?;
|
let proxy = reqwest::Proxy::http(&host)?;
|
||||||
let client = reqwest::Client::builder().proxy(proxy).build();
|
let client = reqwest::Client::builder().proxy(proxy).build();
|
||||||
let host = get_rpc_daemon();
|
let host = format!("{}/json_rpc", get_rpc_daemon());
|
||||||
let params: reqres::XmrDaemonGetBlockParams = reqres::XmrDaemonGetBlockParams { height };
|
let params: reqres::XmrDaemonGetBlockParams = reqres::XmrDaemonGetBlockParams { height };
|
||||||
let req = reqres::XmrDaemonGetBlockRequest {
|
let req = reqres::XmrDaemonGetBlockRequest {
|
||||||
jsonrpc: DaemonFields::Version.value(),
|
jsonrpc: DaemonFields::Version.value(),
|
||||||
|
@ -1300,9 +1297,8 @@ pub async fn p_get_block(height: u64) -> Result<reqres::XmrDaemonGetBlockRespons
|
||||||
pub async fn get_transactions(txs_hashes: Vec<String>) -> reqres::XmrDaemonGetTransactionsResponse {
|
pub async fn get_transactions(txs_hashes: Vec<String>) -> reqres::XmrDaemonGetTransactionsResponse {
|
||||||
info!("fetching {} transactions", txs_hashes.len());
|
info!("fetching {} transactions", txs_hashes.len());
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let args = args::Args::parse();
|
let host = get_rpc_daemon();
|
||||||
let daemon = String::from(args.monero_rpc_daemon);
|
let url = format!("{}/{}", host, DaemonFields::GetTransactions.value());
|
||||||
let url = format!("{}/{}", daemon, DaemonFields::GetTransactions.value());
|
|
||||||
let req = reqres::XmrDaemonGetTransactionsRequest {
|
let req = reqres::XmrDaemonGetTransactionsRequest {
|
||||||
txs_hashes,
|
txs_hashes,
|
||||||
decode_as_json: true,
|
decode_as_json: true,
|
||||||
|
@ -1328,8 +1324,7 @@ pub async fn p_get_transactions(txs_hashes: Vec<String>) -> Result<reqres::XmrDa
|
||||||
let host = utils::get_i2p_http_proxy();
|
let host = utils::get_i2p_http_proxy();
|
||||||
let proxy = reqwest::Proxy::http(&host)?;
|
let proxy = reqwest::Proxy::http(&host)?;
|
||||||
let client = reqwest::Client::builder().proxy(proxy).build();
|
let client = reqwest::Client::builder().proxy(proxy).build();
|
||||||
let args = args::Args::parse();
|
let daemon = get_rpc_daemon();
|
||||||
let daemon = String::from(args.monero_rpc_daemon);
|
|
||||||
let url = format!("{}/{}", daemon, DaemonFields::GetTransactions.value());
|
let url = format!("{}/{}", daemon, DaemonFields::GetTransactions.value());
|
||||||
let req = reqres::XmrDaemonGetTransactionsRequest {
|
let req = reqres::XmrDaemonGetTransactionsRequest {
|
||||||
txs_hashes,
|
txs_hashes,
|
||||||
|
|
|
@ -740,11 +740,6 @@ pub async fn estimate_fee() -> u128 {
|
||||||
let mut height: u64 = 0;
|
let mut height: u64 = 0;
|
||||||
let mut count: u64 = 1;
|
let mut count: u64 = 1;
|
||||||
let mut v_fee: Vec<u128> = Vec::new();
|
let mut v_fee: Vec<u128> = Vec::new();
|
||||||
loop {
|
|
||||||
debug!("current height: {}", height);
|
|
||||||
if v_fee.len() >= 30 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let mut r_height: reqres::XmrDaemonGetHeightResponse = Default::default();
|
let mut r_height: reqres::XmrDaemonGetHeightResponse = Default::default();
|
||||||
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||||
if remote_var == String::from(crate::GUI_SET_REMOTE_NODE) {
|
if remote_var == String::from(crate::GUI_SET_REMOTE_NODE) {
|
||||||
|
@ -757,6 +752,11 @@ pub async fn estimate_fee() -> u128 {
|
||||||
error!("error fetching height");
|
error!("error fetching height");
|
||||||
return ESTIMATE_FEE_FAILURE;
|
return ESTIMATE_FEE_FAILURE;
|
||||||
}
|
}
|
||||||
|
loop {
|
||||||
|
debug!("current height: {}", height);
|
||||||
|
if v_fee.len() >= 30 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
height = r_height.height - count;
|
height = r_height.height - count;
|
||||||
let mut block: reqres::XmrDaemonGetBlockResponse = Default::default();
|
let mut block: reqres::XmrDaemonGetBlockResponse = Default::default();
|
||||||
if remote_var == String::from(crate::GUI_SET_REMOTE_NODE) {
|
if remote_var == String::from(crate::GUI_SET_REMOTE_NODE) {
|
||||||
|
@ -804,7 +804,7 @@ pub async fn can_transfer(invoice: u128) -> bool {
|
||||||
monero::close_wallet(&wallet_name, &wallet_password).await;
|
monero::close_wallet(&wallet_name, &wallet_password).await;
|
||||||
let fee = estimate_fee().await;
|
let fee = estimate_fee().await;
|
||||||
if fee == ESTIMATE_FEE_FAILURE {
|
if fee == ESTIMATE_FEE_FAILURE {
|
||||||
false;
|
return false;
|
||||||
}
|
}
|
||||||
debug!("fee estimated to: {}", fee);
|
debug!("fee estimated to: {}", fee);
|
||||||
debug!("balance: {}", balance.result.unlocked_balance);
|
debug!("balance: {}", balance.result.unlocked_balance);
|
||||||
|
|
|
@ -273,6 +273,11 @@ impl eframe::App for HomeApp {
|
||||||
ui.text_edit_singleline(&mut self.connections.i2p_proxy_host)
|
ui.text_edit_singleline(&mut self.connections.i2p_proxy_host)
|
||||||
.labelled_by(cm_i2p_proxy_label.id);
|
.labelled_by(cm_i2p_proxy_label.id);
|
||||||
});
|
});
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let cm_i2p_socks_label = ui.label("i2p socks host: \t");
|
||||||
|
ui.text_edit_singleline(&mut self.connections.i2p_socks_host)
|
||||||
|
.labelled_by(cm_i2p_socks_label.id);
|
||||||
|
});
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let cm_i2p_tunnels_label = ui.label("tunnels.json dir: ");
|
let cm_i2p_tunnels_label = ui.label("tunnels.json dir: ");
|
||||||
ui.text_edit_singleline(&mut self.connections.i2p_tunnels_json)
|
ui.text_edit_singleline(&mut self.connections.i2p_tunnels_json)
|
||||||
|
@ -301,18 +306,6 @@ impl eframe::App for HomeApp {
|
||||||
self.is_editing_connections = false;
|
self.is_editing_connections = false;
|
||||||
utils::kill_child_processes(true);
|
utils::kill_child_processes(true);
|
||||||
utils::start_core(&self.connections);
|
utils::start_core(&self.connections);
|
||||||
if self.connections.is_i2p_advanced {
|
|
||||||
// set the i2p proxy host for advanced user re-use
|
|
||||||
std::env::set_var(
|
|
||||||
neveko_core::NEVEKO_I2P_PROXY_HOST,
|
|
||||||
self.connections.i2p_proxy_host.clone(),
|
|
||||||
);
|
|
||||||
std::env::set_var(
|
|
||||||
neveko_core::NEVEKO_I2P_TUNNELS_JSON,
|
|
||||||
self.connections.i2p_tunnels_json.clone(),
|
|
||||||
);
|
|
||||||
std::env::set_var(neveko_core::NEVEKO_I2P_ADVANCED_MODE, String::from("1"));
|
|
||||||
}
|
|
||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
start_core_timeout(self.core_timeout_tx.clone(), ctx.clone());
|
start_core_timeout(self.core_timeout_tx.clone(), ctx.clone());
|
||||||
}
|
}
|
||||||
|
@ -444,8 +437,15 @@ impl eframe::App for HomeApp {
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
fn send_xmrd_get_info_req(tx: Sender<reqres::XmrDaemonGetInfoResponse>, ctx: egui::Context) {
|
fn send_xmrd_get_info_req(tx: Sender<reqres::XmrDaemonGetInfoResponse>, ctx: egui::Context) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let info: reqres::XmrDaemonGetInfoResponse = monero::get_info().await;
|
let remote_var = std::env::var(neveko_core::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||||
|
if remote_var == String::from(neveko_core::GUI_SET_REMOTE_NODE) {
|
||||||
|
let p_info = monero::p_get_info().await;
|
||||||
|
let info = p_info.unwrap_or(Default::default());
|
||||||
let _ = tx.send(info);
|
let _ = tx.send(info);
|
||||||
|
} else {
|
||||||
|
let info = monero::get_info().await;
|
||||||
|
let _ = tx.send(info);
|
||||||
|
}
|
||||||
ctx.request_repaint();
|
ctx.request_repaint();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue