tx: receiver address

This commit is contained in:
ardocrat
2024-09-20 02:39:06 +03:00
parent 3e249c5314
commit 0ead11ec6c
2 changed files with 25 additions and 8 deletions
+13 -1
View File
@@ -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<SlatepackAddress> {
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
}
}