mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 19:46:16 +00:00
CAKE-297 | applied subaddress for incoming transaction
This commit is contained in:
parent
d23228ac01
commit
7bbd530319
4 changed files with 41 additions and 5 deletions
12
lib/di.dart
12
lib/di.dart
|
@ -482,10 +482,14 @@ Future setup(
|
||||||
|
|
||||||
getIt
|
getIt
|
||||||
.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
|
.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
|
||||||
(TransactionInfo transactionInfo, _) => TransactionDetailsViewModel(
|
(TransactionInfo transactionInfo, _) {
|
||||||
transactionInfo: transactionInfo,
|
final wallet = getIt.get<AppStore>().wallet;
|
||||||
transactionDescriptionBox: _transactionDescriptionBox,
|
return TransactionDetailsViewModel(
|
||||||
settingsStore: getIt.get<SettingsStore>()));
|
transactionInfo: transactionInfo,
|
||||||
|
transactionDescriptionBox: _transactionDescriptionBox,
|
||||||
|
wallet: wallet,
|
||||||
|
settingsStore: getIt.get<SettingsStore>());
|
||||||
|
});
|
||||||
|
|
||||||
getIt.registerFactoryParam<TransactionDetailsPage, TransactionInfo, void>(
|
getIt.registerFactoryParam<TransactionDetailsPage, TransactionInfo, void>(
|
||||||
(TransactionInfo transactionInfo, _) => TransactionDetailsPage(
|
(TransactionInfo transactionInfo, _) => TransactionDetailsPage(
|
||||||
|
|
|
@ -8,7 +8,7 @@ import 'package:cw_monero/transaction_history.dart';
|
||||||
|
|
||||||
class MoneroTransactionInfo extends TransactionInfo {
|
class MoneroTransactionInfo extends TransactionInfo {
|
||||||
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
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)
|
MoneroTransactionInfo.fromMap(Map map)
|
||||||
: id = (map['hash'] ?? '') as String,
|
: id = (map['hash'] ?? '') as String,
|
||||||
|
@ -21,6 +21,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
isPending = parseBoolFromString(map['isPending'] as String),
|
isPending = parseBoolFromString(map['isPending'] as String),
|
||||||
amount = map['amount'] as int,
|
amount = map['amount'] as int,
|
||||||
accountIndex = int.parse(map['accountIndex'] as String),
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
|
addressIndex = map['addressIndex'] as List<int>,
|
||||||
key = getTxKey((map['hash'] ?? '') as String),
|
key = getTxKey((map['hash'] ?? '') as String),
|
||||||
fee = map['fee'] as int ?? 0;
|
fee = map['fee'] as int ?? 0;
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
isPending = row.isPending != 0,
|
isPending = row.isPending != 0,
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
|
addressIndex = row.getSubaddrIndex(),
|
||||||
key = getTxKey(row.getHash()),
|
key = getTxKey(row.getHash()),
|
||||||
fee = row.fee;
|
fee = row.fee;
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
final bool isPending;
|
final bool isPending;
|
||||||
final int amount;
|
final int amount;
|
||||||
final int fee;
|
final int fee;
|
||||||
|
final List<int> addressIndex;
|
||||||
String recipientAddress;
|
String recipientAddress;
|
||||||
String key;
|
String key;
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
await walletInfo.save();
|
await walletInfo.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getTransactionAddress(int accountIndex, int addressIndex) =>
|
||||||
|
monero_wallet.getAddress(
|
||||||
|
accountIndex: accountIndex,
|
||||||
|
addressIndex: addressIndex);
|
||||||
|
|
||||||
void _setListeners() {
|
void _setListeners() {
|
||||||
_listener?.stop();
|
_listener?.stop();
|
||||||
_listener = monero_wallet.setListeners(_onNewBlock, _onNewTransaction);
|
_listener = monero_wallet.setListeners(_onNewBlock, _onNewTransaction);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
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/entities/transaction_info.dart';
|
||||||
import 'package:cake_wallet/monero/monero_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/standart_list_item.dart';
|
||||||
import 'package:cake_wallet/src/screens/transaction_details/textfield_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/transaction_details_list_item.dart';
|
||||||
import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_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/utils/date_formatter.dart';
|
||||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
@ -22,6 +25,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
TransactionDetailsViewModelBase(
|
TransactionDetailsViewModelBase(
|
||||||
{this.transactionInfo,
|
{this.transactionInfo,
|
||||||
this.transactionDescriptionBox,
|
this.transactionDescriptionBox,
|
||||||
|
this.wallet,
|
||||||
this.settingsStore})
|
this.settingsStore})
|
||||||
: items = [] {
|
: items = [] {
|
||||||
showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false;
|
showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false;
|
||||||
|
@ -56,6 +60,25 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
StandartListItem(title: S.current.transaction_key, value: tx.key));
|
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);
|
items.addAll(_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +145,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
final TransactionInfo transactionInfo;
|
final TransactionInfo transactionInfo;
|
||||||
final Box<TransactionDescription> transactionDescriptionBox;
|
final Box<TransactionDescription> transactionDescriptionBox;
|
||||||
final SettingsStore settingsStore;
|
final SettingsStore settingsStore;
|
||||||
|
final WalletBase wallet;
|
||||||
|
|
||||||
final List<TransactionDetailsListItem> items;
|
final List<TransactionDetailsListItem> items;
|
||||||
bool showRecipientAddress;
|
bool showRecipientAddress;
|
||||||
|
|
Loading…
Reference in a new issue