couple small fixes

This commit is contained in:
julian 2023-11-14 09:57:48 -06:00
parent 279ed8196b
commit 269ad06f14
2 changed files with 17 additions and 46 deletions
lib/wallets

View file

@ -266,32 +266,11 @@ class WalletInfo implements IsarId {
int restoreHeight = 0,
String? walletIdOverride,
}) {
// TODO: make Coin aware of these
// ex.
// walletType = coin.walletType;
// mainAddressType = coin.mainAddressType;
final AddressType mainAddressType;
switch (coin) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
mainAddressType = AddressType.p2wpkh;
break;
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
mainAddressType = AddressType.p2pkh;
break;
default:
throw UnimplementedError();
}
return WalletInfo(
coinName: coin.name,
walletId: walletIdOverride ?? const Uuid().v1(),
name: name,
mainAddressType: mainAddressType,
mainAddressType: coin.primaryAddressType,
restoreHeight: restoreHeight,
);
}

View file

@ -32,10 +32,8 @@ import 'package:stackwallet/wallets/wallet/impl/bitcoincash_wallet.dart';
import 'package:stackwallet/wallets/wallet/impl/ecash_wallet.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart';
import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart';
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart';
import 'package:stackwallet/wallets/wallet/mixins/electrumx_mixin.dart';
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
import 'package:stackwallet/wallets/wallet/mixins/multi_address.dart';
import 'package:stackwallet/wallets/wallet/private_key_based_wallet.dart';
@ -135,28 +133,22 @@ abstract class Wallet<T extends CryptoCurrency> {
prefs: prefs,
);
switch (wallet.runtimeType) {
case Bip39Wallet:
case Bip39HDWallet:
await secureStorageInterface.write(
key: mnemonicKey(walletId: walletInfo.walletId),
value: mnemonic!,
);
await secureStorageInterface.write(
key: mnemonicPassphraseKey(walletId: walletInfo.walletId),
value: mnemonicPassphrase!,
);
break;
if (wallet is MnemonicBasedWallet) {
await secureStorageInterface.write(
key: mnemonicKey(walletId: walletInfo.walletId),
value: mnemonic!,
);
await secureStorageInterface.write(
key: mnemonicPassphraseKey(walletId: walletInfo.walletId),
value: mnemonicPassphrase!,
);
}
case CryptonoteWallet:
break;
case PrivateKeyBasedWallet:
await secureStorageInterface.write(
key: privateKeyKey(walletId: walletInfo.walletId),
value: privateKey!,
);
break;
if (wallet is PrivateKeyBasedWallet) {
await secureStorageInterface.write(
key: privateKeyKey(walletId: walletInfo.walletId),
value: privateKey!,
);
}
// Store in db after wallet creation