From d5decd24061a4d1dabd300f03ec52e45387fbd67 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 23 Aug 2024 09:24:25 +0200 Subject: [PATCH] fix monero.com builds, make passphrase a getter on WalletBase --- cw_core/lib/wallet_base.dart | 2 ++ cw_monero/lib/api/wallet.dart | 8 ++++++++ cw_monero/lib/monero_wallet.dart | 5 ++--- lib/view_model/wallet_keys_view_model.dart | 5 ++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cw_core/lib/wallet_base.dart b/cw_core/lib/wallet_base.dart index 14ba898a7..d56417d36 100644 --- a/cw_core/lib/wallet_base.dart +++ b/cw_core/lib/wallet_base.dart @@ -46,6 +46,8 @@ abstract class WalletBase null; + String get passphrase => ""; + Object get keys; WalletAddresses get walletAddresses; diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 4ccad3022..c4d62d654 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -6,6 +6,7 @@ import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart'; import 'package:monero/monero.dart' as monero; import 'package:mutex/mutex.dart'; +import 'package:polyseed/polyseed.dart'; int getSyncingHeight() { // final height = monero.MONERO_cw_WalletListener_height(getWlptr()); @@ -32,6 +33,13 @@ String getSeed() { // monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); final cakepolyseed = monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed"); + final cakepassphrase = getPassphrase(); + if (cakepassphrase != "") { + final lang = PolyseedLang.getByPhrase(cakepassphrase); + final coin = PolyseedCoin.POLYSEED_MONERO; + final ps = Polyseed.decode(cakepolyseed, lang, coin); + if (ps.isEncrypted) return ps.encode(lang, coin); + } if (cakepolyseed != "") { return cakepolyseed; } diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index dc38decd1..b73fbc15a 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -118,9 +118,8 @@ abstract class MoneroWalletBase extends WalletBase _password; - String? passphrase() { - return monero_wallet.getPassphrase(); - } + @override + String get passphrase => monero_wallet.getPassphrase(); @override MoneroWalletKeys get keys => MoneroWalletKeys( diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index a316e6998..2a650c337 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -97,7 +97,7 @@ abstract class WalletKeysViewModelBase with Store { .seedLegacy(lang.nameEnglish))); } - final passphrase = (_appStore.wallet as MoneroWalletBase).passphrase(); + final passphrase = _appStore.wallet?.passphrase; if (passphrase != null && passphrase != "") { items.add(StandartListItem( title: S.current.passphrase_view_keys, @@ -292,8 +292,7 @@ abstract class WalletKeysViewModelBase with Store { _appStore.wallet!.privateKey != null) 'private_key': _appStore.wallet!.privateKey!, if (restoreHeightResult != null) ...{'height': restoreHeightResult}, - if (_appStore.wallet is MoneroWalletBase) ...{'passphrase': (_appStore.wallet as MoneroWalletBase).passphrase()??''}, - if (_appStore.wallet is WowneroWalletBase) ...{'passphrase': (_appStore.wallet as WowneroWalletBase).passphrase()??''} + if ((_appStore.wallet?.passphrase??"") != "") ...{'passphrase': _appStore.wallet?.passphrase??''}, }; }