Fixes for gray screen bug.
M committed
Oct 1, 2020 at 19:46 UTC
2eb229b91eef92d70f5db0147af04d28653e6941
5 files changed
+36
-7
cw_monero/ios/Classes/monero_api.cpp
+4
@@ -175,6 +175,7 @@ extern "C"
175
Monero::SubaddressAccount *m_account;
176
uint64_t m_last_known_wallet_height;
177
uint64_t m_cached_syncing_blockchain_height = 0;
178
+ std::mutex store_mutex;
179
180
181
void change_current_wallet(Monero::Wallet *wallet)
@@ -293,6 +294,7 @@ extern "C"
294
295
void load_wallet(char *path, char *password, int32_t nettype)
296
{
297
+ nice(19);
298
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
299
Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->openWallet(std::string(path), std::string(password), networkType);
300
change_current_wallet(wallet);
@@ -429,7 +431,9 @@ extern "C"
431
432
void store(char *path)
433
{
434
+ store_mutex.lock();
435
get_current_wallet()->store(std::string(path));
436
+ store_mutex.unlock();
437
}
438
439
bool transaction_create(char *address, char *payment_id, char *amount,
ios/Flutter/.last_build_id
deleted
-1
@@ -1 +0,0 @@
1
-4dc2ef1ba73deeed13cd85894dacb10b
\ No newline at end of file
lib/di.dart
+19
-4
@@ -61,6 +61,7 @@ import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
61
import 'package:flutter/widgets.dart';
62
import 'package:get_it/get_it.dart';
63
import 'package:hive/hive.dart';
64
+import 'package:mobx/mobx.dart';
65
import 'package:shared_preferences/shared_preferences.dart';
66
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
67
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
@@ -177,11 +178,25 @@ Future setup(
178
BiometricAuth()));
179
180
getIt.registerFactory<AuthPage>(
180
- () => AuthPage(getIt.get<AuthViewModel>(),
181
- onAuthenticationFinished: (isAuthenticated, __) {
182
- if (isAuthenticated) {
183
- getIt.get<AuthenticationStore>().allowed();
181
+ () => AuthPage(getIt.get<AuthViewModel>(), onAuthenticationFinished:
182
+ (isAuthenticated, AuthPageState authPageState) {
183
+ if (!isAuthenticated) {
184
+ return;
185
}
186
+ final authStore = getIt.get<AuthenticationStore>();
187
+ final appStore = getIt.get<AppStore>();
188
+
189
+ if (appStore.wallet != null) {
190
+ authStore.allowed();
191
+ return;
192
+ }
193
+
194
+ authPageState.changeProcessText('Loading the wallet');
195
+ ReactionDisposer _reaction;
196
+ _reaction = reaction((_) => appStore.wallet, (Object _) {
197
+ _reaction?.reaction?.dispose();
198
+ authStore.allowed();
199
+ });
200
}, closable: false),
201
instanceName: 'login');
202
lib/monero/monero_wallet.dart
+12
-1
@@ -19,6 +19,7 @@ import 'package:cake_wallet/entities/wallet_info.dart';
19
import 'package:cake_wallet/entities/node.dart';
20
import 'package:cake_wallet/entities/transaction_priority.dart';
21
22
+
23
part 'monero_wallet.g.dart';
24
25
const moneroBlockSize = 1000;
@@ -40,6 +41,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
41
subaddress = subaddressList.subaddresses.first;
42
address = subaddress.address;
43
});
44
+ _cachedRefreshHeight = 0;
45
}
46
47
@override
@@ -80,6 +82,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
82
String _filename;
83
SyncListner _listener;
84
ReactionDisposer _onAccountChangeReaction;
85
+ int _cachedRefreshHeight;
86
87
Future<void> init() async {
88
await accountList.update();
@@ -177,7 +180,9 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
180
181
@override
182
Future<void> save() async {
183
+ print('SAVE CALLED');
184
await monero_wallet.store();
185
+ print('SAVE FINISHED');
186
}
187
188
Future<int> getNodeHeight() async => monero_wallet.getNodeHeight();
@@ -191,12 +196,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
196
197
@override
198
Future<void> rescan({int height}) async {
199
+ walletInfo.restoreHeight = height;
200
+ walletInfo.isRecovery = true;
201
monero_wallet.setRefreshFromBlockHeight(height: height);
202
monero_wallet.rescanBlockchainAsync();
203
await startSync();
204
_askForUpdateBalance();
205
await _askForUpdateTransactionHistory();
206
await save();
207
+ await walletInfo.save();
208
}
209
210
void _setListeners() {
@@ -284,7 +292,10 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
292
await setAsRecovered();
293
}
294
287
- await save();
295
+ if (currentHeight - _cachedRefreshHeight > moneroBlockSize) {
296
+ _cachedRefreshHeight = currentHeight;
297
+ await save();
298
+ }
299
}
300
301
void _onNewTransaction() {
lib/src/screens/dashboard/wallet_menu.dart
+1
-1
@@ -87,8 +87,8 @@ class WalletMenu {
87
rightButtonText: S.of(context).ok,
88
leftButtonText: S.of(context).cancel,
89
actionRightButton: () async {
90
- await reconnect?.call();
90
Navigator.of(context).pop();
91
+ await reconnect?.call();
92
},
93
actionLeftButton: () => Navigator.of(context).pop());
94
});