mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-21 07:54:24 +01:00
* Update example app on Flutter plugin * Expose `empty_wallet_cache` through Dart bindings (#224)
35 lines
915 B
Dart
35 lines
915 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_breez_liquid_example/services/keychain.dart';
|
|
|
|
class CredentialsManager {
|
|
static const String accountMnemonic = "account_mnemonic";
|
|
|
|
final KeyChain keyChain;
|
|
|
|
CredentialsManager({required this.keyChain});
|
|
|
|
Future storeMnemonic({required String mnemonic}) async {
|
|
try {
|
|
await _storeMnemonic(mnemonic);
|
|
debugPrint("Stored credentials successfully");
|
|
} catch (err) {
|
|
throw Exception(err.toString());
|
|
}
|
|
}
|
|
|
|
Future<String> restoreMnemonic() async {
|
|
try {
|
|
String mnemonicStr = await keyChain.read(accountMnemonic) ?? "";
|
|
debugPrint("Restored credentials successfully");
|
|
return mnemonicStr;
|
|
} catch (err) {
|
|
throw Exception(err.toString());
|
|
}
|
|
}
|
|
|
|
// Helper methods
|
|
Future<void> _storeMnemonic(String mnemonic) async {
|
|
await keyChain.write(accountMnemonic, mnemonic);
|
|
}
|
|
}
|