2023-09-18 21:28:31 +00:00
|
|
|
import 'package:stackwallet/exceptions/sw_exception.dart';
|
|
|
|
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
|
|
|
|
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
|
|
|
|
|
|
|
abstract class Bip39Wallet<T extends Bip39Currency> extends Wallet<T> {
|
|
|
|
Bip39Wallet(super.cryptoCurrency);
|
|
|
|
|
|
|
|
Future<String> getMnemonic() async {
|
|
|
|
final mnemonic = await secureStorageInterface.read(
|
2023-11-03 19:46:55 +00:00
|
|
|
key: Wallet.mnemonicKey(walletId: info.walletId),
|
2023-09-18 21:28:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (mnemonic == null) {
|
|
|
|
throw SWException("mnemonic has not been set");
|
|
|
|
}
|
|
|
|
|
|
|
|
return mnemonic;
|
|
|
|
}
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
Future<List<String>> getMnemonicAsWords() async {
|
|
|
|
final mnemonic = await getMnemonic();
|
|
|
|
return mnemonic.split(" ");
|
|
|
|
}
|
|
|
|
|
2023-09-18 21:28:31 +00:00
|
|
|
Future<String> getMnemonicPassphrase() async {
|
|
|
|
final mnemonicPassphrase = await secureStorageInterface.read(
|
2023-11-03 19:46:55 +00:00
|
|
|
key: Wallet.mnemonicPassphraseKey(walletId: info.walletId),
|
2023-09-18 21:28:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (mnemonicPassphrase == null) {
|
|
|
|
throw SWException("mnemonicPassphrase has not been set");
|
|
|
|
}
|
|
|
|
|
|
|
|
return mnemonicPassphrase;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ========== Private ========================================================
|
|
|
|
|
|
|
|
// ========== Overrides ======================================================
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Future<TxData> confirmSend({required TxData txData}) {
|
|
|
|
// // TODO: implement confirmSend
|
|
|
|
// throw UnimplementedError();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @override
|
|
|
|
// Future<TxData> prepareSend({required TxData txData}) {
|
|
|
|
// // TODO: implement prepareSend
|
|
|
|
// throw UnimplementedError();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @override
|
|
|
|
// Future<void> recover({required bool isRescan}) {
|
|
|
|
// // TODO: implement recover
|
|
|
|
// throw UnimplementedError();
|
|
|
|
// }
|
|
|
|
}
|