add card for when monero wallet is in broken state (#1578)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

This commit is contained in:
cyan 2024-08-07 13:40:31 +02:00 committed by GitHub
parent 5e944a8bf7
commit e58d87e94c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -250,6 +250,20 @@ class CryptoBalanceWidget extends StatelessWidget {
Observer(builder: (context) {
return Column(
children: [
if (dashboardViewModel.isMoneroWalletBrokenReasons.isNotEmpty) ...[
SizedBox(height: 10),
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: DashBoardRoundedCardWidget(
customBorder: 30,
title: "Monero wallet is broken",
subTitle: "Here are the things that are broken:\n - "
+dashboardViewModel.isMoneroWalletBrokenReasons.join("\n - ")
+"\n\nPlease restart your wallet and if it doesn't help contact our support.",
onTap: () {},
)
)
],
if (dashboardViewModel.showSilentPaymentsCard) ...[
SizedBox(height: 10),
Padding(

View file

@ -335,6 +335,23 @@ abstract class DashboardViewModelBase with Store {
wallet.type == WalletType.wownero ||
wallet.type == WalletType.haven;
@computed
List<String> get isMoneroWalletBrokenReasons {
if (wallet.type != WalletType.monero) return [];
final keys = monero!.getKeys(wallet);
List<String> errors = [
if (keys['privateSpendKey'] == List.generate(64, (index) => "0").join("")) "Private spend key is 0",
if (keys['privateViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0",
if (keys['publicSpendKey'] == List.generate(64, (index) => "0").join("")) "public spend key is 0",
if (keys['publicViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0",
if (wallet.seed == null) "wallet seed is null",
if (wallet.seed == "") "wallet seed is empty",
if (monero!.getSubaddressList(wallet).getAll(wallet)[0].address == "41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4")
"primary address is invalid, you won't be able to receive / spend funds",
];
return errors;
}
@computed
bool get hasSilentPayments => wallet.type == WalletType.bitcoin && !wallet.isHardwareWallet;