Fixes for LTC and added banner for old bitcoin electrum wallets.

This commit is contained in:
M 2021-05-11 16:52:48 +03:00
parent b096123ea1
commit a439560d4d
25 changed files with 205 additions and 79 deletions

View file

@ -362,7 +362,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 38;
CURRENT_PROJECT_VERSION = 39;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -505,7 +505,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 38;
CURRENT_PROJECT_VERSION = 39;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -540,7 +540,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 38;
CURRENT_PROJECT_VERSION = 39;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (

View file

@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
@ -38,8 +36,8 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -61,8 +59,6 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"

View file

@ -26,6 +26,8 @@ class BitcoinTransactionPriority extends TransactionPriority {
}
}
String get units => 'sat';
@override
String toString() {
var label = '';
@ -46,4 +48,56 @@ class BitcoinTransactionPriority extends TransactionPriority {
return label;
}
String labelWithRate(int rate) => '${toString()} ($rate ${units}/byte)';
}
class LitecoinTransactionPriority extends BitcoinTransactionPriority {
const LitecoinTransactionPriority({String title, int raw})
: super(title: title, raw: raw);
static const List<LitecoinTransactionPriority> all = [fast, medium, slow];
static const LitecoinTransactionPriority slow =
LitecoinTransactionPriority(title: 'Slow', raw: 0);
static const LitecoinTransactionPriority medium =
LitecoinTransactionPriority(title: 'Medium', raw: 1);
static const LitecoinTransactionPriority fast =
LitecoinTransactionPriority(title: 'Fast', raw: 2);
static LitecoinTransactionPriority deserialize({int raw}) {
switch (raw) {
case 0:
return slow;
case 1:
return medium;
case 2:
return fast;
default:
return null;
}
}
@override
String get units => 'Latoshi';
@override
String toString() {
var label = '';
switch (this) {
case LitecoinTransactionPriority.slow:
label = S.current.transaction_priority_slow;
break;
case LitecoinTransactionPriority.medium:
label = S.current.transaction_priority_medium;
break;
case LitecoinTransactionPriority.fast:
label = S.current.transaction_priority_fast;
break;
default:
break;
}
return label;
}
}

View file

