mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 18:44:31 +00:00
timeout check server features on wallet creation (allow offline new wallet creation on timeout)
This commit is contained in:
parent
5c9664c667
commit
d86f0de130
6 changed files with 128 additions and 110 deletions
|
@ -1519,22 +1519,28 @@ class BitcoinWallet extends CoinServiceAPI {
|
|||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.bitcoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.bitcoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.bitcoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.bitcoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1405,22 +1405,28 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
|||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.bitcoincash:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.bitcoincashTestnet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.bitcoincash:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.bitcoincashTestnet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1268,22 +1268,28 @@ class DogecoinWallet extends CoinServiceAPI {
|
|||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.dogecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.dogecoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.dogecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.dogecoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a BitcoinWallet using a non bitcoin coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2148,32 +2148,29 @@ class FiroWallet extends CoinServiceAPI {
|
|||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.firo:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.firoTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a FiroWallet using a non firo coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.firo:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.firoTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a FiroWallet using a non firo coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
// 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
|
||||
|
|
|
@ -1521,23 +1521,29 @@ class LitecoinWallet extends CoinServiceAPI {
|
|||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.litecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
print(features['genesis_hash']);
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.litecoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a LitecoinWallet using a non litecoin coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.litecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
print(features['genesis_hash']);
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
case Coin.litecoinTestNet:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_TESTNET) {
|
||||
throw Exception("genesis hash does not match test net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a LitecoinWallet using a non litecoin coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -344,27 +344,24 @@ class NamecoinWallet extends CoinServiceAPI {
|
|||
Logging.instance.log("IS_INTEGRATION_TEST: $integrationTestFlag",
|
||||
level: LogLevel.Info);
|
||||
if (!integrationTestFlag) {
|
||||
final features = await electrumXClient.getServerFeatures();
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.namecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}");
|
||||
try {
|
||||
final features = await electrumXClient
|
||||
.getServerFeatures()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
Logging.instance.log("features: $features", level: LogLevel.Info);
|
||||
switch (coin) {
|
||||
case Coin.namecoin:
|
||||
if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
||||
throw Exception("genesis hash does not match main net!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception(
|
||||
"Attempted to generate a NamecoinWallet using a non namecoin coin type: ${coin.name}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||
}
|
||||
// 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
|
||||
// this should never fail
|
||||
|
|
Loading…
Reference in a new issue