pub fn initiate_tx(
		&mut self,
		src_acct_name: Option<&str>,
		amount: u64,
		minimum_confirmations: u64,
		max_outputs: usize,
		num_change_outputs: usize,
		selection_strategy_is_use_all: bool,
		message: Option<String>,
	) -> Result<
		(
			Slate,
			impl FnOnce(&mut W, &Transaction) -> Result<(), Error>,
		),
		Error,
	> {
		let mut w = self.wallet.lock();
		w.open_with_credentials()?;
		let parent_key_id = match src_acct_name {
			Some(d) => {
				let pm = w.get_acct_path(d.to_owned())?;
				match pm {
					Some(p) => p.path,
					None => w.parent_key_id(),
				}
			}
			None => w.parent_key_id(),
		};

		let (slate, context, lock_fn) = tx::create_send_tx(
			&mut *w,
			amount,
			minimum_confirmations,
			max_outputs,
			num_change_outputs,
			selection_strategy_is_use_all,
			&parent_key_id,
			message,
		)?;

		// Save the aggsig context in our DB for when we
		// recieve the transaction back
		{
			let mut batch = w.batch()?;
			batch.save_private_context(slate.id.as_bytes(), &context)?;
			batch.commit()?;
		}

		w.close()?;
		Ok((slate, lock_fn))
	}
