CW-432-Add-Bitcoin-Cash-BCH (#1041)

* initial commit

* creating and restoring a wallet

* [skip ci] add transaction priority

* fix send and unspent screen

* fix transaction priority type

* replace Unspend with BitcoinUnspent

* add transaction creation

* fix transaction details screen

* minor fix

* fix create side wallet

* basic transaction creation flow

* fix fiat amount calculation

* edit wallet

* minor fix

* fix address book parsing

* merge commit fixes

* minor fixes

* Update gradle.properties

* fix bch unspent coins

* minor fix

* fix BitcoinCashTransactionPriority

* Fetch tags first before switching to one of them

* Update build_haven.sh

* Update build_haven.sh

* Update build_haven.sh

* Update build_haven.sh

* update transaction build function

* Update build_haven.sh

* add ability to rename and delete

* fix address format

* Update pubspec.lock

* Revert "fix address format"

This reverts commit 1549bf4d8c3bdb0addbd6e3c5f049ebc3799ff8f.

* fix address format for exange

* restore from qr

* Update configure.dart

* [skip ci] minor fix

* fix default fee rate

* Update onramper_buy_provider.dart

* Update wallet_address_list_view_model.dart

* PR comments fixes

* Update exchange_view_model.dart

* fix merge conflict

* Update address_validator.dart

* merge fixes

* update initialMigrationVersion

* move cw_bitbox to Cake tech

* PR fixes

* PR fixes

* Fix configure.dart brackets

* update the new version text after macos 

* dummy change to run workflow

* Fix Nano restore from QR issue
Fix Conflicts with main

* PR fixes

* Update app_config.sh 

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
Serhii
2023-10-13 01:50:16 +03:00
committed by GitHub
co-authored by Omar Hatem
parent acb0517871
commit 66301ff247
88 changed files with 1685 additions and 416 deletions
@@ -72,6 +72,7 @@ class TransactionListItem extends ActionListItem with Keyable {
break;
case WalletType.bitcoin:
case WalletType.litecoin:
case WalletType.bitcoinCash:
amount = calculateFiatAmountRaw(
cryptoAmount: bitcoin!.formatterBitcoinAmountToDouble(amount: transaction.amount),
price: price);
@@ -2,10 +2,12 @@ import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/core/wallet_change_listener_view_model.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/entities/wallet_contact.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/exchange/exolix/exolix_exchange_provider.dart';
import 'package:cake_wallet/exchange/exolix/exolix_request.dart';
import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
@@ -265,8 +267,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
}
bool get hasAllAmount =>
(wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin) &&
depositCurrency == wallet.currency;
(wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.bitcoinCash) &&
depositCurrency == wallet.currency;
bool get isMoneroWallet => wallet.type == WalletType.monero;
@@ -278,7 +282,14 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
case WalletType.bitcoin:
return transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
case WalletType.litecoin:
return transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow();
return transactionPriority ==
bitcoin!.getLitecoinTransactionPrioritySlow();
case WalletType.ethereum:
return transactionPriority ==
ethereum!.getEthereumTransactionPrioritySlow();
case WalletType.bitcoinCash:
return transactionPriority ==
bitcoinCash!.getBitcoinCashTransactionPrioritySlow();
default:
return false;
}
@@ -619,7 +630,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
@action
void calculateDepositAllAmount() {
if (wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin) {
if (wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin || wallet.type == WalletType.bitcoinCash) {
final availableBalance = wallet.balance[wallet.currency]!.available;
final priority = _settingsStore.priority[wallet.type]!;
final fee = wallet.calculateEstimatedFee(priority, null);
@@ -694,6 +705,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
depositCurrency = CryptoCurrency.ltc;
receiveCurrency = CryptoCurrency.xmr;
break;
case WalletType.bitcoinCash:
depositCurrency = CryptoCurrency.bch;
receiveCurrency = CryptoCurrency.xmr;
break;
case WalletType.haven:
depositCurrency = CryptoCurrency.xhv;
receiveCurrency = CryptoCurrency.btc;
@@ -789,6 +804,12 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
case WalletType.litecoin:
_settingsStore.priority[wallet.type] = bitcoin!.getLitecoinTransactionPriorityMedium();
break;
case WalletType.ethereum:
_settingsStore.priority[wallet.type] = ethereum!.getDefaultTransactionPriority();
break;
case WalletType.bitcoinCash:
_settingsStore.priority[wallet.type] = bitcoinCash!.getDefaultTransactionPriority();
break;
default:
break;
}
@@ -66,6 +66,9 @@ abstract class NodeListViewModelBase with Store {
case WalletType.ethereum:
node = getEthereumDefaultNode(nodes: _nodeSource)!;
break;
case WalletType.bitcoinCash:
node = getBitcoinCashDefaultElectrumServer(nodes: _nodeSource)!;
break;
case WalletType.nano:
node = getNanoDefaultNode(nodes: _nodeSource)!;
break;
@@ -1,4 +1,5 @@
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/view_model/restore/restore_mode.dart';
import 'package:cake_wallet/view_model/restore/restore_wallet.dart';
@@ -84,6 +85,9 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
case WalletType.litecoin:
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
case WalletType.bitcoinCash:
return bitcoinCash!.createBitcoinCashRestoreWalletFromSeedCredentials(
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
case WalletType.ethereum:
return ethereum!.createEthereumRestoreWalletFromSeedCredentials(
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
@@ -72,8 +72,13 @@ class WalletRestoreFromQRCode {
case 'litecoin':
case 'litecoin-wallet':
return WalletType.litecoin;
case 'bitcoincash':
case 'bitcoinCash-wallet':
return WalletType.bitcoinCash;
case 'ethereum-wallet':
return WalletType.ethereum;
case 'nano-wallet':
return WalletType.nano;
default:
throw Exception('Unexpected wallet type: ${scheme.toString()}');
}
@@ -107,6 +112,7 @@ class WalletRestoreFromQRCode {
case WalletType.bitcoin:
case WalletType.litecoin:
case WalletType.ethereum:
case WalletType.bitcoinCash:
RegExp regex24 = RegExp(r'\b(\S+\b\s+){23}\S+\b');
RegExp regex18 = RegExp(r'\b(\S+\b\s+){17}\S+\b');
RegExp regex12 = RegExp(r'\b(\S+\b\s+){11}\S+\b');
+6 -4
View File
@@ -81,10 +81,8 @@ abstract class OutputBase with Store {
_amount = monero!.formatterMoneroParseAmount(amount: _cryptoAmount);
break;
case WalletType.bitcoin:
_amount =
bitcoin!.formatterStringDoubleToBitcoinAmount(_cryptoAmount);
break;
case WalletType.litecoin:
case WalletType.bitcoinCash:
_amount =
bitcoin!.formatterStringDoubleToBitcoinAmount(_cryptoAmount);
break;
@@ -116,7 +114,8 @@ abstract class OutputBase with Store {
_settingsStore.priority[_wallet.type]!, formattedCryptoAmount);
if (_wallet.type == WalletType.bitcoin ||
_wallet.type == WalletType.litecoin) {
_wallet.type == WalletType.litecoin ||
_wallet.type == WalletType.bitcoinCash) {
return bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
}
@@ -234,6 +233,9 @@ abstract class OutputBase with Store {
case WalletType.litecoin:
maximumFractionDigits = 8;
break;
case WalletType.bitcoinCash:
maximumFractionDigits = 8;
break;
case WalletType.haven:
maximumFractionDigits = 12;
break;
+15 -31
View File
@@ -185,12 +185,15 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
@computed
bool get hasCoinControl =>
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.monero;
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.monero ||
wallet.type == WalletType.bitcoinCash;
@computed
bool get isElectrumWallet =>
wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin;
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.bitcoinCash;
@computed
bool get hasFees => wallet.type != WalletType.nano && wallet.type != WalletType.banano;
@@ -345,41 +348,24 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
_settingsStore.priority[wallet.type] = priority;
Object _credentials() {
final priority = _settingsStore.priority[wallet.type];
if (priority == null) throw Exception('Priority is null for wallet type: ${wallet.type}');
switch (wallet.type) {
case WalletType.bitcoin:
final priority = _settingsStore.priority[wallet.type];
if (priority == null) {
throw Exception('Priority is null for wallet type: ${wallet.type}');
}
return bitcoin!.createBitcoinTransactionCredentials(outputs, priority: priority);
case WalletType.litecoin:
final priority = _settingsStore.priority[wallet.type];
if (priority == null) {
throw Exception('Priority is null for wallet type: ${wallet.type}');
}
case WalletType.bitcoinCash:
return bitcoin!.createBitcoinTransactionCredentials(outputs, priority: priority);
case WalletType.monero:
final priority = _settingsStore.priority[wallet.type];
if (priority == null) {
throw Exception('Priority is null for wallet type: ${wallet.type}');
}
return monero!
.createMoneroTransactionCreationCredentials(outputs: outputs, priority: priority);
case WalletType.haven:
final priority = _settingsStore.priority[wallet.type];
if (priority == null) {
throw Exception('Priority is null for wallet type: ${wallet.type}');
}
return haven!.createHavenTransactionCreationCredentials(
outputs: outputs, priority: priority, assetType: selectedCryptoCurrency.title);
case WalletType.ethereum:
final priority = _settingsStore.priority[wallet.type];
@@ -390,9 +376,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return ethereum!.createEthereumTransactionCredentials(outputs,
priority: priority, currency: selectedCryptoCurrency);
case WalletType.nano:
return nano!.createNanoTransactionCredentials(
outputs,
);
return nano!.createNanoTransactionCredentials(outputs);
default:
throw Exception('Unexpected wallet type: ${wallet.type}');
}
@@ -63,7 +63,9 @@ abstract class OtherSettingsViewModelBase with Store {
String getDisplayPriority(dynamic priority) {
final _priority = priority as TransactionPriority;
if (_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin) {
if (_wallet.type == WalletType.bitcoin ||
_wallet.type == WalletType.litecoin ||
_wallet.type == WalletType.bitcoinCash) {
final rate = bitcoin!.getFeeRate(_wallet, _priority);
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate);
}
@@ -39,6 +39,7 @@ abstract class TransactionDetailsViewModelBase with Store {
break;
case WalletType.bitcoin:
case WalletType.litecoin:
case WalletType.bitcoinCash:
_addElectrumListItems(tx, dateFormat);
break;
case WalletType.haven:
@@ -115,6 +116,8 @@ abstract class TransactionDetailsViewModelBase with Store {
return 'https://mempool.space/tx/${txId}';
case WalletType.litecoin:
return 'https://blockchair.com/litecoin/transaction/${txId}';
case WalletType.bitcoinCash:
return 'https://blockchair.com/bitcoin-cash/transaction/${txId}';
case WalletType.haven:
return 'https://explorer.havenprotocol.org/search?value=${txId}';
case WalletType.ethereum:
@@ -135,6 +138,7 @@ abstract class TransactionDetailsViewModelBase with Store {
case WalletType.bitcoin:
return S.current.view_transaction_on + 'mempool.space';
case WalletType.litecoin:
case WalletType.bitcoinCash:
return S.current.view_transaction_on + 'Blockchair.com';
case WalletType.haven:
return S.current.view_transaction_on + 'explorer.havenprotocol.org';
@@ -1,9 +1,10 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/src/screens/transaction_details/blockexplorer_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/textfield_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_switch_item.dart';
import 'package:cw_core/wallet_type.dart';
@@ -19,12 +20,14 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
UnspentCoinsDetailsViewModelBase(
{required this.unspentCoinsItem, required this.unspentCoinsListViewModel})
: items = <TransactionDetailsListItem>[],
_type = unspentCoinsListViewModel.wallet.type,
isFrozen = unspentCoinsItem.isFrozen,
note = unspentCoinsItem.note {
items = [
StandartListItem(title: S.current.transaction_details_amount, value: unspentCoinsItem.amount),
StandartListItem(title: S.current.transaction_details_transaction_id, value: unspentCoinsItem.hash),
StandartListItem(title: S.current.widgets_address, value: unspentCoinsItem.address),
StandartListItem(
title: S.current.transaction_details_transaction_id, value: unspentCoinsItem.hash),
StandartListItem(title: S.current.widgets_address, value: formattedAddress),
TextFieldListItem(
title: S.current.note_tap_to_change,
value: note,
@@ -46,14 +49,13 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
})
];
if ([WalletType.bitcoin, WalletType.litecoin].contains(unspentCoinsListViewModel.wallet.type)) {
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(_type)) {
items.add(BlockExplorerListItem(
title: S.current.view_in_block_explorer,
value: _explorerDescription(unspentCoinsListViewModel.wallet.type),
value: _explorerDescription(_type),
onTap: () {
try {
final url = Uri.parse(
_explorerUrl(unspentCoinsListViewModel.wallet.type, unspentCoinsItem.hash));
final url = Uri.parse(_explorerUrl(_type, unspentCoinsItem.hash));
return launchUrl(url);
} catch (e) {}
},
@@ -67,6 +69,8 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
return 'https://ordinals.com/tx/${txId}';
case WalletType.litecoin:
return 'https://litecoin.earlyordies.com/tx/${txId}';
case WalletType.bitcoinCash:
return 'https://blockchair.com/bitcoin-cash/transaction/${txId}';
default:
return '';
}
@@ -78,6 +82,8 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
return S.current.view_transaction_on + 'Ordinals.com';
case WalletType.litecoin:
return S.current.view_transaction_on + 'Earlyordies.com';
case WalletType.bitcoinCash:
return S.current.view_transaction_on + 'Blockchair.com';
default:
return '';
}
@@ -91,5 +97,10 @@ abstract class UnspentCoinsDetailsViewModelBase with Store {
final UnspentCoinsItem unspentCoinsItem;
final UnspentCoinsListViewModel unspentCoinsListViewModel;
final WalletType _type;
List<TransactionDetailsListItem> items;
String get formattedAddress => WalletType.bitcoinCash == _type
? bitcoinCash!.getCashAddrFormat(unspentCoinsItem.address)
: unspentCoinsItem.address;
}
@@ -1,9 +1,10 @@
import 'package:collection/collection.dart';
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/entities/unspent_transaction_output.dart';
import 'package:cw_core/unspent_transaction_output.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:hive/hive.dart';
@@ -24,11 +25,11 @@ abstract class UnspentCoinsListViewModelBase with Store {
final Box<UnspentCoinsInfo> _unspentCoinsInfo;
@computed
ObservableList<UnspentCoinsItem> get items =>
ObservableList.of(_getUnspents().map((elem) {
ObservableList<UnspentCoinsItem> get items => ObservableList.of(_getUnspents().map((elem) {
final amount = formatAmountToString(elem.value) + ' ${wallet.currency.title}';
final info = getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
final info =
getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
return UnspentCoinsItem(
address: elem.address,
@@ -39,13 +40,13 @@ abstract class UnspentCoinsListViewModelBase with Store {
isSending: info?.isSending ?? true,
amountRaw: elem.value,
vout: elem.vout,
keyImage: elem.keyImage
);
keyImage: elem.keyImage);
}));
Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
try {
final info = getUnspentCoinInfo(item.hash, item.address, item.amountRaw, item.vout, item.keyImage);
final info =
getUnspentCoinInfo(item.hash, item.address, item.amountRaw, item.vout, item.keyImage);
if (info == null) {
final newInfo = UnspentCoinsInfo(
walletId: wallet.id,
@@ -56,8 +57,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
isFrozen: item.isFrozen,
isSending: item.isSending,
noteRaw: item.note,
keyImage: item.keyImage
);
keyImage: item.keyImage);
await _unspentCoinsInfo.add(newInfo);
_updateUnspents();
@@ -76,37 +76,34 @@ abstract class UnspentCoinsListViewModelBase with Store {
}
}
UnspentCoinsInfo? getUnspentCoinInfo(String hash, String address, int value, int vout, String? keyImage) {
UnspentCoinsInfo? getUnspentCoinInfo(
String hash, String address, int value, int vout, String? keyImage) {
return _unspentCoinsInfo.values.firstWhereOrNull((element) =>
element.walletId == wallet.id &&
element.hash == hash &&
element.address == address &&
element.value == value &&
element.vout == vout &&
element.keyImage == keyImage
);
element.keyImage == keyImage);
}
String formatAmountToString(int fullBalance) {
if (wallet.type == WalletType.monero)
return monero!.formatterMoneroAmountToString(amount: fullBalance);
if ([WalletType.bitcoin, WalletType.litecoin].contains(wallet.type))
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
return bitcoin!.formatterBitcoinAmountToString(amount: fullBalance);
return '';
}
void _updateUnspents() {
if (wallet.type == WalletType.monero)
return monero!.updateUnspents(wallet);
if ([WalletType.bitcoin, WalletType.litecoin].contains(wallet.type))
if (wallet.type == WalletType.monero) return monero!.updateUnspents(wallet);
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
return bitcoin!.updateUnspents(wallet);
}
List<Unspent> _getUnspents() {
if (wallet.type == WalletType.monero)
return monero!.getUnspents(wallet);
if ([WalletType.bitcoin, WalletType.litecoin].contains(wallet.type))
if (wallet.type == WalletType.monero) return monero!.getUnspents(wallet);
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
return bitcoin!.getUnspents(wallet);
return List.empty();
}
@@ -66,7 +66,8 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store {
final wallet = _wallet;
if (wallet.type == WalletType.bitcoin
|| wallet.type == WalletType.litecoin) {
|| wallet.type == WalletType.litecoin
|| wallet.type == WalletType.bitcoinCash) {
await bitcoin!.generateNewAddress(wallet);
await wallet.save();
}
@@ -107,6 +107,23 @@ class EthereumURI extends PaymentURI {
}
}
class BitcoinCashURI extends PaymentURI {
BitcoinCashURI({required String amount, required String address})
: super(amount: amount, address: address);
@override
String toString() {
var base = address;
if (amount.isNotEmpty) {
base += '?amount=${amount.replaceAll(',', '.')}';
}
return base;
}
}
class NanoURI extends PaymentURI {
NanoURI({required String amount, required String address})
: super(amount: amount, address: address);
@@ -114,7 +131,6 @@ class NanoURI extends PaymentURI {
@override
String toString() {
var base = 'nano:' + address;
if (amount.isNotEmpty) {
base += '?amount=${amount.replaceAll(',', '.')}';
}
@@ -192,6 +208,10 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
return EthereumURI(amount: amount, address: address.address);
}
if (wallet.type == WalletType.bitcoinCash) {
return BitcoinCashURI(amount: amount, address: address.address);
}
if (wallet.type == WalletType.nano) {
return NanoURI(amount: amount, address: address.address);
}
@@ -280,7 +300,9 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
@computed
bool get showElectrumAddressDisclaimer =>
wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin;
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.bitcoinCash;
List<ListItem> _baseItems;
+5 -1
View File
@@ -19,6 +19,7 @@ abstract class WalletKeysViewModelBase with Store {
WalletKeysViewModelBase(this._appStore)
: title = _appStore.wallet!.type == WalletType.bitcoin ||
_appStore.wallet!.type == WalletType.litecoin ||
_appStore.wallet!.type == WalletType.bitcoinCash ||
_appStore.wallet!.type == WalletType.ethereum
? S.current.wallet_seed
: S.current.wallet_keys,
@@ -91,7 +92,8 @@ abstract class WalletKeysViewModelBase with Store {
}
if (_appStore.wallet!.type == WalletType.bitcoin ||
_appStore.wallet!.type == WalletType.litecoin) {
_appStore.wallet!.type == WalletType.litecoin ||
_appStore.wallet!.type == WalletType.bitcoinCash) {
items.addAll([
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
@@ -145,6 +147,8 @@ abstract class WalletKeysViewModelBase with Store {
return 'haven-wallet';
case WalletType.ethereum:
return 'ethereum-wallet';
case WalletType.bitcoinCash:
return 'bitcoinCash-wallet';
case WalletType.nano:
return 'nano-wallet';
case WalletType.banano:
+4 -1
View File
@@ -1,6 +1,7 @@
import 'package:cake_wallet/view_model/restore/restore_wallet.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:flutter/foundation.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/monero/monero.dart';
@@ -46,10 +47,12 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
name: name, language: options as String);
case WalletType.ethereum:
return ethereum!.createEthereumNewWalletCredentials(name: name);
case WalletType.bitcoinCash:
return bitcoinCash!.createBitcoinCashNewWalletCredentials(name: name);
case WalletType.nano:
return nano!.createNanoNewWalletCredentials(name: name);
default:
throw Exception('Unexpected type: ${type.toString()}');;
throw Exception('Unexpected type: ${type.toString()}');
}
}
+12 -7
View File
@@ -2,6 +2,7 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/nano/nano.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/store/app_store.dart';
@@ -92,14 +93,20 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
name: name, height: height, mnemonic: seed, password: password);
case WalletType.ethereum:
return ethereum!.createEthereumRestoreWalletFromSeedCredentials(
name: name, mnemonic: seed, password: password);
name: name,
mnemonic: seed,
password: password);
case WalletType.bitcoinCash:
return bitcoinCash!.createBitcoinCashRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password);
case WalletType.nano:
return nano!.createNanoRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password,
derivationType: derivationType,
);
derivationType: derivationType);
default:
break;
}
@@ -145,8 +152,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
name: name,
password: password,
seedKey: options['private_key'] as String,
derivationType: options["derivationType"] as DerivationType,
);
derivationType: options["derivationType"] as DerivationType);
default:
break;
}
@@ -167,8 +173,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
return nanoUtil!.compareDerivationMethods(
mnemonic: mnemonic,
privateKey: seedKey,
node: node,
);
node: node);
default:
break;
}