mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02: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:
@@ -253,9 +253,10 @@ class CWMonero extends Monero {
|
||||
required String name,
|
||||
required String language,
|
||||
required bool isPolyseed,
|
||||
required String? passphrase,
|
||||
String? password}) =>
|
||||
MoneroNewWalletCredentials(
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed);
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed, passphrase: passphrase);
|
||||
|
||||
@override
|
||||
Map<String, String> getKeys(Object wallet) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:cake_wallet/entities/qr_view_data.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
@@ -15,6 +17,8 @@ import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_keys_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class WalletKeysPage extends BasePage {
|
||||
@@ -162,6 +166,8 @@ class _WalletKeysPageBodyState extends State<WalletKeysPageBody>
|
||||
children: [
|
||||
if (isLegacySeedOnly || isLegacySeed) _buildHeightBox(),
|
||||
const SizedBox(height: 20),
|
||||
(_buildPassphraseBox() ?? Container()),
|
||||
if (widget.walletKeysViewModel.passphrase.isNotEmpty) const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: SeedPhraseGridWidget(
|
||||
list: isLegacySeed
|
||||
@@ -262,6 +268,64 @@ class _WalletKeysPageBodyState extends State<WalletKeysPageBody>
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget? _buildPassphraseBox() {
|
||||
if (widget.walletKeysViewModel.passphrase.isEmpty) return null;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Theme.of(context).cardColor,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
S.of(context).passphrase_view_keys,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Observer(builder: (BuildContext context) {
|
||||
return Text(
|
||||
(widget.walletKeysViewModel.obscurePassphrase) ?
|
||||
"*****" :
|
||||
widget.walletKeysViewModel.passphrase,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor,
|
||||
),
|
||||
);
|
||||
}),
|
||||
Observer(builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
widget.walletKeysViewModel.obscurePassphrase = !widget.walletKeysViewModel.obscurePassphrase;
|
||||
},
|
||||
child: Icon(
|
||||
widget.walletKeysViewModel.obscurePassphrase ? Icons.visibility_off : Icons.visibility,
|
||||
size: 16,
|
||||
color: Theme.of(context).textTheme.bodyLarge?.color?.withOpacity(0.7),
|
||||
)
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildBottomActionPanel({
|
||||
|
||||
@@ -78,8 +78,8 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
WalletType.ethereum,
|
||||
WalletType.polygon,
|
||||
WalletType.tron,
|
||||
if (isRestore) WalletType.monero,
|
||||
if (isRestore) WalletType.wownero,
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
if (isRestore) WalletType.zano,
|
||||
].contains(type);
|
||||
|
||||
|
||||
@@ -86,9 +86,21 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
if (_wallet.type == WalletType.monero) {
|
||||
return monero!.getRestoreHeight(_wallet)?.toString() ?? '';
|
||||
}
|
||||
if (_wallet.type == WalletType.wownero) {
|
||||
return wownero!.getRestoreHeight(_wallet)?.toString() ?? '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@observable
|
||||
bool obscurePassphrase = true;
|
||||
|
||||
String get passphrase {
|
||||
return _wallet.passphrase ?? '';
|
||||
}
|
||||
|
||||
/// The Regex split the words based on any whitespace character.
|
||||
///
|
||||
/// Either standard ASCII space (U+0020) or the full-width space character (U+3000) used by the Japanese.
|
||||
@@ -309,6 +321,12 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
}
|
||||
|
||||
Future<String?> get restoreHeight async {
|
||||
if (_wallet.type == WalletType.monero) {
|
||||
return monero!.getRestoreHeight(_wallet)?.toString();
|
||||
}
|
||||
if (_wallet.type == WalletType.wownero) {
|
||||
return wownero!.getRestoreHeight(_wallet)?.toString();
|
||||
}
|
||||
if (_restoreHeightByTransactions != 0)
|
||||
return getRoundedRestoreHeight(_restoreHeightByTransactions);
|
||||
if (_restoreHeight != 0) return _restoreHeight.toString();
|
||||
|
||||
@@ -100,6 +100,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
name: name,
|
||||
language: options!.first as String,
|
||||
password: walletPassword,
|
||||
passphrase: passphrase,
|
||||
isPolyseed: options.last as bool);
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
@@ -168,6 +169,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
language: options!.first as String,
|
||||
isPolyseed: options.last as bool,
|
||||
password: walletPassword,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoNewWalletCredentials(
|
||||
|
||||
@@ -233,9 +233,10 @@ class CWWownero extends Wownero {
|
||||
{required String name,
|
||||
required String language,
|
||||
required bool isPolyseed,
|
||||
String? password}) =>
|
||||
String? password,
|
||||
String? passphrase}) =>
|
||||
WowneroNewWalletCredentials(
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed);
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed, passphrase: passphrase);
|
||||
|
||||
@override
|
||||
Map<String, String> getKeys(Object wallet) {
|
||||
@@ -250,6 +251,12 @@ class CWWownero extends Wownero {
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
int? getRestoreHeight(Object wallet) {
|
||||
final wowneroWallet = wallet as WowneroWallet;
|
||||
return wowneroWallet.restoreHeight;
|
||||
}
|
||||
|
||||
@override
|
||||
Object createWowneroTransactionCreationCredentials(
|
||||
{required List<Output> outputs, required TransactionPriority priority}) =>
|
||||
|
||||
Reference in New Issue
Block a user