Revert "do not check server features on wallet creation (allow offline new wallet creation)"

This reverts commit 745abe0f10.
This commit is contained in:
julian 2022-11-30 09:46:28 -06:00
parent 745abe0f10
commit 5c9664c667
6 changed files with 140 additions and 122 deletions

View file

@ -1516,27 +1516,27 @@ class BitcoinWallet extends CoinServiceAPI {
} }
Future<void> _generateNewWallet() async { Future<void> _generateNewWallet() async {
// Logging.instance Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.bitcoin: case Coin.bitcoin:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// case Coin.bitcoinTestNet: case Coin.bitcoinTestNet:
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!"); throw Exception("genesis hash does not match test net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}"); "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
// } }
// } }
// this should never fail // this should never fail
if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) { if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) {

View file

@ -1402,27 +1402,27 @@ class BitcoinCashWallet extends CoinServiceAPI {
} }
Future<void> _generateNewWallet() async { Future<void> _generateNewWallet() async {
// Logging.instance Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.bitcoincash: case Coin.bitcoincash:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// case Coin.bitcoincashTestnet: case Coin.bitcoincashTestnet:
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!"); throw Exception("genesis hash does not match test net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}"); "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
// } }
// } }
// this should never fail // this should never fail
if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) { if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) {

View file

@ -1265,27 +1265,27 @@ class DogecoinWallet extends CoinServiceAPI {
} }
Future<void> _generateNewWallet() async { Future<void> _generateNewWallet() async {
// Logging.instance Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.dogecoin: case Coin.dogecoin:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!"); throw Exception("genesis hash does not match test net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}"); "Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
// } }
// } }
// this should never fail // this should never fail
if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) { if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) {

View file

@ -2145,27 +2145,36 @@ class FiroWallet extends CoinServiceAPI {
/// Generates initial wallet values such as mnemonic, chain (receive/change) arrays and indexes. /// Generates initial wallet values such as mnemonic, chain (receive/change) arrays and indexes.
Future<void> _generateNewWallet() async { Future<void> _generateNewWallet() async {
// Logging.instance Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.firo: case Coin.firo:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// case Coin.firoTestNet: case Coin.firoTestNet:
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!"); throw Exception("genesis hash does not match test net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a FiroWallet using a non firo coin type: ${coin.name}"); "Attempted to generate a FiroWallet using a non firo coin type: ${coin.name}");
// } }
// } // if (_networkType == BasicNetworkType.main) {
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match!");
// }
// } else if (_networkType == BasicNetworkType.test) {
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match!");
// }
// }
}
// this should never fail as overwriting a mnemonic is big bad // this should never fail as overwriting a mnemonic is big bad
assert((await _secureStore.read(key: '${_walletId}_mnemonic')) == null); assert((await _secureStore.read(key: '${_walletId}_mnemonic')) == null);

View file

@ -1518,28 +1518,28 @@ class LitecoinWallet extends CoinServiceAPI {
} }
Future<void> _generateNewWallet() async { Future<void> _generateNewWallet() async {
// Logging.instance Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info); .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.litecoin: case Coin.litecoin:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// print(features['genesis_hash']); print(features['genesis_hash']);
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// case Coin.litecoinTestNet: case Coin.litecoinTestNet:
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) { if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!"); throw Exception("genesis hash does not match test net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a LitecoinWallet using a non litecoin coin type: ${coin.name}"); "Attempted to generate a LitecoinWallet using a non litecoin coin type: ${coin.name}");
// } }
// } }
// this should never fail // this should never fail
if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) { if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) {

View file

@ -341,22 +341,31 @@ class NamecoinWallet extends CoinServiceAPI {
longMutex = true; longMutex = true;
final start = DateTime.now(); final start = DateTime.now();
try { try {
// Logging.instance.log("IS_INTEGRATION_TEST: $integrationTestFlag", Logging.instance.log("IS_INTEGRATION_TEST: $integrationTestFlag",
// level: LogLevel.Info); level: LogLevel.Info);
// if (!integrationTestFlag) { if (!integrationTestFlag) {
// final features = await electrumXClient.getServerFeatures(); final features = await electrumXClient.getServerFeatures();
// Logging.instance.log("features: $features", level: LogLevel.Info); Logging.instance.log("features: $features", level: LogLevel.Info);
// switch (coin) { switch (coin) {
// case Coin.namecoin: case Coin.namecoin:
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) { if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!"); throw Exception("genesis hash does not match main net!");
// } }
// break; break;
// default: default:
// throw Exception( throw Exception(
// "Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}"); "Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}");
// } }
// } // if (_networkType == BasicNetworkType.main) {
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
// throw Exception("genesis hash does not match main net!");
// }
// } else if (_networkType == BasicNetworkType.test) {
// if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
// throw Exception("genesis hash does not match test net!");
// }
// }
}
// check to make sure we aren't overwriting a mnemonic // check to make sure we aren't overwriting a mnemonic
// this should never fail // this should never fail
if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) { if ((await _secureStore.read(key: '${_walletId}_mnemonic')) != null) {