CW-711 passphrase for XMR/WOWcreation (#1992)

* add monero passphrase
add wownero passphrase
add passphrase to seed screen

* obscure passphrase by default
disable passphrase create for zano

* Update lib/view_model/wallet_keys_view_model.dart [skip ci]

* Update lib/src/screens/wallet_keys/wallet_keys_page.dart [skip ci]

* Update lib/view_model/advanced_privacy_settings_view_model.dart

* dynamic passphrase icon

* fix polyseed not being encrypted by passphrase

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan 2025-02-01 02:43:01 +01:00 committed by GitHub
parent 96921d5767
commit 8b56c52dc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 138 additions and 20 deletions

View file

@ -45,12 +45,11 @@ String getSeed() {
if (cakepolyseed != "") {
if (cakepassphrase != "") {
try {
final lang = PolyseedLang.getByPhrase(cakepassphrase);
final lang = PolyseedLang.getByPhrase(cakepolyseed);
final coin = PolyseedCoin.POLYSEED_MONERO;
final ps = Polyseed.decode(cakepolyseed, lang, coin);
final passphrase = getPassphrase();
if (ps.isEncrypted || passphrase == "") return ps.encode(lang, coin);
ps.crypt(getPassphrase());
if (ps.isEncrypted || cakepassphrase == "") return ps.encode(lang, coin);
ps.crypt(cakepassphrase);
return ps.encode(lang, coin);
} catch (e) {
printV(e);

View file

@ -70,6 +70,7 @@ void createWalletSync(
{required String path,
required String password,
required String language,
required String passphrase,
int nettype = 0}) {
txhistory = null;
final newWptr = monero.WalletManager_createWallet(wmPtr,
@ -80,6 +81,7 @@ void createWalletSync(
throw WalletCreationException(message: monero.Wallet_errorString(newWptr));
}
wptr = newWptr;
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase);
monero.Wallet_store(wptr!, path: path);
openedWalletsByPath[path] = wptr!;
_lastOpenedWallet = path;
@ -390,8 +392,9 @@ void _createWallet(Map<String, dynamic> args) {
final path = args['path'] as String;
final password = args['password'] as String;
final language = args['language'] as String;
final passphrase = args['passphrase'] as String;
createWalletSync(path: path, password: password, language: language);
createWalletSync(path: path, password: password, language: language, passphrase: passphrase);
}
void _restoreFromSeed(Map<String, dynamic> args) {
@ -459,11 +462,13 @@ Future<void> createWallet(
{required String path,
required String password,
required String language,
required String passphrase,
int nettype = 0}) async =>
_createWallet({
'path': path,
'password': password,
'language': language,
'passphrase': passphrase,
'nettype': nettype
});

View file

@ -135,7 +135,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
passphrase: monero_wallet.getPassphrase());
int? get restoreHeight =>
transactionHistory.transactions.values.firstOrNull?.height;
transactionHistory.transactions.values.firstOrNull?.height ?? monero.Wallet_getRefreshFromBlockHeight(wptr!);
monero_wallet.SyncListener? _listener;
ReactionDisposer? _onAccountChangeReaction;

View file

@ -26,11 +26,12 @@ import 'package:polyseed/polyseed.dart';
class MoneroNewWalletCredentials extends WalletCredentials {
MoneroNewWalletCredentials(
{required String name, required this.language, required this.isPolyseed, String? password})
{required String name, required this.language, required this.isPolyseed, String? password, this.passphrase})
: super(name: name, password: password);
final String language;
final bool isPolyseed;
final String? passphrase;
}
class MoneroRestoreWalletFromHardwareCredentials extends WalletCredentials {
@ -92,7 +93,7 @@ class MoneroWalletService extends WalletService<
@override
WalletType getType() => WalletType.monero;
@override
@override
Future<MoneroWallet> create(MoneroNewWalletCredentials credentials, {bool? isTestnet}) async {
try {
final path = await pathForWallet(name: credentials.name, type: getType());
@ -112,7 +113,7 @@ class MoneroWalletService extends WalletService<
}
await monero_wallet_manager.createWallet(
path: path, password: credentials.password!, language: credentials.language);
path: path, password: credentials.password!, language: credentials.language, passphrase: credentials.passphrase??"");
final wallet = MoneroWallet(
walletInfo: credentials.walletInfo!,
unspentCoinsInfo: unspentCoinsInfoSource,
@ -382,6 +383,10 @@ class MoneroWalletService extends WalletService<
restoreHeight: height,
spendKey: spendKey);
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase??'');
final wallet = MoneroWallet(
walletInfo: walletInfo,
unspentCoinsInfo: unspentCoinsInfoSource,