mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +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,7 +1519,10 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -1536,6 +1539,9 @@ class BitcoinWallet extends CoinServiceAPI {
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should never fail
|
// this should never fail
|
||||||
|
|
|
@ -1405,7 +1405,10 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -1422,6 +1425,9 @@ class BitcoinCashWallet extends CoinServiceAPI {
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should never fail
|
// this should never fail
|
||||||
|
|
|
@ -1268,7 +1268,10 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -1285,6 +1288,9 @@ class DogecoinWallet extends CoinServiceAPI {
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should never fail
|
// this should never fail
|
||||||
|
|
|
@ -2148,7 +2148,10 @@ class FiroWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -2165,15 +2168,9 @@ class FiroWallet extends CoinServiceAPI {
|
||||||
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) {
|
} catch (e, s) {
|
||||||
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
// 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
|
||||||
|
|
|
@ -1521,7 +1521,10 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -1539,6 +1542,9 @@ class LitecoinWallet extends CoinServiceAPI {
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should never fail
|
// this should never fail
|
||||||
|
|
|
@ -344,7 +344,10 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
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();
|
try {
|
||||||
|
final features = await electrumXClient
|
||||||
|
.getServerFeatures()
|
||||||
|
.timeout(const Duration(seconds: 3));
|
||||||
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:
|
||||||
|
@ -356,15 +359,9 @@ class NamecoinWallet extends CoinServiceAPI {
|
||||||
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) {
|
} catch (e, s) {
|
||||||
// if (features['genesis_hash'] != GENESIS_HASH_MAINNET) {
|
Logging.instance.log("$e/n$s", level: LogLevel.Info);
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in a new issue