V4.20.0 rc2 (#1727)

* version 4.20.0

* update build numbers

* UI updates and script fix for ios bundle identifier

* disable mweb for desktop

* change hardcoded ltc server ip address
electrum connection enhancement

* MWEB enhancements 2.0 (#1735)

* additional logging and minor fixes

* additional logging and minor fixes

* addresses pt.1

* Allow Wallet Group Names to be the same as Wallet Names (#1730)

* fix: Issues with imaging

* fix: Allow group names to be the same as wallet names

* fix: Bug with wallet grouping when a wallet is minimized

* fix: Bug with wallet grouping when a wallet is minimized

* logs of fixes and experimental changes, close wallet before opening next

* save

* fix icon

* fixes

* [skip ci] updates

* [skip ci] updates

* updates

* minor optimizations

* fix for when switching between wallets

* [skip ci] updates

* [skip ci] updates

* Update cw_bitcoin/lib/litecoin_wallet.dart

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* Update cw_bitcoin/lib/litecoin_wallet.dart

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* mobx

* mostly logging

* stream fix pt.1 [skip ci]

* updates

* some fixes and enhancements

* [skip ci] minor

* potential partial fix for streamsink closed

* fix stream sink closed errors

* fix mweb logo colors

* save

* minor enhancements [skip ci]

* save

* experimental

* minor

* minor [skip ci]

---------

Co-authored-by: David Adegoke <64401859+Blazebrain@users.noreply.github.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* fix menu list removing from original list

---------

Co-authored-by: Matthew Fosse <matt@fosse.co>
Co-authored-by: David Adegoke <64401859+Blazebrain@users.noreply.github.com>
This commit is contained in:
Omar Hatem
2024-10-13 02:13:52 +03:00
committed by GitHub
co-authored by David Adegoke Matthew Fosse
parent 8acf8bdfb2
commit 380f7653b2
80 changed files with 572 additions and 329 deletions
+11 -4
View File
@@ -262,7 +262,14 @@ class CWBitcoin extends Bitcoin {
List<ReceivePageOption> getBitcoinReceivePageOptions() => BitcoinReceivePageOption.all;
@override
List<ReceivePageOption> getLitecoinReceivePageOptions() => BitcoinReceivePageOption.allLitecoin;
List<ReceivePageOption> getLitecoinReceivePageOptions() {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
return BitcoinReceivePageOption.allLitecoin
.where((element) => element != BitcoinReceivePageOption.mweb)
.toList();
}
return BitcoinReceivePageOption.allLitecoin;
}
@override
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option) {
@@ -608,7 +615,7 @@ class CWBitcoin extends Bitcoin {
final updatedOutputs = outputs.map((output) {
try {
final pendingOut = pendingTx!.outputs[outputs.indexOf(output)];
final pendingOut = pendingTx.outputs[outputs.indexOf(output)];
final updatedOutput = output;
updatedOutput.stealthAddress = P2trAddress.fromScriptPubkey(script: pendingOut.scriptPubKey)
@@ -658,8 +665,8 @@ class CWBitcoin extends Bitcoin {
String? getUnusedMwebAddress(Object wallet) {
try {
final electrumWallet = wallet as ElectrumWallet;
final walletAddresses = electrumWallet.walletAddresses as ElectrumWalletAddresses;
final mwebAddress = walletAddresses.mwebAddresses.firstWhere((element) => !element.isUsed);
final mwebAddress =
electrumWallet.walletAddresses.mwebAddresses.firstWhere((element) => !element.isUsed);
return mwebAddress.address;
} catch (_) {
return null;
@@ -6,7 +6,6 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/dashboard/pages/nft_listing_page.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/action_button.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/home_screen_account_widget.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
@@ -20,12 +19,11 @@ import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
import 'package:cake_wallet/utils/feature_flag.dart';
import 'package:cake_wallet/utils/payment_request.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart';
import 'package:cw_bitcoin/bitcoin_receive_page_option.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -382,18 +380,10 @@ class CryptoBalanceWidget extends StatelessWidget {
child: DashBoardRoundedCardWidget(
customBorder: 30,
title: S.of(context).litecoin_mweb,
subTitle: '',
subTitle: S.of(context).litecoin_mweb_description,
hint: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).litecoin_mweb_description,
style: TextStyle(
color: Colors.white,
fontSize: 14,
),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => launchUrl(
@@ -401,53 +391,64 @@ class CryptoBalanceWidget extends StatelessWidget {
"https://guides.cakewallet.com/docs/cryptos/litecoin/#mweb"),
mode: LaunchMode.externalApplication,
),
child: Center(
child: Text(
S.of(context).learn_more,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context)
.extension<BalancePageTheme>()!
.labelTextColor,
height: 1,
),
softWrap: true,
child: Text(
S.of(context).learn_more,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context)
.extension<BalancePageTheme>()!
.labelTextColor,
height: 1,
),
softWrap: true,
),
),
SizedBox(height: 24),
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () => _dismissMweb(context),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
Expanded(
child: ElevatedButton(
onPressed: () => _dismissMweb(context),
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
),
child: Text(
S.of(context).litecoin_mweb_dismiss,
style: TextStyle(color: Colors.white),
),
),
child: Text(
S.of(context).litecoin_mweb_dismiss,
style: TextStyle(color: Colors.white),
),
),
ElevatedButton(
onPressed: () => _enableMweb(context),
child: Text(S.of(context).litecoin_enable_mweb_sync),
const SizedBox(width: 8),
Expanded(
child: ElevatedButton(
onPressed: () => _enableMweb(context),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
),
child: Text(
S.of(context).enable,
maxLines: 1,
),
),
),
],
),
],
),
onTap: () => {},
icon: ImageIcon(
AssetImage('assets/images/mweb_logo.png'),
color:
Theme.of(context).extension<DashboardPageTheme>()!.pageTitleTextColor,
size: 50,
icon: Container(
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: ImageIcon(
AssetImage('assets/images/mweb_logo.png'),
color: Color.fromARGB(255, 11, 70, 129),
size: 40,
),
),
),
),
@@ -505,7 +506,7 @@ class CryptoBalanceWidget extends StatelessWidget {
},
));
}
dashboardViewModel.setMwebScanningActive();
dashboardViewModel.setMwebEnabled();
}
Future<void> _dismissMweb(BuildContext context) async {
@@ -850,23 +851,15 @@ class BalanceRowWidget extends StatelessWidget {
padding: EdgeInsets.only(right: 16, top: 16),
child: Column(
children: [
CakeImageWidget(
imageUrl: 'assets/images/mweb_logo.png',
height: 40,
width: 40,
displayOnError: Container(
height: 30.0,
width: 30.0,
child: Center(
child: Text(
currency.title.substring(0, min(currency.title.length, 2)),
style: TextStyle(fontSize: 11),
),
),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey.shade400,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: ImageIcon(
AssetImage('assets/images/mweb_logo.png'),
color: Color.fromARGB(255, 11, 70, 129),
size: 40,
),
),
const SizedBox(height: 10),
@@ -97,14 +97,13 @@ class MenuWidgetState extends State<MenuWidget> {
@override
Widget build(BuildContext context) {
List<SettingActions> items = SettingActions.all;
List<SettingActions> items = List.of(SettingActions.all);
if (!widget.dashboardViewModel.hasSilentPayments) {
items.removeWhere((element) => element.name(context) == S.of(context).silent_payments_settings);
}
// if (!widget.dashboardViewModel.hasMweb) {
// itemCount--;
// items.removeWhere((element) => element.name(context) == S.of(context).litecoin_mweb_settings);
// }
if (!widget.dashboardViewModel.hasMweb) {
items.removeWhere((element) => element.name(context) == S.of(context).litecoin_mweb_settings);
}
int itemCount = items.length;
moneroIcon = Image.asset('assets/images/monero_menu.png',
@@ -191,11 +190,6 @@ class MenuWidgetState extends State<MenuWidget> {
final item = items[index];
if (!widget.dashboardViewModel.hasMweb &&
item.name(context) == S.of(context).litecoin_mweb_settings) {
return const SizedBox();
}
final isLastTile = index == itemCount - 1;
return SettingActionButton(
-7
View File
@@ -135,10 +135,6 @@ class RootState extends State<Root> with WidgetsBindingObserver {
setState(() => _setInactive(true));
}
if (widget.appStore.wallet?.type == WalletType.litecoin) {
widget.appStore.wallet?.stopSync();
}
break;
case AppLifecycleState.resumed:
widget.authService.requireAuth().then((value) {
@@ -148,9 +144,6 @@ class RootState extends State<Root> with WidgetsBindingObserver {
});
}
});
if (widget.appStore.wallet?.type == WalletType.litecoin) {
widget.appStore.wallet?.startSync();
}
break;
default:
break;
+2 -3
View File
@@ -4,7 +4,6 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
import 'package:cake_wallet/view_model/settings/mweb_settings_view_model.dart';
import 'package:cake_wallet/view_model/settings/silent_payments_settings_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -33,9 +32,9 @@ class MwebSettingsPage extends BasePage {
),
SettingsSwitcherCell(
title: S.current.litecoin_mweb_always_scan,
value: _mwebSettingsViewModel.mwebAlwaysScan,
value: _mwebSettingsViewModel.mwebEnabled,
onValueChange: (_, bool value) {
_mwebSettingsViewModel.setMwebAlwaysScan(value);
_mwebSettingsViewModel.setMwebEnabled(value);
},
),
SettingsCellWithArrow(
+1 -2
View File
@@ -31,7 +31,6 @@ class SettingActions {
walletSettingAction,
addressBookSettingAction,
silentPaymentsSettingAction,
litecoinMwebSettingAction,
securityBackupSettingAction,
privacySettingAction,
displaySettingAction,
@@ -50,7 +49,7 @@ class SettingActions {
static SettingActions litecoinMwebSettingAction = SettingActions._(
name: (context) => S.of(context).litecoin_mweb_settings,
image: 'assets/images/bitcoin_menu.png',
image: 'assets/images/litecoin_menu.png',
onTap: (BuildContext context) {
Navigator.pop(context);
Navigator.of(context).pushNamed(Routes.mwebSettings);
+2 -1
View File
@@ -37,7 +37,8 @@ abstract class AppStoreBase with Store {
@action
Future<void> changeCurrentWallet(
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet) async {
this.wallet?.close();
bool changingToSameWalletType = this.wallet?.type == wallet.type;
this.wallet?.close(shouldCleanup: !changingToSameWalletType);
this.wallet = wallet;
this.wallet!.setExceptionHandler(ExceptionHandler.onError);
@@ -1,3 +1,4 @@
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/entities/sort_balance_types.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
@@ -31,6 +32,7 @@ class BalanceRecord {
required this.fiatSecondAdditionalBalance,
required this.asset,
required this.formattedAssetTitle});
final String fiatAdditionalBalance;
final String fiatAvailableBalance;
final String fiatFrozenBalance;
@@ -53,7 +55,22 @@ abstract class BalanceViewModelBase with Store {
: isReversing = false,
isShowCard = appStore.wallet!.walletInfo.isShowIntroCakePayCard,
wallet = appStore.wallet! {
reaction((_) => appStore.wallet, _onWalletChange);
reaction((_) => appStore.wallet, (wallet) {
_onWalletChange(wallet);
_checkMweb();
});
_checkMweb();
reaction((_) => settingsStore.mwebAlwaysScan, (bool value) {
_checkMweb();
});
}
void _checkMweb() {
if (wallet.type == WalletType.litecoin) {
mwebEnabled = bitcoin!.getMwebEnabled(wallet);
}
}
final AppStore appStore;
@@ -336,14 +353,19 @@ abstract class BalanceViewModelBase with Store {
});
}
@observable
bool mwebEnabled = false;
@computed
bool get hasAdditionalBalance => _hasAdditionalBalanceForWalletType(wallet.type);
@computed
bool get hasSecondAdditionalBalance => _hasSecondAdditionalBalanceForWalletType(wallet.type);
bool get hasSecondAdditionalBalance =>
mwebEnabled && _hasSecondAdditionalBalanceForWalletType(wallet.type);
@computed
bool get hasSecondAvailableBalance => _hasSecondAvailableBalanceForWalletType(wallet.type);
bool get hasSecondAvailableBalance =>
mwebEnabled && _hasSecondAvailableBalanceForWalletType(wallet.type);
bool _hasAdditionalBalanceForWalletType(WalletType type) {
switch (type) {
@@ -358,15 +380,16 @@ abstract class BalanceViewModelBase with Store {
}
bool _hasSecondAdditionalBalanceForWalletType(WalletType type) {
if (wallet.type == WalletType.litecoin && settingsStore.mwebAlwaysScan) {
// if ((wallet.balance[CryptoCurrency.ltc]?.secondAdditional ?? 0) > 0)
return true;
if (wallet.type == WalletType.litecoin) {
if ((wallet.balance[CryptoCurrency.ltc]?.secondAdditional ?? 0) > 0) {
return true;
}
}
return false;
}
bool _hasSecondAvailableBalanceForWalletType(WalletType type) {
if (wallet.type == WalletType.litecoin && settingsStore.mwebAlwaysScan) {
if (wallet.type == WalletType.litecoin) {
return true;
}
return false;
@@ -1,4 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io' show Platform;
import 'package:cake_wallet/.secrets.g.dart' as secrets;
import 'package:cake_wallet/bitcoin/bitcoin.dart';
@@ -222,7 +224,10 @@ abstract class DashboardViewModelBase with Store {
// subname = nano!.getCurrentAccount(_wallet).label;
// }
reaction((_) => appStore.wallet, _onWalletChange);
reaction((_) => appStore.wallet, (wallet) {
_onWalletChange(wallet);
_checkMweb();
});
connectMapToListWithTransform(
appStore.wallet!.transactionHistory.transactions,
@@ -256,16 +261,16 @@ abstract class DashboardViewModelBase with Store {
});
}
_checkMweb();
reaction((_) => settingsStore.mwebAlwaysScan, (bool value) {
_checkMweb();
});
}
void _checkMweb() {
if (hasMweb) {
mwebScanningActive = bitcoin!.getMwebEnabled(wallet);
settingsStore.mwebEnabled = mwebScanningActive;
reaction((_) => settingsStore.mwebAlwaysScan, (bool alwaysScan) {
if (alwaysScan) {
mwebScanningActive = true;
} else {
mwebScanningActive = false;
}
});
mwebEnabled = bitcoin!.getMwebEnabled(wallet);
balanceViewModel.mwebEnabled = mwebEnabled;
}
}
@@ -430,34 +435,36 @@ abstract class DashboardViewModelBase with Store {
}
@computed
bool get hasMweb => wallet.type == WalletType.litecoin;
bool get hasMweb => wallet.type == WalletType.litecoin && (Platform.isIOS || Platform.isAndroid);
@computed
bool get showMwebCard => hasMweb && settingsStore.mwebCardDisplay && !mwebScanningActive;
bool get showMwebCard => hasMweb && settingsStore.mwebCardDisplay && !mwebEnabled;
@observable
bool mwebScanningActive = false;
bool mwebEnabled = false;
@computed
bool get hasEnabledMwebBefore => settingsStore.hasEnabledMwebBefore;
@action
void setMwebScanningActive() {
void setMwebEnabled() {
if (!hasMweb) {
return;
}
settingsStore.hasEnabledMwebBefore = true;
mwebScanningActive = true;
mwebEnabled = true;
bitcoin!.setMwebEnabled(wallet, true);
balanceViewModel.mwebEnabled = true;
settingsStore.mwebAlwaysScan = true;
}
@action
void dismissMweb() {
settingsStore.mwebCardDisplay = false;
balanceViewModel.mwebEnabled = false;
settingsStore.mwebAlwaysScan = false;
mwebScanningActive = false;
mwebEnabled = false;
bitcoin!.setMwebEnabled(wallet, false);
}
@@ -8,7 +8,10 @@ part 'mweb_settings_view_model.g.dart';
class MwebSettingsViewModel = MwebSettingsViewModelBase with _$MwebSettingsViewModel;
abstract class MwebSettingsViewModelBase with Store {
MwebSettingsViewModelBase(this._settingsStore, this._wallet);
MwebSettingsViewModelBase(this._settingsStore, this._wallet) {
mwebEnabled = bitcoin!.getMwebEnabled(_wallet);
_settingsStore.mwebAlwaysScan = mwebEnabled;
}
final SettingsStore _settingsStore;
final WalletBase _wallet;
@@ -16,8 +19,8 @@ abstract class MwebSettingsViewModelBase with Store {
@computed
bool get mwebCardDisplay => _settingsStore.mwebCardDisplay;
@computed
bool get mwebAlwaysScan => _settingsStore.mwebAlwaysScan;
@observable
late bool mwebEnabled;
@action
void setMwebCardDisplay(bool value) {
@@ -25,8 +28,9 @@ abstract class MwebSettingsViewModelBase with Store {
}
@action
void setMwebAlwaysScan(bool value) {
_settingsStore.mwebAlwaysScan = value;
void setMwebEnabled(bool value) {
mwebEnabled = value;
bitcoin!.setMwebEnabled(_wallet, value);
_settingsStore.mwebAlwaysScan = value;
}
}
+25 -23
View File
@@ -188,36 +188,38 @@ abstract class WalletCreationVMBase with Store {
}
}
Future<List<DerivationInfo>> getDerivationInfoFromQRCredentials(RestoredWallet restoreWallet) async {
var list = <DerivationInfo>[];
final walletType = restoreWallet.type;
var appStore = getIt.get<AppStore>();
var node = appStore.settingsStore.getCurrentNode(walletType);
Future<List<DerivationInfo>> getDerivationInfoFromQRCredentials(
RestoredWallet restoreWallet) async {
var list = <DerivationInfo>[];
final walletType = restoreWallet.type;
var appStore = getIt.get<AppStore>();
var node = appStore.settingsStore.getCurrentNode(walletType);
switch (walletType) {
case WalletType.bitcoin:
case WalletType.litecoin:
return bitcoin!.getDerivationsFromMnemonic(
mnemonic: restoreWallet.mnemonicSeed!,
node: node,
passphrase: restoreWallet.passphrase,
);
case WalletType.nano:
return nanoUtil!.getDerivationsFromMnemonic(
mnemonic: restoreWallet.mnemonicSeed!,
node: node,
);
default:
break;
}
return list;
switch (walletType) {
case WalletType.bitcoin:
case WalletType.litecoin:
return bitcoin!.getDerivationsFromMnemonic(
mnemonic: restoreWallet.mnemonicSeed!,
node: node,
passphrase: restoreWallet.passphrase,
);
case WalletType.nano:
return nanoUtil!.getDerivationsFromMnemonic(
mnemonic: restoreWallet.mnemonicSeed!,
node: node,
);
default:
break;
}
return list;
}
WalletCredentials getCredentials(dynamic options) => throw UnimplementedError();
Future<WalletBase> process(WalletCredentials credentials) => throw UnimplementedError();
Future<WalletCredentials> getWalletCredentialsFromQRCredentials(RestoredWallet restoreWallet) async =>
Future<WalletCredentials> getWalletCredentialsFromQRCredentials(
RestoredWallet restoreWallet) async =>
throw UnimplementedError();
Future<WalletBase> processFromRestoredWallet(
@@ -70,6 +70,8 @@ abstract class WalletListViewModelBase with Store {
@action
Future<void> loadWallet(WalletListItem walletItem) async {
// bool switchingToSameWalletType = walletItem.type == _appStore.wallet?.type;
// await _appStore.wallet?.close(shouldCleanup: !switchingToSameWalletType);
final wallet = await _walletLoadingService.load(walletItem.type, walletItem.name);
await _appStore.changeCurrentWallet(wallet);
}