CAKE-297 | applied subaddress for incoming transaction

wownero
OleksandrSobol 3 years ago
parent d23228ac01
commit 7bbd530319

@ -482,10 +482,14 @@ Future setup(
getIt
.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
(TransactionInfo transactionInfo, _) => TransactionDetailsViewModel(
transactionInfo: transactionInfo,
transactionDescriptionBox: _transactionDescriptionBox,
settingsStore: getIt.get<SettingsStore>()));
(TransactionInfo transactionInfo, _) {
final wallet = getIt.get<AppStore>().wallet;
return TransactionDetailsViewModel(
transactionInfo: transactionInfo,
transactionDescriptionBox: _transactionDescriptionBox,
wallet: wallet,
settingsStore: getIt.get<SettingsStore>());
});
getIt.registerFactoryParam<TransactionDetailsPage, TransactionInfo, void>(
(TransactionInfo transactionInfo, _) => TransactionDetailsPage(

@ -8,7 +8,7 @@ import 'package:cw_monero/transaction_history.dart';
class MoneroTransactionInfo extends TransactionInfo {
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
this.isPending, this.amount, this.accountIndex, this.fee);
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee);
MoneroTransactionInfo.fromMap(Map map)
: id = (map['hash'] ?? '') as String,
@ -21,6 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo {
isPending = parseBoolFromString(map['isPending'] as String),
amount = map['amount'] as int,
accountIndex = int.parse(map['accountIndex'] as String),
addressIndex = map['addressIndex'] as List<int>,
key = getTxKey((map['hash'] ?? '') as String),
fee = map['fee'] as int ?? 0;
@ -33,6 +34,7 @@ class MoneroTransactionInfo extends TransactionInfo {
isPending = row.isPending != 0,
amount = row.getAmount(),
accountIndex = row.subaddrAccount,
addressIndex = row.getSubaddrIndex(),
key = getTxKey(row.getHash()),
fee = row.fee;
@ -44,6 +46,7 @@ class MoneroTransactionInfo extends TransactionInfo {
final bool isPending;
final int amount;
final int fee;
final List<int> addressIndex;
String recipientAddress;
String key;

@ -262,6 +262,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
await walletInfo.save();
}
String getTransactionAddress(int accountIndex, int addressIndex) =>
monero_wallet.getAddress(
accountIndex: accountIndex,
addressIndex: addressIndex);
void _setListeners() {
_listener?.stop();
_listener = monero_wallet.setListeners(_onNewBlock, _onNewTransaction);

@ -1,10 +1,13 @@
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/entities/transaction_info.dart';
import 'package:cake_wallet/monero/monero_transaction_info.dart';
import 'package:cake_wallet/monero/monero_wallet.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_list_item.dart';
import 'package:cake_wallet/entities/transaction_direction.dart';
import 'package:cake_wallet/utils/date_formatter.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:hive/hive.dart';
@ -22,6 +25,7 @@ abstract class TransactionDetailsViewModelBase with Store {
TransactionDetailsViewModelBase(
{this.transactionInfo,
this.transactionDescriptionBox,
this.wallet,
this.settingsStore})
: items = [] {
showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false;
@ -56,6 +60,25 @@ abstract class TransactionDetailsViewModelBase with Store {
StandartListItem(title: S.current.transaction_key, value: tx.key));
}
if ((tx.direction == TransactionDirection.incoming)&&
(wallet is MoneroWallet)) {
try {
final accountIndex = tx.accountIndex;
final addressIndex = tx.addressIndex;
final _wallet = wallet as MoneroWallet;
for (var index in addressIndex) {
final address = _wallet.getTransactionAddress(accountIndex, index);
_items.add(
StandartListItem(
title: S.current.transaction_details_recipient_address,
value: address));
}
} catch (e) {
print(e.toString());
}
}
items.addAll(_items);
}
@ -122,6 +145,7 @@ abstract class TransactionDetailsViewModelBase with Store {
final TransactionInfo transactionInfo;
final Box<TransactionDescription> transactionDescriptionBox;
final SettingsStore settingsStore;
final WalletBase wallet;
final List<TransactionDetailsListItem> items;
bool showRecipientAddress;

Loading…
Cancel
Save