/// Sends a new transaction to a recipient
/// # Arguments
/// 'dest_pubkey': The Comms pubkey of the recipient node
/// 'amount': The amount of Tari to send to the recipient
/// 'fee_per_gram': The amount of fee per transaction gram to be included in transaction
Sends a new transaction to a recipient
Sends a new transaction to a recipient
pub async fn send_transaction(
        &mut self,
        dest_pubkey: CommsPublicKey,
        amount: MicroTari,
        fee_per_gram: MicroTari,
        message: String,
        join_handles: &mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>,
    ) -> Result<TxId, TransactionServiceError>
    {
        let sender_protocol = self
            .output_manager_service
            .prepare_transaction_to_send(amount, fee_per_gram, None, message.clone())
            .await?;
        let tx_id = sender_protocol.get_tx_id()?;
        let (tx_reply_sender, tx_reply_receiver) = mpsc::channel(100);
        let (cancellation_sender, cancellation_receiver) = oneshot::channel();
        self.pending_transaction_reply_senders.insert(tx_id, tx_reply_sender);
        self.send_transaction_cancellation_senders
            .insert(tx_id, cancellation_sender);
        let protocol = TransactionSendProtocol::new(
            tx_id,
            self.resources.clone(),
            tx_reply_receiver,
            cancellation_receiver,
            dest_pubkey,
            amount,
            message,
            sender_protocol,
            TransactionSendProtocolStage::Initial,
        );
        let join_handle = tokio::spawn(protocol.execute());
        join_handles.push(join_handle);
        Ok(tx_id)
    }
pub async fn send_transaction ( & mut self , dest_pubkey : CommsPublicKey , amount : MicroTari , fee_per_gram : MicroTari , message : String , join_handles : & mut FuturesUnordered < JoinHandle < Result < u64 , TransactionServiceProtocolError > > > , ) -> Result < TxId , TransactionServiceError > { let sender_protocol = self . output_manager_service . prepare_transaction_to_send ( amount , fee_per_gram , None , message . clone ( ) ) . await ? ; let tx_id = sender_protocol . get_tx_id ( ) ? ; let ( tx_reply_sender , tx_reply_receiver ) = mpsc :: channel ( 100 ) ; let ( cancellation_sender , cancellation_receiver ) = oneshot :: channel ( ) ; self . pending_transaction_reply_senders . insert ( tx_id , tx_reply_sender ) ; self . send_transaction_cancellation_senders . insert ( tx_id , cancellation_sender ) ; let protocol = TransactionSendProtocol :: new ( tx_id , self . resources . clone ( ) , tx_reply_receiver , cancellation_receiver , dest_pubkey , amount , message , sender_protocol , TransactionSendProtocolStage :: Initial , ) ; let join_handle = tokio :: spawn ( protocol . execute ( ) ) ; join_handles . push ( join_handle ) ; Ok ( tx_id ) }
Sends a new transaction to a recipient
Sends a new transaction to a recipient
&mut self
dest_pubkey
CommsPublicKey
amount
MicroTari
fee_per_gram
MicroTari
message
String
join_handles
&mut FuturesUnordered<JoinHandle<Result<u64, TransactionServiceProtocolError>>>