pub fn foreign_listener<T: ?Sized, C, K>(
	wallet: Arc<Mutex<T>>,
	addr: &str,
	tls_config: Option<TLSConfig>,
) -> Result<(), Error>
where
	T: WalletBackend<C, K> + Send + Sync + 'static,
	C: NodeClient + 'static,
	K: Keychain + 'static,
{
	let api_handler = ForeignAPIHandler::new(wallet);

	let mut router = Router::new();
	router
		.add_route("/v1/wallet/foreign/**", Arc::new(api_handler))
		.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;

	let mut apis = ApiServer::new();
	info!("Starting HTTP Foreign API server at {}.", addr);
	let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");
	let api_thread =
		apis.start(socket_addr, router, tls_config)
			.context(ErrorKind::GenericError(
				"API thread failed to start".to_string(),
			))?;

	api_thread
		.join()
		.map_err(|e| ErrorKind::GenericError(format!("API thread panicked :{:?}", e)).into())
}
/// Listener version, providing same API but listening for requests on a
/// port and wrapping the calls
Listener version, providing same API but listening for requests on a
port and wrapping the calls
Listener version providing same API but listening for requests on a port and wrapping the calls
pub fn foreign_listener<T: ?Sized, C, K>(
	wallet: Arc<Mutex<T>>,
	addr: &str,
	tls_config: Option<TLSConfig>,
) -> Result<(), Error>
where
	T: WalletBackend<C, K> + Send + Sync + 'static,
	C: NodeClient + 'static,
	K: Keychain + 'static,
{
	let api_handler = ForeignAPIHandler::new(wallet);
	let mut router = Router::new();
	router
		.add_route("/v1/wallet/foreign/**", Arc::new(api_handler))
		.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;
	let mut apis = ApiServer::new();
	info!("Starting HTTP Foreign API server at {}.", addr);
	let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");
	let api_thread =
		apis.start(socket_addr, router, tls_config)
			.context(ErrorKind::GenericError(
				"API thread failed to start".to_string(),
			))?;
	api_thread
		.join()
		.map_err(|e| ErrorKind::GenericError(format!("API thread panicked :{:?}", e)).into())
}
pub fn foreign_listener < T : ? Sized , C , K > ( wallet : Arc < Mutex < T > > , addr : & str , tls_config : Option < TLSConfig > , ) -> Result < ( ) , Error > where T : WalletBackend < C , K > + Send + Sync + ' static , C : NodeClient + ' static , K : Keychain + ' static , { let api_handler = ForeignAPIHandler :: new ( wallet ) ; let mut router = Router :: new ( ) ; router . add_route ( " " , Arc :: new ( api_handler ) ) . map_err ( | _ | ErrorKind :: GenericError ( " " . to_string ( ) ) ) ? ; let mut apis = ApiServer :: new ( ) ; info ! ( " " addr ) ; let socket_addr : SocketAddr = addr . parse ( ) . expect ( " " ) ; let api_thread = apis . start ( socket_addr , router , tls_config ) . context ( ErrorKind :: GenericError ( " " . to_string ( ) , ) ) ? ; api_thread . join ( ) . map_err ( | e | ErrorKind :: GenericError ( format ! ( " " e ) ) . into ( ) ) }
Listener version, providing same API but listening for requests on a
port and wrapping the calls
Listener version providing same API but listening for requests on a port and wrapping the calls
wallet
Arc<Mutex<T>>
addr
&str
tls_config
Option<TLSConfig>