pub fn cancel_tx<T: ?Sized, C, K>(
	wallet: &mut T,
	parent_key_id: &Identifier,
	tx_id: Option<u32>,
	tx_slate_id: Option<Uuid>,
) -> Result<(), Error>
where
	T: WalletBackend<C, K>,
	C: NodeClient,
	K: Keychain,
{
	let mut tx_id_string = String::new();
	if let Some(tx_id) = tx_id {
		tx_id_string = tx_id.to_string();
	} else if let Some(tx_slate_id) = tx_slate_id {
		tx_id_string = tx_slate_id.to_string();
	}
	let tx_vec = updater::retrieve_txs(wallet, tx_id, tx_slate_id, Some(&parent_key_id), false)?;
	if tx_vec.len() != 1 {
		return Err(ErrorKind::TransactionDoesntExist(tx_id_string))?;
	}
	let tx = tx_vec[0].clone();
	if tx.tx_type != TxLogEntryType::TxSent && tx.tx_type != TxLogEntryType::TxReceived {
		return Err(ErrorKind::TransactionNotCancellable(tx_id_string))?;
	}
	if tx.confirmed == true {
		return Err(ErrorKind::TransactionNotCancellable(tx_id_string))?;
	}
	// get outputs associated with tx
	let res = updater::retrieve_outputs(wallet, false, Some(tx.id), Some(&parent_key_id))?;
	let outputs = res.iter().map(|m| m.output.clone()).collect();
	updater::cancel_tx_and_outputs(wallet, tx, outputs, parent_key_id)?;
	Ok(())
}
/// Rollback outputs associated with a transaction in the wallet
Rollback outputs associated with a transaction in the wallet
Rollback outputs associated with a transaction in the wallet
pub fn cancel_tx<T: ?Sized, C, K>(
	wallet: &mut T,
	parent_key_id: &Identifier,
	tx_id: Option<u32>,
	tx_slate_id: Option<Uuid>,
) -> Result<(), Error>
where
	T: WalletBackend<C, K>,
	C: NodeClient,
	K: Keychain,
{
	let mut tx_id_string = String::new();
	if let Some(tx_id) = tx_id {
		tx_id_string = tx_id.to_string();
	} else if let Some(tx_slate_id) = tx_slate_id {
		tx_id_string = tx_slate_id.to_string();
	}
	let tx_vec = updater::retrieve_txs(wallet, tx_id, tx_slate_id, Some(&parent_key_id), false)?;
	if tx_vec.len() != 1 {
		return Err(ErrorKind::TransactionDoesntExist(tx_id_string))?;
	}
	let tx = tx_vec[0].clone();
	if tx.tx_type != TxLogEntryType::TxSent && tx.tx_type != TxLogEntryType::TxReceived {
		return Err(ErrorKind::TransactionNotCancellable(tx_id_string))?;
	}
	if tx.confirmed == true {
		return Err(ErrorKind::TransactionNotCancellable(tx_id_string))?;
	}
	// get outputs associated with tx
	let res = updater::retrieve_outputs(wallet, false, Some(tx.id), Some(&parent_key_id))?;
	let outputs = res.iter().map(|m| m.output.clone()).collect();
	updater::cancel_tx_and_outputs(wallet, tx, outputs, parent_key_id)?;
	Ok(())
}
pub fn cancel_tx < T : ? Sized , C , K > ( wallet : & mut T , parent_key_id : & Identifier , tx_id : Option < u32 > , tx_slate_id : Option < Uuid > , ) -> Result < ( ) , Error > where T : WalletBackend < C , K > , C : NodeClient , K : Keychain , { let mut tx_id_string = String :: new ( ) ; if let Some ( tx_id ) = tx_id { tx_id_string = tx_id . to_string ( ) ; } else if let Some ( tx_slate_id ) = tx_slate_id { tx_id_string = tx_slate_id . to_string ( ) ; } let tx_vec = updater :: retrieve_txs ( wallet , tx_id , tx_slate_id , Some ( & parent_key_id ) , false ) ? ; if tx_vec . len ( ) != 1 { return Err ( ErrorKind :: TransactionDoesntExist ( tx_id_string ) ) ? ; } let tx = tx_vec [ 0 ] . clone ( ) ; if tx . tx_type != TxLogEntryType :: TxSent && tx . tx_type != TxLogEntryType :: TxReceived { return Err ( ErrorKind :: TransactionNotCancellable ( tx_id_string ) ) ? ; } if tx . confirmed == true { return Err ( ErrorKind :: TransactionNotCancellable ( tx_id_string ) ) ? ; } // get outputs associated with tx let res = updater :: retrieve_outputs ( wallet , false , Some ( tx . id ) , Some ( & parent_key_id ) ) ? ; let outputs = res . iter ( ) . map ( | m | m . output . clone ( ) ) . collect ( ) ; updater :: cancel_tx_and_outputs ( wallet , tx , outputs , parent_key_id ) ? ; Ok ( ( ) ) }
Rollback outputs associated with a transaction in the wallet
Rollback outputs associated with a transaction in the wallet
wallet
&mut T
parent_key_id
&Identifier
tx_id
Option<u32>
tx_slate_id
Option<Uuid>