mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 22:58:49 +00:00
couple small fixes
This commit is contained in:
parent
279ed8196b
commit
269ad06f14
2 changed files with 17 additions and 46 deletions
|
@ -266,32 +266,11 @@ class WalletInfo implements IsarId {
|
||||||
int restoreHeight = 0,
|
int restoreHeight = 0,
|
||||||
String? walletIdOverride,
|
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(
|
return WalletInfo(
|
||||||
coinName: coin.name,
|
coinName: coin.name,
|
||||||
walletId: walletIdOverride ?? const Uuid().v1(),
|
walletId: walletIdOverride ?? const Uuid().v1(),
|
||||||
name: name,
|
name: name,
|
||||||
mainAddressType: mainAddressType,
|
mainAddressType: coin.primaryAddressType,
|
||||||
restoreHeight: restoreHeight,
|
restoreHeight: restoreHeight,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/ecash_wallet.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/impl/epiccash_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/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/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/mixins/multi_address.dart';
|
||||||
import 'package:stackwallet/wallets/wallet/private_key_based_wallet.dart';
|
import 'package:stackwallet/wallets/wallet/private_key_based_wallet.dart';
|
||||||
|
|
||||||
|
@ -135,28 +133,22 @@ abstract class Wallet<T extends CryptoCurrency> {
|
||||||
prefs: prefs,
|
prefs: prefs,
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (wallet.runtimeType) {
|
if (wallet is MnemonicBasedWallet) {
|
||||||
case Bip39Wallet:
|
await secureStorageInterface.write(
|
||||||
case Bip39HDWallet:
|
key: mnemonicKey(walletId: walletInfo.walletId),
|
||||||
await secureStorageInterface.write(
|
value: mnemonic!,
|
||||||
key: mnemonicKey(walletId: walletInfo.walletId),
|
);
|
||||||
value: mnemonic!,
|
await secureStorageInterface.write(
|
||||||
);
|
key: mnemonicPassphraseKey(walletId: walletInfo.walletId),
|
||||||
await secureStorageInterface.write(
|
value: mnemonicPassphrase!,
|
||||||
key: mnemonicPassphraseKey(walletId: walletInfo.walletId),
|
);
|
||||||
value: mnemonicPassphrase!,
|
}
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CryptonoteWallet:
|
if (wallet is PrivateKeyBasedWallet) {
|
||||||
break;
|
await secureStorageInterface.write(
|
||||||
|
key: privateKeyKey(walletId: walletInfo.walletId),
|
||||||
case PrivateKeyBasedWallet:
|
value: privateKey!,
|
||||||
await secureStorageInterface.write(
|
);
|
||||||
key: privateKeyKey(walletId: walletInfo.walletId),
|
|
||||||
value: privateKey!,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store in db after wallet creation
|
// Store in db after wallet creation
|
||||||
|
|
Loading…
Reference in a new issue