Added validation for bitcoin seed. Changed transaction properties for bitcoin wallet type. Added special text after sending for bitcoin.

M committed Dec 3, 2020 at 21:34 UTC 93653d4554697d28f16572f89ef1203f90c9601d
8 files changed +53 -32
lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart new
+5
@@ -0,0 +1,5 @@
1 +class BitcoinMnemonicIsIncorrectException implements Exception {
2 + @override
3 + String toString() =>
4 + 'Bitcoin mnemonic has incorrect format. Mnemonic should contain 12 words separated by space.';
5 +}
lib/bitcoin/bitcoin_wallet_service.dart
+5
@@ -1,5 +1,6 @@
1 import 'dart:io';
2 import 'package:cake_wallet/bitcoin/bitcoin_mnemonic.dart';
3 +import 'package:cake_wallet/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart';
4 import 'package:cake_wallet/bitcoin/file.dart';
5 import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
6 import 'package:cake_wallet/core/wallet_base.dart';
@@ -74,6 +75,10 @@ class BitcoinWalletService extends WalletService<
75 @override
76 Future<BitcoinWallet> restoreFromSeed(
77 BitcoinRestoreWalletFromSeedCredentials credentials) async {
78 + if (!validateMnemonic(credentials.mnemonic)) {
79 + throw BitcoinMnemonicIsIncorrectException();
80 + }
81 +
82 final dirPath = await pathForWalletDir(
83 type: WalletType.bitcoin, name: credentials.name);
84 final wallet = BitcoinWalletBase.build(
lib/entities/transaction_priority.dart
+17
@@ -1,3 +1,4 @@
1 +import 'package:cake_wallet/entities/wallet_type.dart';
2 import 'package:cake_wallet/generated/i18n.dart';
3 import 'package:cake_wallet/entities/enumerable_item.dart';
4
@@ -19,6 +20,22 @@ class TransactionPriority extends EnumerableItem<int> with Serializable<int> {
20 static const fastest = TransactionPriority(title: 'Fastest', raw: 4);
21 static const standart = slow;
22
23 +
24 + static List<TransactionPriority> forWalletType(WalletType type) {
25 + switch (type) {
26 + case WalletType.monero:
27 + return TransactionPriority.all;
28 + case WalletType.bitcoin:
29 + return [
30 + TransactionPriority.slow,
31 + TransactionPriority.regular,
32 + TransactionPriority.fast
33 + ];
34 + default:
35 + return [];
36 + }
37 + }
38 +
39 static TransactionPriority deserialize({int raw}) {
40 switch (raw) {
41 case 0:
lib/generated/i18n.dart
+12 -12
@@ -206,7 +206,7 @@ class S implements WidgetsLocalizations {
206 String get send_new => "New";
207 String get send_payment_id => "Payment ID (optional)";
208 String get send_sending => "Sending...";
209 - String get send_success => "Your Monero was successfully sent";
209 + String send_success(String crypto) => "Your ${crypto} was successfully sent";
210 String get send_templates => "Templates";
211 String get send_title => "Send";
212 String get send_xmr => "Send XMR";
@@ -612,7 +612,7 @@ class $de extends S {
612 @override
613 String get trade_details_created_at => "Hergestellt in";
614 @override
615 - String get send_success => "Ihr Monero wurde erfolgreich gesendet";
615 + String send_success(String crypto) => "Ihr ${crypto} wurde erfolgreich gesendet";
616 @override
617 String get settings_wallets => "Brieftaschen";
618 @override
@@ -1280,7 +1280,7 @@ class $hi extends S {
1280 @override
1281 String get trade_details_created_at => "पर बनाया गया";
1282 @override
1283 - String get send_success => "आपका Monero सफलतापूर्वक भेजा गया";
1283 + String send_success(String crypto) => "आपका ${crypto} सफलतापूर्वक भेजा गया";
1284 @override
1285 String get settings_wallets => "पर्स";
1286 @override
@@ -1948,7 +1948,7 @@ class $ru extends S {
1948 @override
1949 String get trade_details_created_at => "Создано";
1950 @override
1951 - String get send_success => "Ваш Monero был успешно отправлен";
1951 + String send_success(String crypto) => "Ваш ${crypto} был успешно отправлен";
1952 @override
1953 String get settings_wallets => "Кошельки";
1954 @override
@@ -2616,7 +2616,7 @@ class $ko extends S {
2616 @override
2617 String get trade_details_created_at => "에 작성";
2618 @override
2619 - String get send_success => "Monero가 성공적으로 전송되었습니다";
2619 + String send_success(String crypto) => "${crypto}가 성공적으로 전송되었습니다";
2620 @override
2621 String get settings_wallets => "지갑";
2622 @override
@@ -3284,7 +3284,7 @@ class $pt extends S {
3284 @override
3285 String get trade_details_created_at => "Criada em";
3286 @override
3287 - String get send_success => "Seu Monero foi enviado com sucesso";
3287 + String send_success(String crypto) => "Seu ${crypto} foi enviado com sucesso";
3288 @override
3289 String get settings_wallets => "Carteiras";
3290 @override
@@ -3952,7 +3952,7 @@ class $uk extends S {
3952 @override
3953 String get trade_details_created_at => "Створено";
3954 @override
3955 - String get send_success => "Ваш Monero успішно надісланий";
3955 + String send_success(String crypto) => "Ваш ${crypto} успішно надісланий";
3956 @override
3957 String get settings_wallets => "Гаманці";
3958 @override
@@ -4620,7 +4620,7 @@ class $ja extends S {
4620 @override
4621 String get trade_details_created_at => "で作成";
4622 @override
4623 - String get send_success => "Moneroが送信されました";
4623 + String send_success(String crypto) => "${crypto}が送信されました";
4624 @override
4625 String get settings_wallets => "財布";
4626 @override
@@ -5292,7 +5292,7 @@ class $pl extends S {
5292 @override
5293 String get trade_details_created_at => "Utworzono w";
5294 @override
5295 - String get send_success => "Twoje Monero zostało pomyślnie wysłane";
5295 + String send_success(String crypto) => "Twoje ${crypto} zostało pomyślnie wysłane";
5296 @override
5297 String get settings_wallets => "Portfele";
5298 @override
@@ -5960,7 +5960,7 @@ class $es extends S {
5960 @override
5961 String get trade_details_created_at => "Creado en";
5962 @override
5963 - String get send_success => "Su Monero fue enviado con éxito";
5963 + String send_success(String crypto) => "Su ${crypto} fue enviado con éxito";
5964 @override
5965 String get settings_wallets => "Carteras";
5966 @override
@@ -6628,7 +6628,7 @@ class $nl extends S {
6628 @override
6629 String get trade_details_created_at => "Gemaakt bij";
6630 @override
6631 - String get send_success => "Uw Monero is succesvol verzonden";
6631 + String send_success(String crypto) => "Uw ${crypto} is succesvol verzonden";
6632 @override
6633 String get settings_wallets => "Portemonnee";
6634 @override
@@ -7296,7 +7296,7 @@ class $zh extends S {
7296 @override
7297 String get trade_details_created_at => "创建于";
7298 @override
7299 - String get send_success => "你Monero已成功發送";
7299 + String send_success(String crypto) => "你${crypto}已成功發送";
7300 @override
7301 String get settings_wallets => "皮夹";
7302 @override
lib/src/screens/exchange_trade/exchange_trade_page.dart
+7 -2
@@ -227,7 +227,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
227 final sendingState =
228 widget.exchangeTradeViewModel.sendViewModel.state;
229
230 - return trade.from == CryptoCurrency.xmr && !(sendingState is TransactionCommitted)
230 + return trade.from == CryptoCurrency.xmr &&
231 + !(sendingState is TransactionCommitted)
232 ? LoadingPrimaryButton(
233 isDisabled: trade.inputAddress == null ||
234 trade.inputAddress.isEmpty,
@@ -306,7 +307,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
307 padding: EdgeInsets.only(
308 top: 220, left: 24, right: 24),
309 child: Text(
309 - S.of(context).send_success,
310 + S.of(context).send_success(widget
311 + .exchangeTradeViewModel
312 + .wallet
313 + .currency
314 + .toString()),
315 textAlign: TextAlign.center,
316 style: TextStyle(
317 fontSize: 22,
lib/src/screens/send/send_page.dart
+5 -2
@@ -634,7 +634,9 @@ class SendPage extends BasePage {
634 padding: EdgeInsets.only(
635 top: 220, left: 24, right: 24),
636 child: Text(
637 - S.of(context).send_success,
637 + S.of(context).send_success(
638 + sendViewModel.currency
639 + .toString()),
640 textAlign: TextAlign.center,
641 style: TextStyle(
642 fontSize: 22,
@@ -748,7 +750,8 @@ class SendPage extends BasePage {
750 }
751
752 Future<void> _setTransactionPriority(BuildContext context) async {
751 - final items = TransactionPriority.all;
753 + final items =
754 + TransactionPriority.forWalletType(sendViewModel.walletType);
755 final selectedItem = items.indexOf(sendViewModel.transactionPriority);
756
757 await showPopUp<void>(
lib/view_model/send/send_view_model.dart
+1
@@ -97,6 +97,7 @@ abstract class SendViewModelBase with Store {
97 @computed
98 ObservableList<Template> get templates => _sendTemplateStore.templates;
99
100 + WalletType get walletType => _wallet.type;
101 final WalletBase _wallet;
102 final SettingsStore _settingsStore;
103 final SendTemplateStore _sendTemplateStore;
lib/view_model/settings/settings_view_model.dart
+1 -16
@@ -50,7 +50,7 @@ abstract class SettingsViewModelBase with Store {
50 setFiatCurrency(currency)),
51 PickerListItem(
52 title: S.current.settings_fee_priority,
53 - items: _transactionPriorities(wallet.type),
53 + items: TransactionPriority.forWalletType(wallet.type),
54 selectedItem: () => transactionPriority,
55 isAlwaysShowScrollThumb: true,
56 onItemSelected: (TransactionPriority priority) =>
@@ -234,19 +234,4 @@ abstract class SettingsViewModelBase with Store {
234
235 @action
236 void _showTrades() => actionlistDisplayMode.add(ActionListDisplayMode.trades);
237 -
238 - static List<TransactionPriority> _transactionPriorities(WalletType type) {
239 - switch (type) {
240 - case WalletType.monero:
241 - return TransactionPriority.all;
242 - case WalletType.bitcoin:
243 - return [
244 - TransactionPriority.slow,
245 - TransactionPriority.regular,
246 - TransactionPriority.fast
247 - ];
248 - default:
249 - return [];
250 - }
251 - }
237 }