mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 03:05:11 +00:00
cleanup [skip ci]
This commit is contained in:
parent
0f7b104d2f
commit
c59e4dfee9
4 changed files with 34 additions and 38 deletions
|
@ -80,16 +80,9 @@ String getSeedLegacy(String? language) {
|
|||
Map<int, Map<int, Map<int, String>>> addressCache = {};
|
||||
|
||||
String getAddress({int accountIndex = 0, int addressIndex = 0}) {
|
||||
|
||||
int count = 0;
|
||||
|
||||
|
||||
while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex) - 1 < addressIndex) {
|
||||
printV("adding subaddress");
|
||||
monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex);
|
||||
if (count > 10) {
|
||||
throw Exception("Failed to add subaddress");
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
addressCache[wptr!.address] ??= {};
|
||||
|
|
|
@ -37,10 +37,8 @@ abstract class MoneroSubaddressListBase with Store {
|
|||
subaddresses.clear();
|
||||
subaddresses.addAll(getAll());
|
||||
_isUpdating = false;
|
||||
} catch (e, s) {
|
||||
} catch (e) {
|
||||
_isUpdating = false;
|
||||
printV("here");
|
||||
printV(s.toString());
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +59,7 @@ abstract class MoneroSubaddressListBase with Store {
|
|||
return Subaddress(
|
||||
id: id,
|
||||
address: address,
|
||||
balance: (s.received / 1e12).toStringAsFixed(6),
|
||||
balance: (s.received/1e12).toStringAsFixed(6),
|
||||
txCount: s.txCount,
|
||||
label: label);
|
||||
}).toList();
|
||||
|
@ -139,25 +137,26 @@ abstract class MoneroSubaddressListBase with Store {
|
|||
final address = s.address;
|
||||
final label = s.label;
|
||||
return Subaddress(
|
||||
id: id,
|
||||
address: address,
|
||||
balance: (s.received / 1e12).toStringAsFixed(6),
|
||||
txCount: s.txCount,
|
||||
label: id == 0 && label.toLowerCase() == 'Primary account'.toLowerCase()
|
||||
? 'Primary address'
|
||||
: label);
|
||||
})
|
||||
.toList()
|
||||
.reversed
|
||||
.toList();
|
||||
id: id,
|
||||
address: address,
|
||||
balance: (s.received/1e12).toStringAsFixed(6),
|
||||
txCount: s.txCount,
|
||||
label: id == 0 &&
|
||||
label.toLowerCase() == 'Primary account'.toLowerCase()
|
||||
? 'Primary address'
|
||||
: label);
|
||||
}).toList().reversed.toList();
|
||||
}
|
||||
|
||||
Future<bool> _newSubaddress({required int accountIndex, required String label}) async {
|
||||
await subaddress_list.addSubaddress(accountIndex: accountIndex, label: label);
|
||||
|
||||
return subaddress_list.getAllSubaddresses().where((s) {
|
||||
final address = s.address;
|
||||
return !_usedAddresses.contains(address);
|
||||
}).isNotEmpty;
|
||||
return subaddress_list
|
||||
.getAllSubaddresses()
|
||||
.where((s) {
|
||||
final address = s.address;
|
||||
return !_usedAddresses.contains(address);
|
||||
})
|
||||
.isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,15 +85,15 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store {
|
|||
addressesMap.clear();
|
||||
addressInfos.clear();
|
||||
|
||||
// accountList.accounts.forEach((account) {
|
||||
// _subaddressList.update(accountIndex: account.id);
|
||||
// _subaddressList.subaddresses.forEach((subaddress) {
|
||||
// addressesMap[subaddress.address] = subaddress.label;
|
||||
// addressInfos[account.id] ??= [];
|
||||
// addressInfos[account.id]?.add(AddressInfo(
|
||||
// address: subaddress.address, label: subaddress.label, accountIndex: account.id));
|
||||
// });
|
||||
// });
|
||||
accountList.accounts.forEach((account) {
|
||||
_subaddressList.update(accountIndex: account.id);
|
||||
_subaddressList.subaddresses.forEach((subaddress) {
|
||||
addressesMap[subaddress.address] = subaddress.label;
|
||||
addressInfos[account.id] ??= [];
|
||||
addressInfos[account.id]?.add(AddressInfo(
|
||||
address: subaddress.address, label: subaddress.label, accountIndex: account.id));
|
||||
});
|
||||
});
|
||||
|
||||
await saveAddressesInBox();
|
||||
} catch (e, s) {
|
||||
|
|
|
@ -213,13 +213,18 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
.where((element) => [WalletType.monero, WalletType.wownero].contains(element.type))
|
||||
.toList();
|
||||
|
||||
printV("LOADING MONERO WALLETS");
|
||||
|
||||
for (int i = 0; i < moneroWallets.length; i++) {
|
||||
final wallet = await walletLoadingService.load(moneroWallets[i].type, moneroWallets[i].name);
|
||||
// stop regular sync process if it's been started
|
||||
await wallet.stopSync(isBackgroundSync: false);
|
||||
// await wallet.stopSync(isBackgroundSync: false);
|
||||
await Future.delayed(const Duration(seconds: 10));
|
||||
syncingWallets.add(wallet);
|
||||
}
|
||||
|
||||
printV("MONERO WALLETS LOADED");
|
||||
|
||||
// get all litecoin wallets and add them:
|
||||
final List<WalletListItem> litecoinWallets = walletListViewModel.wallets
|
||||
.where((element) => element.type == WalletType.litecoin)
|
||||
|
@ -475,7 +480,6 @@ Future<void> onStart(ServiceInstance service) async {
|
|||
// to detect if we are in the background since it's much faster
|
||||
_bgTimer = Timer.periodic(const Duration(seconds: 1), (timer) async {
|
||||
fgCount++;
|
||||
printV("fgCount: $fgCount");
|
||||
// we haven't been pinged in a while, so we are likely in the background:
|
||||
if (fgCount == 4) {
|
||||
setReady();
|
||||
|
|
Loading…
Reference in a new issue