pub fn swap_process<'a, L, C, K, F>(
	wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
	keychain_mask: Option<&SecretKey>,
	swap_id: &str,
	message_sender: F,
	message_file_name: Option<String>,
	buyer_refund_address: Option<String>,
	secondary_fee: Option<f32>,
	secondary_address: Option<String>,
) -> Result<StateProcessRespond, Error>
where
	L: WalletLCProvider<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
	F: FnOnce(Message, String, String) -> Result<(bool, String), Error> + 'a,
{
	let (node_client, keychain) = {
		wallet_lock!(wallet_inst, w);
		let node_client = w.w2n_client().clone();
		let keychain = w.keychain(keychain_mask)?;
		(node_client, keychain)
	};

	let skey = get_swap_storage_key(&keychain)?;
	let swap_lock = trades::get_swap_lock(&swap_id.to_string());
	let _l = swap_lock.lock();

	let (context, mut swap) = trades::get_swap_trade(swap_id, &skey, &*swap_lock)?;

	match swap_process_impl(
		wallet_inst,
		keychain_mask,
		swap_lock.clone(),
		&mut swap,
		&context,
		node_client,
		keychain,
		message_sender,
		message_file_name,
		buyer_refund_address,
		secondary_fee,
		secondary_address,
	) {
		Ok(respond) => {
			trades::store_swap_trade(&context, &swap, &skey, &*swap_lock)?;
			Ok(respond)
		}
		Err(e) => {
			swap.add_journal_message(format!("Processing error: {}", e));
			trades::store_swap_trade(&context, &swap, &skey, &*swap_lock)?;
			Err(e)
		}
	}
}
/// Process the action for the swap. Action has to match the expected one
/// message_sender - method that can send the message to another party. Caller defines how it can be done
/// Return: new State & Action
Process the action for the swap. Action has to match the expected one
message_sender - method that can send the message to another party. Caller defines how it can be done
Return: new State & Action
Process the action for the swap . Action has to match the expected one message_sender - method that can send the message to another party . Caller defines how it can be done Return : new State & Action
pub fn swap_process<'a, L, C, K, F>(
	wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
	keychain_mask: Option<&SecretKey>,
	swap_id: &str,
	message_sender: F,
	message_file_name: Option<String>,
	buyer_refund_address: Option<String>,
	secondary_fee: Option<f32>,
	secondary_address: Option<String>,
) -> Result<StateProcessRespond, Error>
where
	L: WalletLCProvider<'a, C, K>,
	C: NodeClient + 'a,
	K: Keychain + 'a,
	F: FnOnce(Message, String, String) -> Result<(bool, String), Error> + 'a,
{
	let (node_client, keychain) = {
		wallet_lock!(wallet_inst, w);
		let node_client = w.w2n_client().clone();
		let keychain = w.keychain(keychain_mask)?;
		(node_client, keychain)
	};
	let skey = get_swap_storage_key(&keychain)?;
	let swap_lock = trades::get_swap_lock(&swap_id.to_string());
	let _l = swap_lock.lock();
	let (context, mut swap) = trades::get_swap_trade(swap_id, &skey, &*swap_lock)?;
	match swap_process_impl(
		wallet_inst,
		keychain_mask,
		swap_lock.clone(),
		&mut swap,
		&context,
		node_client,
		keychain,
		message_sender,
		message_file_name,
		buyer_refund_address,
		secondary_fee,
		secondary_address,
	) {
		Ok(respond) => {
			trades::store_swap_trade(&context, &swap, &skey, &*swap_lock)?;
			Ok(respond)
		}
		Err(e) => {
			swap.add_journal_message(format!("Processing error: {}", e));
			trades::store_swap_trade(&context, &swap, &skey, &*swap_lock)?;
			Err(e)
		}
	}
}
pub fn swap_process < ' a , L , C , K , F > ( wallet_inst : Arc < Mutex < Box < dyn WalletInst < ' a , L , C , K > > > > , keychain_mask : Option < & SecretKey > , swap_id : & str , message_sender : F , message_file_name : Option < String > , buyer_refund_address : Option < String > , secondary_fee : Option < f32 > , secondary_address : Option < String > , ) -> Result < StateProcessRespond , Error > where L : WalletLCProvider < ' a , C , K > , C : NodeClient + ' a , K : Keychain + ' a , F : FnOnce ( Message , String , String ) -> Result < ( bool , String ) , Error > + ' a , { let ( node_client , keychain ) = { wallet_lock ! ( wallet_inst w ) ; let node_client = w . w2n_client ( ) . clone ( ) ; let keychain = w . keychain ( keychain_mask ) ? ; ( node_client , keychain ) } ; let skey = get_swap_storage_key ( & keychain ) ? ; let swap_lock = trades :: get_swap_lock ( & swap_id . to_string ( ) ) ; let _l = swap_lock . lock ( ) ; let ( context , mut swap ) = trades :: get_swap_trade ( swap_id , & skey , & * swap_lock ) ? ; match swap_process_impl ( wallet_inst , keychain_mask , swap_lock . clone ( ) , & mut swap , & context , node_client , keychain , message_sender , message_file_name , buyer_refund_address , secondary_fee , secondary_address , ) { Ok ( respond ) => { trades :: store_swap_trade ( & context , & swap , & skey , & * swap_lock ) ? ; Ok ( respond ) } Err ( e ) => { swap . add_journal_message ( format ! ( " " e ) ) ; trades :: store_swap_trade ( & context , & swap , & skey , & * swap_lock ) ? ; Err ( e ) } } }
Process the action for the swap.
Process the action for the swap .
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>
keychain_mask
Option<&SecretKey>
swap_id
&str
message_sender
F
message_file_name
Option<String>
buyer_refund_address
Option<String>
secondary_fee
Option<f32>
secondary_address
Option<String>
wallet_inst
Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>
keychain_mask
Option<&SecretKey>
swap_id
&str
message_sender
F
message_file_name
Option<String>
buyer_refund_address
Option<String>
secondary_fee
Option<f32>
secondary_address
Option<String>