mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 11:16:26 +00:00
Merge pull request #134 from cake-tech/CAKE-297-subaddress-for-incoming-transaction
Cake 297 subaddress for incoming transaction
This commit is contained in:
commit
951cdbeb50
6 changed files with 47 additions and 5 deletions
|
@ -134,6 +134,7 @@ extern "C"
|
|||
uint32_t subaddrAccount;
|
||||
int8_t direction;
|
||||
int8_t isPending;
|
||||
uint32_t subaddrIndex;
|
||||
|
||||
char *hash;
|
||||
char *paymentId;
|
||||
|
@ -146,6 +147,8 @@ extern "C"
|
|||
fee = transaction->fee();
|
||||
blockHeight = transaction->blockHeight();
|
||||
subaddrAccount = transaction->subaddrAccount();
|
||||
std::set<uint32_t>::iterator it = transaction->subaddrIndex().begin();
|
||||
subaddrIndex = *it;
|
||||
confirmations = transaction->confirmations();
|
||||
datetime = static_cast<int64_t>(transaction->timestamp());
|
||||
direction = transaction->direction();
|
||||
|
|
|
@ -23,6 +23,9 @@ class TransactionInfoRow extends Struct {
|
|||
@Int8()
|
||||
int isPending;
|
||||
|
||||
@Uint32()
|
||||
int subaddrIndex;
|
||||
|
||||
Pointer<Utf8> hash;
|
||||
|
||||
Pointer<Utf8> paymentId;
|
||||
|
|
12
lib/di.dart
12
lib/di.dart
|
@ -490,10 +490,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 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.subaddrIndex,
|
||||
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 int addressIndex;
|
||||
String recipientAddress;
|
||||
String key;
|
||||
|
||||
|
|
|
@ -271,6 +271,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
|||
await walletInfo.save();
|
||||
}
|
||||
|
||||
String getTransactionAddress(int accountIndex, int addressIndex) =>
|
||||
monero_wallet.getAddress(
|
||||
accountIndex: accountIndex,
|
||||
addressIndex: addressIndex);
|
||||
|
||||
@override
|
||||
Future<Map<String, MoneroTransactionInfo>> fetchTransactions() async {
|
||||
monero_transaction_history.refreshTransactions();
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import 'package:cake_wallet/bitcoin/electrum_transaction_info.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.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';
|
||||
|
@ -23,6 +26,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
TransactionDetailsViewModelBase(
|
||||
{this.transactionInfo,
|
||||
this.transactionDescriptionBox,
|
||||
this.wallet,
|
||||
this.settingsStore})
|
||||
: items = [] {
|
||||
showRecipientAddress = settingsStore?.shouldSaveRecipientAddress ?? false;
|
||||
|
@ -51,6 +55,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;
|
||||
final address =
|
||||
_wallet.getTransactionAddress(accountIndex, addressIndex);
|
||||
if (address?.isNotEmpty ?? false) {
|
||||
_items.add(
|
||||
StandartListItem(
|
||||
title: S.current.transaction_details_recipient_address,
|
||||
value: address));
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
items.addAll(_items);
|
||||
}
|
||||
|
||||
|
@ -124,6 +147,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…
Reference in a new issue