fix monero.com builds, make passphrase a getter on WalletBase

This commit is contained in:
Czarek Nakamoto 2024-08-23 09:24:25 +02:00
parent 6f2ea35b77
commit d5decd2406
4 changed files with 14 additions and 6 deletions

View file

@ -46,6 +46,8 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
String? get hexSeed => null;
String get passphrase => "";
Object get keys;
WalletAddresses get walletAddresses;

View file

@ -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;
}

View file

@ -118,9 +118,8 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
@override
String get password => _password;
String? passphrase() {
return monero_wallet.getPassphrase();
}
@override
String get passphrase => monero_wallet.getPassphrase();
@override
MoneroWalletKeys get keys => MoneroWalletKeys(

View file

@ -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??''},
};
}