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