mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-11-21 22:54:09 +01:00
Deprecate HTTP(S) (#532)
* Deprecate HTTP(S) * Remove http support altogether
This commit is contained in:
@@ -39,7 +39,7 @@ pub struct HttpSlateSender {
|
||||
|
||||
impl HttpSlateSender {
|
||||
/// Create, return Err if scheme is not "http"
|
||||
pub fn new(base_url: &str) -> Result<HttpSlateSender, SchemeNotHttp> {
|
||||
fn new(base_url: &str) -> Result<HttpSlateSender, SchemeNotHttp> {
|
||||
if !base_url.starts_with("http") && !base_url.starts_with("https") {
|
||||
Err(SchemeNotHttp)
|
||||
} else {
|
||||
|
||||
@@ -22,9 +22,8 @@ pub use self::http::{HttpSlateSender, SchemeNotHttp};
|
||||
pub use self::keybase::{KeybaseAllChannels, KeybaseChannel};
|
||||
pub use self::slatepack::PathToSlatepack;
|
||||
|
||||
use crate::config::{TorConfig, WalletConfig};
|
||||
use crate::libwallet::{Error, ErrorKind, Slate};
|
||||
use crate::tor::config::complete_tor_address;
|
||||
use crate::config::WalletConfig;
|
||||
use crate::libwallet::{Error, Slate};
|
||||
use crate::util::ZeroingString;
|
||||
|
||||
/// Sends transactions to a corresponding SlateReceiver
|
||||
@@ -59,64 +58,3 @@ pub trait SlateGetter {
|
||||
/// Returns (Slate, whether it was in binary form)
|
||||
fn get_tx(&self) -> Result<(Slate, bool), Error>;
|
||||
}
|
||||
|
||||
/// select a SlateSender based on method and dest fields from, e.g., SendArgs
|
||||
pub fn create_sender(
|
||||
method: &str,
|
||||
dest: &str,
|
||||
tor_config: Option<TorConfig>,
|
||||
) -> Result<Box<dyn SlateSender>, Error> {
|
||||
let invalid = || {
|
||||
ErrorKind::WalletComms(format!(
|
||||
"Invalid wallet comm type and destination. method: {}, dest: {}",
|
||||
method, dest
|
||||
))
|
||||
};
|
||||
|
||||
let mut method = method;
|
||||
|
||||
// will test if this is a tor address and fill out
|
||||
// the http://[].onion if missing
|
||||
let dest = match complete_tor_address(dest) {
|
||||
Ok(d) => {
|
||||
method = "tor";
|
||||
d
|
||||
}
|
||||
Err(_) => dest.into(),
|
||||
};
|
||||
|
||||
Ok(match method {
|
||||
"http" => Box::new(HttpSlateSender::new(&dest).map_err(|_| invalid())?),
|
||||
"tor" => match tor_config {
|
||||
None => {
|
||||
return Err(
|
||||
ErrorKind::WalletComms("Tor Configuration required".to_string()).into(),
|
||||
);
|
||||
}
|
||||
Some(tc) => Box::new(
|
||||
HttpSlateSender::with_socks_proxy(&dest, &tc.socks_proxy_addr, &tc.send_config_dir)
|
||||
.map_err(|_| invalid())?,
|
||||
),
|
||||
},
|
||||
"keybase" => Box::new(KeybaseChannel::new(dest)?),
|
||||
"self" => {
|
||||
return Err(ErrorKind::WalletComms(
|
||||
"No sender implementation for \"self\".".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
"file" => {
|
||||
return Err(ErrorKind::WalletComms(
|
||||
"File based transactions must be performed asynchronously.".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
_ => {
|
||||
return Err(ErrorKind::WalletComms(format!(
|
||||
"Wallet comm method \"{}\" does not exist.",
|
||||
method
|
||||
))
|
||||
.into());
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ pub mod test_framework;
|
||||
pub mod tor;
|
||||
|
||||
pub use crate::adapters::{
|
||||
create_sender, HttpSlateSender, KeybaseAllChannels, KeybaseChannel, PathToSlate,
|
||||
PathToSlatepack, SlateGetter, SlatePutter, SlateReceiver, SlateSender,
|
||||
HttpSlateSender, KeybaseAllChannels, KeybaseChannel, PathToSlate, PathToSlatepack, SlateGetter,
|
||||
SlatePutter, SlateReceiver, SlateSender,
|
||||
};
|
||||
pub use crate::backends::{wallet_db_exists, LMDBBackend};
|
||||
pub use crate::error::{Error, ErrorKind};
|
||||
|
||||
Reference in New Issue
Block a user