Fixes.

M committed Nov 11, 2020 at 00:24 UTC f5e19a13ab26fc6a6dddfd35fa5344561bd697db
4 files changed +25 -13
cw_monero/lib/wallet.dart
+4 -4
@@ -240,16 +240,16 @@ class SyncListener {
240 _initialSyncHeight = 0;
241 _updateSyncInfoTimer ??=
242 Timer.periodic(Duration(milliseconds: 1200), (_) async {
243 - final _isNeededToRefresh = isNeededToRefresh();
244 - print('isNeededToRefresh $_isNeededToRefresh');
243 + // final _isNeededToRefresh = isNeededToRefresh();
244 + // print('isNeededToRefresh $_isNeededToRefresh');
245
246 - if (isNewTransactionExist() || _isNeededToRefresh) {
246 + if (isNewTransactionExist()) {
247 onNewTransaction?.call();
248 }
249
250 var syncHeight = getSyncingHeight();
251
252 - print('syncHeight $syncHeight');
252 + // print('syncHeight $syncHeight');
253
254 if (syncHeight <= 0) {
255 syncHeight = getCurrentHeight();
lib/monero/monero_transaction_info.dart
+11 -4
@@ -8,7 +8,7 @@ import 'package:cw_monero/transaction_history.dart';
8
9 class MoneroTransactionInfo extends TransactionInfo {
10 MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
11 - this.isPending, this.amount, this.accountIndex);
11 + this.isPending, this.amount, this.accountIndex, this.fee);
12
13 MoneroTransactionInfo.fromMap(Map map)
14 : id = (map['hash'] ?? '') as String,
@@ -21,7 +21,8 @@ class MoneroTransactionInfo extends TransactionInfo {
21 isPending = parseBoolFromString(map['isPending'] as String),
22 amount = map['amount'] as int,
23 accountIndex = int.parse(map['accountIndex'] as String),
24 - key = getTxKey((map['hash'] ?? '') as String);
24 + key = getTxKey((map['hash'] ?? '') as String),
25 + fee = map['fee'] as int ?? 0;
26
27 MoneroTransactionInfo.fromRow(TransactionInfoRow row)
28 : id = row.getHash(),
@@ -32,7 +33,8 @@ class MoneroTransactionInfo extends TransactionInfo {
33 isPending = row.isPending != 0,
34 amount = row.getAmount(),
35 accountIndex = row.subaddrAccount,
35 - key = getTxKey(row.getHash());
36 + key = getTxKey(row.getHash()),
37 + fee = row.fee;
38
39 final String id;
40 final int height;
@@ -41,17 +43,22 @@ class MoneroTransactionInfo extends TransactionInfo {
43 final int accountIndex;
44 final bool isPending;
45 final int amount;
46 + final int fee;
47 String recipientAddress;
48 String key;
49
50 String _fiatAmount;
51
52 @override
50 - String amountFormatted() => '${formatAmount(moneroAmountToString(amount: amount))} XMR';
53 + String amountFormatted() =>
54 + '${formatAmount(moneroAmountToString(amount: amount))} XMR';
55
56 @override
57 String fiatAmount() => _fiatAmount ?? '';
58
59 @override
60 void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
61 +
62 + String feeFormatted() =>
63 + '${formatAmount(moneroAmountToString(amount: fee))} XMR';
64 }
lib/monero/monero_wallet.dart
+6 -4
@@ -101,7 +101,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
101 balance = MoneroBalance(
102 fullBalance: monero_wallet.getFullBalance(accountIndex: account.id),
103 unlockedBalance:
104 - monero_wallet.getFullBalance(accountIndex: account.id));
104 + monero_wallet.getUnlockedBalance(accountIndex: account.id));
105 address = subaddress.address;
106 _setListeners();
107 await transactionHistory.update();
@@ -186,8 +186,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
186
187 if ((amount != null && unlockedBalance < amount) ||
188 (amount == null && unlockedBalance <= 0)) {
189 + final formattedBalance = moneroAmountToString(amount: unlockedBalance);
190 +
191 throw MoneroTransactionCreationException(
190 - 'Incorrect unlocked balance. Unlocked: $unlockedBalance. Transaction amount: ${_credentials.amount}.');
192 + 'Incorrect unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${_credentials.amount}.');
193 }
194
195 if (!(syncStatus is SyncedSyncStatus)) {
@@ -363,11 +365,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
365 print('_onNewBlock called');
366 if (walletInfo.isRecovery) {
367 _askForUpdateTransactionHistory();
368 + _askForUpdateBalance();
369 }
370
368 - _askForUpdateBalance();
369 -
371 if (blocksLeft < 100) {
372 + _askForUpdateBalance();
373 syncStatus = SyncedSyncStatus();
374 await _afterSyncSave();
375
lib/src/screens/transaction_details/transaction_details_page.dart
+4 -1
@@ -29,7 +29,10 @@ class TransactionDetailsPage extends BasePage {
29 title: S.current.transaction_details_height, value: '${tx.height}'),
30 StandartListItem(
31 title: S.current.transaction_details_amount,
32 - value: tx.amountFormatted())
32 + value: tx.amountFormatted()),
33 + StandartListItem(
34 + title: S.current.send_fee,
35 + value: tx.feeFormatted())
36 ];
37
38 if (showRecipientAddress) {