add card for when monero wallet is in broken state (#1578)
cyan committed
Aug 7, 2024 at 13:40 UTC
e58d87e94cc82e268fc5e5901e4bea47c7c4ce50
2 files changed
+31
lib/src/screens/dashboard/pages/balance_page.dart
+14
@@ -250,6 +250,20 @@ class CryptoBalanceWidget extends StatelessWidget {
250
Observer(builder: (context) {
251
return Column(
252
children: [
253
+ if (dashboardViewModel.isMoneroWalletBrokenReasons.isNotEmpty) ...[
254
+ SizedBox(height: 10),
255
+ Padding(
256
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
257
+ child: DashBoardRoundedCardWidget(
258
+ customBorder: 30,
259
+ title: "Monero wallet is broken",
260
+ subTitle: "Here are the things that are broken:\n - "
261
+ +dashboardViewModel.isMoneroWalletBrokenReasons.join("\n - ")
262
+ +"\n\nPlease restart your wallet and if it doesn't help contact our support.",
263
+ onTap: () {},
264
+ )
265
+ )
266
+ ],
267
if (dashboardViewModel.showSilentPaymentsCard) ...[
268
SizedBox(height: 10),
269
Padding(
lib/view_model/dashboard/dashboard_view_model.dart
+17
@@ -335,6 +335,23 @@ abstract class DashboardViewModelBase with Store {
335
wallet.type == WalletType.wownero ||
336
wallet.type == WalletType.haven;
337
338
+ @computed
339
+ List<String> get isMoneroWalletBrokenReasons {
340
+ if (wallet.type != WalletType.monero) return [];
341
+ final keys = monero!.getKeys(wallet);
342
+ List<String> errors = [
343
+ if (keys['privateSpendKey'] == List.generate(64, (index) => "0").join("")) "Private spend key is 0",
344
+ if (keys['privateViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0",
345
+ if (keys['publicSpendKey'] == List.generate(64, (index) => "0").join("")) "public spend key is 0",
346
+ if (keys['publicViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0",
347
+ if (wallet.seed == null) "wallet seed is null",
348
+ if (wallet.seed == "") "wallet seed is empty",
349
+ if (monero!.getSubaddressList(wallet).getAll(wallet)[0].address == "41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4")
350
+ "primary address is invalid, you won't be able to receive / spend funds",
351
+ ];
352
+ return errors;
353
+ }
354
+
355
@computed
356
bool get hasSilentPayments => wallet.type == WalletType.bitcoin && !wallet.isHardwareWallet;
357