From 46d5f260541200d019d138db7f0993848203328e Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 19 Oct 2022 14:21:48 -0600 Subject: [PATCH 01/13] fix bitcoin cash null errors --- .../coins/bitcoincash/bitcoincash_wallet.dart | 69 ++++++++++++++----- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 30f04e918..5708ee735 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -43,7 +43,7 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; -const int MINIMUM_CONFIRMATIONS = 3; +const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 546; const String GENESIS_HASH_MAINNET = @@ -265,6 +265,9 @@ class BitcoinCashWallet extends CoinServiceAPI { DerivePathType addressType({required String address}) { Uint8List? decodeBase58; Segwit? decodeBech32; + if (Bitbox.Address.detectFormat(address) == 0) { + address = Bitbox.Address.toLegacyAddress(address); + } try { decodeBase58 = bs58check.decode(address); } catch (err) { @@ -825,9 +828,6 @@ class BitcoinCashWallet extends CoinServiceAPI { /// Refreshes display data for the wallet @override Future refresh() async { - final bchaddr = Bitbox.Address.toCashAddress(await currentReceivingAddress); - print("bchaddr: $bchaddr ${await currentReceivingAddress}"); - if (refreshMutex) { Logging.instance.log("$walletId $walletName refreshMutex denied", level: LogLevel.Info); @@ -1384,7 +1384,9 @@ class BitcoinCashWallet extends CoinServiceAPI { initialChangeAddressP2SH, 1, DerivePathType.bip49); // this._currentReceivingAddress = Future(() => initialReceivingAddress); - _currentReceivingAddressP2PKH = Future(() => initialReceivingAddressP2PKH); + + var newaddr = await _getCurrentAddressForChain(0, DerivePathType.bip44); + _currentReceivingAddressP2PKH = Future(() => newaddr); _currentReceivingAddressP2SH = Future(() => initialReceivingAddressP2SH); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); @@ -1521,6 +1523,11 @@ class BitcoinCashWallet extends CoinServiceAPI { print("Array key is ${jsonEncode(arrayKey)}"); final internalChainArray = DB.instance.get(boxName: walletId, key: arrayKey); + if (derivePathType == DerivePathType.bip44) { + if (Bitbox.Address.detectFormat(internalChainArray.last as String) == 1) { + return Bitbox.Address.toCashAddress(internalChainArray.last as String); + } + } return internalChainArray.last as String; } @@ -1986,6 +1993,9 @@ class BitcoinCashWallet extends CoinServiceAPI { /// Returns the scripthash or throws an exception on invalid bch address String _convertToScriptHash(String bchAddress, NetworkType network) { try { + if (Bitbox.Address.detectFormat(bchAddress) == 0) { + bchAddress = Bitbox.Address.toLegacyAddress(bchAddress); + } final output = Address.addressToOutputScript(bchAddress, network); final hash = sha256.convert(output.toList(growable: false)).toString(); @@ -2058,11 +2068,27 @@ class BitcoinCashWallet extends CoinServiceAPI { } Future _fetchTransactionData() async { - final List allAddresses = await _fetchAllOwnAddresses(); + List allAddressesOld = await _fetchAllOwnAddresses(); + List allAddresses = []; + for (String address in allAddressesOld) { + if (Bitbox.Address.detectFormat(address) == 1) { + allAddresses.add(Bitbox.Address.toCashAddress(address)); + } else { + allAddresses.add(address); + } + } - final changeAddressesP2PKH = + var changeAddressesP2PKHOld = DB.instance.get(boxName: walletId, key: 'changeAddressesP2PKH') as List; + List changeAddressesP2PKH = []; + for (var address in changeAddressesP2PKHOld) { + if (Bitbox.Address.detectFormat(address as String) == 1) { + changeAddressesP2PKH.add(Bitbox.Address.toCashAddress(address)); + } else { + changeAddressesP2PKH.add(address); + } + } final List> allTxHashes = await _fetchHistory(allAddresses); @@ -2166,7 +2192,8 @@ class BitcoinCashWallet extends CoinServiceAPI { .log("recipientsArray: $recipientsArray", level: LogLevel.Info); final foundInSenders = - allAddresses.any((element) => sendersArray.contains(element)); + allAddresses.any((element) => sendersArray.contains(element)) || + allAddressesOld.any((element) => sendersArray.contains(element)); Logging.instance .log("foundInSenders: $foundInSenders", level: LogLevel.Info); @@ -2228,7 +2255,8 @@ class BitcoinCashWallet extends CoinServiceAPI { .toBigInt() .toInt(); totalOut += value; - if (allAddresses.contains(address)) { + if (allAddresses.contains(address) || + allAddressesOld.contains(address)) { outputAmtAddressedToWallet += value; } } @@ -2743,7 +2771,10 @@ class BitcoinCashWallet extends CoinServiceAPI { for (final output in tx["vout"] as List) { final n = output["n"]; if (n != null && n == utxosToUse[i].vout) { - final address = output["scriptPubKey"]["addresses"][0] as String; + String address = output["scriptPubKey"]["addresses"][0] as String; + if (Bitbox.Address.detectFormat(address) == 0) { + address = Bitbox.Address.toLegacyAddress(address); + } if (!addressTxid.containsKey(address)) { addressTxid[address] = []; } @@ -2772,8 +2803,13 @@ class BitcoinCashWallet extends CoinServiceAPI { derivePathType: DerivePathType.bip44, ); for (int i = 0; i < p2pkhLength; i++) { + String address = addressesP2PKH[i]; + if (Bitbox.Address.detectFormat(address) == 0) { + address = Bitbox.Address.toLegacyAddress(address); + } + // receives - final receiveDerivation = receiveDerivations[addressesP2PKH[i]]; + final receiveDerivation = receiveDerivations[address]; // if a match exists it will not be null if (receiveDerivation != null) { final data = P2PKH( @@ -2783,7 +2819,7 @@ class BitcoinCashWallet extends CoinServiceAPI { network: _network, ).data; - for (String tx in addressTxid[addressesP2PKH[i]]!) { + for (String tx in addressTxid[address]!) { results[tx] = { "output": data.output, "keyPair": ECPair.fromWIF( @@ -2794,7 +2830,7 @@ class BitcoinCashWallet extends CoinServiceAPI { } } else { // if its not a receive, check change - final changeDerivation = changeDerivations[addressesP2PKH[i]]; + final changeDerivation = changeDerivations[address]; // if a match exists it will not be null if (changeDerivation != null) { final data = P2PKH( @@ -2804,7 +2840,7 @@ class BitcoinCashWallet extends CoinServiceAPI { network: _network, ).data; - for (String tx in addressTxid[addressesP2PKH[i]]!) { + for (String tx in addressTxid[address]!) { results[tx] = { "output": data.output, "keyPair": ECPair.fromWIF( @@ -3377,8 +3413,9 @@ class BitcoinCashWallet extends CoinServiceAPI { 0, DerivePathType .bip44); // Add that new receiving address to the array of receiving addresses - _currentReceivingAddressP2PKH = Future(() => - newReceivingAddress); // Set the new receiving address that the service + var newaddr = await _getCurrentAddressForChain(0, DerivePathType.bip44); + _currentReceivingAddressP2PKH = Future( + () => newaddr); // Set the new receiving address that the service return true; } catch (e, s) { From 2a3997e8371904e8ef8c24426d8b4c69f2c1be36 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 19 Oct 2022 16:05:36 -0600 Subject: [PATCH 02/13] refresh bitcoin cash cache if it has old data --- .../coins/bitcoincash/bitcoincash_wallet.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 5708ee735..314a03b09 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2113,7 +2113,16 @@ class BitcoinCashWallet extends CoinServiceAPI { if (txHeight > 0 && txHeight < latestTxnBlockHeight - MINIMUM_CONFIRMATIONS) { if (unconfirmedCachedTransactions[tx["tx_hash"] as String] == null) { - allTxHashes.remove(tx); + print(cachedTransactions.findTransaction(tx["tx_hash"] as String)); + print(unconfirmedCachedTransactions[tx["tx_hash"] as String]); + final cachedTx = + cachedTransactions.findTransaction(tx["tx_hash"] as String); + if (!(cachedTx != null && + addressType(address: cachedTx.address) == + DerivePathType.bip44 && + Bitbox.Address.detectFormat(cachedTx.address) == 1)) { + allTxHashes.remove(tx); + } } } } @@ -2122,7 +2131,6 @@ class BitcoinCashWallet extends CoinServiceAPI { List> allTransactions = []; for (final txHash in allTxHashes) { - Logging.instance.log("bch: $txHash", level: LogLevel.Info); final tx = await cachedElectrumXClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, From 27c2e3831131ab5a4b83b1fe8b3f82a4c8aa3b59 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 19 Oct 2022 16:16:00 -0600 Subject: [PATCH 03/13] fix bitcoin cash tests --- .../coins/bitcoincash/bitcoincash_wallet.dart | 8 +++++--- .../bitcoincash/bitcoincash_wallet_test.dart | 20 +++++-------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 314a03b09..3a5cebdec 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -265,9 +265,11 @@ class BitcoinCashWallet extends CoinServiceAPI { DerivePathType addressType({required String address}) { Uint8List? decodeBase58; Segwit? decodeBech32; - if (Bitbox.Address.detectFormat(address) == 0) { - address = Bitbox.Address.toLegacyAddress(address); - } + try { + if (Bitbox.Address.detectFormat(address) == 0) { + address = Bitbox.Address.toLegacyAddress(address); + } + } catch (e, s) {} try { decodeBase58 = bs58check.decode(address); } catch (err) { diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index a9a7fdaf7..4c392fe81 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -26,7 +26,7 @@ import 'bitcoincash_wallet_test_parameters.dart'; void main() { group("bitcoincash constants", () { test("bitcoincash minimum confirmations", () async { - expect(MINIMUM_CONFIRMATIONS, 3); + expect(MINIMUM_CONFIRMATIONS, 1); }); test("bitcoincash dust limit", () async { expect(DUST_LIMIT, 546); @@ -831,18 +831,9 @@ void main() { await bch?.initializeNew(); await bch?.initializeExisting(); - expect( - Address.validateAddress( - await bch!.currentReceivingAddress, bitcoincashtestnet), - true); - expect( - Address.validateAddress( - await bch!.currentReceivingAddress, bitcoincashtestnet), - true); - expect( - Address.validateAddress( - await bch!.currentReceivingAddress, bitcoincashtestnet), - true); + expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); + expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); + expect(bch?.validateAddress(await bch!.currentReceivingAddress), true); verifyNever(client?.ping()).called(0); verify(client?.getServerFeatures()).called(1); @@ -884,8 +875,7 @@ void main() { expect(addresses?.length, 2); for (int i = 0; i < 2; i++) { - expect( - Address.validateAddress(addresses![i], bitcoincashtestnet), true); + expect(bch?.validateAddress(addresses![i]), true); } verifyNever(client?.ping()).called(0); From b8836397a9a49b85abcc81204e9e7b7e28f42ea2 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 19 Oct 2022 16:51:50 -0600 Subject: [PATCH 04/13] externalCalls set and db migration --- lib/main.dart | 11 +++++++++-- lib/services/price.dart | 7 ++++--- lib/utilities/constants.dart | 2 +- lib/utilities/db_version_migration.dart | 12 ++++++++++++ lib/utilities/prefs.dart | 9 +++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index ad1ef9b7f..eb7cd8e64 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -143,7 +143,12 @@ void main() async { boxName: DB.boxNameDBInfo, key: "hive_data_version") as int? ?? 0; if (dbVersion < Constants.currentHiveDbVersion) { - await DbVersionMigrator().migrate(dbVersion); + try { + await DbVersionMigrator().migrate(dbVersion); + } catch (e, s) { + Logging.instance.log("Cannot migrate database\n$e $s", + level: LogLevel.Error, printFullLength: true); + } } monero.onStartup(); @@ -231,7 +236,9 @@ class _MaterialAppWithThemeState extends ConsumerState // unawaited(_nodeService.updateCommunityNodes()); // run without awaiting - if (Constants.enableExchange && _prefs.externalCalls) { + if (Constants.enableExchange && + _prefs.externalCalls && + await _prefs.isExternalCallsSet()) { unawaited(ExchangeDataLoadingService().loadAll(ref)); } diff --git a/lib/services/price.dart b/lib/services/price.dart index 4f6650b06..b44e055d5 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -78,12 +78,12 @@ class PriceAPI { } final externalCalls = Prefs.instance.externalCalls; - if (!Logger.isTestEnv && !externalCalls) { + if ((!Logger.isTestEnv && !externalCalls) || + !(await Prefs.instance.isExternalCallsSet())) { Logging.instance.log("User does not want to use external calls", level: LogLevel.Info); return _cachedPrices; } - Map> result = {}; try { final uri = Uri.parse( @@ -123,7 +123,8 @@ class PriceAPI { static Future?> availableBaseCurrencies() async { final externalCalls = Prefs.instance.externalCalls; - if (!Logger.isTestEnv && !externalCalls) { + if ((!Logger.isTestEnv && !externalCalls) || + !(await Prefs.instance.isExternalCallsSet())) { Logging.instance.log("User does not want to use external calls", level: LogLevel.Info); return null; diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 4eb69d7e1..2495a6be4 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -36,7 +36,7 @@ abstract class Constants { // Enable Logger.print statements static const bool disableLogger = false; - static const int currentHiveDbVersion = 2; + static const int currentHiveDbVersion = 3; static List possibleLengthsForCoin(Coin coin) { final List values = []; diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 26af1c48a..d1763e266 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -143,6 +143,18 @@ class DbVersionMigrator { // try to continue migrating return await migrate(2); + case 2: + await Hive.openBox(DB.boxNamePrefs); + final prefs = Prefs.instance; + await prefs.init(); + if (!(await prefs.isExternalCallsSet())) { + prefs.externalCalls = true; + } + + // update version + await DB.instance.put( + boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 3); + return await migrate(3); default: // finally return diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 2fc21a78d..246291053 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -571,4 +571,13 @@ class Prefs extends ChangeNotifier { boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ?? true; } + + Future isExternalCallsSet() async { + if (await DB.instance + .get(boxName: DB.boxNamePrefs, key: "externalCalls") == + null) { + return false; + } + return true; + } } From 1dd5df5916b9c084132de3b6bf7f153b2f34c617 Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Wed, 19 Oct 2022 17:24:28 -0600 Subject: [PATCH 05/13] v1.5.9 build 79 --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ec3100f8e..32c584797 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -451,7 +451,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 78; + CURRENT_PROJECT_VERSION = 79; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -505,7 +505,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.8; + MARKETING_VERSION = 1.5.9; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -635,7 +635,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 78; + CURRENT_PROJECT_VERSION = 79; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -689,7 +689,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.8; + MARKETING_VERSION = 1.5.9; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -711,7 +711,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 78; + CURRENT_PROJECT_VERSION = 79; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -765,7 +765,7 @@ "$(PROJECT_DIR)/../crypto_plugins/flutter_libmonero/cw_shared_external/ios/External/ios/**", "$(PROJECT_DIR)/../crypto_plugins/flutter_libepiccash/ios/libs", ); - MARKETING_VERSION = 1.5.8; + MARKETING_VERSION = 1.5.9; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/pubspec.yaml b/pubspec.yaml index d4d354625..517f6222e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Stack Wallet # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.5.8+78 +version: 1.5.9+79 environment: sdk: ">=2.17.0 <3.0.0" From c55a7fb73d78dbe8cdd827f7a19266a7bcb5243e Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 19 Oct 2022 17:49:19 -0600 Subject: [PATCH 06/13] fix price test tests --- test/price_test.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/price_test.dart b/test/price_test.dart index b806bfd61..6abbb6741 100644 --- a/test/price_test.dart +++ b/test/price_test.dart @@ -16,6 +16,9 @@ void main() { setUp(() async { await setUpTestHive(); await Hive.openBox(DB.boxNamePriceCache); + await Hive.openBox(DB.boxNamePrefs); + await DB.instance.put( + boxName: DB.boxNamePrefs, key: "externalCalls", value: true); }); test("getPricesAnd24hChange fetch", () async { From 3177563524c609fbe4f3bf566c5e7ba82dc483a6 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 09:03:16 -0600 Subject: [PATCH 07/13] exchange rate update fix --- lib/models/exchange/exchange_form_state.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 2e237dd1c..62509f7bb 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -276,6 +276,12 @@ class ExchangeFormState extends ChangeNotifier { void _onExchangeRateTypeChanged() { print("_onExchangeRateTypeChanged"); + updateRanges(shouldNotifyListeners: true).then( + (_) => updateEstimate( + shouldNotifyListeners: true, + reversed: reversed, + ), + ); } void _onExchangeTypeChanged() { From 6cc0feb025434a11ceec8fc7f47e6fe09de949c6 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 20 Oct 2022 10:00:45 -0600 Subject: [PATCH 08/13] get rid of incorrect fatal error --- lib/services/coins/epiccash/epiccash_wallet.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 112e6c176..7ccb7feaf 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1990,7 +1990,6 @@ class EpicCashWallet extends CoinServiceAPI { Future refreshIfThereIsNewData() async { if (_hasCalledExit) return false; - Logging.instance.log("Can we do this here?", level: LogLevel.Fatal); // TODO returning true here signals this class to call refresh() after which it will fire an event that notifies the UI that new data has been fetched/found for this wallet return true; // TODO: do a quick check to see if there is any new data that would require a refresh From 64ca94ddfb381837ceafbb9c97fecd58e72b0525 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 10:21:42 -0600 Subject: [PATCH 09/13] fix nodes connect button color --- lib/widgets/node_options_sheet.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/widgets/node_options_sheet.dart b/lib/widgets/node_options_sheet.dart index 58a5bf30a..effe97097 100644 --- a/lib/widgets/node_options_sheet.dart +++ b/lib/widgets/node_options_sheet.dart @@ -306,10 +306,10 @@ class NodeOptionsSheet extends ConsumerWidget { style: status == "Connected" ? Theme.of(context) .extension()! - .getPrimaryEnabledButtonColor(context) + .getPrimaryDisabledButtonColor(context) : Theme.of(context) .extension()! - .getPrimaryDisabledButtonColor(context), + .getPrimaryEnabledButtonColor(context), onPressed: status == "Connected" ? null : () async { From a57fac4952303a94c38b72ed9d91dedcc9b09fd4 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 10:22:01 -0600 Subject: [PATCH 10/13] update monero and wownero default nodes --- lib/utilities/default_nodes.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index b09787d33..566b829ce 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -70,28 +70,24 @@ abstract class DefaultNodes { isDown: false, ); - // TODO: eventually enable ssl and set scheme to https - // currently get certificate failure static NodeModel get monero => NodeModel( - host: "http://monero.stackwallet.com", + host: "https://monero.stackwallet.com", port: 18081, name: defaultName, id: _nodeId(Coin.monero), - useSSL: false, + useSSL: true, enabled: true, coinName: Coin.monero.name, isFailover: true, isDown: false, ); - // TODO: eventually enable ssl and set scheme to https - // currently get certificate failure static NodeModel get wownero => NodeModel( - host: "http://eu-west-2.wow.xmr.pm", + host: "https://wownero.stackwallet.com", port: 34568, name: defaultName, id: _nodeId(Coin.wownero), - useSSL: false, + useSSL: true, enabled: true, coinName: Coin.wownero.name, isFailover: true, From b6a28403689fee7060e6a6f3e84d4ceb221804fe Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 11:01:25 -0600 Subject: [PATCH 11/13] check and update primary node if primary node is a default node that was updated --- lib/services/node_service.dart | 13 +++++++++++++ lib/utilities/enums/coin_enum.dart | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index 06c8c40ea..5b9fe5063 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -39,6 +39,19 @@ class NodeService extends ChangeNotifier { key: savedNode.id, value: defaultNode.copyWith(enabled: savedNode.enabled)); } + + // check if a default node is the primary node for the crypto currency + // and update it if needed + final coin = coinFromPrettyName(defaultNode.coinName); + final primaryNode = getPrimaryNodeFor(coin: coin); + if (primaryNode != null && primaryNode.id == defaultNode.id) { + await setPrimaryNodeFor( + coin: coin, + node: defaultNode.copyWith( + enabled: primaryNode.enabled, + ), + ); + } } } diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index 78a04e220..c25a5ca4e 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -181,25 +181,32 @@ Coin coinFromPrettyName(String name) { case "Bitcoin": case "bitcoin": return Coin.bitcoin; + case "Bitcoincash": case "bitcoincash": case "Bitcoin Cash": return Coin.bitcoincash; + case "Dogecoin": case "dogecoin": return Coin.dogecoin; + case "Epic Cash": case "epicCash": return Coin.epicCash; + case "Firo": case "firo": return Coin.firo; + case "Monero": case "monero": return Coin.monero; + case "Namecoin": case "namecoin": return Coin.namecoin; + case "Bitcoin Testnet": case "tBitcoin": case "bitcoinTestNet": @@ -208,19 +215,24 @@ Coin coinFromPrettyName(String name) { case "Bitcoincash Testnet": case "tBitcoin Cash": case "Bitcoin Cash Testnet": + case "bitcoincashTestnet": return Coin.bitcoincashTestnet; + case "Firo Testnet": case "tFiro": case "firoTestNet": return Coin.firoTestNet; + case "Dogecoin Testnet": case "tDogecoin": case "dogecoinTestNet": return Coin.dogecoinTestNet; + case "Wownero": case "tWownero": case "wownero": return Coin.wownero; + default: throw ArgumentError.value( name, "name", "No Coin enum value with that prettyName"); From a9e3b7696e4ed79ac48725149c3520d182be1d36 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 11:04:25 -0600 Subject: [PATCH 12/13] fix linter warning --- .../restore_options_view/restore_options_view.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index 0edc110be..e25d80019 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -144,6 +144,8 @@ class _RestoreOptionsViewState extends ConsumerState { Future chooseDate() async { final height = MediaQuery.of(context).size.height; + final fetchedColor = + Theme.of(context).extension()!.accentColorDark; // check and hide keyboard if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); @@ -155,8 +157,7 @@ class _RestoreOptionsViewState extends ConsumerState { initialDate: DateTime.now(), height: height * 0.5, theme: ThemeData( - primarySwatch: Util.createMaterialColor( - Theme.of(context).extension()!.accentColorDark), + primarySwatch: Util.createMaterialColor(fetchedColor), ), //TODO pick a better initial date // 2007 chosen as that is just before bitcoin launched From 6d77ecad3ffb0b40ffb753f0b743dcc4c9889893 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 20 Oct 2022 11:09:15 -0600 Subject: [PATCH 13/13] restore options date display ui fix --- .../restore_options_view.dart | 1 + .../sub_widgets/restore_from_date_picker.dart | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index e25d80019..76e74fa14 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -273,6 +273,7 @@ class _RestoreOptionsViewState extends ConsumerState { // if (!isDesktop) RestoreFromDatePicker( onTap: chooseDate, + controller: _dateController, ), // if (isDesktop) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart index 8a24e95bb..e5637cfc6 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart @@ -5,10 +5,14 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; class RestoreFromDatePicker extends StatefulWidget { - const RestoreFromDatePicker({Key? key, required this.onTap}) - : super(key: key); + const RestoreFromDatePicker({ + Key? key, + required this.onTap, + required this.controller, + }) : super(key: key); final VoidCallback onTap; + final TextEditingController controller; @override State createState() => _RestoreFromDatePickerState(); @@ -21,17 +25,11 @@ class _RestoreFromDatePickerState extends State { @override void initState() { onTap = widget.onTap; - _dateController = TextEditingController(); + _dateController = widget.controller; super.initState(); } - @override - void dispose() { - _dateController.dispose(); - super.dispose(); - } - @override Widget build(BuildContext context) { return Container(