/// Initiates a new transaction as the sender, creating a new
/// [`Slate`](../../libtx/slate/struct.Slate.html) object containing
/// the sender's inputs, change outputs, and public signature data. This slate can
/// then be sent to the recipient to continue the transaction via the
/// [Foreign API's `receive_tx`](struct.APIForeign.html#method.receive_tx) method.
///
/// When a transaction is created, the wallet must also lock inputs (and create unconfirmed
/// outputs) corresponding to the transaction created in the slate, so that the wallet doesn't
/// attempt to re-spend outputs that are already included in a transaction before the transaction
/// is confirmed. This method also returns a function that will perform that locking, and it is
/// up to the caller to decide the best time to call the lock function
/// (via the [`tx_lock_outputs`](struct.APIOwner.html#method.tx_lock_outputs) method).
/// If the exchange method is intended to be synchronous (such as via a direct http call,)
/// then the lock call can wait until the response is confirmed. If it is asynchronous, (such
/// as via file transfer,) the lock call should happen immediately (before the file is sent
/// to the recipient).
///
/// # Arguments
/// * `src_acct_name` - The human readable account name from which to draw outputs
/// for the transaction, overriding whatever the active account is as set via the
/// [`set_active_account`](struct.APIOwner.html#method.set_active_account) method.
/// If None, the transaction will use the active account.
/// * `amount` - The amount to send, in nanogrins. (`1 G = 1_000_000_000nG`)
/// * `minimum_confirmations` - The minimum number of confirmations an output
/// should have in order to be included in the transaction.
/// * `max_outputs` - By default, the wallet selects as many inputs as possible in a
/// transaction, to reduce the Output set and the fees. The wallet will attempt to spend
/// include up to `max_outputs` in a transaction, however if this is not enough to cover
/// the whole amount, the wallet will include more outputs. This parameter should be considered
/// a soft limit.
/// * `num_change_outputs` - The target number of change outputs to create in the transaction.
/// The actual number created will be `num_change_outputs` + whatever remainder is needed.
/// * `selection_strategy_is_use_all` - If `true`, attempt to use up as many outputs as
/// possible to create the transaction, up the 'soft limit' of `max_outputs`. This helps
/// to reduce the size of the UTXO set and the amount of data stored in the wallet, and
/// minimizes fees. This will generally result in many inputs and a large change output(s),
/// usually much larger than the amount being sent. If `false`, the transaction will include
/// as many outputs as are needed to meet the amount, (and no more) starting with the smallest
/// value outputs.
/// * `message` - An optional participant message to include alongside the sender's public
/// ParticipantData within the slate. This message will include a signature created with the
/// sender's private keys, and will be publically verifiable. Note this message is for
/// the convenience of the participants during the exchange; it is not included in the final
/// transaction sent to the chain. Validation of this message is optional.
///
/// # Returns
/// * a result containing:
/// * ([`Slate`](../../libtx/slate/struct.Slate.html), lock_function) - A tuple:
/// * The transaction Slate, which can be forwarded to the recieving party by any means.
/// * A lock function, which should be called when the caller deems it appropriate to lock
/// the transaction outputs (i.e. there is relative certaintly that the slate will be
/// transmitted to the receiving party). Must be called before calling
/// [`finalize_tx`](struct.APIOwner.html#method.finalize_tx).
/// * or [`libwallet::Error`](../struct.Error.html) if an error is encountered.
///
/// # Remarks
///
/// * This method requires an active connection to a node, and will fail with error if a node
/// cannot be contacted to refresh output statuses.
/// * This method will store a partially completed transaction in the wallet's transaction log,
/// which will be updated on the corresponding call to [`finalize_tx`](struct.APIOwner.html#method.finalize_tx).
///
/// # Example
/// Set up as in [new](struct.APIOwner.html#method.new) method above.
/// ```
/// # extern crate grin_wallet as wallet;
/// # extern crate grin_keychain as keychain;
/// # extern crate grin_util as util;
/// # use std::sync::Arc;
/// # use util::Mutex;
/// # use keychain::ExtKeychain;
/// # use wallet::libwallet::api::APIOwner;
/// # use wallet::{LMDBBackend, HTTPNodeClient, WalletBackend,  WalletConfig};
/// # let mut wallet_config = WalletConfig::default();
/// # let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None);
/// # let mut wallet:Arc<Mutex<WalletBackend<HTTPNodeClient, ExtKeychain>>> =
/// # Arc::new(Mutex::new(
/// # 	LMDBBackend::new(wallet_config.clone(), "", node_client).unwrap()
/// # ));
///
/// let mut api_owner = APIOwner::new(wallet.clone());
/// let amount = 2_000_000_000;
///
/// // Attempt to create a transaction using the 'default' account
/// let result = api_owner.initiate_tx(
///		None,
///		amount,     // amount
///		10,         // minimum confirmations
///		500,        // max outputs
///		1,          // num change outputs
///		true,       // select all outputs
///		Some("Have some Grins. Love, Yeastplume".to_owned()),
///	);
///
/// if let Ok((slate, lock_fn)) = result {
///		// Send slate somehow
///		// ...
///		// Lock our outputs if we're happy the slate was (or is being) sent
///		api_owner.tx_lock_outputs(&slate, lock_fn);
/// }
/// ```
Initiates a new transaction as the sender, creating a new
[`Slate`](../../libtx/slate/struct.Slate.html) object containing
the sender's inputs, change outputs, and public signature data. This slate can
then be sent to the recipient to continue the transaction via the
[Foreign API's `receive_tx`](struct.APIForeign.html#method.receive_tx) method.

When a transaction is created, the wallet must also lock inputs (and create unconfirmed
outputs) corresponding to the transaction created in the slate, so that the wallet doesn't
attempt to re-spend outputs that are already included in a transaction before the transaction
is confirmed. This method also returns a function that will perform that locking, and it is
up to the caller to decide the best time to call the lock function
(via the [`tx_lock_outputs`](struct.APIOwner.html#method.tx_lock_outputs) method).
If the exchange method is intended to be synchronous (such as via a direct http call,)
then the lock call can wait until the response is confirmed. If it is asynchronous, (such
as via file transfer,) the lock call should happen immediately (before the file is sent
to the recipient).
Initiates a new transaction as the sender creating a new [ ` Slate ` ] ( .. / .. / libtx / slate / struct . Slate . html ) object containing the sender ' s inputs change outputs and public signature data . This slate can then be sent to the recipient to continue the transaction via the [ Foreign API ' s ` receive_tx ` ] ( struct . APIForeign . html#method . receive_tx ) method . When a transaction is created the wallet must also lock inputs ( and create unconfirmed outputs ) corresponding to the transaction created in the slate so that the wallet doesn ' t attempt to re - spend outputs that are already included in a transaction before the transaction is confirmed . This method also returns a function that will perform that locking and it is up to the caller to decide the best time to call the lock function ( via the [ ` tx_lock_outputs ` ] ( struct . APIOwner . html#method . tx_lock_outputs ) method ) . If the exchange method is intended to be synchronous ( such as via a direct http call ) then the lock call can wait until the response is confirmed . If it is asynchronous ( such as via file transfer ) the lock call should happen immediately ( before the file is sent to the recipient ) .
pub fn initiate_tx(
		&mut self,
		src_acct_name: Option<&str>,
		amount: u64,
		minimum_confirmations: u64,
		max_outputs: usize,
		num_change_outputs: usize,
		selection_strategy_is_use_all: bool,
		message: Option<String>,
	) -> Result<
		(
			Slate,
			impl FnOnce(&mut W, &Transaction) -> Result<(), Error>,
		),
		Error,
	> {
		let mut w = self.wallet.lock();
		w.open_with_credentials()?;
		let parent_key_id = match src_acct_name {
			Some(d) => {
				let pm = w.get_acct_path(d.to_owned())?;
				match pm {
					Some(p) => p.path,
					None => w.parent_key_id(),
				}
			}
			None => w.parent_key_id(),
		};
		let (slate, context, lock_fn) = tx::create_send_tx(
			&mut *w,
			amount,
			minimum_confirmations,
			max_outputs,
			num_change_outputs,
			selection_strategy_is_use_all,
			&parent_key_id,
			message,
		)?;
		// Save the aggsig context in our DB for when we
		// recieve the transaction back
		{
			let mut batch = w.batch()?;
			batch.save_private_context(slate.id.as_bytes(), &context)?;
			batch.commit()?;
		}
		w.close()?;
		Ok((slate, lock_fn))
	}
pub fn initiate_tx ( & mut self , src_acct_name : Option < & str > , amount : u64 , minimum_confirmations : u64 , max_outputs : usize , num_change_outputs : usize , selection_strategy_is_use_all : bool , message : Option < String > , ) -> Result < ( Slate , impl FnOnce ( & mut W , & Transaction ) -> Result < ( ) , Error > , ) , Error , > { let mut w = self . wallet . lock ( ) ; w . open_with_credentials ( ) ? ; let parent_key_id = match src_acct_name { Some ( d ) => { let pm = w . get_acct_path ( d . to_owned ( ) ) ? ; match pm { Some ( p ) => p . path , None => w . parent_key_id ( ) , } } None => w . parent_key_id ( ) , } ; let ( slate , context , lock_fn ) = tx :: create_send_tx ( & mut * w , amount , minimum_confirmations , max_outputs , num_change_outputs , selection_strategy_is_use_all , & parent_key_id , message , ) ? ; // Save the aggsig context in our DB for when we // recieve the transaction back { let mut batch = w . batch ( ) ? ; batch . save_private_context ( slate . id . as_bytes ( ) , & context ) ? ; batch . commit ( ) ? ; } w . close ( ) ? ; Ok ( ( slate , lock_fn ) ) }
Initiates a new transaction as the sender, creating a new
[`Slate`](../../libtx/slate/struct.Slate.html) object containing
the sender's inputs, change outputs, and public signature data.
Initiates a new transaction as the sender creating a new [ ` Slate ` ] ( .. / .. / libtx / slate / struct . Slate . html ) object containing the sender ' s inputs change outputs and public signature data .
a result containing:
([`Slate`](../../libtx/slate/struct.Slate.html), lock_function) - A tuple:
The transaction Slate, which can be forwarded to the recieving party by any means.
A lock function, which should be called when the caller deems it appropriate to lock
the transaction outputs . Must be called before calling
[`finalize_tx`](struct.APIOwner.html#method.finalize_tx).
or [`libwallet::Error`](../struct.Error.html) if an error is encountered.
a result containing : ( [ ` Slate ` ] ( .. / .. / libtx / slate / struct . Slate . html ) lock_function ) - A tuple : The transaction Slate which can be forwarded to the recieving party by any means . A lock function which should be called when the caller deems it appropriate to lock the transaction outputs . Must be called before calling [ ` finalize_tx ` ] ( struct . APIOwner . html#method . finalize_tx ) . or [ ` libwallet :: Error ` ] ( .. / struct . Error . html ) if an error is encountered .
&mut self
src_acct_name
Option<&str>
amount
u64
minimum_confirmations
u64
max_outputs
usize
num_change_outputs
usize
selection_strategy_is_use_all
bool
message
Option<String>
remarks
This method requires an active connection to a node, and will fail with error if a node
cannot be contacted to refresh output statuses.
This method will store a partially completed transaction in the wallet's transaction log,
which will be updated on the corresponding call to [`finalize_tx`](struct.APIOwner.html#method.finalize_tx).
This method requires an active connection to a node and will fail with error if a node cannot be contacted to refresh output statuses . This method will store a partially completed transaction in the wallet ' s transaction log which will be updated on the corresponding call to [ ` finalize_tx ` ] ( struct . APIOwner . html#method . finalize_tx ) .
example
Set up as in [new](struct.APIOwner.html#method.new) method above.
Set up as in [ new ] ( struct . APIOwner . html#method . new ) method above .
extern crate grin_wallet as wallet;
None
extern crate grin_keychain as keychain;
None
extern crate grin_util as util;
None
use std::sync::arc;
None
use util::mutex;
None
use keychain::extkeychain;
None
use wallet::libwallet::api::apiowner;
None
use wallet::{lmdbbackend, httpnodeclient, walletbackend,  walletconfig};
None
let mut wallet_config = walletconfig::default();
None
let node_client = httpnodeclient::new(&wallet_config.check_node_api_http_addr, none);
None
let mut wallet:arc<mutex<walletbackend<httpnodeclient, extkeychain>>> 
None
arc::new(mutex::new(
None
lmdbbackend::new(wallet_config.clone(), "", node_client).unwrap()
None
));


Attempt to create a transaction using the 'default' account
let result = api_owner.initiate_tx(
None,
amount,     // amount
10,         // minimum confirmations
500,        // max outputs
1,          // num change outputs
true,       // select all outputs
Some("Have some Grins. Love, Yeastplume".to_owned()),
).

if let Ok((slate, lock_fn)) = result {
Send slate somehow

Lock our outputs if we're happy the slate was (or is being) sent
api_owner.tx_lock_outputs(&slate, lock_fn);
}
```
Attempt to create a transaction using the ' default ' account let result = api_owner . initiate_tx ( None amount // amount 10 // minimum confirmations 500 // max outputs 1 // num change outputs true // select all outputs Some ( " Have some Grins . Love Yeastplume " . to_owned () ) ) . if let Ok (( slate lock_fn )) = result { Send slate somehow Lock our outputs if we ' re happy the slate was ( or is being ) sent api_owner . tx_lock_outputs ( &slate lock_fn ) ; } ` ` `