mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
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:
parent
96921d5767
commit
8b56c52dc6
15 changed files with 138 additions and 20 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue