mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Added validation for bitcoin seed. Changed transaction properties for bitcoin wallet type. Added special text after sending for bitcoin.
This commit is contained in:
parent
62a877dd61
commit
93653d4554
8 changed files with 53 additions and 32 deletions
5
lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart
Normal file
5
lib/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
class BitcoinMnemonicIsIncorrectException implements Exception {
|
||||
@override
|
||||
String toString() =>
|
||||
'Bitcoin mnemonic has incorrect format. Mnemonic should contain 12 words separated by space.';
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:io';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_mnemonic.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart';
|
||||
import 'package:cake_wallet/bitcoin/file.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
|
@ -74,6 +75,10 @@ class BitcoinWalletService extends WalletService<
|
|||
@override
|
||||
Future<BitcoinWallet> restoreFromSeed(
|
||||
BitcoinRestoreWalletFromSeedCredentials credentials) async {
|
||||
if (!validateMnemonic(credentials.mnemonic)) {
|
||||
throw BitcoinMnemonicIsIncorrectException();
|
||||
}
|
||||
|
||||
final dirPath = await pathForWalletDir(
|
||||
type: WalletType.bitcoin, name: credentials.name);
|
||||
final wallet = BitcoinWalletBase.build(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/entities/enumerable_item.dart';
|
||||
|
||||
|
@ -19,6 +20,22 @@ class TransactionPriority extends EnumerableItem<int> with Serializable<int> {
|
|||
static const fastest = TransactionPriority(title: 'Fastest', raw: 4);
|
||||
static const standart = slow;
|
||||
|
||||
|
||||
static List<TransactionPriority> forWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
return TransactionPriority.all;
|
||||
case WalletType.bitcoin:
|
||||
return [
|
||||
TransactionPriority.slow,
|
||||
TransactionPriority.regular,
|
||||
TransactionPriority.fast
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
static TransactionPriority deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
|
|
|
@ -206,7 +206,7 @@ class S implements WidgetsLocalizations {
|
|||
String get send_new => "New";
|
||||
String get send_payment_id => "Payment ID (optional)";
|
||||
String get send_sending => "Sending...";
|
||||
String get send_success => "Your Monero was successfully sent";
|
||||
String send_success(String crypto) => "Your ${crypto} was successfully sent";
|
||||
String get send_templates => "Templates";
|
||||
String get send_title => "Send";
|
||||
String get send_xmr => "Send XMR";
|
||||
|
@ -612,7 +612,7 @@ class $de extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Hergestellt in";
|
||||
@override
|
||||
String get send_success => "Ihr Monero wurde erfolgreich gesendet";
|
||||
String send_success(String crypto) => "Ihr ${crypto} wurde erfolgreich gesendet";
|
||||
@override
|
||||
String get settings_wallets => "Brieftaschen";
|
||||
@override
|
||||
|
@ -1280,7 +1280,7 @@ class $hi extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "पर बनाया गया";
|
||||
@override
|
||||
String get send_success => "आपका Monero सफलतापूर्वक भेजा गया";
|
||||
String send_success(String crypto) => "आपका ${crypto} सफलतापूर्वक भेजा गया";
|
||||
@override
|
||||
String get settings_wallets => "पर्स";
|
||||
@override
|
||||
|
@ -1948,7 +1948,7 @@ class $ru extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Создано";
|
||||
@override
|
||||
String get send_success => "Ваш Monero был успешно отправлен";
|
||||
String send_success(String crypto) => "Ваш ${crypto} был успешно отправлен";
|
||||
@override
|
||||
String get settings_wallets => "Кошельки";
|
||||
@override
|
||||
|
@ -2616,7 +2616,7 @@ class $ko extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "에 작성";
|
||||
@override
|
||||
String get send_success => "Monero가 성공적으로 전송되었습니다";
|
||||
String send_success(String crypto) => "${crypto}가 성공적으로 전송되었습니다";
|
||||
@override
|
||||
String get settings_wallets => "지갑";
|
||||
@override
|
||||
|
@ -3284,7 +3284,7 @@ class $pt extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Criada em";
|
||||
@override
|
||||
String get send_success => "Seu Monero foi enviado com sucesso";
|
||||
String send_success(String crypto) => "Seu ${crypto} foi enviado com sucesso";
|
||||
@override
|
||||
String get settings_wallets => "Carteiras";
|
||||
@override
|
||||
|
@ -3952,7 +3952,7 @@ class $uk extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Створено";
|
||||
@override
|
||||
String get send_success => "Ваш Monero успішно надісланий";
|
||||
String send_success(String crypto) => "Ваш ${crypto} успішно надісланий";
|
||||
@override
|
||||
String get settings_wallets => "Гаманці";
|
||||
@override
|
||||
|
@ -4620,7 +4620,7 @@ class $ja extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "で作成";
|
||||
@override
|
||||
String get send_success => "Moneroが送信されました";
|
||||
String send_success(String crypto) => "${crypto}が送信されました";
|
||||
@override
|
||||
String get settings_wallets => "財布";
|
||||
@override
|
||||
|
@ -5292,7 +5292,7 @@ class $pl extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Utworzono w";
|
||||
@override
|
||||
String get send_success => "Twoje Monero zostało pomyślnie wysłane";
|
||||
String send_success(String crypto) => "Twoje ${crypto} zostało pomyślnie wysłane";
|
||||
@override
|
||||
String get settings_wallets => "Portfele";
|
||||
@override
|
||||
|
@ -5960,7 +5960,7 @@ class $es extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Creado en";
|
||||
@override
|
||||
String get send_success => "Su Monero fue enviado con éxito";
|
||||
String send_success(String crypto) => "Su ${crypto} fue enviado con éxito";
|
||||
@override
|
||||
String get settings_wallets => "Carteras";
|
||||
@override
|
||||
|
@ -6628,7 +6628,7 @@ class $nl extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "Gemaakt bij";
|
||||
@override
|
||||
String get send_success => "Uw Monero is succesvol verzonden";
|
||||
String send_success(String crypto) => "Uw ${crypto} is succesvol verzonden";
|
||||
@override
|
||||
String get settings_wallets => "Portemonnee";
|
||||
@override
|
||||
|
@ -7296,7 +7296,7 @@ class $zh extends S {
|
|||
@override
|
||||
String get trade_details_created_at => "创建于";
|
||||
@override
|
||||
String get send_success => "你Monero已成功發送";
|
||||
String send_success(String crypto) => "你${crypto}已成功發送";
|
||||
@override
|
||||
String get settings_wallets => "皮夹";
|
||||
@override
|
||||
|
|
|
@ -227,7 +227,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
final sendingState =
|
||||
widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
|
||||
return trade.from == CryptoCurrency.xmr && !(sendingState is TransactionCommitted)
|
||||
return trade.from == CryptoCurrency.xmr &&
|
||||
!(sendingState is TransactionCommitted)
|
||||
? LoadingPrimaryButton(
|
||||
isDisabled: trade.inputAddress == null ||
|
||||
trade.inputAddress.isEmpty,
|
||||
|
@ -306,7 +307,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
padding: EdgeInsets.only(
|
||||
top: 220, left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(context).send_success,
|
||||
S.of(context).send_success(widget
|
||||
.exchangeTradeViewModel
|
||||
.wallet
|
||||
.currency
|
||||
.toString()),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
|
|
|
@ -634,7 +634,9 @@ class SendPage extends BasePage {
|
|||
padding: EdgeInsets.only(
|
||||
top: 220, left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(context).send_success,
|
||||
S.of(context).send_success(
|
||||
sendViewModel.currency
|
||||
.toString()),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
|
@ -748,7 +750,8 @@ class SendPage extends BasePage {
|
|||
}
|
||||
|
||||
Future<void> _setTransactionPriority(BuildContext context) async {
|
||||
final items = TransactionPriority.all;
|
||||
final items =
|
||||
TransactionPriority.forWalletType(sendViewModel.walletType);
|
||||
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
||||
|
||||
await showPopUp<void>(
|
||||
|
|
|
@ -97,6 +97,7 @@ abstract class SendViewModelBase with Store {
|
|||
@computed
|
||||
ObservableList<Template> get templates => _sendTemplateStore.templates;
|
||||
|
||||
WalletType get walletType => _wallet.type;
|
||||
final WalletBase _wallet;
|
||||
final SettingsStore _settingsStore;
|
||||
final SendTemplateStore _sendTemplateStore;
|
||||
|
|
|
@ -50,7 +50,7 @@ abstract class SettingsViewModelBase with Store {
|
|||
setFiatCurrency(currency)),
|
||||
PickerListItem(
|
||||
title: S.current.settings_fee_priority,
|
||||
items: _transactionPriorities(wallet.type),
|
||||
items: TransactionPriority.forWalletType(wallet.type),
|
||||
selectedItem: () => transactionPriority,
|
||||
isAlwaysShowScrollThumb: true,
|
||||
onItemSelected: (TransactionPriority priority) =>
|
||||
|
@ -234,19 +234,4 @@ abstract class SettingsViewModelBase with Store {
|
|||
|
||||
@action
|
||||
void _showTrades() => actionlistDisplayMode.add(ActionListDisplayMode.trades);
|
||||
|
||||
static List<TransactionPriority> _transactionPriorities(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
return TransactionPriority.all;
|
||||
case WalletType.bitcoin:
|
||||
return [
|
||||
TransactionPriority.slow,
|
||||
TransactionPriority.regular,
|
||||
TransactionPriority.fast
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue