mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
fix: wallet seed display
fix: wownero not refreshing
This commit is contained in:
parent
442bae17cc
commit
4c061addab
5 changed files with 177 additions and 108 deletions
|
@ -43,6 +43,15 @@ String getSeed() {
|
|||
return legacy;
|
||||
}
|
||||
|
||||
String getSeedLegacy(String? language) {
|
||||
var legacy = monero.Wallet_seed(wptr!, seedOffset: '');
|
||||
if (monero.Wallet_status(wptr!) != 0) {
|
||||
monero.Wallet_setSeedLanguage(wptr!, language: language ?? "English");
|
||||
legacy = monero.Wallet_seed(wptr!, seedOffset: '');
|
||||
}
|
||||
return legacy;
|
||||
}
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 1}) =>
|
||||
monero.Wallet_address(wptr!,
|
||||
accountIndex: accountIndex, addressIndex: addressIndex);
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:cw_core/transaction_priority.dart';
|
|||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_monero/api/account_list.dart';
|
||||
import 'package:cw_monero/api/coins_info.dart';
|
||||
import 'package:cw_monero/api/monero_output.dart';
|
||||
import 'package:cw_monero/api/structs/pending_transaction.dart';
|
||||
|
@ -105,6 +106,9 @@ abstract class MoneroWalletBase
|
|||
|
||||
@override
|
||||
String get seed => monero_wallet.getSeed();
|
||||
String seedLegacy(String? language) {
|
||||
return monero_wallet.getSeedLegacy(language);
|
||||
}
|
||||
|
||||
@override
|
||||
MoneroWalletKeys get keys => MoneroWalletKeys(
|
||||
|
|
|
@ -15,15 +15,17 @@ int getSyncingHeight() {
|
|||
}
|
||||
|
||||
bool isNeededToRefresh() {
|
||||
final ret = wownero.WOWNERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
||||
wownero.WOWNERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
||||
return ret;
|
||||
// final ret = wownero.WOWNERO_cw_WalletListener_isNeedToRefresh(getWlptr());
|
||||
// wownero.WOWNERO_cw_WalletListener_resetNeedToRefresh(getWlptr());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isNewTransactionExist() {
|
||||
final ret = wownero.WOWNERO_cw_WalletListener_isNewTransactionExist(getWlptr());
|
||||
wownero.WOWNERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
||||
return ret;
|
||||
// final ret =
|
||||
// wownero.WOWNERO_cw_WalletListener_isNewTransactionExist(getWlptr());
|
||||
// wownero.WOWNERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr());
|
||||
// NOTE: I don't know why wownero is being funky, but
|
||||
return true;
|
||||
}
|
||||
|
||||
String getFilename() => wownero.Wallet_filename(wptr!);
|
||||
|
@ -43,6 +45,15 @@ String getSeed() {
|
|||
return legacy;
|
||||
}
|
||||
|
||||
String getSeedLegacy(String? language) {
|
||||
var legacy = wownero.Wallet_seed(wptr!, seedOffset: '');
|
||||
if (wownero.Wallet_status(wptr!) != 0) {
|
||||
wownero.Wallet_setSeedLanguage(wptr!, language: language ?? "English");
|
||||
legacy = wownero.Wallet_seed(wptr!, seedOffset: '');
|
||||
}
|
||||
return legacy;
|
||||
}
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 1}) =>
|
||||
wownero.Wallet_address(wptr!,
|
||||
accountIndex: accountIndex, addressIndex: addressIndex);
|
||||
|
|
|
@ -5,8 +5,6 @@ import 'dart:isolate';
|
|||
|
||||
import 'package:cw_core/account.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/wownero_amount_format.dart';
|
||||
import 'package:cw_core/wownero_balance.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/monero_wallet_keys.dart';
|
||||
import 'package:cw_core/monero_wallet_utils.dart';
|
||||
|
@ -19,20 +17,22 @@ import 'package:cw_core/transaction_priority.dart';
|
|||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wownero_amount_format.dart';
|
||||
import 'package:cw_core/wownero_balance.dart';
|
||||
import 'package:cw_wownero/api/coins_info.dart';
|
||||
import 'package:cw_wownero/api/wownero_output.dart';
|
||||
import 'package:cw_wownero/api/structs/pending_transaction.dart';
|
||||
import 'package:cw_wownero/api/transaction_history.dart' as transaction_history;
|
||||
import 'package:cw_wownero/api/wallet.dart' as wownero_wallet;
|
||||
import 'package:cw_wownero/api/wallet_manager.dart';
|
||||
import 'package:cw_wownero/api/wownero_output.dart';
|
||||
import 'package:cw_wownero/exceptions/wownero_transaction_creation_exception.dart';
|
||||
import 'package:cw_wownero/exceptions/wownero_transaction_no_inputs_exception.dart';
|
||||
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
||||
import 'package:cw_wownero/wownero_transaction_creation_credentials.dart';
|
||||
import 'package:cw_wownero/wownero_transaction_history.dart';
|
||||
import 'package:cw_wownero/wownero_transaction_info.dart';
|
||||
import 'package:cw_wownero/wownero_unspent.dart';
|
||||
import 'package:cw_wownero/wownero_wallet_addresses.dart';
|
||||
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
@ -46,10 +46,11 @@ const MIN_RESTORE_HEIGHT = 1000;
|
|||
|
||||
class WowneroWallet = WowneroWalletBase with _$WowneroWallet;
|
||||
|
||||
abstract class WowneroWalletBase
|
||||
extends WalletBase<WowneroBalance, WowneroTransactionHistory, WowneroTransactionInfo> with Store {
|
||||
abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
|
||||
WowneroTransactionHistory, WowneroTransactionInfo> with Store {
|
||||
WowneroWalletBase(
|
||||
{required WalletInfo walletInfo, required Box<UnspentCoinsInfo> unspentCoinsInfo})
|
||||
{required WalletInfo walletInfo,
|
||||
required Box<UnspentCoinsInfo> unspentCoinsInfo})
|
||||
: balance = ObservableMap<CryptoCurrency, WowneroBalance>.of({
|
||||
CryptoCurrency.xmr: WowneroBalance(
|
||||
fullBalance: wownero_wallet.getFullBalance(accountIndex: 0),
|
||||
|
@ -65,13 +66,17 @@ abstract class WowneroWalletBase
|
|||
transactionHistory = WowneroTransactionHistory();
|
||||
walletAddresses = WowneroWalletAddresses(walletInfo, transactionHistory);
|
||||
|
||||
_onAccountChangeReaction = reaction((_) => walletAddresses.account, (Account? account) {
|
||||
_onAccountChangeReaction =
|
||||
reaction((_) => walletAddresses.account, (Account? account) {
|
||||
if (account == null) return;
|
||||
|
||||
balance = ObservableMap<CryptoCurrency, WowneroBalance>.of(<CryptoCurrency, WowneroBalance>{
|
||||
balance = ObservableMap<CryptoCurrency,
|
||||
WowneroBalance>.of(<CryptoCurrency, WowneroBalance>{
|
||||
currency: WowneroBalance(
|
||||
fullBalance: wownero_wallet.getFullBalance(accountIndex: account.id),
|
||||
unlockedBalance: wownero_wallet.getUnlockedBalance(accountIndex: account.id))
|
||||
fullBalance:
|
||||
wownero_wallet.getFullBalance(accountIndex: account.id),
|
||||
unlockedBalance:
|
||||
wownero_wallet.getUnlockedBalance(accountIndex: account.id))
|
||||
});
|
||||
_updateSubAddress(isEnabledAutoGenerateSubaddress, account: account);
|
||||
_askForUpdateTransactionHistory();
|
||||
|
@ -106,6 +111,10 @@ abstract class WowneroWalletBase
|
|||
@override
|
||||
String get seed => wownero_wallet.getSeed();
|
||||
|
||||
String seedLegacy(String? language) {
|
||||
return wownero_wallet.getSeedLegacy(language);
|
||||
}
|
||||
|
||||
@override
|
||||
MoneroWalletKeys get keys => MoneroWalletKeys(
|
||||
privateSpendKey: wownero_wallet.getSecretSpendKey(),
|
||||
|
@ -122,11 +131,13 @@ abstract class WowneroWalletBase
|
|||
|
||||
Future<void> init() async {
|
||||
await walletAddresses.init();
|
||||
balance = ObservableMap<CryptoCurrency, WowneroBalance>.of(<CryptoCurrency, WowneroBalance>{
|
||||
balance = ObservableMap<CryptoCurrency, WowneroBalance>.of(<CryptoCurrency,
|
||||
WowneroBalance>{
|
||||
currency: WowneroBalance(
|
||||
fullBalance: wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id),
|
||||
unlockedBalance:
|
||||
wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id))
|
||||
fullBalance: wownero_wallet.getFullBalance(
|
||||
accountIndex: walletAddresses.account!.id),
|
||||
unlockedBalance: wownero_wallet.getUnlockedBalance(
|
||||
accountIndex: walletAddresses.account!.id))
|
||||
});
|
||||
_setListeners();
|
||||
await updateTransactions();
|
||||
|
@ -135,12 +146,13 @@ abstract class WowneroWalletBase
|
|||
wownero_wallet.setRecoveringFromSeed(isRecovery: walletInfo.isRecovery);
|
||||
|
||||
if (wownero_wallet.getCurrentHeight() <= 1) {
|
||||
wownero_wallet.setRefreshFromBlockHeight(height: walletInfo.restoreHeight);
|
||||
wownero_wallet.setRefreshFromBlockHeight(
|
||||
height: walletInfo.restoreHeight);
|
||||
}
|
||||
}
|
||||
|
||||
_autoSaveTimer =
|
||||
Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save());
|
||||
_autoSaveTimer = Timer.periodic(
|
||||
Duration(seconds: _autoSaveInterval), (_) async => await save());
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -212,8 +224,8 @@ abstract class WowneroWalletBase
|
|||
final inputs = <String>[];
|
||||
final outputs = _credentials.outputs;
|
||||
final hasMultiDestination = outputs.length > 1;
|
||||
final unlockedBalance =
|
||||
wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id);
|
||||
final unlockedBalance = wownero_wallet.getUnlockedBalance(
|
||||
accountIndex: walletAddresses.account!.id);
|
||||
var allInputsAmount = 0;
|
||||
|
||||
PendingTransactionDescription pendingTransactionDescription;
|
||||
|
@ -235,16 +247,20 @@ abstract class WowneroWalletBase
|
|||
final spendAllCoins = inputs.length == unspentCoins.length;
|
||||
|
||||
if (hasMultiDestination) {
|
||||
if (outputs.any((item) => item.sendAll || (item.formattedCryptoAmount ?? 0) <= 0)) {
|
||||
throw WowneroTransactionCreationException('You do not have enough XMR to send this amount.');
|
||||
if (outputs.any(
|
||||
(item) => item.sendAll || (item.formattedCryptoAmount ?? 0) <= 0)) {
|
||||
throw WowneroTransactionCreationException(
|
||||
'You do not have enough XMR to send this amount.');
|
||||
}
|
||||
|
||||
final int totalAmount =
|
||||
outputs.fold(0, (acc, value) => acc + (value.formattedCryptoAmount ?? 0));
|
||||
final int totalAmount = outputs.fold(
|
||||
0, (acc, value) => acc + (value.formattedCryptoAmount ?? 0));
|
||||
|
||||
final estimatedFee = calculateEstimatedFee(_credentials.priority, totalAmount);
|
||||
final estimatedFee =
|
||||
calculateEstimatedFee(_credentials.priority, totalAmount);
|
||||
if (unlockedBalance < totalAmount) {
|
||||
throw WowneroTransactionCreationException('You do not have enough XMR to send this amount.');
|
||||
throw WowneroTransactionCreationException(
|
||||
'You do not have enough XMR to send this amount.');
|
||||
}
|
||||
|
||||
if (!spendAllCoins && (allInputsAmount < totalAmount + estimatedFee)) {
|
||||
|
@ -252,22 +268,28 @@ abstract class WowneroWalletBase
|
|||
}
|
||||
|
||||
final wowneroOutputs = outputs.map((output) {
|
||||
final outputAddress = output.isParsedAddress ? output.extractedAddress : output.address;
|
||||
final outputAddress =
|
||||
output.isParsedAddress ? output.extractedAddress : output.address;
|
||||
|
||||
return WowneroOutput(
|
||||
address: outputAddress!, amount: output.cryptoAmount!.replaceAll(',', '.'));
|
||||
address: outputAddress!,
|
||||
amount: output.cryptoAmount!.replaceAll(',', '.'));
|
||||
}).toList();
|
||||
|
||||
pendingTransactionDescription = await transaction_history.createTransactionMultDest(
|
||||
outputs: wowneroOutputs,
|
||||
priorityRaw: _credentials.priority.serialize(),
|
||||
accountIndex: walletAddresses.account!.id,
|
||||
preferredInputs: inputs);
|
||||
pendingTransactionDescription =
|
||||
await transaction_history.createTransactionMultDest(
|
||||
outputs: wowneroOutputs,
|
||||
priorityRaw: _credentials.priority.serialize(),
|
||||
accountIndex: walletAddresses.account!.id,
|
||||
preferredInputs: inputs);
|
||||
} else {
|
||||
final output = outputs.first;
|
||||
final address = output.isParsedAddress ? output.extractedAddress : output.address;
|
||||
final amount = output.sendAll ? null : output.cryptoAmount!.replaceAll(',', '.');
|
||||
final formattedAmount = output.sendAll ? null : output.formattedCryptoAmount;
|
||||
final address =
|
||||
output.isParsedAddress ? output.extractedAddress : output.address;
|
||||
final amount =
|
||||
output.sendAll ? null : output.cryptoAmount!.replaceAll(',', '.');
|
||||
final formattedAmount =
|
||||
output.sendAll ? null : output.formattedCryptoAmount;
|
||||
|
||||
if ((formattedAmount != null && unlockedBalance < formattedAmount) ||
|
||||
(formattedAmount == null && unlockedBalance <= 0)) {
|
||||
|
@ -277,19 +299,22 @@ abstract class WowneroWalletBase
|
|||
'You do not have enough unlocked balance. Unlocked: $formattedBalance. Transaction amount: ${output.cryptoAmount}.');
|
||||
}
|
||||
|
||||
final estimatedFee = calculateEstimatedFee(_credentials.priority, formattedAmount);
|
||||
final estimatedFee =
|
||||
calculateEstimatedFee(_credentials.priority, formattedAmount);
|
||||
if (!spendAllCoins &&
|
||||
((formattedAmount != null && allInputsAmount < (formattedAmount + estimatedFee)) ||
|
||||
((formattedAmount != null &&
|
||||
allInputsAmount < (formattedAmount + estimatedFee)) ||
|
||||
formattedAmount == null)) {
|
||||
throw WowneroTransactionNoInputsException(inputs.length);
|
||||
}
|
||||
|
||||
pendingTransactionDescription = await transaction_history.createTransaction(
|
||||
address: address!,
|
||||
amount: amount,
|
||||
priorityRaw: _credentials.priority.serialize(),
|
||||
accountIndex: walletAddresses.account!.id,
|
||||
preferredInputs: inputs);
|
||||
pendingTransactionDescription =
|
||||
await transaction_history.createTransaction(
|
||||
address: address!,
|
||||
amount: amount,
|
||||
priorityRaw: _credentials.priority.serialize(),
|
||||
accountIndex: walletAddresses.account!.id,
|
||||
preferredInputs: inputs);
|
||||
}
|
||||
|
||||
return PendingWowneroTransaction(pendingTransactionDescription);
|
||||
|
@ -347,18 +372,17 @@ abstract class WowneroWalletBase
|
|||
final waddr = openedWalletsByPath["$currentWalletDirPath/$name"]!.address;
|
||||
await Isolate.run(() {
|
||||
wownero.WalletManager_closeWallet(
|
||||
Pointer.fromAddress(wmaddr),
|
||||
Pointer.fromAddress(waddr),
|
||||
true
|
||||
);
|
||||
Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true);
|
||||
});
|
||||
openedWalletsByPath.remove("$currentWalletDirPath/$name");
|
||||
print("wallet closed");
|
||||
}
|
||||
try {
|
||||
// -- rename the waller folder --
|
||||
final currentWalletDir = Directory(await pathForWalletDir(name: name, type: type));
|
||||
final newWalletDirPath = await pathForWalletDir(name: newWalletName, type: type);
|
||||
final currentWalletDir =
|
||||
Directory(await pathForWalletDir(name: name, type: type));
|
||||
final newWalletDirPath =
|
||||
await pathForWalletDir(name: newWalletName, type: type);
|
||||
await currentWalletDir.rename(newWalletDirPath);
|
||||
|
||||
// -- use new waller folder to rename files with old names still --
|
||||
|
@ -368,7 +392,8 @@ abstract class WowneroWalletBase
|
|||
final currentKeysFile = File('$renamedWalletPath.keys');
|
||||
final currentAddressListFile = File('$renamedWalletPath.address.txt');
|
||||
|
||||
final newWalletPath = await pathForWallet(name: newWalletName, type: type);
|
||||
final newWalletPath =
|
||||
await pathForWallet(name: newWalletName, type: type);
|
||||
|
||||
if (currentCacheFile.existsSync()) {
|
||||
await currentCacheFile.rename(newWalletPath);
|
||||
|
@ -388,7 +413,8 @@ abstract class WowneroWalletBase
|
|||
final currentKeysFile = File('$currentWalletPath.keys');
|
||||
final currentAddressListFile = File('$currentWalletPath.address.txt');
|
||||
|
||||
final newWalletPath = await pathForWallet(name: newWalletName, type: type);
|
||||
final newWalletPath =
|
||||
await pathForWallet(name: newWalletName, type: type);
|
||||
|
||||
// Copies current wallet files into new wallet name's dir and files
|
||||
if (currentCacheFile.existsSync()) {
|
||||
|
@ -407,7 +433,8 @@ abstract class WowneroWalletBase
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> changePassword(String password) async => wownero_wallet.setPasswordSync(password);
|
||||
Future<void> changePassword(String password) async =>
|
||||
wownero_wallet.setPasswordSync(password);
|
||||
|
||||
Future<int> getNodeHeight() async => wownero_wallet.getNodeHeight();
|
||||
|
||||
|
@ -452,7 +479,8 @@ abstract class WowneroWalletBase
|
|||
wownero.CoinsInfo_unlocked(coin),
|
||||
);
|
||||
if (unspent.hash.isNotEmpty) {
|
||||
unspent.isChange = transaction_history.getTransaction(unspent.hash) == 1;
|
||||
unspent.isChange =
|
||||
transaction_history.getTransaction(unspent.hash) == 1;
|
||||
}
|
||||
unspentCoins.add(unspent);
|
||||
}
|
||||
|
@ -514,13 +542,15 @@ abstract class WowneroWalletBase
|
|||
Future<void> _refreshUnspentCoinsInfo() async {
|
||||
try {
|
||||
final List<dynamic> keys = <dynamic>[];
|
||||
final currentWalletUnspentCoins = unspentCoinsInfo.values.where((element) =>
|
||||
element.walletId.contains(id) && element.accountIndex == walletAddresses.account!.id);
|
||||
final currentWalletUnspentCoins = unspentCoinsInfo.values.where(
|
||||
(element) =>
|
||||
element.walletId.contains(id) &&
|
||||
element.accountIndex == walletAddresses.account!.id);
|
||||
|
||||
if (currentWalletUnspentCoins.isNotEmpty) {
|
||||
currentWalletUnspentCoins.forEach((element) {
|
||||
final existUnspentCoins =
|
||||
unspentCoins.where((coin) => element.keyImage!.contains(coin.keyImage!));
|
||||
final existUnspentCoins = unspentCoins
|
||||
.where((coin) => element.keyImage!.contains(coin.keyImage!));
|
||||
|
||||
if (existUnspentCoins.isEmpty) {
|
||||
keys.add(element.key);
|
||||
|
@ -537,14 +567,17 @@ abstract class WowneroWalletBase
|
|||
}
|
||||
|
||||
String getTransactionAddress(int accountIndex, int addressIndex) =>
|
||||
wownero_wallet.getAddress(accountIndex: accountIndex, addressIndex: addressIndex);
|
||||
wownero_wallet.getAddress(
|
||||
accountIndex: accountIndex, addressIndex: addressIndex);
|
||||
|
||||
@override
|
||||
Future<Map<String, WowneroTransactionInfo>> fetchTransactions() async {
|
||||
transaction_history.refreshTransactions();
|
||||
return _getAllTransactionsOfAccount(walletAddresses.account?.id)
|
||||
.fold<Map<String, WowneroTransactionInfo>>(<String, WowneroTransactionInfo>{},
|
||||
(Map<String, WowneroTransactionInfo> acc, WowneroTransactionInfo tx) {
|
||||
.fold<Map<String, WowneroTransactionInfo>>(
|
||||
<String, WowneroTransactionInfo>{},
|
||||
(Map<String, WowneroTransactionInfo> acc,
|
||||
WowneroTransactionInfo tx) {
|
||||
acc[tx.id] = tx;
|
||||
return acc;
|
||||
});
|
||||
|
@ -571,28 +604,32 @@ abstract class WowneroWalletBase
|
|||
String getSubaddressLabel(int accountIndex, int addressIndex) =>
|
||||
wownero_wallet.getSubaddressLabel(accountIndex, addressIndex);
|
||||
|
||||
List<WowneroTransactionInfo> _getAllTransactionsOfAccount(int? accountIndex) => transaction_history
|
||||
.getAllTransactions()
|
||||
.map((row) => WowneroTransactionInfo(
|
||||
row.hash,
|
||||
row.blockheight,
|
||||
row.isSpend ? TransactionDirection.outgoing : TransactionDirection.incoming,
|
||||
row.timeStamp,
|
||||
row.isPending,
|
||||
row.amount,
|
||||
row.accountIndex,
|
||||
0,
|
||||
row.fee,
|
||||
row.confirmations,
|
||||
|
||||
)..additionalInfo = <String, dynamic>{
|
||||
'key': row.key,
|
||||
'accountIndex': row.accountIndex,
|
||||
'addressIndex': row.addressIndex
|
||||
},
|
||||
)
|
||||
.where((element) => element.accountIndex == (accountIndex ?? 0))
|
||||
.toList();
|
||||
List<WowneroTransactionInfo> _getAllTransactionsOfAccount(
|
||||
int? accountIndex) =>
|
||||
transaction_history
|
||||
.getAllTransactions()
|
||||
.map(
|
||||
(row) => WowneroTransactionInfo(
|
||||
row.hash,
|
||||
row.blockheight,
|
||||
row.isSpend
|
||||
? TransactionDirection.outgoing
|
||||
: TransactionDirection.incoming,
|
||||
row.timeStamp,
|
||||
row.isPending,
|
||||
row.amount,
|
||||
row.accountIndex,
|
||||
0,
|
||||
row.fee,
|
||||
row.confirmations,
|
||||
)..additionalInfo = <String, dynamic>{
|
||||
'key': row.key,
|
||||
'accountIndex': row.accountIndex,
|
||||
'addressIndex': row.addressIndex
|
||||
},
|
||||
)
|
||||
.where((element) => element.accountIndex == (accountIndex ?? 0))
|
||||
.toList();
|
||||
|
||||
void _setListeners() {
|
||||
_listener?.stop();
|
||||
|
@ -630,7 +667,8 @@ abstract class WowneroWalletBase
|
|||
}
|
||||
|
||||
int _getHeightDistance(DateTime date) {
|
||||
final distance = DateTime.now().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
|
||||
final distance =
|
||||
DateTime.now().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
|
||||
final daysTmp = (distance / 86400).round();
|
||||
final days = daysTmp < 1 ? 1 : daysTmp;
|
||||
|
||||
|
@ -658,22 +696,27 @@ abstract class WowneroWalletBase
|
|||
balance[currency]!.unlockedBalance != unlockedBalance ||
|
||||
balance[currency]!.frozenBalance != frozenBalance) {
|
||||
balance[currency] = WowneroBalance(
|
||||
fullBalance: fullBalance, unlockedBalance: unlockedBalance, frozenBalance: frozenBalance);
|
||||
fullBalance: fullBalance,
|
||||
unlockedBalance: unlockedBalance,
|
||||
frozenBalance: frozenBalance);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _askForUpdateTransactionHistory() async => await updateTransactions();
|
||||
Future<void> _askForUpdateTransactionHistory() async =>
|
||||
await updateTransactions();
|
||||
|
||||
int _getFullBalance() => wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id);
|
||||
int _getFullBalance() =>
|
||||
wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id);
|
||||
|
||||
int _getUnlockedBalance() =>
|
||||
wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id);
|
||||
int _getUnlockedBalance() => wownero_wallet.getUnlockedBalance(
|
||||
accountIndex: walletAddresses.account!.id);
|
||||
|
||||
int _getFrozenBalance() {
|
||||
var frozenBalance = 0;
|
||||
|
||||
for (var coin in unspentCoinsInfo.values.where((element) =>
|
||||
element.walletId == id && element.accountIndex == walletAddresses.account!.id)) {
|
||||
element.walletId == id &&
|
||||
element.accountIndex == walletAddresses.account!.id)) {
|
||||
if (coin.isFrozen) frozenBalance += coin.value;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import 'package:cw_core/transaction_direction.dart';
|
|||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_monero/monero_wallet.dart';
|
||||
import 'package:cw_wownero/wownero_wallet.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:polyseed/polyseed.dart';
|
||||
|
||||
|
@ -76,13 +78,13 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||
]);
|
||||
|
||||
if (_appStore.wallet?.seed != null && Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
|
||||
if (_appStore.wallet?.seed != null &&
|
||||
Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
|
||||
final lang = PolyseedLang.getByPhrase(_appStore.wallet!.seed!);
|
||||
final legacyLang = _getLegacySeedLang(lang);
|
||||
final legacySeed =
|
||||
Polyseed.decode(_appStore.wallet!.seed!, lang, PolyseedCoin.POLYSEED_MONERO)
|
||||
.toLegacySeed(legacyLang);
|
||||
items.add(StandartListItem(title: S.current.wallet_seed_legacy, value: legacySeed));
|
||||
items.add(StandartListItem(
|
||||
title: S.current.wallet_seed_legacy,
|
||||
value: (_appStore.wallet as MoneroWalletBase)
|
||||
.seedLegacy(lang.nameEnglish)));
|
||||
}
|
||||
|
||||
final restoreHeight = monero!.getRestoreHeight(_appStore.wallet!);
|
||||
|
@ -123,13 +125,13 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||
]);
|
||||
|
||||
if (_appStore.wallet?.seed != null && Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
|
||||
if (_appStore.wallet?.seed != null &&
|
||||
Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
|
||||
final lang = PolyseedLang.getByPhrase(_appStore.wallet!.seed!);
|
||||
final legacyLang = _getLegacySeedLang(lang);
|
||||
final legacySeed =
|
||||
Polyseed.decode(_appStore.wallet!.seed!, lang, PolyseedCoin.POLYSEED_WOWNERO)
|
||||
.toLegacySeed(legacyLang);
|
||||
items.add(StandartListItem(title: S.current.wallet_seed_legacy, value: legacySeed));
|
||||
items.add(StandartListItem(
|
||||
title: S.current.wallet_seed_legacy,
|
||||
value: (_appStore.wallet as WowneroWalletBase)
|
||||
.seedLegacy(lang.nameEnglish)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue