pub fn process_invoice_tx<'a, T: ?Sized, C, K>(
	w: &mut T,
	keychain_mask: Option<&SecretKey>,
	slate: &Slate,
	args: InitTxArgs,
	use_test_rng: bool,
	refresh_from_node: bool,
) -> Result<Slate, Error>
where
	T: WalletBackend<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
{
	let mut ret_slate = slate.clone();
	check_ttl(w, &ret_slate, refresh_from_node)?;
	let parent_key_id = match args.src_acct_name {
		Some(d) => {
			let pm = w.get_acct_path(d)?;
			match pm {
				Some(p) => p.path,
				None => w.parent_key_id(),
			}
		}
		None => w.parent_key_id(),
	};
	// Don't do this multiple times
	let tx = updater::retrieve_txs(
		&mut *w,
		keychain_mask,
		None,
		Some(ret_slate.id),
		Some(&parent_key_id),
		use_test_rng,
		None,
		None,
	)?;
	for t in &tx {
		if t.tx_type == TxLogEntryType::TxSent {
			return Err(ErrorKind::TransactionAlreadyReceived(ret_slate.id.to_string()).into());
		}
	}

	let message = match args.message {
		Some(mut m) => {
			m.truncate(USER_MESSAGE_MAX_LEN);
			Some(m)
		}
		None => None,
	};

	// update slate current height
	ret_slate.height = w.w2n_client().get_chain_tip()?.0;

	// update ttl if desired
	if let Some(b) = args.ttl_blocks {
		ret_slate.ttl_cutoff_height = Some(ret_slate.height + b);
	}

	let context = tx::add_inputs_to_slate(
		&mut *w,
		keychain_mask,
		&mut ret_slate,
		args.minimum_confirmations,
		args.max_outputs as usize,
		args.num_change_outputs as usize,
		args.selection_strategy_is_use_all,
		&parent_key_id,
		1, // Participant id 1 for mwc713 compatibility
		message,
		false,
		use_test_rng,
		None,
		1,
		args.exclude_change_outputs.unwrap_or(false),
		args.minimum_confirmations_change_outputs,
	)?;

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

	if let Some(v) = args.target_slate_version {
		ret_slate.version_info.orig_version = v;
	}

	Ok(ret_slate)
}
/// Receive an invoice tx, essentially adding inputs to whatever
/// output was specified
/// Caller is responsible for wallet refresh
Receive an invoice tx, essentially adding inputs to whatever
output was specified
Caller is responsible for wallet refresh
Receive an invoice tx essentially adding inputs to whatever output was specified Caller is responsible for wallet refresh
pub fn process_invoice_tx<'a, T: ?Sized, C, K>(
	w: &mut T,
	keychain_mask: Option<&SecretKey>,
	slate: &Slate,
	args: InitTxArgs,
	use_test_rng: bool,
	refresh_from_node: bool,
) -> Result<Slate, Error>
where
	T: WalletBackend<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
{
	let mut ret_slate = slate.clone();
	check_ttl(w, &ret_slate, refresh_from_node)?;
	let parent_key_id = match args.src_acct_name {
		Some(d) => {
			let pm = w.get_acct_path(d)?;
			match pm {
				Some(p) => p.path,
				None => w.parent_key_id(),
			}
		}
		None => w.parent_key_id(),
	};
	// Don't do this multiple times
	let tx = updater::retrieve_txs(
		&mut *w,
		keychain_mask,
		None,
		Some(ret_slate.id),
		Some(&parent_key_id),
		use_test_rng,
		None,
		None,
	)?;
	for t in &tx {
		if t.tx_type == TxLogEntryType::TxSent {
			return Err(ErrorKind::TransactionAlreadyReceived(ret_slate.id.to_string()).into());
		}
	}
	let message = match args.message {
		Some(mut m) => {
			m.truncate(USER_MESSAGE_MAX_LEN);
			Some(m)
		}
		None => None,
	};
	// update slate current height
	ret_slate.height = w.w2n_client().get_chain_tip()?.0;
	// update ttl if desired
	if let Some(b) = args.ttl_blocks {
		ret_slate.ttl_cutoff_height = Some(ret_slate.height + b);
	}
	let context = tx::add_inputs_to_slate(
		&mut *w,
		keychain_mask,
		&mut ret_slate,
		args.minimum_confirmations,
		args.max_outputs as usize,
		args.num_change_outputs as usize,
		args.selection_strategy_is_use_all,
		&parent_key_id,
		1, // Participant id 1 for mwc713 compatibility
		message,
		false,
		use_test_rng,
		None,
		1,
		args.exclude_change_outputs.unwrap_or(false),
		args.minimum_confirmations_change_outputs,
	)?;
	// Save the aggsig context in our DB for when we
	// recieve the transaction back
	{
		let mut batch = w.batch(keychain_mask)?;
		// Participant id 1 for mwc713 compatibility
		batch.save_private_context(slate.id.as_bytes(), 1, &context)?;
		batch.commit()?;
	}
	if let Some(v) = args.target_slate_version {
		ret_slate.version_info.orig_version = v;
	}
	Ok(ret_slate)
}
pub fn process_invoice_tx < ' a , T : ? Sized , C , K > ( w : & mut T , keychain_mask : Option < & SecretKey > , slate : & Slate , args : InitTxArgs , use_test_rng : bool , refresh_from_node : bool , ) -> Result < Slate , Error > where T : WalletBackend < ' a , C , K > , C : NodeClient + ' a , K : Keychain + ' a , { let mut ret_slate = slate . clone ( ) ; check_ttl ( w , & ret_slate , refresh_from_node ) ? ; let parent_key_id = match args . src_acct_name { Some ( d ) => { let pm = w . get_acct_path ( d ) ? ; match pm { Some ( p ) => p . path , None => w . parent_key_id ( ) , } } None => w . parent_key_id ( ) , } ; // Don't do this multiple times let tx = updater :: retrieve_txs ( & mut * w , keychain_mask , None , Some ( ret_slate . id ) , Some ( & parent_key_id ) , use_test_rng , None , None , ) ? ; for t in & tx { if t . tx_type == TxLogEntryType :: TxSent { return Err ( ErrorKind :: TransactionAlreadyReceived ( ret_slate . id . to_string ( ) ) . into ( ) ) ; } } let message = match args . message { Some ( mut m ) => { m . truncate ( USER_MESSAGE_MAX_LEN ) ; Some ( m ) } None => None , } ; // update slate current height ret_slate . height = w . w2n_client ( ) . get_chain_tip ( ) ? . 0 ; // update ttl if desired if let Some ( b ) = args . ttl_blocks { ret_slate . ttl_cutoff_height = Some ( ret_slate . height + b ) ; } let context = tx :: add_inputs_to_slate ( & mut * w , keychain_mask , & mut ret_slate , args . minimum_confirmations , args . max_outputs as usize , args . num_change_outputs as usize , args . selection_strategy_is_use_all , & parent_key_id , 1 , // Participant id 1 for mwc713 compatibility message , false , use_test_rng , None , 1 , args . exclude_change_outputs . unwrap_or ( false ) , args . minimum_confirmations_change_outputs , ) ? ; // Save the aggsig context in our DB for when we // recieve the transaction back { let mut batch = w . batch ( keychain_mask ) ? ; // Participant id 1 for mwc713 compatibility batch . save_private_context ( slate . id . as_bytes ( ) , 1 , & context ) ? ; batch . commit ( ) ? ; } if let Some ( v ) = args . target_slate_version { ret_slate . version_info . orig_version = v ; } Ok ( ret_slate ) }
Receive an invoice tx, essentially adding inputs to whatever
output was specified
Caller is responsible for wallet refresh
Receive an invoice tx essentially adding inputs to whatever output was specified Caller is responsible for wallet refresh
w
&mut T
keychain_mask
Option<&SecretKey>
slate
&Slate
args
InitTxArgs
use_test_rng
bool
refresh_from_node
bool
w
&mut T
keychain_mask
Option<&SecretKey>
slate
&Slate
args
InitTxArgs
use_test_rng
bool
refresh_from_node
bool