pub fn check_other_version(
		&self,
		url: &str,
		timeout: Option<u128>,
	) -> Result<SlateVersion, Error> {
		let res_str: String;
		let start_time = std::time::Instant::now();
		trace!("starting now check version");

		loop {
			let req = json!({
				"jsonrpc": "2.0",
				"method": "check_version",
				"id": 1,
				"params": []
			});

			let res = self.post(url, self.apisecret.clone(), req);

			let diff_time = start_time.elapsed().as_millis();
			trace!("elapsed time check version = {}", diff_time);
			// we try until it's taken more than 30 seconds.
			if res.is_err() && diff_time <= timeout.unwrap_or(30_000) {
				let res_err_str = format!("{:?}", res);
				trace!(
					"Got error (version_check), but continuing: {}, time elapsed = {}ms",
					res_err_str,
					diff_time
				);
				// the api seems to have "GeneralFailures"
				// on some platforms. retry is fast and can be
				// done again.
				// keep trying for 30 seconds.
				continue;
			} else if !res.is_err() {
				res_str = res.unwrap();
				break;
			}

			res.map_err(|e| {
				let mut report =
					format!("Performing version check (is recipient listening?): {}", e);
				let err_string = format!("{}", e);
				if err_string.contains("404") {
					// Report that the other version of the wallet is out of date
					report = "Other wallet is incompatible and requires an upgrade. \
				          	Please urge the other wallet owner to upgrade and try the transaction again."
						.to_string();
				}
				error!("{}", report);
				ErrorKind::ClientCallback(report)
			})?;
		}

		let res: Value = serde_json::from_str(&res_str).map_err(|e| {
			ErrorKind::GenericError(format!("Unable to parse respond {}, {}", res_str, e))
		})?;
		trace!("Response: {}", res);
		if res["error"] != json!(null) {
			let report = format!(
				"Posting transaction slate: Error: {}, Message: {}",
				res["error"]["code"], res["error"]["message"]
			);
			error!("{}", report);
			return Err(ErrorKind::ClientCallback(report).into());
		}

		let resp_value = res["result"]["Ok"].clone();
		trace!("resp_value: {}", resp_value.clone());
		let foreign_api_version: u16 =
			serde_json::from_value(resp_value["foreign_api_version"].clone()).map_err(|e| {
				ErrorKind::GenericError(format!(
					"Unable to read respond foreign_api_version value {}, {}",
					res_str, e
				))
			})?;
		let supported_slate_versions: Vec<String> = serde_json::from_value(
			resp_value["supported_slate_versions"].clone(),
		)
		.map_err(|e| {
			ErrorKind::GenericError(format!(
				"Unable to read respond supported_slate_versions value {}, {}",
				res_str, e
			))
		})?;

		// trivial tests for now, but will be expanded later
		if foreign_api_version < 2 {
			let report = "Other wallet reports unrecognized API format.".to_string();
			error!("{}", report);
			return Err(ErrorKind::ClientCallback(report).into());
		}

		if supported_slate_versions.contains(&"V3B".to_owned()) {
			return Ok(SlateVersion::V3B);
		}

		if supported_slate_versions.contains(&"V3".to_owned()) {
			return Ok(SlateVersion::V3);
		}
		if supported_slate_versions.contains(&"V2".to_owned()) {
			return Ok(SlateVersion::V2);
		}

		let report = "Unable to negotiate slate format with other wallet.".to_string();
		error!("{}", report);
		Err(ErrorKind::ClientCallback(report).into())
	}
