fn generate_tx(
        &self,
        request_payload: &RequestPayload,
    ) -> Result<(mobilecoind_api::TxProposal, u64), String> {
        let pb = ProgressBar::new_spinner();
        pb.enable_steady_tick(120);
        pb.set_message("Preparing transaction...");

        // Get our UnspentTxOuts.
        let mut req = mobilecoind_api::GetUnspentTxOutListRequest::new();
        req.set_monitor_id(self.monitor_id.clone());
        req.set_subaddress_index(0);

        let resp = self
            .client
            .get_unspent_tx_out_list(&req)
            .map_err(|err| format!("Unable to get unspent txouts: {}", err))?;
        let utxos = resp.output_list;
        let balance = utxos.iter().map(|utxo| utxo.get_value()).sum::<u64>();

        // Create the outlay
        let mut outlay = mobilecoind_api::Outlay::new();
        outlay.set_value(request_payload.value);
        outlay.set_receiver(mobilecoind_api::PublicAddress::from(
            &request_payload.into(),
        ));

        // Construct the tx
        let mut req = mobilecoind_api::GenerateTxRequest::new();
        req.set_sender_monitor_id(self.monitor_id.clone());
        req.set_change_subaddress(0);
        req.set_input_list(utxos);
        req.set_outlay_list(RepeatedField::from_vec(vec![outlay]));

        let mut resp = self
            .client
            .generate_tx(&req)
            .map_err(|err| format!("Unable to generate transaction: {}", err))?;
        Ok((resp.take_tx_proposal(), balance))
    }
/// Helper method for generating a transaction from a B58 request code.
Helper method for generating a transaction from a B58 request code.
Helper method for generating a transaction from a B58 request code .
fn generate_tx(
        &self,
        request_payload: &RequestPayload,
    ) -> Result<(mobilecoind_api::TxProposal, u64), String> {
        let pb = ProgressBar::new_spinner();
        pb.enable_steady_tick(120);
        pb.set_message("Preparing transaction...");
        // Get our UnspentTxOuts.
        let mut req = mobilecoind_api::GetUnspentTxOutListRequest::new();
        req.set_monitor_id(self.monitor_id.clone());
        req.set_subaddress_index(0);
        let resp = self
            .client
            .get_unspent_tx_out_list(&req)
            .map_err(|err| format!("Unable to get unspent txouts: {}", err))?;
        let utxos = resp.output_list;
        let balance = utxos.iter().map(|utxo| utxo.get_value()).sum::<u64>();
        // Create the outlay
        let mut outlay = mobilecoind_api::Outlay::new();
        outlay.set_value(request_payload.value);
        outlay.set_receiver(mobilecoind_api::PublicAddress::from(
            &request_payload.into(),
        ));
        // Construct the tx
        let mut req = mobilecoind_api::GenerateTxRequest::new();
        req.set_sender_monitor_id(self.monitor_id.clone());
        req.set_change_subaddress(0);
        req.set_input_list(utxos);
        req.set_outlay_list(RepeatedField::from_vec(vec![outlay]));
        let mut resp = self
            .client
            .generate_tx(&req)
            .map_err(|err| format!("Unable to generate transaction: {}", err))?;
        Ok((resp.take_tx_proposal(), balance))
    }
fn generate_tx ( & self , request_payload : & RequestPayload , ) -> Result < ( mobilecoind_api :: TxProposal , u64 ) , String > { let pb = ProgressBar :: new_spinner ( ) ; pb . enable_steady_tick ( 120 ) ; pb . set_message ( " " ) ; // Get our UnspentTxOuts. let mut req = mobilecoind_api :: GetUnspentTxOutListRequest :: new ( ) ; req . set_monitor_id ( self . monitor_id . clone ( ) ) ; req . set_subaddress_index ( 0 ) ; let resp = self . client . get_unspent_tx_out_list ( & req ) . map_err ( | err | format ! ( " " err ) ) ? ; let utxos = resp . output_list ; let balance = utxos . iter ( ) . map ( | utxo | utxo . get_value ( ) ) . sum :: < u64 > ( ) ; // Create the outlay let mut outlay = mobilecoind_api :: Outlay :: new ( ) ; outlay . set_value ( request_payload . value ) ; outlay . set_receiver ( mobilecoind_api :: PublicAddress :: from ( & request_payload . into ( ) , ) ) ; // Construct the tx let mut req = mobilecoind_api :: GenerateTxRequest :: new ( ) ; req . set_sender_monitor_id ( self . monitor_id . clone ( ) ) ; req . set_change_subaddress ( 0 ) ; req . set_input_list ( utxos ) ; req . set_outlay_list ( RepeatedField :: from_vec ( vec ! [ outlay ] ) ) ; let mut resp = self . client . generate_tx ( & req ) . map_err ( | err | format ! ( " " err ) ) ? ; Ok ( ( resp . take_tx_proposal ( ) , balance ) ) }
Helper method for generating a transaction from a B58 request code.
Helper method for generating a transaction from a B58 request code .
&self
request_payload
&RequestPayload
&self
request_payload
&RequestPayload