pub fn new(
		wallet_inst: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
		custom_channel: Option<Sender<StatusMessage>>,
		tor_config: Option<TorConfig>,
	) -> Self {
		let updater_running = Arc::new(AtomicBool::new(false));
		let updater = Arc::new(Mutex::new(owner_updater::Updater::new(
			wallet_inst.clone(),
			updater_running.clone(),
		)));
		let updater_messages = Arc::new(Mutex::new(vec![]));

		let running = Arc::new(AtomicBool::new(true));
		let (tx, handle) = match custom_channel {
			Some(c) => (c, None),
			None => {
				let (tx, rx) = channel();
				let handle =
					start_updater_log_thread(rx, updater_messages.clone(), running.clone())
						.unwrap();
				(tx, Some(handle))
			}
		};

		Owner {
			wallet_inst,
			doctest_mode: false,
			shared_key: Arc::new(Mutex::new(None)),
			updater,
			updater_running,
			status_tx: Mutex::new(Some(tx)),
			updater_messages,
			tor_config: Mutex::new(tor_config),
			updater_log_thread: handle,
			updater_log_running_state: running,
		}
	}
/// Create a new API instance with the given wallet instance. All subsequent
/// API calls will operate on this instance of the wallet.
///
/// Each method will call the [`WalletBackend`](../mimble_wallet_libwallet/types/trait.WalletBackend.html)'s
/// [`open_with_credentials`](../mimble_wallet_libwallet/types/trait.WalletBackend.html#tymethod.open_with_credentials)
/// (initialising a keychain with the master seed,) perform its operation, then close the keychain
/// with a call to [`close`](../mimble_wallet_libwallet/types/trait.WalletBackend.html#tymethod.close)
///
/// # Arguments
/// * `wallet_in` - A reference-counted mutex containing an implementation of the
/// * `custom_channel` - A custom MPSC Tx/Rx pair to capture status
/// updates
/// [`WalletBackend`](../mimble_wallet_libwallet/types/trait.WalletBackend.html) trait.
///
/// # Returns
/// * An instance of the OwnerApi holding a reference to the provided wallet
///
/// # Example
/// ```
/// use mimble_wallet_util::mimble_keychain as keychain;
/// use mimble_wallet_util::mimble_util as util;
/// use mimble_wallet_api as api;
/// use mimble_wallet_config as config;
/// use mimble_wallet_impls as impls;
/// use mimble_wallet_libwallet as libwallet;
///
/// use keychain::ExtKeychain;
/// use tempfile::tempdir;
///
/// use std::sync::Arc;
/// use util::{Mutex, ZeroingString};
///
/// use api::Owner;
/// use config::WalletConfig;
/// use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
/// use libwallet::WalletInst;
///
/// let mut wallet_config = WalletConfig::default();
/// # let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
/// # let dir = dir
/// #   .path()
/// #   .to_str()
/// #   .ok_or("Failed to convert tmpdir path to string.".to_owned())
/// #   .unwrap();
/// # wallet_config.data_file_dir = dir.to_owned();
///
/// // A NodeClient must first be created to handle communication between
/// // the wallet and the node.
/// let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None).unwrap();
///
/// // impls::DefaultWalletImpl is provided for convenience in instantiating the wallet
/// // It contains the LMDBBackend, DefaultLCProvider (lifecycle) and ExtKeychain used
/// // by the reference wallet implementation.
/// // These traits can be replaced with alternative implementations if desired
///
/// let mut wallet = Box::new(DefaultWalletImpl::<'static, HTTPNodeClient>::new(node_client.clone()).unwrap())
///     as Box<WalletInst<'static, DefaultLCProvider<HTTPNodeClient, ExtKeychain>, HTTPNodeClient, ExtKeychain>>;
///
/// // Wallet LifeCycle Provider provides all functions init wallet and work with seeds, etc...
/// let lc = wallet.lc_provider().unwrap();
///
/// // The top level wallet directory should be set manually (in the reference implementation,
/// // this is provided in the WalletConfig)
/// let _ = lc.set_top_level_directory(&wallet_config.data_file_dir);
///
/// // Wallet must be opened with the password (TBD)
/// let pw = ZeroingString::from("wallet_password");
/// lc.open_wallet(None, pw, false, false, None);
///
/// // All wallet functions operate on an Arc::Mutex to allow multithreading where needed
/// let mut wallet = Arc::new(Mutex::new(wallet));
///
/// let api_owner = Owner::new(wallet.clone(), None, None);
/// // .. perform wallet operations
///
/// ```
Create a new API instance with the given wallet instance. All subsequent
API calls will operate on this instance of the wallet.


Create a new API instance with the given wallet instance . All subsequent API calls will operate on this instance of the wallet .
pub fn new(
		wallet_inst: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
		custom_channel: Option<Sender<StatusMessage>>,
		tor_config: Option<TorConfig>,
	) -> Self {
		let updater_running = Arc::new(AtomicBool::new(false));
		let updater = Arc::new(Mutex::new(owner_updater::Updater::new(
			wallet_inst.clone(),
			updater_running.clone(),
		)));
		let updater_messages = Arc::new(Mutex::new(vec![]));
		let running = Arc::new(AtomicBool::new(true));
		let (tx, handle) = match custom_channel {
			Some(c) => (c, None),
			None => {
				let (tx, rx) = channel();
				let handle =
					start_updater_log_thread(rx, updater_messages.clone(), running.clone())
						.unwrap();
				(tx, Some(handle))
			}
		};
		Owner {
			wallet_inst,
			doctest_mode: false,
			shared_key: Arc::new(Mutex::new(None)),
			updater,
			updater_running,
			status_tx: Mutex::new(Some(tx)),
			updater_messages,
			tor_config: Mutex::new(tor_config),
			updater_log_thread: handle,
			updater_log_running_state: running,
		}
	}