@ -72,13 +72,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
@override
int feeRate(TransactionPriority priority) {
if (priority is BitcoinTransactionPriority) {
if (priority is LitecoinTransactionPriority) {
switch (priority) {
case BitcoinTransactionPriority.slow:
case LitecoinTransactionPriority.slow:
return 1;
case BitcoinTransactionPriority.medium:
case LitecoinTransactionPriority.medium:
return 2;
case BitcoinTransactionPriority.fast:
case LitecoinTransactionPriority.fast:
return 3;
}
}

View file

@ -74,7 +74,7 @@ Future<void> main() async {
if (!Hive.isAdapterRegistered(Order.typeId)) {
Hive.registerAdapter(OrderAdapter());
}
final secureStorage = FlutterSecureStorage();
final transactionDescriptionsBoxKey = await getEncryptionKey(
secureStorage: secureStorage, forKey: TransactionDescription.boxKey);

View file

@ -16,6 +16,7 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -26,8 +27,8 @@ class DashboardPage extends BasePage {
});
@override
Color get backgroundLightColor => currentTheme.type == ThemeType.bright
? Colors.transparent : Colors.white;
Color get backgroundLightColor =>
currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white;
@override
Color get backgroundDarkColor => Colors.transparent;
@ -56,9 +57,8 @@ class DashboardPage extends BasePage {
@override
Widget trailing(BuildContext context) {
final menuButton =
Image.asset('assets/images/menu.png',
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
final menuButton = Image.asset('assets/images/menu.png',
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
return Container(
alignment: Alignment.centerRight,
@ -81,15 +81,18 @@ class DashboardPage extends BasePage {
@override
Widget body(BuildContext context) {
final sendImage = Image.asset('assets/images/upload.png',
height: 22.24, width: 24,
height: 22.24,
width: 24,
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
final exchangeImage = Image.asset('assets/images/transfer.png',
height: 24.27, width: 22.25,
height: 24.27,
width: 22.25,
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
final buyImage = Image.asset('assets/images/coins.png',
height: 22.24, width: 24,
height: 22.24,
width: 24,
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
_setEffects();
_setEffects(context);
return SafeArea(
child: Column(
@ -111,7 +114,9 @@ class DashboardPage extends BasePage {
dotWidth: 6.0,
dotHeight: 6.0,
dotColor: Theme.of(context).indicatorColor,
activeDotColor: Theme.of(context).accentTextTheme.display1
activeDotColor: Theme.of(context)
.accentTextTheme
.display1
.backgroundColor),
)),
Container(
@ -129,25 +134,27 @@ class DashboardPage extends BasePage {
route: Routes.exchange),
Observer(
builder: (_) => Stack(
clipBehavior: Clip.none,
alignment: Alignment.topCenter,
children: [
if (walletViewModel.isRunningWebView) Positioned(
top: -5,
child: SpinKitRing(
color: Theme.of(context).buttonColor,
lineWidth: 3,
size: 70.0,
),
),
ActionButton(
image: buyImage,
title: S.of(context).buy,
onClick: walletViewModel.isRunningWebView
? null
: () async => await _onClickBuyButton(context))
],
)),
clipBehavior: Clip.none,
alignment: Alignment.topCenter,
children: [
if (walletViewModel.isRunningWebView)
Positioned(
top: -5,
child: SpinKitRing(
color: Theme.of(context).buttonColor,
lineWidth: 3,
size: 70.0,
),
),
ActionButton(
image: buyImage,
title: S.of(context).buy,
onClick: walletViewModel.isRunningWebView
? null
: () async =>
await _onClickBuyButton(context))
],
)),
],
),
)
@ -155,7 +162,7 @@ class DashboardPage extends BasePage {
));
}
void _setEffects() {
void _setEffects(BuildContext context) {
if (_isEffectsInstalled) {
return;
}
@ -164,14 +171,42 @@ class DashboardPage extends BasePage {
pages.add(BalancePage(dashboardViewModel: walletViewModel));
pages.add(TransactionsPage(dashboardViewModel: walletViewModel));
autorun((_) async {
if (!walletViewModel.isOutdatedElectrumWallet) {
return;
}
await Future<void>.delayed(Duration(seconds: 1));
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).pre_seed_title,
alertContent:
S.of(context).outdated_electrum_wallet_desceription,
buttonText: S.of(context).understand,
buttonAction: () => Navigator.of(context).pop());
});
});
_isEffectsInstalled = true;
}
Future <void> _onClickBuyButton(BuildContext context) async {
Future<void> _onClickBuyButton(BuildContext context) async {
final walletType = walletViewModel.type;
switch (walletType) {
case WalletType.monero:
case WalletType.bitcoin:
try {
walletViewModel.isRunningWebView = true;
final url = await walletViewModel.wyreViewModel.wyreUrl;
await Navigator.of(context).pushNamed(Routes.wyre, arguments: url);
walletViewModel.isRunningWebView = false;
} catch (_) {
walletViewModel.isRunningWebView = false;
}
break;
default:
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
@ -182,16 +217,6 @@ class DashboardPage extends BasePage {
buttonAction: () => Navigator.of(context).pop());
});
break;
default:
try {
walletViewModel.isRunningWebView = true;
final url = await walletViewModel.wyreViewModel.wyreUrl;
await Navigator.of(context).pushNamed(Routes.wyre, arguments: url);
walletViewModel.isRunningWebView = false;
} catch(_) {
walletViewModel.isRunningWebView = false;
}
break;
}
}
}

View file

@ -234,6 +234,10 @@ abstract class DashboardViewModelBase with Store {
await wallet.connectToNode(node: node);
}
@computed
bool get isOutdatedElectrumWallet =>
wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24;
@action
void _onWalletChange(
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,

View file

@ -372,7 +372,7 @@ abstract class SendViewModelBase with Store {
if (wallet is ElectrumWallet) {
final rate = wallet.feeRate(_priority);
return '${priority.toString()} ($rate sat/byte)';
return '${priority.labelWithRate(rate)}';
}
return priority.toString();

View file

@ -39,7 +39,7 @@ List<TransactionPriority> priorityForWalletType(WalletType type) {
case WalletType.bitcoin:
return BitcoinTransactionPriority.all;
case WalletType.litecoin:
return BitcoinTransactionPriority.all;
return LitecoinTransactionPriority.all;
default:
return [];
}
@ -87,7 +87,7 @@ abstract class SettingsViewModelBase with Store {
if (wallet is ElectrumWallet) {
final rate = wallet.feeRate(_priority);
return '${priority.toString()} ($rate sat/byte)';
return '${priority.labelWithRate(rate)}';
}
return priority.toString();

View file

@ -1,7 +1,3 @@
import 'package:cake_wallet/core/transaction_history.dart';
import 'package:cake_wallet/entities/balance.dart';
import 'package:cake_wallet/entities/transaction_info.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
@ -12,6 +8,11 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_h
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/bitcoin/electrum_wallet.dart';
import 'package:cake_wallet/core/transaction_history.dart';
import 'package:cake_wallet/entities/balance.dart';
import 'package:cake_wallet/entities/transaction_info.dart';
import 'package:cake_wallet/store/app_store.dart';
part 'wallet_address_list_view_model.g.dart';
@ -175,7 +176,7 @@ abstract class WalletAddressListViewModelBase with Store {
void nextAddress() {
final wallet = _wallet;
if (wallet is BitcoinWallet) {
if (wallet is ElectrumWallet) {
wallet.nextAddress();
}
}

View file

@ -11,7 +11,7 @@ description: Cake 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: 4.2.0+48
version: 4.2.0+49
environment:
sdk: ">=2.7.0 <3.0.0"

View file

@ -471,5 +471,8 @@
"submit_request" : "Einen Antrag stellen",
"buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser"
"buy_alert_content" : "Derzeit unterstützen wir nur den Kauf von Bitcoin. Um Bitcoin zu kaufen, erstellen Sie bitte Ihre Bitcoin-Brieftasche oder wechseln Sie zu dieser",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "submit a request",
"buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet"
"buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "presentar una solicitud",
"buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin"
"buy_alert_content" : "Actualmente solo apoyamos la compra de Bitcoin. Para comprar Bitcoin, cree o cambie a su billetera Bitcoin",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "एक अनुरोध सबमिट करें",
"buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें"
"buy_alert_content" : "वर्तमान में हम केवल बिटकॉइन की खरीद का समर्थन करते हैं। बिटकॉइन खरीदने के लिए, कृपया अपना बिटकॉइन वॉलेट बनाएं या स्विच करें",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -469,5 +469,10 @@
"unconfirmed" : "Nepotvrđeno",
"displayable" : "Dostupno za prikaz",
"submit_request" : "podnesi zahtjev"
"submit_request" : "podnesi zahtjev",
"buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -469,5 +469,10 @@
"unconfirmed" : "Non confermato",
"displayable" : "Visualizzabile",
"submit_request" : "invia una richiesta"
"submit_request" : "invia una richiesta",
"buy_alert_content" : "Currently we only support the purchase of Bitcoin. To buy Bitcoin, please create or switch to your Bitcoin wallet",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "リクエストを送信する",
"buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください"
"buy_alert_content" : "現在、ビットコインの購入のみをサポートしています。 ビットコインを購入するには、ビットコインウォレットを作成するか切り替えてください",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "요청을 제출",
"buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오"
"buy_alert_content" : "현재 우리는 비트 코인 구매 만 지원합니다. 비트 코인을 구매하려면 비트 코인 지갑을 생성하거나 전환하십시오",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "een verzoek indienen",
"buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen"
"buy_alert_content" : "Momenteel ondersteunen we alleen de aankoop van Bitcoin. Om Bitcoin te kopen, moet u uw Bitcoin-portemonnee aanmaken of naar uw Bitcoin-portemonnee overschakelen",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "złożyć wniosek",
"buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin"
"buy_alert_content" : "Obecnie obsługujemy tylko zakup Bitcoinów. Aby kupić Bitcoin, utwórz lub przełącz się na swój portfel Bitcoin",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "enviar um pedido",
"buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin"
"buy_alert_content" : "Atualmente, apoiamos apenas a compra de Bitcoin. Para comprar Bitcoin, crie ou mude para sua carteira Bitcoin",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "отправить запрос",
"buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек"
"buy_alert_content" : "В настоящее время мы поддерживаем только покупку Bitcoin. Чтобы купить Bitcoin, создайте или переключитесь на ваш Bitcoin кошелек",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -471,5 +471,8 @@
"submit_request" : "надіслати запит",
"buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець"
"buy_alert_content" : "На даний час ми підтримуємо тільки покупку Bitcoin. Щоб купити Bitcoin, будь ласка, створіть або переключіться на ваш Bitcoin гаманець",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}

View file

@ -468,5 +468,8 @@
"unconfirmed" : "未经证实",
"displayable" : "可显示",
"submit_request" : "提交请求",
"buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包"
"buy_alert_content" : "目前,我們僅支持購買比特幣。 要購買比特幣,請創建或切換到您的比特幣錢包",
"outdated_electrum_wallet_desceription" : "New Bitcoin wallets created in Cake now have the 24-word seed. It is mandatory that you create a new Bitcoin wallet and transfer all of your funds to the new 24-seed wallet and stop using wallets with the 12-word seed. Please do this immediately to secure your funds.",
"understand" : "I undersand"
}