fn handle_memo_helper(
        &mut self,
        tx_out: &TxOut,
        account_key: &AccountKey,
    ) -> Result<Option<MemoType>, MemoHandlerError> {
        let decompressed_tx_pub = RistrettoPublic::try_from(&tx_out.public_key)?;
        let shared_secret =
            get_tx_out_shared_secret(account_key.view_private_key(), &decompressed_tx_pub);

        let memo_payload = tx_out.decrypt_memo(&shared_secret);

        let memo_type = MemoType::try_from(&memo_payload)?;
        log::info!(self.logger, "Obtained a memo: {:?}", memo_type);
        match memo_type.clone() {
            MemoType::Unused(_) => Ok(None),
            MemoType::AuthenticatedSender(memo) => {
                if let Some(addr) = self.contacts.get(&memo.sender_address_hash()) {
                    if bool::from(memo.validate(
                        addr,
                        &account_key.default_subaddress_view_private(),
                        &tx_out.public_key,
                    )) {
                        Ok(Some(memo_type))
                    } else {
                        Err(MemoHandlerError::FailedHmacValidation)
                    }
                } else {
                    Err(MemoHandlerError::UnknownSender)
                }
            }
            MemoType::AuthenticatedSenderWithPaymentRequestId(memo) => {
                if let Some(addr) = self.contacts.get(&memo.sender_address_hash()) {
                    if bool::from(memo.validate(
                        addr,
                        &account_key.default_subaddress_view_private(),
                        &tx_out.public_key,
                    )) {
                        Ok(Some(memo_type))
                    } else {
                        Err(MemoHandlerError::FailedHmacValidation)
                    }
                } else {
                    Err(MemoHandlerError::UnknownSender)
                }
            }
            MemoType::Destination(_) => {
                if subaddress_matches_tx_out(account_key, CHANGE_SUBADDRESS_INDEX, tx_out)? {
                    Ok(Some(memo_type))
                } else {
                    Err(MemoHandlerError::FailedSubaddressValidation)
                }
            }
        }
    }
// Helper for handle_memo function. The result of this gets assigned to
// self.last_memo, and so we can use rust ? syntax in this code.
Helper for handle_memo function. The result of this gets assigned to
self.last_memo, and so we can use rust . syntax in this code.
Helper for handle_memo function . The result of this gets assigned to self . last_memo and so we can use rust . syntax in this code .
fn handle_memo_helper(
        &mut self,
        tx_out: &TxOut,
        account_key: &AccountKey,
    ) -> Result<Option<MemoType>, MemoHandlerError> {
        let decompressed_tx_pub = RistrettoPublic::try_from(&tx_out.public_key)?;
        let shared_secret =
            get_tx_out_shared_secret(account_key.view_private_key(), &decompressed_tx_pub);
        let memo_payload = tx_out.decrypt_memo(&shared_secret);
        let memo_type = MemoType::try_from(&memo_payload)?;
        log::info!(self.logger, "Obtained a memo: {:?}", memo_type);
        match memo_type.clone() {
            MemoType::Unused(_) => Ok(None),
            MemoType::AuthenticatedSender(memo) => {
                if let Some(addr) = self.contacts.get(&memo.sender_address_hash()) {
                    if bool::from(memo.validate(
                        addr,
                        &account_key.default_subaddress_view_private(),
                        &tx_out.public_key,
                    )) {
                        Ok(Some(memo_type))
                    } else {
                        Err(MemoHandlerError::FailedHmacValidation)
                    }
                } else {
                    Err(MemoHandlerError::UnknownSender)
                }
            }
            MemoType::AuthenticatedSenderWithPaymentRequestId(memo) => {
                if let Some(addr) = self.contacts.get(&memo.sender_address_hash()) {
                    if bool::from(memo.validate(
                        addr,
                        &account_key.default_subaddress_view_private(),
                        &tx_out.public_key,
                    )) {
                        Ok(Some(memo_type))
                    } else {
                        Err(MemoHandlerError::FailedHmacValidation)
                    }
                } else {
                    Err(MemoHandlerError::UnknownSender)
                }
            }
            MemoType::Destination(_) => {
                if subaddress_matches_tx_out(account_key, CHANGE_SUBADDRESS_INDEX, tx_out)? {
                    Ok(Some(memo_type))
                } else {
                    Err(MemoHandlerError::FailedSubaddressValidation)
                }
            }
        }
    }
fn handle_memo_helper ( & mut self , tx_out : & TxOut , account_key : & AccountKey , ) -> Result < Option < MemoType > , MemoHandlerError > { let decompressed_tx_pub = RistrettoPublic :: try_from ( & tx_out . public_key ) ? ; let shared_secret = get_tx_out_shared_secret ( account_key . view_private_key ( ) , & decompressed_tx_pub ) ; let memo_payload = tx_out . decrypt_memo ( & shared_secret ) ; let memo_type = MemoType :: try_from ( & memo_payload ) ? ; log :: info ! ( self logger " " memo_type ) ; match memo_type . clone ( ) { MemoType :: Unused ( _ ) => Ok ( None ) , MemoType :: AuthenticatedSender ( memo ) => { if let Some ( addr ) = self . contacts . get ( & memo . sender_address_hash ( ) ) { if bool :: from ( memo . validate ( addr , & account_key . default_subaddress_view_private ( ) , & tx_out . public_key , ) ) { Ok ( Some ( memo_type ) ) } else { Err ( MemoHandlerError :: FailedHmacValidation ) } } else { Err ( MemoHandlerError :: UnknownSender ) } } MemoType :: AuthenticatedSenderWithPaymentRequestId ( memo ) => { if let Some ( addr ) = self . contacts . get ( & memo . sender_address_hash ( ) ) { if bool :: from ( memo . validate ( addr , & account_key . default_subaddress_view_private ( ) , & tx_out . public_key , ) ) { Ok ( Some ( memo_type ) ) } else { Err ( MemoHandlerError :: FailedHmacValidation ) } } else { Err ( MemoHandlerError :: UnknownSender ) } } MemoType :: Destination ( _ ) => { if subaddress_matches_tx_out ( account_key , CHANGE_SUBADDRESS_INDEX , tx_out ) ? { Ok ( Some ( memo_type ) ) } else { Err ( MemoHandlerError :: FailedSubaddressValidation ) } } } }
Helper for handle_memo function.
Helper for handle_memo function .
&mut self
tx_out
&TxOut
account_key
&AccountKey