Optional Tor Send/Listen Functionality (#226)

* udpate for beta release

* initial tor explorations

* rustfmt

* basic tor tx send working

* rustfmt

* add tor proxy info to config file

* rustfmt

* add utilities to output tor hidden service configuration files

* output tor config as part of listener startup

* rustfmt

* fully automate config and startup of tor process

* rustfmt

* remove unnecessary process kill commands from listener

* rustfmt

* assume defaults for tor sending config if section doesn't exist in grin-wallet.toml

* rustfmt

* ignore tor dev test

* update default paths output by config, compilation + confirmed working on windows

* rustfmt

* fix on osx/unix

* add timeout to tor connector, remove unwrap in client

* allow specifiying tor address without 'http://[].onion' on the command line

* fix api test

* rustfmt

* update address derivation path as per spec

* rustfmt

* move tor init to separate function

* rustfmt

* re-ignore tor dev test

* listen on tor by default if tor available

* rustfmt

* test fix

* remove explicit send via tor flag, and assume tor if address fits

* rustfmt
This commit is contained in:
Yeastplume
2019-10-14 20:24:09 +01:00
committed by GitHub
parent c60301946f
commit b4eeb50c66
34 changed files with 2311 additions and 153 deletions
+8 -5
View File
@@ -17,7 +17,7 @@
use chrono::prelude::*;
use uuid::Uuid;
use crate::config::WalletConfig;
use crate::config::{TorConfig, WalletConfig};
use crate::core::core::Transaction;
use crate::core::global;
use crate::impls::create_sender;
@@ -579,7 +579,8 @@ where
.into());
}
};
let comm_adapter = create_sender(&sa.method, &sa.dest)
//TODO: no TOR just now via this method, to keep compatibility for now
let comm_adapter = create_sender(&sa.method, &sa.dest, None)
.map_err(|e| ErrorKind::GenericError(format!("{}", e)))?;
slate = comm_adapter.send_tx(&slate)?;
self.tx_lock_outputs(keychain_mask, &slate, 0)?;
@@ -1361,7 +1362,7 @@ where
/// let api_owner = Owner::new(wallet.clone());
/// let _ = api_owner.set_top_level_directory(dir);
///
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// if let Ok(_) = result {
/// //...
@@ -1373,6 +1374,7 @@ where
chain_type: &global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), Error> {
let mut w_lock = self.wallet_inst.lock();
let lc = w_lock.lc_provider()?;
@@ -1381,6 +1383,7 @@ where
"grin-wallet.toml",
wallet_config,
logging_config,
tor_config,
)
}
@@ -1429,7 +1432,7 @@ where
/// let _ = api_owner.set_top_level_directory(dir);
///
/// // Create configuration
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// // create new wallet wirh random seed
/// let pw = ZeroingString::from("my_password");
@@ -1496,7 +1499,7 @@ where
/// let _ = api_owner.set_top_level_directory(dir);
///
/// // Create configuration
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None);
/// let result = api_owner.create_config(&ChainTypes::Mainnet, None, None, None);
///
/// // create new wallet wirh random seed
/// let pw = ZeroingString::from("my_password");
+10 -2
View File
@@ -15,7 +15,7 @@
//! JSON-RPC Stub generation for the Owner API
use uuid::Uuid;
use crate::config::WalletConfig;
use crate::config::{TorConfig, WalletConfig};
use crate::core::core::Transaction;
use crate::core::global;
use crate::keychain::{Identifier, Keychain};
@@ -1469,6 +1469,11 @@ pub trait OwnerRpcS {
"log_max_size": null,
"log_max_files": null,
"tui_running": null
},
"tor_config" : {
"use_tor_listener": true,
"socks_proxy_addr": "127.0.0.1:9050",
"send_config_dir": "."
}
},
"id": 1
@@ -1492,6 +1497,7 @@ pub trait OwnerRpcS {
chain_type: global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), ErrorKind>;
/**
@@ -1912,8 +1918,10 @@ where
chain_type: global::ChainTypes,
wallet_config: Option<WalletConfig>,
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), ErrorKind> {
Owner::create_config(self, &chain_type, wallet_config, logging_config).map_err(|e| e.kind())
Owner::create_config(self, &chain_type, wallet_config, logging_config, tor_config)
.map_err(|e| e.kind())
}
fn create_wallet(