From aac93494001492bfd7edf58d2fc6d3439c28d297 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Sat, 24 Feb 2024 23:37:33 -0600 Subject: [PATCH 01/25] fix mobile restore wallet view for small screens --- .../restore_wallet_view.dart | 697 +++++++++--------- 1 file changed, 360 insertions(+), 337 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 9d40e4106..6cf3cc9d9 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 @@ -726,350 +726,374 @@ class _RestoreWalletViewState extends ConsumerState { color: Theme.of(context).extension()!.background, child: Padding( padding: const EdgeInsets.all(12.0), - child: SingleChildScrollView( - child: Column( - children: [ - /*if (isDesktop) + child: Expanded( + child: SingleChildScrollView( + controller: controller, + child: Column( + children: [ + /*if (isDesktop) const Spacer( flex: 10, ),*/ - if (!isDesktop) - Text( - widget.walletName, - style: STextStyles.itemSubtitle(context), - ), - SizedBox( - height: isDesktop ? 0 : 4, - ), - Text( - "Recovery phrase", - style: isDesktop - ? STextStyles.desktopH2(context) - : STextStyles.pageTitleH1(context), - ), - SizedBox( - height: isDesktop ? 16 : 8, - ), - Text( - "Enter your $_seedWordCount-word recovery phrase.", - style: isDesktop - ? STextStyles.desktopSubtitleH2(context) - : STextStyles.subtitle(context), - ), - SizedBox( - height: isDesktop ? 16 : 10, - ), - if (isDesktop) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextButton( - onPressed: pasteMnemonic, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 12, - ), - child: Row( - children: [ - SvgPicture.asset( - Assets.svg.clipboard, - width: 22, - height: 22, - color: Theme.of(context) - .extension()! - .buttonTextSecondary, - ), - const SizedBox( - width: 8, - ), - Text( - "Paste", - style: STextStyles - .desktopButtonSmallSecondaryEnabled(context), - ) - ], - ), - ), + if (!isDesktop) + Text( + widget.walletName, + style: STextStyles.itemSubtitle(context), ), - ], - ), - if (isDesktop) - const SizedBox( - height: 20, - ), - if (isDesktop) - ConstrainedBox( - constraints: const BoxConstraints( - maxWidth: 1008, + SizedBox( + height: isDesktop ? 0 : 4, ), - child: Builder( - builder: (BuildContext context) { - const cols = 4; - final int rows = _seedWordCount ~/ cols; - final int remainder = _seedWordCount % cols; - - return Column( - children: [ - Form( - key: _formKey, - child: TableView( - shrinkWrap: true, - rowSpacing: 20, - rows: [ - for (int i = 0; i < rows; i++) - TableViewRow( - crossAxisAlignment: - CrossAxisAlignment.start, - spacing: 16, - cells: [ - for (int j = 1; j <= cols; j++) - TableViewCell( - flex: 1, - child: Column( - children: [ - TextFormField( - autocorrect: !isDesktop, - enableSuggestions: !isDesktop, - textCapitalization: - TextCapitalization.none, - key: Key( - "restoreMnemonicFormField_$i"), - decoration: - _getInputDecorationFor( - _inputStatuses[ - i * 4 + j - 1], - "${i * 4 + j}"), - autovalidateMode: - AutovalidateMode - .onUserInteraction, - selectionControls: - i * 4 + j - 1 == 1 - ? textSelectionControls - : null, - // focusNode: - // _focusNodes[i * 4 + j - 1], - onChanged: (value) { - final FormInputStatus - formInputStatus; - - if (value.isEmpty) { - formInputStatus = - FormInputStatus.empty; - } else if (_isValidMnemonicWord( - value - .trim() - .toLowerCase())) { - formInputStatus = - FormInputStatus.valid; - } else { - formInputStatus = - FormInputStatus.invalid; - } - - // if (formInputStatus == - // FormInputStatus.valid) { - // if (i * 4 + j < - // _focusNodes.length) { - // _focusNodes[i * 4 + j] - // .requestFocus(); - // } else if (i * 4 + j == - // _focusNodes.length) { - // _focusNodes[i * 4 + j - 1] - // .unfocus(); - // } - // } - setState(() { - _inputStatuses[i * 4 + - j - - 1] = formInputStatus; - }); - }, - controller: - _controllers[i * 4 + j - 1], - style: - STextStyles.field(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textRestore, - fontSize: isDesktop ? 16 : 14, - ), - ), - if (_inputStatuses[ - i * 4 + j - 1] == - FormInputStatus.invalid) - Align( - alignment: Alignment.topLeft, - child: Padding( - padding: - const EdgeInsets.only( - left: 12.0, - bottom: 4.0, - ), - child: Text( - "Please check spelling", - textAlign: TextAlign.left, - style: STextStyles.label( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textError, - ), - ), - ), - ) - ], - ), - ), - ], - expandingChild: null, - ), - if (remainder > 0) - TableViewRow( - spacing: 16, - cells: [ - for (int i = rows * cols; - i < _seedWordCount; - i++) ...[ - TableViewCell( - flex: 1, - child: Column( - children: [ - TextFormField( - autocorrect: !isDesktop, - enableSuggestions: !isDesktop, - textCapitalization: - TextCapitalization.none, - key: Key( - "restoreMnemonicFormField_$i"), - decoration: - _getInputDecorationFor( - _inputStatuses[i], - "${i + 1}"), - autovalidateMode: - AutovalidateMode - .onUserInteraction, - selectionControls: i == 1 - ? textSelectionControls - : null, - // focusNode: _focusNodes[i], - onChanged: (value) { - final FormInputStatus - formInputStatus; - - if (value.isEmpty) { - formInputStatus = - FormInputStatus.empty; - } else if (_isValidMnemonicWord( - value - .trim() - .toLowerCase())) { - formInputStatus = - FormInputStatus.valid; - } else { - formInputStatus = - FormInputStatus.invalid; - } - - // if (formInputStatus == - // FormInputStatus - // .valid && - // (i - 1) < - // _focusNodes.length) { - // Focus.of(context) - // .requestFocus( - // _focusNodes[i]); - // } - - // if (formInputStatus == - // FormInputStatus.valid) { - // if (i + 1 < - // _focusNodes.length) { - // _focusNodes[i + 1] - // .requestFocus(); - // } else if (i + 1 == - // _focusNodes.length) { - // _focusNodes[i].unfocus(); - // } - // } - }, - controller: _controllers[i], - style: - STextStyles.field(context) - .copyWith( - color: Theme.of(context) - .extension()! - .overlay, - fontSize: isDesktop ? 16 : 14, - ), - ), - if (_inputStatuses[i] == - FormInputStatus.invalid) - Align( - alignment: Alignment.topLeft, - child: Padding( - padding: - const EdgeInsets.only( - left: 12.0, - bottom: 4.0, - ), - child: Text( - "Please check spelling", - textAlign: TextAlign.left, - style: STextStyles.label( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textError, - ), - ), - ), - ) - ], - ), - ), - ], - for (int i = remainder; - i < cols; - i++) ...[ - TableViewCell( - flex: 1, - child: Container(), - ), - ], - ], - expandingChild: null, - ), + Text( + "Recovery phrase", + style: isDesktop + ? STextStyles.desktopH2(context) + : STextStyles.pageTitleH1(context), + ), + SizedBox( + height: isDesktop ? 16 : 8, + ), + Text( + "Enter your $_seedWordCount-word recovery phrase.", + style: isDesktop + ? STextStyles.desktopSubtitleH2(context) + : STextStyles.subtitle(context), + ), + SizedBox( + height: isDesktop ? 16 : 10, + ), + if (isDesktop) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: pasteMnemonic, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 12, + ), + child: Row( + children: [ + SvgPicture.asset( + Assets.svg.clipboard, + width: 22, + height: 22, + color: Theme.of(context) + .extension()! + .buttonTextSecondary, + ), + const SizedBox( + width: 8, + ), + Text( + "Paste", + style: STextStyles + .desktopButtonSmallSecondaryEnabled( + context), + ) ], ), ), - const SizedBox( - height: 32, - ), - PrimaryButton( - label: "Restore wallet", - width: 480, - onPressed: requestRestore, - ), - ], - ); - }, - ), - ), - /*if (isDesktop) + ), + ], + ), + if (isDesktop) + const SizedBox( + height: 20, + ), + if (isDesktop) + ConstrainedBox( + constraints: const BoxConstraints( + maxWidth: 1008, + ), + child: Builder( + builder: (BuildContext context) { + const cols = 4; + final int rows = _seedWordCount ~/ cols; + final int remainder = _seedWordCount % cols; + + return Column( + children: [ + Form( + key: _formKey, + child: TableView( + shrinkWrap: true, + rowSpacing: 20, + rows: [ + for (int i = 0; i < rows; i++) + TableViewRow( + crossAxisAlignment: + CrossAxisAlignment.start, + spacing: 16, + cells: [ + for (int j = 1; j <= cols; j++) + TableViewCell( + flex: 1, + child: Column( + children: [ + TextFormField( + autocorrect: !isDesktop, + enableSuggestions: + !isDesktop, + textCapitalization: + TextCapitalization.none, + key: Key( + "restoreMnemonicFormField_$i"), + decoration: + _getInputDecorationFor( + _inputStatuses[ + i * 4 + j - 1], + "${i * 4 + j}"), + autovalidateMode: + AutovalidateMode + .onUserInteraction, + selectionControls: i * 4 + + j - + 1 == + 1 + ? textSelectionControls + : null, + // focusNode: + // _focusNodes[i * 4 + j - 1], + onChanged: (value) { + final FormInputStatus + formInputStatus; + + if (value.isEmpty) { + formInputStatus = + FormInputStatus + .empty; + } else if (_isValidMnemonicWord( + value + .trim() + .toLowerCase())) { + formInputStatus = + FormInputStatus + .valid; + } else { + formInputStatus = + FormInputStatus + .invalid; + } + + // if (formInputStatus == + // FormInputStatus.valid) { + // if (i * 4 + j < + // _focusNodes.length) { + // _focusNodes[i * 4 + j] + // .requestFocus(); + // } else if (i * 4 + j == + // _focusNodes.length) { + // _focusNodes[i * 4 + j - 1] + // .unfocus(); + // } + // } + setState(() { + _inputStatuses[ + i * 4 + j - 1] = + formInputStatus; + }); + }, + controller: _controllers[ + i * 4 + j - 1], + style: STextStyles.field( + context) + .copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textRestore, + fontSize: + isDesktop ? 16 : 14, + ), + ), + if (_inputStatuses[ + i * 4 + j - 1] == + FormInputStatus.invalid) + Align( + alignment: + Alignment.topLeft, + child: Padding( + padding: + const EdgeInsets + .only( + left: 12.0, + bottom: 4.0, + ), + child: Text( + "Please check spelling", + textAlign: + TextAlign.left, + style: + STextStyles.label( + context) + .copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textError, + ), + ), + ), + ) + ], + ), + ), + ], + expandingChild: null, + ), + if (remainder > 0) + TableViewRow( + spacing: 16, + cells: [ + for (int i = rows * cols; + i < _seedWordCount; + i++) ...[ + TableViewCell( + flex: 1, + child: Column( + children: [ + TextFormField( + autocorrect: !isDesktop, + enableSuggestions: + !isDesktop, + textCapitalization: + TextCapitalization.none, + key: Key( + "restoreMnemonicFormField_$i"), + decoration: + _getInputDecorationFor( + _inputStatuses[i], + "${i + 1}"), + autovalidateMode: + AutovalidateMode + .onUserInteraction, + selectionControls: i == 1 + ? textSelectionControls + : null, + // focusNode: _focusNodes[i], + onChanged: (value) { + final FormInputStatus + formInputStatus; + + if (value.isEmpty) { + formInputStatus = + FormInputStatus + .empty; + } else if (_isValidMnemonicWord( + value + .trim() + .toLowerCase())) { + formInputStatus = + FormInputStatus + .valid; + } else { + formInputStatus = + FormInputStatus + .invalid; + } + + // if (formInputStatus == + // FormInputStatus + // .valid && + // (i - 1) < + // _focusNodes.length) { + // Focus.of(context) + // .requestFocus( + // _focusNodes[i]); + // } + + // if (formInputStatus == + // FormInputStatus.valid) { + // if (i + 1 < + // _focusNodes.length) { + // _focusNodes[i + 1] + // .requestFocus(); + // } else if (i + 1 == + // _focusNodes.length) { + // _focusNodes[i].unfocus(); + // } + // } + }, + controller: _controllers[i], + style: STextStyles.field( + context) + .copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .overlay, + fontSize: + isDesktop ? 16 : 14, + ), + ), + if (_inputStatuses[i] == + FormInputStatus.invalid) + Align( + alignment: + Alignment.topLeft, + child: Padding( + padding: + const EdgeInsets + .only( + left: 12.0, + bottom: 4.0, + ), + child: Text( + "Please check spelling", + textAlign: + TextAlign.left, + style: + STextStyles.label( + context) + .copyWith( + color: Theme.of( + context) + .extension< + StackColors>()! + .textError, + ), + ), + ), + ) + ], + ), + ), + ], + for (int i = remainder; + i < cols; + i++) ...[ + TableViewCell( + flex: 1, + child: Container(), + ), + ], + ], + expandingChild: null, + ), + ], + ), + ), + const SizedBox( + height: 32, + ), + PrimaryButton( + label: "Restore wallet", + width: 480, + onPressed: requestRestore, + ), + ], + ); + }, + ), + ), + /*if (isDesktop) const Spacer( flex: 15, ),*/ - if (!isDesktop) - Expanded( - child: SingleChildScrollView( - controller: controller, - child: Padding( + if (!isDesktop) + Padding( padding: const EdgeInsets.all(4.0), child: Form( key: _formKey, @@ -1169,13 +1193,12 @@ class _RestoreWalletViewState extends ConsumerState { ), ), ), - ), - ), - ], + ], + ), + ), ), ), ), - ), ); } } From ca01a87e8815fd77b092b4b6cbe0dd6f7fe79c99 Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Sun, 25 Feb 2024 10:57:41 -0700 Subject: [PATCH 02/25] Update version (v1.10.1, build 210) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 223c9a95b..c2e6de1fc 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+209 +version: 1.10.1+210 environment: sdk: ">=3.0.2 <4.0.0" From 557fb4b1d7ea9e921fb5424652dfb503703b9cb6 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Sun, 25 Feb 2024 21:11:52 -0600 Subject: [PATCH 03/25] use ConditionalParent to only use an Expanded widget if isDesktop --- .../restore_wallet_view/restore_wallet_view.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 6cf3cc9d9..3151a7a05 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 @@ -56,6 +56,7 @@ import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart'; import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart'; import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; import 'package:stackwallet/wallets/wallet/wallet.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; @@ -726,7 +727,11 @@ class _RestoreWalletViewState extends ConsumerState { color: Theme.of(context).extension()!.background, child: Padding( padding: const EdgeInsets.all(12.0), - child: Expanded( + child: ConditionalParent( + condition: !isDesktop, + builder: (child) => Expanded( + child: child, + ), child: SingleChildScrollView( controller: controller, child: Column( From d0d7843b4dbbd5f7e792831272e3de859e68e8ca Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Sun, 25 Feb 2024 20:17:01 -0700 Subject: [PATCH 04/25] Update version (v1.10.1, build 211) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c2e6de1fc..e9a293809 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+210 +version: 1.10.1+211 environment: sdk: ">=3.0.2 <4.0.0" From 4d94de2e3d85e7012a7692fac91964434f751ebc Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 10:23:34 -0600 Subject: [PATCH 05/25] do not validate "p" (P2SH) addresses --- lib/wallets/crypto_currency/coins/ecash.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index 6858796cb..07e164c6e 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -185,7 +185,8 @@ class Ecash extends Bip39HDCurrency { addr = cashAddr.split(":").last; } - return addr.startsWith("q") || addr.startsWith("p"); + return addr.startsWith("q") /*|| addr.startsWith("p")*/; + // Do not validate "p" (P2SH) addresses. } @override From c8a5a0087ab99f408039824469c2eb293fe4ba08 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 10:29:46 -0600 Subject: [PATCH 06/25] invert condition --- .../restore_wallet_view/restore_wallet_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3151a7a05..e025d621b 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 @@ -728,7 +728,7 @@ class _RestoreWalletViewState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(12.0), child: ConditionalParent( - condition: !isDesktop, + condition: isDesktop, builder: (child) => Expanded( child: child, ), From a75f5597df5ca8dcdbf6c611477ffc013d01742f Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 14:00:01 -0600 Subject: [PATCH 07/25] update electrum_adapter package to support scientific notation doubles --- pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 2bba3135a..07ee80f19 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -528,8 +528,8 @@ packages: dependency: "direct main" description: path: "." - ref: "0a34f7f48d921fb33f551cb11dfc9b2930522240" - resolved-ref: "0a34f7f48d921fb33f551cb11dfc9b2930522240" + ref: "2897c6448e131241d4d91fe23fdab83305134225" + resolved-ref: "2897c6448e131241d4d91fe23fdab83305134225" url: "https://github.com/cypherstack/electrum_adapter.git" source: git version: "3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index e9a293809..2e9ba0a78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -176,7 +176,7 @@ dependencies: electrum_adapter: git: url: https://github.com/cypherstack/electrum_adapter.git - ref: 0a34f7f48d921fb33f551cb11dfc9b2930522240 + ref: 2897c6448e131241d4d91fe23fdab83305134225 stream_channel: ^2.1.0 dev_dependencies: From f67c9e64020b61149a7b1fd144f658f92d7e2dd6 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 14:02:55 -0600 Subject: [PATCH 08/25] remove temporary doge fee hackfix Closes #763. --- lib/electrumx_rpc/electrumx_client.dart | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 98c6614f9..9ca3dfeb1 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -1020,18 +1020,6 @@ 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 51b709e682ce4ac22d3c74307400d9cb231ebea8 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 26 Feb 2024 14:27:39 -0600 Subject: [PATCH 09/25] 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 10/25] 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 11/25] 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 fadff229b8661da479126a0e2e0f96db846bb753 Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Mon, 26 Feb 2024 22:04:39 -0700 Subject: [PATCH 12/25] Update version (v1.10.1, build 212) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 2e9ba0a78..13b50ee5e 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+211 +version: 1.10.1+212 environment: sdk: ">=3.0.2 <4.0.0" From 06e64072599e34c8c7e5df2fcb2a991b3eee3a50 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 27 Feb 2024 13:48:48 -0600 Subject: [PATCH 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] 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 18/25] 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 19/25] 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 20/25] 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 21/25] 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 22/25] 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 23/25] 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 24/25] 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 25/25] 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"