/// Check version of the listening wallet
Check version of the listening wallet
Check version of the listening wallet
pub fn check_other_version(
		&self,
		url: &str,
		timeout: Option<u128>,
	) -> Result<SlateVersion, Error> {
		let res_str: String;
		let start_time = std::time::Instant::now();
		trace!("starting now check version");
		loop {
			let req = json!({
				"jsonrpc": "2.0",
				"method": "check_version",
				"id": 1,
				"params": []
			});
			let res = self.post(url, self.apisecret.clone(), req);
			let diff_time = start_time.elapsed().as_millis();
			trace!("elapsed time check version = {}", diff_time);
			// we try until it's taken more than 30 seconds.
			if res.is_err() && diff_time <= timeout.unwrap_or(30_000) {
				let res_err_str = format!("{:?}", res);
				trace!(
					"Got error (version_check), but continuing: {}, time elapsed = {}ms",
					res_err_str,
					diff_time
				);
				// the api seems to have "GeneralFailures"
				// on some platforms. retry is fast and can be
				// done again.
				// keep trying for 30 seconds.
				continue;
			} else if !res.is_err() {
				res_str = res.unwrap();
				break;
			}
			res.map_err(|e| {
				let mut report =
					format!("Performing version check (is recipient listening?): {}", e);
				let err_string = format!("{}", e);
				if err_string.contains("404") {
					// Report that the other version of the wallet is out of date
					report = "Other wallet is incompatible and requires an upgrade. \
				          	Please urge the other wallet owner to upgrade and try the transaction again."
						.to_string();
				}
				error!("{}", report);
				ErrorKind::ClientCallback(report)
			})?;
		}
		let res: Value = serde_json::from_str(&res_str).map_err(|e| {
			ErrorKind::GenericError(format!("Unable to parse respond {}, {}", res_str, e))
		})?;
		trace!("Response: {}", res);
		if res["error"] != json!(null) {
			let report = format!(
				"Posting transaction slate: Error: {}, Message: {}",
				res["error"]["code"], res["error"]["message"]
			);
			error!("{}", report);
			return Err(ErrorKind::ClientCallback(report).into());
		}
		let resp_value = res["result"]["Ok"].clone();
		trace!("resp_value: {}", resp_value.clone());
		let foreign_api_version: u16 =
			serde_json::from_value(resp_value["foreign_api_version"].clone()).map_err(|e| {
				ErrorKind::GenericError(format!(
					"Unable to read respond foreign_api_version value {}, {}",
					res_str, e
				))
			})?;
		let supported_slate_versions: Vec<String> = serde_json::from_value(
			resp_value["supported_slate_versions"].clone(),
		)
		.map_err(|e| {
			ErrorKind::GenericError(format!(
				"Unable to read respond supported_slate_versions value {}, {}",
				res_str, e
			))
		})?;
		// trivial tests for now, but will be expanded later
		if foreign_api_version < 2 {
			let report = "Other wallet reports unrecognized API format.".to_string();
			error!("{}", report);
			return Err(ErrorKind::ClientCallback(report).into());
		}
		if supported_slate_versions.contains(&"V3B".to_owned()) {
			return Ok(SlateVersion::V3B);
		}
		if supported_slate_versions.contains(&"V3".to_owned()) {
			return Ok(SlateVersion::V3);
		}
		if supported_slate_versions.contains(&"V2".to_owned()) {
			return Ok(SlateVersion::V2);
		}
		let report = "Unable to negotiate slate format with other wallet.".to_string();
		error!("{}", report);
		Err(ErrorKind::ClientCallback(report).into())
	}
pub fn check_other_version ( & self , url : & str , timeout : Option < u128 > , ) -> Result < SlateVersion , Error > { let res_str : String ; let start_time = std :: time :: Instant :: now ( ) ; trace ! ( " " ) ; loop { let req = json ! ( { " " " " " " " " " " 1 " " [ ] } ) ; let res = self . post ( url , self . apisecret . clone ( ) , req ) ; let diff_time = start_time . elapsed ( ) . as_millis ( ) ; trace ! ( " " diff_time ) ; // we try until it's taken more than 30 seconds. if res . is_err ( ) && diff_time <= timeout . unwrap_or ( 30_000 ) { let res_err_str = format ! ( " " res ) ; trace ! ( " " res_err_str diff_time ) ; // the api seems to have "GeneralFailures" // on some platforms. retry is fast and can be // done again. // keep trying for 30 seconds. continue ; } else if ! res . is_err ( ) { res_str = res . unwrap ( ) ; break ; } res . map_err ( | e | { let mut report = format ! ( " " e ) ; let err_string = format ! ( " " e ) ; if err_string . contains ( " " ) { // Report that the other version of the wallet is out of date report = " \
 " . to_string ( ) ; } error ! ( " " report ) ; ErrorKind :: ClientCallback ( report ) } ) ? ; } let res : Value = serde_json :: from_str ( & res_str ) . map_err ( | e | { ErrorKind :: GenericError ( format ! ( " " res_str e ) ) } ) ? ; trace ! ( " " res ) ; if res [ " " ] != json ! ( null ) { let report = format ! ( " " res [ " " ] [ " " ] res [ " " ] [ " " ] ) ; error ! ( " " report ) ; return Err ( ErrorKind :: ClientCallback ( report ) . into ( ) ) ; } let resp_value = res [ " " ] [ " " ] . clone ( ) ; trace ! ( " " resp_value clone ( ) ) ; let foreign_api_version : u16 = serde_json :: from_value ( resp_value [ " " ] . clone ( ) ) . map_err ( | e | { ErrorKind :: GenericError ( format ! ( " " res_str e ) ) } ) ? ; let supported_slate_versions : Vec < String > = serde_json :: from_value ( resp_value [ " " ] . clone ( ) , ) . map_err ( | e | { ErrorKind :: GenericError ( format ! ( " " res_str e ) ) } ) ? ; // trivial tests for now, but will be expanded later if foreign_api_version < 2 { let report = " " . to_string ( ) ; error ! ( " " report ) ; return Err ( ErrorKind :: ClientCallback ( report ) . into ( ) ) ; } if supported_slate_versions . contains ( & " " . to_owned ( ) ) { return Ok ( SlateVersion :: V3B ) ; } if supported_slate_versions . contains ( & " " . to_owned ( ) ) { return Ok ( SlateVersion :: V3 ) ; } if supported_slate_versions . contains ( & " " . to_owned ( ) ) { return Ok ( SlateVersion :: V2 ) ; } let report = " " . to_string ( ) ; error ! ( " " report ) ; Err ( ErrorKind :: ClientCallback ( report ) . into ( ) ) }
Check version of the listening wallet
Check version of the listening wallet
&self
url
&str
timeout
Option<u128>
&self
url
&str
timeout
Option<u128>