From 51b709e682ce4ac22d3c74307400d9cb231ebea8 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 14:27:39 -0600 Subject: [PATCH 01/24] use add_return_used_coins branch of flutter_libsparkmobile TODO: merge to main after integration & testing. See https://github.com/cypherstack/flutter_libsparkmobile/pull/26 --- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 2bba3135a..e0f1bd8aa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -674,8 +674,8 @@ packages: dependency: "direct main" description: path: "." - ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5 - resolved-ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5 + ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 + resolved-ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 url: "https://github.com/cypherstack/flutter_libsparkmobile.git" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index e9a293809..c05a511f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: flutter_libsparkmobile: git: url: https://github.com/cypherstack/flutter_libsparkmobile.git - ref: fb50031056fbea0326f7dd76ad59d165c1e5eee5 + ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 flutter_libmonero: path: ./crypto_plugins/flutter_libmonero From 5d9dc02eb1a393c6b26a20be595f06ed6dda6766 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 14:30:44 -0600 Subject: [PATCH 02/24] update _createSparkSend signature to return used coins --- .../wallet/wallet_mixin_interfaces/spark_interface.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index b60e8c8a8..c84063d15 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -1499,6 +1499,13 @@ Future< Uint8List serializedSpendPayload, List outputScripts, int fee, + List< + ({ + int groupId, + int height, + String serializedCoin, + String serializedCoinContext + })> usedCoins, })> _createSparkSend( ({ String privateKeyHex, From 01881aae4f3dbd9ade955bd049cf9de047770f0c Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 19:05:17 -0600 Subject: [PATCH 03/24] translate usedCoins to usedUTXOs --- .../spark_interface.dart | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index c84063d15..28d1d553d 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -499,6 +499,35 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { ), ); + // Find out which coins were used and translate them into UTXOs. + final usedUTXOs = coins.where((coin) { + return spend.usedCoins.any((usedCoin) { + return usedCoin.serializedCoin == coin.serializedCoinB64 && + usedCoin.serializedCoinContext == coin.contextB64; + }); + }).map((coin) { + return UTXO( + walletId: walletId, + txid: extractedTx.getId(), + vout: coin.groupId, + value: coin.value.toInt(), + name: '', + isBlocked: false, // true? + blockedReason: null, // "Used in Spark spend."? + isCoinbase: false, + blockHash: null, + blockHeight: coin.height, + blockTime: null, + address: null, + used: true, + otherData: jsonEncode(( + groupId: coin.groupId, + serializedCoin: coin.serializedCoinB64, + serializedCoinContext: coin.contextB64, + )), + ); + }).toList(); + return txData.copyWith( raw: rawTxHex, vSize: extractedTx.virtualSize(), @@ -523,7 +552,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { height: null, version: 3, ), - // TODO used coins + usedUTXOs: usedUTXOs, ); } @@ -540,17 +569,13 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info); txData = txData.copyWith( - // TODO mark spark coins as spent locally and update balance before waiting to check via electrumx? - - // usedUTXOs: - // txData.usedUTXOs!.map((e) => e.copyWith(used: true)).toList(), - + usedUTXOs: txData.usedUTXOs, // TODO revisit setting these both txHash: txHash, txid: txHash, ); - // // mark utxos as used - // await mainDB.putUTXOs(txData.usedUTXOs!); + // mark utxos as used + await mainDB.putUTXOs(txData.usedUTXOs!); return await updateSentCachedTxData(txData: txData); } catch (e, s) { From 06e64072599e34c8c7e5df2fcb2a991b3eee3a50 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 27 Feb 2024 13:48:48 -0600 Subject: [PATCH 04/24] Revert "remove temporary doge fee hackfix" This reverts commit f67c9e64020b61149a7b1fd144f658f92d7e2dd6. --- lib/electrumx_rpc/electrumx_client.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 9ca3dfeb1..98c6614f9 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -1020,6 +1020,18 @@ class ElectrumXClient { ], ); try { + // If the response is -1 or null, return a temporary hardcoded value for + // Dogecoin. This is a temporary fix until the fee estimation is fixed. + if (coin == Coin.dogecoin && + (response == null || + response == -1 || + Decimal.parse(response.toString()) == Decimal.parse("-1"))) { + // Return 0.05 for slow, 0.2 for average, and 1 for fast txs. + // These numbers produce tx fees in line with txs in the wild on + // https://dogechain.info/ + return Decimal.parse((1 / blocks).toString()); + // TODO [prio=med]: Fix fee estimation. + } return Decimal.parse(response.toString()); } catch (e, s) { final String msg = "Error parsing fee rate. Response: $response" From 2513600a634abf1ed4fd5b81398635f3c8b9e23a Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 27 Feb 2024 14:45:13 -0600 Subject: [PATCH 05/24] update epicbox --- lib/utilities/default_epicboxes.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities/default_epicboxes.dart b/lib/utilities/default_epicboxes.dart index 6f0fbc7c5..f83f84cf5 100644 --- a/lib/utilities/default_epicboxes.dart +++ b/lib/utilities/default_epicboxes.dart @@ -17,7 +17,7 @@ abstract class DefaultEpicBoxes { static List get defaultIds => ['americas', 'asia', 'europe']; static EpicBoxServerModel get americas => EpicBoxServerModel( - host: 'stackwallet.epicbox.com', + host: 'epicbox.stackwallet.com', port: 443, name: 'Americas', id: 'americas', From 2ac155826681f5617e9f3dd0ccb108b77f16b710 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 27 Feb 2024 19:01:53 -0600 Subject: [PATCH 06/24] find SparkCoins that correspond to the usedCoins returned from spark lib instead of translating used coins to UTXOs, we find which SparkCoins in isar match the usedCoins returned from sparkmobile and update them as isUsed: true in db. --- lib/wallets/models/tx_data.dart | 18 +++++++ .../spark_interface.dart | 54 ++++++++----------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/wallets/models/tx_data.dart b/lib/wallets/models/tx_data.dart index f8b3f6803..78a25b548 100644 --- a/lib/wallets/models/tx_data.dart +++ b/lib/wallets/models/tx_data.dart @@ -69,6 +69,13 @@ class TxData { bool isChange, })>? sparkRecipients; final List? sparkMints; + final List< + ({ + String serializedCoin, + String serializedCoinContext, + int groupId, + int height, + })>? usedCoins; final TransactionV2? tempTx; @@ -105,6 +112,7 @@ class TxData { this.tezosOperationsList, this.sparkRecipients, this.sparkMints, + this.usedCoins, this.tempTx, }); @@ -187,6 +195,14 @@ class TxData { })>? sparkRecipients, List? sparkMints, + List< + ({ + String serializedCoin, + String serializedCoinContext, + int groupId, + int height, + })>? + usedCoins, TransactionV2? tempTx, }) { return TxData( @@ -224,6 +240,7 @@ class TxData { tezosOperationsList: tezosOperationsList ?? this.tezosOperationsList, sparkRecipients: sparkRecipients ?? this.sparkRecipients, sparkMints: sparkMints ?? this.sparkMints, + usedCoins: usedCoins ?? this.usedCoins, tempTx: tempTx ?? this.tempTx, ); } @@ -262,6 +279,7 @@ class TxData { 'tezosOperationsList: $tezosOperationsList, ' 'sparkRecipients: $sparkRecipients, ' 'sparkMints: $sparkMints, ' + 'usedCoins: $usedCoins, ' 'tempTx: $tempTx, ' '}'; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 28d1d553d..c7ff03572 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -499,35 +499,6 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { ), ); - // Find out which coins were used and translate them into UTXOs. - final usedUTXOs = coins.where((coin) { - return spend.usedCoins.any((usedCoin) { - return usedCoin.serializedCoin == coin.serializedCoinB64 && - usedCoin.serializedCoinContext == coin.contextB64; - }); - }).map((coin) { - return UTXO( - walletId: walletId, - txid: extractedTx.getId(), - vout: coin.groupId, - value: coin.value.toInt(), - name: '', - isBlocked: false, // true? - blockedReason: null, // "Used in Spark spend."? - isCoinbase: false, - blockHash: null, - blockHeight: coin.height, - blockTime: null, - address: null, - used: true, - otherData: jsonEncode(( - groupId: coin.groupId, - serializedCoin: coin.serializedCoinB64, - serializedCoinContext: coin.contextB64, - )), - ); - }).toList(); - return txData.copyWith( raw: rawTxHex, vSize: extractedTx.virtualSize(), @@ -552,7 +523,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { height: null, version: 3, ), - usedUTXOs: usedUTXOs, + usedCoins: spend.usedCoins, ); } @@ -569,13 +540,30 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { Logging.instance.log("Sent txHash: $txHash", level: LogLevel.Info); txData = txData.copyWith( - usedUTXOs: txData.usedUTXOs, // TODO revisit setting these both txHash: txHash, txid: txHash, ); - // mark utxos as used - await mainDB.putUTXOs(txData.usedUTXOs!); + + // Update coins as used in database. + final List usedCoins = []; + for (final usedCoin in txData.usedCoins!) { + // Find the SparkCoin that matches the usedCoin. + final sparkCoin = await mainDB.isar.sparkCoins + .where() + .walletIdEqualToAnyLTagHash(walletId) + .filter() + .serializedCoinB64EqualTo(usedCoin.serializedCoin) + .findFirst(); + + // Add the SparkCoin to usedCoins if it exists. + if (sparkCoin != null) { + usedCoins.add(sparkCoin.copyWith(isUsed: true)); + } + } + + // Update the SparkCoins in the database. + await _addOrUpdateSparkCoins(usedCoins); return await updateSentCachedTxData(txData: txData); } catch (e, s) { From a90071f6ebe7f4577ad2528ea33cc7f461d9f4ad Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 27 Feb 2024 19:54:15 -0600 Subject: [PATCH 07/24] use base64 used coins returned from flutter_libsparkmobile --- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e0f1bd8aa..37d623bde 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -674,8 +674,8 @@ packages: dependency: "direct main" description: path: "." - ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 - resolved-ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 + ref: "5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1" + resolved-ref: "5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1" url: "https://github.com/cypherstack/flutter_libsparkmobile.git" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index c05a511f8..8f748b572 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: flutter_libsparkmobile: git: url: https://github.com/cypherstack/flutter_libsparkmobile.git - ref: ca5c3a821b9e5fa7dfb5a3df9577caa7bdd46f11 + ref: 5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1 flutter_libmonero: path: ./crypto_plugins/flutter_libmonero From 38c9de21f4b22f2efd88b7bf15478e67efbd09e5 Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 28 Feb 2024 07:04:55 +0200 Subject: [PATCH 08/24] WIP: Update to latest Epic release --- crypto_plugins/flutter_libepiccash | 2 +- .../transaction_views/tx_v2/transaction_v2_details_view.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 9eb24dd00..396d519a4 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 9eb24dd00cd0e1df08624ece1ca47090c158c08c +Subproject commit 396d519a4c3ae1c47c8406e5506b0966f1f7098f diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart index d44588b3c..5a1ae2032 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart @@ -1048,7 +1048,7 @@ class _TransactionV2DetailsViewState pTransactionNote( ( txid: (coin == Coin.epicCash) ? - _transaction.slateId as String + _transaction.slateId.toString() : _transaction.txid, walletId: walletId ), From 4c98ee0db37b911ddd4272c920eae8d7dba0d986 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 28 Feb 2024 14:42:32 +0700 Subject: [PATCH 09/24] tweak spark used coins update on successful send --- lib/wallets/models/tx_data.dart | 24 +++------- .../spark_interface.dart | 46 +++++++++++-------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/wallets/models/tx_data.dart b/lib/wallets/models/tx_data.dart index 78a25b548..22101003c 100644 --- a/lib/wallets/models/tx_data.dart +++ b/lib/wallets/models/tx_data.dart @@ -5,6 +5,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; +import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; import 'package:tezart/tezart.dart' as tezart; import 'package:web3dart/web3dart.dart' as web3dart; @@ -69,13 +70,7 @@ class TxData { bool isChange, })>? sparkRecipients; final List? sparkMints; - final List< - ({ - String serializedCoin, - String serializedCoinContext, - int groupId, - int height, - })>? usedCoins; + final List? usedSparkCoins; final TransactionV2? tempTx; @@ -112,7 +107,7 @@ class TxData { this.tezosOperationsList, this.sparkRecipients, this.sparkMints, - this.usedCoins, + this.usedSparkCoins, this.tempTx, }); @@ -195,14 +190,7 @@ class TxData { })>? sparkRecipients, List? sparkMints, - List< - ({ - String serializedCoin, - String serializedCoinContext, - int groupId, - int height, - })>? - usedCoins, + List? usedSparkCoins, TransactionV2? tempTx, }) { return TxData( @@ -240,7 +228,7 @@ class TxData { tezosOperationsList: tezosOperationsList ?? this.tezosOperationsList, sparkRecipients: sparkRecipients ?? this.sparkRecipients, sparkMints: sparkMints ?? this.sparkMints, - usedCoins: usedCoins ?? this.usedCoins, + usedSparkCoins: usedSparkCoins ?? this.usedSparkCoins, tempTx: tempTx ?? this.tempTx, ); } @@ -279,7 +267,7 @@ class TxData { 'tezosOperationsList: $tezosOperationsList, ' 'sparkRecipients: $sparkRecipients, ' 'sparkMints: $sparkMints, ' - 'usedCoins: $usedCoins, ' + 'usedSparkCoins: $usedSparkCoins, ' 'tempTx: $tempTx, ' '}'; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index c7ff03572..74848182e 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -499,6 +499,27 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { ), ); + final List usedSparkCoins = []; + + for (final usedCoin in spend.usedCoins) { + try { + usedSparkCoins.add(coins + .firstWhere((e) => + usedCoin.height == e.height && + usedCoin.groupId == e.groupId && + base64Decode(e.serializedCoinB64!) + .toHex + .startsWith(base64Decode(usedCoin.serializedCoin).toHex)) + .copyWith( + isUsed: true, + )); + } catch (_) { + throw Exception( + "Unexpectedly did not find used spark coin. This should never happen.", + ); + } + } + return txData.copyWith( raw: rawTxHex, vSize: extractedTx.virtualSize(), @@ -523,7 +544,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { height: null, version: 3, ), - usedCoins: spend.usedCoins, + usedSparkCoins: usedSparkCoins, ); } @@ -545,26 +566,13 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { txid: txHash, ); - // Update coins as used in database. - final List usedCoins = []; - for (final usedCoin in txData.usedCoins!) { - // Find the SparkCoin that matches the usedCoin. - final sparkCoin = await mainDB.isar.sparkCoins - .where() - .walletIdEqualToAnyLTagHash(walletId) - .filter() - .serializedCoinB64EqualTo(usedCoin.serializedCoin) - .findFirst(); - - // Add the SparkCoin to usedCoins if it exists. - if (sparkCoin != null) { - usedCoins.add(sparkCoin.copyWith(isUsed: true)); - } + // Update used spark coins as used in database. They should already have + // been marked as isUsed. + // TODO: [prio=med] Could (probably should) throw an exception here if txData.usedSparkCoins is null or empty + if (txData.usedSparkCoins != null && txData.usedSparkCoins!.isNotEmpty) { + await _addOrUpdateSparkCoins(txData.usedSparkCoins!); } - // Update the SparkCoins in the database. - await _addOrUpdateSparkCoins(usedCoins); - return await updateSentCachedTxData(txData: txData); } catch (e, s) { Logging.instance.log("Exception rethrown from confirmSend(): $e\n$s", From ab3df052d43871d5b683466b097004774d2f4bb8 Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 28 Feb 2024 15:43:53 +0200 Subject: [PATCH 10/24] Check if default Epicbox is up on start up, always update wallet address to connected Epicbox server --- lib/utilities/default_epicboxes.dart | 2 +- lib/wallets/wallet/impl/epiccash_wallet.dart | 115 +++++++++---------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/lib/utilities/default_epicboxes.dart b/lib/utilities/default_epicboxes.dart index 6f0fbc7c5..f83f84cf5 100644 --- a/lib/utilities/default_epicboxes.dart +++ b/lib/utilities/default_epicboxes.dart @@ -17,7 +17,7 @@ abstract class DefaultEpicBoxes { static List get defaultIds => ['americas', 'asia', 'europe']; static EpicBoxServerModel get americas => EpicBoxServerModel( - host: 'stackwallet.epicbox.com', + host: 'epicbox.stackwallet.com', port: 443, name: 'Americas', id: 'americas', diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index 7f37aa318..bca8453bc 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -104,45 +104,28 @@ class EpiccashWallet extends Bip39Wallet { Future getEpicBoxConfig() async { EpicBoxConfigModel? _epicBoxConfig; - // read epicbox config from secure store - String? storedConfig = - await secureStorageInterface.read(key: '${walletId}_epicboxConfig'); - // we should move to storing the primary server model like we do with nodes, and build the config from that (see epic-mobile) - // EpicBoxServerModel? _epicBox = epicBox ?? - // DB.instance.get( - // boxName: DB.boxNamePrimaryEpicBox, key: 'primary'); - // Logging.instance.log( - // "Read primary Epic Box config: ${jsonEncode(_epicBox)}", - // level: LogLevel.Info); + //Get the default Epicbox server and check if it's conected + bool isEpicboxConnected = await _testEpicboxServer( + DefaultEpicBoxes.defaultEpicBoxServer.host, DefaultEpicBoxes.defaultEpicBoxServer.port ?? 443); - if (storedConfig == null) { - // if no config stored, use the default epicbox server as config + if (isEpicboxConnected) { + //Use default server for as Epicbox config _epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer); } else { - // if a config is stored, test it - - _epicBoxConfig = EpicBoxConfigModel.fromString( - storedConfig); // fromString handles checking old config formats - } - - bool isEpicboxConnected = await _testEpicboxServer( - _epicBoxConfig.host, _epicBoxConfig.port ?? 443); - - if (!isEpicboxConnected) { - // default Epicbox is not connected, default to Europe + //Use Europe config _epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.europe); - - // example of selecting another random server from the default list - // alternative servers: copy list of all default EB servers but remove the default default - // List alternativeServers = DefaultEpicBoxes.all; - // alternativeServers.removeWhere((opt) => opt.name == DefaultEpicBoxes.defaultEpicBoxServer.name); - // alternativeServers.shuffle(); // randomize which server is used - // _epicBoxConfig = EpicBoxConfigModel.fromServer(alternativeServers.first); - - // TODO test this connection before returning it } + // // example of selecting another random server from the default list + // // alternative servers: copy list of all default EB servers but remove the default default + // // List alternativeServers = DefaultEpicBoxes.all; + // // alternativeServers.removeWhere((opt) => opt.name == DefaultEpicBoxes.defaultEpicBoxServer.name); + // // alternativeServers.shuffle(); // randomize which server is used + // // _epicBoxConfig = EpicBoxConfigModel.fromServer(alternativeServers.first); + // + // // TODO test this connection before returning it + // } return _epicBoxConfig; } @@ -334,36 +317,52 @@ class EpiccashWallet extends Bip39Wallet { int index, ) async { Address? address = await getCurrentReceivingAddress(); + EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig(); - if (address == null) { - final wallet = - await secureStorageInterface.read(key: '${walletId}_wallet'); - EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig(); + if (address != null) { + final splitted = address.value.split('@'); + //Check if the address is the same as the current epicbox index + if (splitted[1] != epicboxConfig.host) { + //Update the address + address = await thisWalletAddress(index, epicboxConfig); + } - final walletAddress = await epiccash.LibEpiccash.getAddressInfo( - wallet: wallet!, - index: index, - epicboxConfig: epicboxConfig.toString(), - ); - - Logging.instance.log( - "WALLET_ADDRESS_IS $walletAddress", - level: LogLevel.Info, - ); - - address = Address( - walletId: walletId, - value: walletAddress, - derivationIndex: index, - derivationPath: null, - type: AddressType.mimbleWimble, - subType: AddressSubType.receiving, - publicKey: [], // ?? - ); - - await mainDB.updateOrPutAddresses([address]); + } else { + address = await thisWalletAddress(index, epicboxConfig); } + + // print("NOW THIS ADDRESS IS $address"); + return address; + } + + Future
thisWalletAddress(int index, EpicBoxConfigModel epicboxConfig) async { + final wallet = + await secureStorageInterface.read(key: '${walletId}_wallet'); + // EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig(); + + final walletAddress = await epiccash.LibEpiccash.getAddressInfo( + wallet: wallet!, + index: index, + epicboxConfig: epicboxConfig.toString(), + ); + + Logging.instance.log( + "WALLET_ADDRESS_IS $walletAddress", + level: LogLevel.Info, + ); + + final address = Address( + walletId: walletId, + value: walletAddress, + derivationIndex: index, + derivationPath: null, + type: AddressType.mimbleWimble, + subType: AddressSubType.receiving, + publicKey: [], // ?? + ); + + await mainDB.updateOrPutAddresses([address]); return address; } From 891f2d8702d55b5d05d2f10a23082a592cbe8fde Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 28 Feb 2024 19:23:55 +0200 Subject: [PATCH 11/24] Attemp to update cached receiving address --- lib/wallets/wallet/impl/epiccash_wallet.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index bca8453bc..3509ca08a 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -332,7 +332,7 @@ class EpiccashWallet extends Bip39Wallet { } - // print("NOW THIS ADDRESS IS $address"); + print("NOW THIS ADDRESS IS $address"); return address; } @@ -363,6 +363,12 @@ class EpiccashWallet extends Bip39Wallet { ); await mainDB.updateOrPutAddresses([address]); + if (info.cachedReceivingAddress != address.value) { + await info.updateReceivingAddress( + newAddress: address.value, + isar: mainDB.isar, + ); + } return address; } @@ -935,6 +941,7 @@ class EpiccashWallet extends Bip39Wallet { .findAll(); final myAddressesSet = myAddresses.toSet(); + final transactions = await epiccash.LibEpiccash.getTransactions( wallet: wallet!, refreshFromNode: refreshFromNode, From 41d71f0529c4556494b831c19486ceef6011f03d Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 28 Feb 2024 20:11:18 +0200 Subject: [PATCH 12/24] Remove failover options for Epicbox --- lib/wallets/wallet/impl/epiccash_wallet.dart | 35 ++++++++------------ 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index 3509ca08a..8228ab7c8 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -103,20 +103,21 @@ class EpiccashWallet extends Bip39Wallet { } Future getEpicBoxConfig() async { - EpicBoxConfigModel? _epicBoxConfig; + EpicBoxConfigModel? _epicBoxConfig = + EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer); //Get the default Epicbox server and check if it's conected - bool isEpicboxConnected = await _testEpicboxServer( - DefaultEpicBoxes.defaultEpicBoxServer.host, DefaultEpicBoxes.defaultEpicBoxServer.port ?? 443); + // bool isEpicboxConnected = await _testEpicboxServer( + // DefaultEpicBoxes.defaultEpicBoxServer.host, DefaultEpicBoxes.defaultEpicBoxServer.port ?? 443); - if (isEpicboxConnected) { + // if (isEpicboxConnected) { //Use default server for as Epicbox config - _epicBoxConfig = - EpicBoxConfigModel.fromServer(DefaultEpicBoxes.defaultEpicBoxServer); - } else { - //Use Europe config - _epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.europe); - } + + // } + // else { + // //Use Europe config + // _epicBoxConfig = EpicBoxConfigModel.fromServer(DefaultEpicBoxes.europe); + // } // // example of selecting another random server from the default list // // alternative servers: copy list of all default EB servers but remove the default default // // List alternativeServers = DefaultEpicBoxes.all; @@ -321,18 +322,16 @@ class EpiccashWallet extends Bip39Wallet { if (address != null) { final splitted = address.value.split('@'); - //Check if the address is the same as the current epicbox index + //Check if the address is the same as the current epicbox domain + //Since we're only using one epicbpox now this doesn't apply but will be + // useful in the future if (splitted[1] != epicboxConfig.host) { //Update the address address = await thisWalletAddress(index, epicboxConfig); } - } else { address = await thisWalletAddress(index, epicboxConfig); } - - - print("NOW THIS ADDRESS IS $address"); return address; } @@ -363,12 +362,6 @@ class EpiccashWallet extends Bip39Wallet { ); await mainDB.updateOrPutAddresses([address]); - if (info.cachedReceivingAddress != address.value) { - await info.updateReceivingAddress( - newAddress: address.value, - isar: mainDB.isar, - ); - } return address; } From e6fd6d0c5b79112fd3a7d6a4b06267a2129917a2 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 28 Feb 2024 14:36:42 -0600 Subject: [PATCH 13/24] point to flutter_libsparkmobile main post merge of add_return_used_coins to main therein --- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 37d623bde..86cc05eb6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -674,8 +674,8 @@ packages: dependency: "direct main" description: path: "." - ref: "5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1" - resolved-ref: "5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1" + ref: "3f986ca1a94bdac5d31373454c989cc2f5842de8" + resolved-ref: "3f986ca1a94bdac5d31373454c989cc2f5842de8" url: "https://github.com/cypherstack/flutter_libsparkmobile.git" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 8f748b572..22b8efd66 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: flutter_libsparkmobile: git: url: https://github.com/cypherstack/flutter_libsparkmobile.git - ref: 5bc70bc4d8b3799a9c3d6cad0f8fe585be9de2f1 + ref: 3f986ca1a94bdac5d31373454c989cc2f5842de8 flutter_libmonero: path: ./crypto_plugins/flutter_libmonero From defc301053aea858c650d04f2eecc20455bd03fc Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 28 Feb 2024 14:42:16 -0600 Subject: [PATCH 14/24] add "&all" param to eth api call --- lib/services/ethereum/ethereum_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index b9a118352..3931b4573 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -612,7 +612,7 @@ abstract class EthereumAPI { final response = await client.get( url: Uri.parse( // "$stackBaseServer/tokens?addrs=$contractAddress&parts=all", - "$stackBaseServer/names?terms=$contractAddress", + "$stackBaseServer/names?terms=$contractAddress&all", ), proxyInfo: Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() From 3a5a886e7a9d394a95e6002fae8b0bb84b0b78c6 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 29 Feb 2024 18:44:38 -0600 Subject: [PATCH 15/24] remove Expanded widget from restore wallet view resolves gray screen on Windows in release mode --- .../restore_wallet_view/restore_wallet_view.dart | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index e025d621b..e9f0442d5 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -724,15 +724,10 @@ class _RestoreWalletViewState extends ConsumerState { ], ), body: Container( - color: Theme.of(context).extension()!.background, - child: Padding( - padding: const EdgeInsets.all(12.0), - child: ConditionalParent( - condition: isDesktop, - builder: (child) => Expanded( - child: child, - ), - child: SingleChildScrollView( + color: Theme.of(context).extension()!.background, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: SingleChildScrollView( controller: controller, child: Column( children: [ @@ -1203,7 +1198,6 @@ class _RestoreWalletViewState extends ConsumerState { ), ), ), - ), - ); + ); } } From 375ca6e6352b460b734f14a0b28b2b4f2c2529b7 Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Thu, 29 Feb 2024 20:41:22 -0700 Subject: [PATCH 16/24] Update version (v1.10.2, build 213) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 44dc98d34..7fe8bc38c 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.10.1+212 +version: 1.10.2+213 environment: sdk: ">=3.0.2 <4.0.0" From fd47c13fbdc5ffa6b14ebaaabe0c925f05941d02 Mon Sep 17 00:00:00 2001 From: likho Date: Fri, 1 Mar 2024 20:30:34 +0200 Subject: [PATCH 17/24] Update to latest version of Epic --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 396d519a4..666fbb9b0 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 396d519a4c3ae1c47c8406e5506b0966f1f7098f +Subproject commit 666fbb9b04205aa909b17165c24e521028abbdb6 From 794e969089660903e3b388d5d396f732146b4557 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 11:42:41 -0600 Subject: [PATCH 18/24] export specific NDK version for flutter_libepiccash android build --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 666fbb9b0..d290eda87 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 666fbb9b04205aa909b17165c24e521028abbdb6 +Subproject commit d290eda87ef95b454bf4a2a58f262d5d66796eed From a55775d0829dc360de1f9416c237f975f6c5d7ba Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 12:01:16 -0600 Subject: [PATCH 19/24] move epic hackfix into build_all.sh so ./Configure works as expected --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index d290eda87..052bf7096 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit d290eda87ef95b454bf4a2a58f262d5d66796eed +Subproject commit 052bf70964465e5c8e82746880b43a84d263af0f From c0d54ee15d3b7c9807413dedab43f4a520b178e2 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 12:06:33 -0600 Subject: [PATCH 20/24] update ANDROID_NDK_HOME var --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 052bf7096..b08ffa683 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 052bf70964465e5c8e82746880b43a84d263af0f +Subproject commit b08ffa683935fd93a7eae957663b09c3869877a4 From 0060f9cb0d36dad3169758b778900d109906031f Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 12:14:21 -0600 Subject: [PATCH 21/24] fix r21 NDK URL in flutter_libepiccash --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index b08ffa683..4af5e146f 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit b08ffa683935fd93a7eae957663b09c3869877a4 +Subproject commit 4af5e146f9dee393eae69bf2eab35d965489b963 From 414803dc81cfb850a88ba472136c6afdf47413c2 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 12:46:25 -0600 Subject: [PATCH 22/24] scripts fixes --- crypto_plugins/flutter_libepiccash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto_plugins/flutter_libepiccash b/crypto_plugins/flutter_libepiccash index 4af5e146f..cef5d3aa8 160000 --- a/crypto_plugins/flutter_libepiccash +++ b/crypto_plugins/flutter_libepiccash @@ -1 +1 @@ -Subproject commit 4af5e146f9dee393eae69bf2eab35d965489b963 +Subproject commit cef5d3aa8c74c8dc9a466f803c964b243ad653a3 From e8939455d47b371835dceb86fcba718b04865921 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 4 Mar 2024 12:57:36 -0600 Subject: [PATCH 23/24] build opensll for flutter_libepiccash android as well --- scripts/android/build_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh index b67cd92a4..3f499e3f9 100755 --- a/scripts/android/build_all.sh +++ b/scripts/android/build_all.sh @@ -11,7 +11,7 @@ mkdir -p build ./install_ndk.sh (cd ../../crypto_plugins/flutter_liblelantus/scripts/android && ./build_all.sh ) & -(cd ../../crypto_plugins/flutter_libepiccash/scripts/android && ./install_ndk.sh && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libepiccash/scripts/android && ./install_ndk.sh && ./build_opensll.sh && ./build_all.sh ) & (cd ../../crypto_plugins/flutter_libmonero/scripts/android/ && ./build_all.sh ) & wait From 7cebd31268616fd802f521a7b9e4bb7ed7f33c19 Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Mon, 4 Mar 2024 11:59:19 -0700 Subject: [PATCH 24/24] Update version (v1.10.2, build 214) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 7fe8bc38c..b9b3a004e 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.10.2+213 +version: 1.10.2+214 environment: sdk: ">=3.0.2 <4.0.0"