Skip to content

Commit

Permalink
add passphrase support for zano
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Jan 19, 2025
1 parent 3dee563 commit b14b95b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cw_zano/lib/zano_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ abstract class ZanoWalletBase extends WalletBase<ZanoBalance, ZanoTransactionHis
final wallet = ZanoWallet(credentials.walletInfo!, credentials.password!); await wallet.initWallet();
await wallet.initWallet();
final path = await pathForWallet(name: credentials.name, type: credentials.walletInfo!.type);
final createWalletResult = await wallet.restoreWalletFromSeed(path, credentials.password!, credentials.mnemonic);
final createWalletResult = await wallet.restoreWalletFromSeed(path, credentials.password!, credentials.mnemonic, credentials.passphrase);
await wallet.initWallet();
await wallet.parseCreateWalletResult(createWalletResult);
await wallet.init(createWalletResult.wi.address);
Expand Down
4 changes: 2 additions & 2 deletions cw_zano/lib/zano_wallet_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ mixin ZanoWalletApi {
return result;
}

Future<CreateWalletResult> restoreWalletFromSeed(String path, String password, String seed) async {
Future<CreateWalletResult> restoreWalletFromSeed(String path, String password, String seed, String? passphrase) async {
info('restore_wallet path $path password ${_shorten(password)} seed ${_shorten(seed)}');
final json = zano.PlainWallet_restore(seed, path, password, "");
final json = zano.PlainWallet_restore(seed, path, password, passphrase??'');
_json('restore_wallet', json);
final map = jsonDecode(json) as Map<String, dynamic>?;
if (map?['error'] != null) {
Expand Down
4 changes: 2 additions & 2 deletions cw_zano/lib/zano_wallet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ZanoNewWalletCredentials extends WalletCredentials {
}

class ZanoRestoreWalletFromSeedCredentials extends WalletCredentials {
ZanoRestoreWalletFromSeedCredentials({required String name, required String password, required int height, required this.mnemonic})
: super(name: name, password: password, height: height);
ZanoRestoreWalletFromSeedCredentials({required String name, required String password, required String passphrase, required int height, required this.mnemonic})
: super(name: name, password: password, passphrase: passphrase, height: height);

final String mnemonic;
}
Expand Down
1 change: 1 addition & 0 deletions lib/view_model/advanced_privacy_settings_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
WalletType.tron,
WalletType.monero,
WalletType.wownero,
WalletType.zano,
].contains(type);

@computed
Expand Down
7 changes: 6 additions & 1 deletion lib/view_model/restore/restore_from_qr_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
);
case WalletType.zano:
return zano!.createZanoRestoreWalletFromSeedCredentials(
name: name, password: password, height: height, mnemonic: restoreWallet.mnemonicSeed ?? '');
name: name,
password: password,
height: height,
mnemonic: restoreWallet.mnemonicSeed ?? '',
passphrase: restoreWallet.passphrase ?? '',
);
default:
throw Exception('Unexpected type: ${type.toString()}');
}
Expand Down
1 change: 1 addition & 0 deletions lib/view_model/wallet_restore_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
name: name,
password: password,
height: height,
passphrase: passphrase??'',
mnemonic: seed);
case WalletType.none:
break;
Expand Down
4 changes: 2 additions & 2 deletions lib/zano/cw_zano.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class CWZano extends Zano {

@override
WalletCredentials createZanoRestoreWalletFromSeedCredentials(
{required String name, required String password, required int height, required String mnemonic}) {
return ZanoRestoreWalletFromSeedCredentials(name: name, password: password, height: height, mnemonic: mnemonic);
{required String name, required String password, required int height, required String passphrase, required String mnemonic}) {
return ZanoRestoreWalletFromSeedCredentials(name: name, password: password, passphrase: passphrase, height: height, mnemonic: mnemonic);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion tool/configure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ abstract class Zano {
List<TransactionPriority> getTransactionPriorities();
List<String> getWordList(String language);
WalletCredentials createZanoRestoreWalletFromSeedCredentials({required String name, required String password, required int height, required String mnemonic});
WalletCredentials createZanoRestoreWalletFromSeedCredentials({required String name, required String password, required String passphrase, required int height, required String mnemonic});
WalletCredentials createZanoNewWalletCredentials({required String name, required String? password});
Object createZanoTransactionCredentials({required List<Output> outputs, required TransactionPriority priority, required CryptoCurrency currency});
double formatterIntAmountToDouble({required int amount, required CryptoCurrency currency, required bool forFee});
Expand Down

0 comments on commit b14b95b

Please sign in to comment.