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

	let mut router = Router::new();
	if api_secret.is_some() {
		let api_basic_auth =
			"Basic ".to_string() + &to_base64(&("grin:".to_string() + &api_secret.unwrap()));
		let basic_realm = "Basic realm=GrinOwnerAPI".to_string();
		let basic_auth_middleware = Arc::new(BasicAuthMiddleware::new(api_basic_auth, basic_realm));
		router.add_middleware(basic_auth_middleware);
	}
	router
		.add_route("/v1/wallet/owner/**", Arc::new(api_handler))
		.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;

	let mut apis = ApiServer::new();
	info!("Starting HTTP Owner 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 owner_listener<T: ?Sized, C, K>(
	wallet: Arc<Mutex<T>>,
	addr: &str,
	api_secret: Option<String>,
	tls_config: Option<TLSConfig>,
) -> Result<(), Error>
where
	T: WalletBackend<C, K> + Send + Sync + 'static,
	OwnerAPIHandler<T, C, K>: Handler,
	C: NodeClient + 'static,
	K: Keychain + 'static,
{
	let api_handler = OwnerAPIHandler::new(wallet);
	let mut router = Router::new();
	if api_secret.is_some() {
		let api_basic_auth =
			"Basic ".to_string() + &to_base64(&("grin:".to_string() + &api_secret.unwrap()));
		let basic_realm = "Basic realm=GrinOwnerAPI".to_string();
		let basic_auth_middleware = Arc::new(BasicAuthMiddleware::new(api_basic_auth, basic_realm));
		router.add_middleware(basic_auth_middleware);
	}
	router
		.add_route("/v1/wallet/owner/**", Arc::new(api_handler))
		.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;
	let mut apis = ApiServer::new();
	info!("Starting HTTP Owner 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 owner_listener < T : ? Sized , C , K > ( wallet : Arc < Mutex < T > > , addr : & str , api_secret : Option < String > , tls_config : Option < TLSConfig > , ) -> Result < ( ) , Error > where T : WalletBackend < C , K > + Send + Sync + ' static , OwnerAPIHandler < T , C , K > : Handler , C : NodeClient + ' static , K : Keychain + ' static , { let api_handler = OwnerAPIHandler :: new ( wallet ) ; let mut router = Router :: new ( ) ; if api_secret . is_some ( ) { let api_basic_auth = " " . to_string ( ) + & to_base64 ( & ( " " . to_string ( ) + & api_secret . unwrap ( ) ) ) ; let basic_realm = " " . to_string ( ) ; let basic_auth_middleware = Arc :: new ( BasicAuthMiddleware :: new ( api_basic_auth , basic_realm ) ) ; router . add_middleware ( basic_auth_middleware ) ; } 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
api_secret
Option<String>
tls_config
Option<TLSConfig>