From 0ead11ec6c7c24976ff42679b21c7090dcdf958a Mon Sep 17 00:00:00 2001 From: ardocrat Date: Fri, 20 Sep 2024 02:39:06 +0300 Subject: [PATCH] tx: receiver address --- src/gui/views/wallets/wallet/txs/tx.rs | 19 ++++++++++++------- src/wallet/types.rs | 14 +++++++++++++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/gui/views/wallets/wallet/txs/tx.rs b/src/gui/views/wallets/wallet/txs/tx.rs index 06395ab..542fe93 100644 --- a/src/gui/views/wallets/wallet/txs/tx.rs +++ b/src/gui/views/wallets/wallet/txs/tx.rs @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::sync::Arc; use std::thread; -use egui::{Align, Id, Layout, RichText, Rounding, ScrollArea}; -use egui::scroll_area::ScrollBarVisibility; -use grin_core::core::amount_to_hr_string; -use grin_util::ToHex; -use grin_wallet_libwallet::{Error, Slate, SlateState, TxLogEntryType}; +use std::sync::Arc; use parking_lot::RwLock; +use egui::scroll_area::ScrollBarVisibility; +use egui::{Align, Id, Layout, RichText, Rounding, ScrollArea}; +use grin_util::ToHex; +use grin_core::core::amount_to_hr_string; +use grin_wallet_libwallet::{Error, Slate, SlateState, TxLogEntryType}; + use crate::gui::Colors; use crate::gui::icons::{BROOM, CHECK, CLIPBOARD_TEXT, COPY, CUBE, FILE_ARCHIVE, FILE_TEXT, HASH_STRAIGHT, PROHIBIT, QR_CODE, SCAN}; use crate::gui::platform::PlatformCallbacks; - use crate::gui::views::{CameraContent, FilePickButton, Modal, QrCodeContent, View}; use crate::gui::views::wallets::wallet::txs::WalletTransactions; use crate::gui::views::wallets::wallet::types::SLATEPACK_MESSAGE_HINT; @@ -176,6 +176,11 @@ impl WalletTransactionModal { let label = format!("{} {}", FILE_ARCHIVE, t!("kernel")); Self::info_item_ui(ui, kernel.0.to_hex(), label, true, cb); } + // Show receiver address. + if let Some(rec) = tx.receiver() { + let label = format!("{} {}", CUBE, t!("network_mining.address")); + Self::info_item_ui(ui, rec.to_string(), label, true, cb); + } // Show block height. if let Some(height) = tx.height { if height != 0 { diff --git a/src/wallet/types.rs b/src/wallet/types.rs index e35c304..c95d333 100644 --- a/src/wallet/types.rs +++ b/src/wallet/types.rs @@ -17,7 +17,8 @@ use std::sync::Arc; use grin_keychain::ExtKeychain; use grin_util::Mutex; use grin_wallet_impls::{DefaultLCProvider, HTTPNodeClient}; -use grin_wallet_libwallet::{TxLogEntry, TxLogEntryType, WalletInfo, WalletInst}; +use grin_wallet_libwallet::{SlatepackAddress, TxLogEntry, TxLogEntryType, WalletInfo, WalletInst}; +use grin_wallet_util::OnionV3Address; use serde_derive::{Deserialize, Serialize}; /// Mnemonic phrase word. @@ -176,4 +177,15 @@ impl WalletTransaction { self.data.tx_type != TxLogEntryType::TxReceivedCancelled && self.data.tx_type != TxLogEntryType::TxSentCancelled } + + /// Get receiver address if payment proof was created. + pub fn receiver(&self) -> Option { + if let Some(proof) = &self.data.payment_proof { + let onion_addr = OnionV3Address::from_bytes(proof.receiver_address.to_bytes()); + if let Ok(addr) = SlatepackAddress::try_from(onion_addr) { + return Some(addr); + } + } + None + } } \ No newline at end of file