pub fn new ( wallet_inst : Arc < Mutex < Box < dyn WalletInst < ' static , L , C , K > > > > , custom_channel : Option < Sender < StatusMessage > > , tor_config : Option < TorConfig > , ) -> Self { let updater_running = Arc :: new ( AtomicBool :: new ( false ) ) ; let updater = Arc :: new ( Mutex :: new ( owner_updater :: Updater :: new ( wallet_inst . clone ( ) , updater_running . clone ( ) , ) ) ) ; let updater_messages = Arc :: new ( Mutex :: new ( vec ! [ ] ) ) ; let running = Arc :: new ( AtomicBool :: new ( true ) ) ; let ( tx , handle ) = match custom_channel { Some ( c ) => ( c , None ) , None => { let ( tx , rx ) = channel ( ) ; let handle = start_updater_log_thread ( rx , updater_messages . clone ( ) , running . clone ( ) ) . unwrap ( ) ; ( tx , Some ( handle ) ) } } ; Owner { wallet_inst , doctest_mode : false , shared_key : Arc :: new ( Mutex :: new ( None ) ) , updater , updater_running , status_tx : Mutex :: new ( Some ( tx ) ) , updater_messages , tor_config : Mutex :: new ( tor_config ) , updater_log_thread : handle , updater_log_running_state : running , } }
Create a new API instance with the given wallet instance.
Create a new API instance with the given wallet instance .
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>
custom_channel
Option<Sender<StatusMessage>>
tor_config
Option<TorConfig>
An instance of the OwnerApi holding a reference to the provided wallet
An instance of the OwnerApi holding a reference to the provided wallet
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>
custom_channel
Option<Sender<StatusMessage>>
tor_config
Option<TorConfig>
example


use keychain::ExtKeychain;
use tempfile::tempdir.

use std::sync::Arc;
use util::{Mutex, ZeroingString}.

use api::Owner;
use config::WalletConfig;
use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
use libwallet::WalletInst.

let mut wallet_config = WalletConfig::default().
use keychain :: ExtKeychain ; use tempfile :: tempdir . use std :: sync :: Arc ; use util :: { Mutex ZeroingString } . use api :: Owner ; use config :: WalletConfig ; use impls :: { DefaultWalletImpl DefaultLCProvider HTTPNodeClient } ; use libwallet :: WalletInst . let mut wallet_config = WalletConfig :: default () .
let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
None
let dir = dir
None
.path()
None
.to_str()
None
.ok_or("failed to convert tmpdir path to string.".to_owned())
None
.unwrap();
None
wallet_config.data_file_dir = dir.to_owned();
A NodeClient must first be created to handle communication between
the wallet and the node.
let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None).unwrap().

:DefaultWalletImpl is provided for convenience in instantiating the wallet
It contains the LMDBBackend, DefaultLCProvider (lifecycle) and ExtKeychain used
by the reference wallet implementation.
These traits can be replaced with alternative implementations if desired

let mut wallet = Box::new(DefaultWalletImpl::<'static, HTTPNodeClient>::new(node_client.clone()).unwrap())
as Box, HTTPNodeClient, ExtKeychain>>.

Wallet LifeCycle Provider provides all functions init wallet and work with seeds, etc
let lc = wallet.lc_provider().unwrap().

The top level wallet directory should be set manually (in the reference implementation,
this is provided in the WalletConfig)
let _ = lc.set_top_level_directory(&wallet_config.data_file_dir).

Wallet must be opened with the password (TBD)
let pw = ZeroingString::from("wallet_password");
lc.open_wallet(None, pw, false, false, None).

All wallet functions operate on an Arc::Mutex to allow multithreading where needed
let mut wallet = Arc::new(Mutex::new(wallet)).

let api_owner = Owner::new(wallet.clone(), None, None);
perform wallet operations


A NodeClient must first be created to handle communication between the wallet and the node . let node_client = HTTPNodeClient :: new ( &wallet_config . check_node_api_http_addr None ) . unwrap () . : DefaultWalletImpl is provided for convenience in instantiating the wallet It contains the LMDBBackend DefaultLCProvider ( lifecycle ) and ExtKeychain used by the reference wallet implementation . These traits can be replaced with alternative implementations if desired let mut wallet = Box :: new ( DefaultWalletImpl :: < ' static HTTPNodeClient > :: new ( node_client . clone () ) . unwrap () ) as Box HTTPNodeClient ExtKeychain >> . Wallet LifeCycle Provider provides all functions init wallet and work with seeds etc let lc = wallet . lc_provider () . unwrap () . The top level wallet directory should be set manually ( in the reference implementation this is provided in the WalletConfig ) let _ = lc . set_top_level_directory ( &wallet_config . data_file_dir ) . Wallet must be opened with the password ( TBD ) let pw = ZeroingString :: from ( " wallet_password " ) ; lc . open_wallet ( None pw false false None ) . All wallet functions operate on an Arc :: Mutex to allow multithreading where needed let mut wallet = Arc :: new ( Mutex :: new ( wallet )) . let api_owner = Owner :: new ( wallet . clone () None None ) ; perform wallet operations