mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
Fixes.
This commit is contained in:
@@ -7,9 +7,11 @@ final moneroAmountFormat = NumberFormat()
|
||||
..maximumFractionDigits = moneroAmountLength
|
||||
..minimumFractionDigits = 1;
|
||||
|
||||
String moneroAmountToString({int amount}) =>
|
||||
moneroAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
|
||||
String moneroAmountToString({int amount}) => moneroAmountFormat
|
||||
.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
|
||||
|
||||
double moneroAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
|
||||
double moneroAmountToDouble({int amount}) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
|
||||
|
||||
int moneroParseAmount({String amount}) => moneroAmountFormat.parse(amount).toInt();
|
||||
int moneroParseAmount({String amount}) =>
|
||||
(double.parse(amount) * moneroAmountDivider).toInt();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class MoneroTransactionCreationException implements Exception {
|
||||
MoneroTransactionCreationException(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cake_wallet/monero/monero_amount_format.dart';
|
||||
import 'package:cake_wallet/monero/monero_transaction_creation_exception.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_monero/wallet.dart';
|
||||
@@ -170,6 +174,19 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||
@override
|
||||
Future<PendingTransaction> createTransaction(Object credentials) async {
|
||||
final _credentials = credentials as MoneroTransactionCreationCredentials;
|
||||
final amount = moneroParseAmount(amount: _credentials.amount);
|
||||
final unlockedBalance =
|
||||
monero_wallet.getUnlockedBalance(accountIndex: account.id);
|
||||
|
||||
if (unlockedBalance < amount) {
|
||||
throw MoneroTransactionCreationException(
|
||||
'Incorrect unlocked balance. Unlocked: $unlockedBalance. Transaction amount: ${_credentials.amount}.');
|
||||
}
|
||||
|
||||
if (!(syncStatus is SyncedSyncStatus)) {
|
||||
throw MoneroTransactionCreationException('The wallet is not synced.');
|
||||
}
|
||||
|
||||
final pendingTransactionDescription =
|
||||
await transaction_history.createTransaction(
|
||||
address: _credentials.address,
|
||||
|
||||
Reference in New Issue
Block a user