This commit is contained in:
M 2020-11-11 00:24:50 +02:00
parent 93049b4aa1
commit f5e19a13ab
4 changed files with 25 additions and 13 deletions

View file

@ -240,16 +240,16 @@ class SyncListener {
_initialSyncHeight = 0;
_updateSyncInfoTimer ??=
Timer.periodic(Duration(milliseconds: 1200), (_) async {
final _isNeededToRefresh = isNeededToRefresh();
print('isNeededToRefresh $_isNeededToRefresh');
// final _isNeededToRefresh = isNeededToRefresh();
// print('isNeededToRefresh $_isNeededToRefresh');
if (isNewTransactionExist() || _isNeededToRefresh) {
if (isNewTransactionExist()) {
onNewTransaction?.call();
}
var syncHeight = getSyncingHeight();
print('syncHeight $syncHeight');
// print('syncHeight $syncHeight');
if (syncHeight <= 0) {
syncHeight = getCurrentHeight();

View file

@ -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.isPending, this.amount, this.accountIndex, this.fee);
MoneroTransactionInfo.fromMap(Map map)
: id = (map['hash'] ?? '') as String,
@ -21,7 +21,8 @@ class MoneroTransactionInfo extends TransactionInfo {
isPending = parseBoolFromString(map['isPending'] as String),
amount = map['amount'] as int,
accountIndex = int.parse(map['accountIndex'] as String),
key = getTxKey((map['hash'] ?? '') as String);
key = getTxKey((map['hash'] ?? '') as String),
fee = map['fee'] as int ?? 0;
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(),
@ -32,7 +33,8 @@ class MoneroTransactionInfo extends TransactionInfo {
isPending = row.isPending != 0,
amount = row.getAmount(),
accountIndex = row.subaddrAccount,
key = getTxKey(row.getHash());
key = getTxKey(row.getHash()),
fee = row.fee;
final String id;
final int height;
@ -41,17 +43,22 @@ class MoneroTransactionInfo extends TransactionInfo {
final int accountIndex;
final bool isPending;
final int amount;
final int fee;
String recipientAddress;
String key;
String _fiatAmount;
@override
String amountFormatted() => '${formatAmount(moneroAmountToString(amount: amount))} XMR';
String amountFormatted() =>
'${formatAmount(moneroAmountToString(amount: amount))} XMR';
@override
String fiatAmount() => _fiatAmount ?? '';
@override
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
String feeFormatted() =>
'${formatAmount(moneroAmountToString(amount: fee))} XMR';
}

View file

@ -101,7 +101,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
balance = MoneroBalance(
fullBalance: monero_wallet.getFullBalance(accountIndex: account.id),
unlockedBalance:
monero_wallet.getFullBalance(accountIndex: account.id));
monero_wallet.getUnlockedBalance(accountIndex: account.id));
address = subaddress.address;
_setListeners();
await transactionHistory.update();
@ -186,8 +186,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
if ((amount != null && unlockedBalance < amount) ||
(amount == null && unlockedBalance <= 0)) {
final formattedBalance = moneroAmountToString(amount: unlockedBalance);
throw MoneroTransactionCreationException(
'Incorrect unlocked balance. Unlocked: $unlockedBalance. Transaction amount: ${_credentials.amount}.');
'Incorrect unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${_credentials.amount}.');
}
if (!(syncStatus is SyncedSyncStatus)) {
@ -363,11 +365,11 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
print('_onNewBlock called');
if (walletInfo.isRecovery) {
_askForUpdateTransactionHistory();
_askForUpdateBalance();
}
_askForUpdateBalance();
if (blocksLeft < 100) {
_askForUpdateBalance();
syncStatus = SyncedSyncStatus();
await _afterSyncSave();

View file

@ -29,7 +29,10 @@ class TransactionDetailsPage extends BasePage {
title: S.current.transaction_details_height, value: '${tx.height}'),
StandartListItem(
title: S.current.transaction_details_amount,
value: tx.amountFormatted())
value: tx.amountFormatted()),
StandartListItem(
title: S.current.send_fee,
value: tx.feeFormatted())
];
if (showRecipientAddress) {