mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Fixes for tx key for monero wallet
This commit is contained in:
parent
c2dfa3330d
commit
28cf8163ff
5 changed files with 45 additions and 24 deletions
|
@ -1,5 +1,4 @@
|
||||||
import 'package:cw_core/transaction_direction.dart';
|
import 'package:cw_core/transaction_direction.dart';
|
||||||
//import 'package:cake_wallet/utils/mobx.dart';
|
|
||||||
import 'package:cw_core/keyable.dart';
|
import 'package:cw_core/keyable.dart';
|
||||||
|
|
||||||
abstract class TransactionInfo extends Object with Keyable {
|
abstract class TransactionInfo extends Object with Keyable {
|
||||||
|
@ -18,4 +17,6 @@ abstract class TransactionInfo extends Object with Keyable {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic get keyIndex => id;
|
dynamic get keyIndex => id;
|
||||||
|
|
||||||
|
Map<String, dynamic> additionalInfo;
|
||||||
}
|
}
|
|
@ -23,7 +23,13 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
accountIndex = int.parse(map['accountIndex'] as String),
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
addressIndex = map['addressIndex'] as int,
|
addressIndex = map['addressIndex'] as 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 {
|
||||||
|
additionalInfo = {
|
||||||
|
'key': key,
|
||||||
|
'accountIndex': accountIndex,
|
||||||
|
'addressIndex': addressIndex
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
|
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
|
||||||
: id = row.getHash(),
|
: id = row.getHash(),
|
||||||
|
@ -36,7 +42,13 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
key = getTxKey(row.getHash()),
|
key = getTxKey(row.getHash()),
|
||||||
fee = row.fee;
|
fee = row.fee {
|
||||||
|
additionalInfo = {
|
||||||
|
'key': key,
|
||||||
|
'accountIndex': accountIndex,
|
||||||
|
'addressIndex': addressIndex
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final int height;
|
final int height;
|
||||||
|
|
|
@ -288,4 +288,9 @@ class CWMonero extends Monero {
|
||||||
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource) {
|
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource) {
|
||||||
return MoneroWalletService(walletInfoSource);
|
return MoneroWalletService(walletInfoSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
|
||||||
|
final moneroWallet = wallet as MoneroWallet;
|
||||||
|
return moneroWallet.getTransactionAddress(accountIndex, addressIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import 'package:cake_wallet/monero/monero.dart';
|
||||||
|
|
||||||
part 'transaction_details_view_model.g.dart';
|
part 'transaction_details_view_model.g.dart';
|
||||||
|
|
||||||
|
@ -31,6 +32,9 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
|
|
||||||
final dateFormat = DateFormatter.withCurrentLocal();
|
final dateFormat = DateFormatter.withCurrentLocal();
|
||||||
final tx = transactionInfo;
|
final tx = transactionInfo;
|
||||||
|
final key = tx.additionalInfo['key'] as String;
|
||||||
|
final accountIndex = tx.additionalInfo['accountIndex'] as int;
|
||||||
|
final addressIndex = tx.additionalInfo['addressIndex'] as int;
|
||||||
|
|
||||||
if (wallet.type == WalletType.monero) {
|
if (wallet.type == WalletType.monero) {
|
||||||
final _items = [
|
final _items = [
|
||||||
|
@ -46,30 +50,27 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
value: tx.amountFormatted()),
|
value: tx.amountFormatted()),
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.transaction_details_fee, value: tx.feeFormatted()),
|
title: S.current.transaction_details_fee, value: tx.feeFormatted()),
|
||||||
|
if (key?.isNotEmpty ?? false)
|
||||||
|
StandartListItem(title: S.current.transaction_key, value: key)
|
||||||
];
|
];
|
||||||
|
|
||||||
//if (tx.key?.isNotEmpty ?? null) {
|
if (tx.direction == TransactionDirection.incoming &&
|
||||||
// _items.add(
|
accountIndex != null &&
|
||||||
// StandartListItem(title: S.current.transaction_key, value: tx.key));
|
addressIndex != null) {
|
||||||
//}
|
try {
|
||||||
|
final address = monero.getTransactionAddress(wallet, accountIndex, addressIndex);
|
||||||
|
|
||||||
//if (tx.direction == TransactionDirection.incoming) {
|
if (address?.isNotEmpty ?? false) {
|
||||||
// try {
|
isRecipientAddressShown = true;
|
||||||
// final accountIndex = tx.accountIndex;
|
_items.add(
|
||||||
// final addressIndex = tx.addressIndex;
|
StandartListItem(
|
||||||
//final address = moneroUtils.getTransactionAddress(wallet, accountIndex, addressIndex);
|
title: S.current.transaction_details_recipient_address,
|
||||||
|
value: address));
|
||||||
//if (address?.isNotEmpty ?? false) {
|
}
|
||||||
// isRecipientAddressShown = true;
|
} catch (e) {
|
||||||
// _items.add(
|
print(e.toString());
|
||||||
// StandartListItem(
|
}
|
||||||
// title: S.current.transaction_details_recipient_address,
|
}
|
||||||
// value: address));
|
|
||||||
//}
|
|
||||||
// } catch (e) {
|
|
||||||
// print(e.toString());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
items.addAll(_items);
|
items.addAll(_items);
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,8 @@ abstract class Monero {
|
||||||
|
|
||||||
MoneroWalletDetails getMoneroWalletDetails(Object wallet);
|
MoneroWalletDetails getMoneroWalletDetails(Object wallet);
|
||||||
|
|
||||||
|
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex);
|
||||||
|
|
||||||
int getHeigthByDate({DateTime date});
|
int getHeigthByDate({DateTime date});
|
||||||
TransactionPriority getDefaultTransactionPriority();
|
TransactionPriority getDefaultTransactionPriority();
|
||||||
TransactionPriority deserializeMoneroTransactionPriority({int raw});
|
TransactionPriority deserializeMoneroTransactionPriority({int raw});
|
||||||
|
|
Loading…
Reference in a new issue