* fix: scanning issues

* fix: sync, storing silent unspents

* chore: deps

* fix: label issues, clear spent utxo

* chore: deps

* fix: build

* fix: missing types

* feat: new electrs API & changes, fixes for last block scanning

* feat: Scan Silent Payments homepage toggle

* chore: build configure

* feat: generic fixes, testnet UI improvements, useSSL on bitcoin nodes

* fix: invalid Object in sendData

* feat: improve addresses page & address book displays

* feat: silent payments labeled addresses disclaimer

* fix: missing i18n

* chore: print

* feat: single block scan, rescan by date working for btc mainnet

* feat: new cake features page replace market page, move sp scan toggle, auto switch node pop up alert

* feat: delete silent addresses

* fix: red dot in non ssl nodes

* fix: inconsistent connection states, fix tx history

* fix: tx & balance displays, cpfp sending

* feat: new rust lib

* chore: node path

* fix: check node based on network

* fix: missing txcount from addresses

* style: padding in feature page cards

* fix: restore not getting all wallet addresses by type

* fix: auto switch node broken

* fix: silent payment txs not being restored

* feat: change scanning to subscription model, sync improvements

* fix: scan re-subscription

* fix: default nodes

* fix: improve scanning by date, fix single block scan

* refactor: common function for input tx selection

* various fixes for build issues

* initial monero.dart implementation

* ...

* multiple wallets
new lib
minor fixes

* other fixes from monero.dart and monero_c

* fix: nodes & build

* update build scripts
fix polyseed

* remove unnecessary code

* Add windows app, build scripts and build guide for it.

* Minor fix in generated monero configs

* fix: send all with multiple outs

* add missing monero_c command

* add android build script

* Merge and fix main

* undo android ndk removal

* Fix modified exception_handler.dart

* Temporarily remove haven

* fix build issues

* fix pr script

* Fixes for build monero.dart (monero_c) for windows.

* monero build script

* wip: ios build script

* refactor: unchanged file

* Added build guides for iOS and macOS. Replaced nproc call on macOS. Added macOS configuration for configure_cake_wallet.sh script.

* Update monero.dart and monero_c versions.

* Add missed windows build scripts

* Update the application configuration for windows build script.

* Update cw_monero pubspec lock file for monero.dart

* Update pr_test_build.yml

* chore: upgrade

* chore: merge changes

* refactor: unchanged files [skip ci]

* Fix conflicts with main

* fix for multiple wallets

* Add tron to windows application configuration.

* Add macOS option for description message in configure_cake_wallet.sh

* Include missed monero dll for windows.

* fix conflicts with main

* Disable haven configuration for iOS as default. Add ability to configure cakewallet for iOS with  for configuration script. Remove cw_shared configuration for cw_monero.

* fix: scan fixes, add date, allow sending while scanning

* add missing nano secrets file [skip ci]

* ios library

* don't pull prebuilds android

* Add auto generation of manifest file for android project even for iOS, macOS, Windows.

* feat: sync fixes, sp settings

* feat: fix resyncing

* store crash fix

* make init async so it won't lag
disable print starts

* fix monero_c build issues

* libstdc++

* Fix MacOS saving wallet file issue
Fix Secure Storage issue (somehow)

* update pubspec.lock

* fix build script

* Use dylib as iOS framework. Use custom path for loading of iOS framework for monero.dart. Add script for generate iOS framework for monero wallet.

* fix: date from height logic, status disconnected & chain tip get

* fix: params

* feat: electrum migration if using cake electrum

* fix nodes
update versions

* re-enable tron

* update sp_scanner to work on iOS [skip ci]

* bump monero_c hash

* bump monero_c commit

* bump moneroc version

* bump monero_c commit

* Add ability to build monero wallet lib as universal lib. Update macOS build guide. Change default arch for macOS project to .

* fix: wrong socket for old electrum nodes

* Fix unchecked wallet type call

* get App Dir correctly in default_settings_migration.dart

* handle previous issue with fetching linux documents directory [skip ci]

* backup fix

* fix NTFS issues

* Close the wallet when the wallet gets changed

* fix: double balance

* feat: node domain

* fix: menu name

* bump monero_c commit

* fix: update tip on set scanning

* fix: connection switching back and forth

* feat: check if node is electrs, and supports sp

* chore: fix build

* minor enhancements

* fixes and enhancements

* solve conflicts with main

* Only stop wallet on rename and delete

* fix: status toggle

* minor enhancement

* Monero.com fixes

* bump monero_c commit

* update sp_scanner to include windows and linux

* Update macOS build guide. Change brew dependencies for build unbound locally.

* fix conflicts and update macos build guide

* remove build cache when on gh actions

* update secure storage

* free up even more storage

* free up more storage

* Add initial wownero

* fix conflicts

* fix workflow issue

* build wownero

* ios and windows changes

* macos

* complete wownero flow (app side)

* add keychain group entitlement and update script for RunnerBase on macos

* update secure_storage version to 8.1.0 in configure.dart

* add wownero framework

* update ios builds

* proper path for wownero and monero

* finalizing wownero

* finalizing wownero

* free up even more storage

* revert commenting of build gradle configs

* revert commenting of secrets [skip ci]

* free more storage

* minor fixes

* link android wownero libraries

* bump monero_c commit

* wownero fixes

* rename target

* build_single.sh using clean env

* bump monero_c commit

* minor fix

* Add wownero polyseed

* fix conflicts with main

* fix: wallet seed display
fix: wownero not refreshing

* fix: wallet seed display
fix: wownero not refreshing

* bump monero_c commit

* minor fixes

* fix: incorrectly displaying XMR instead of WOW

* fix: incorrect restore height in wownero

* bump monero_c commit

* Add Inno Setup Script for windows exe installer

* drop libc++_shared.so

* fixes from comments

* Fix CMake for windows

* Merge latest monero dart changes [skip ci]

* bump monero_c commit

* add wownero to build scripts for macos [skip ci]

* add 14 word seed support to wownero

* UI fixes for wownero seed restore

* minor fixes

* reformat code to pass lints

* wownero: fixes
haven: removal popup

* minor iOS fix [skip ci]

* fix: wownero confirmation count (it is spendable after 3 confirms)
fix: transaction history not displaying in WOW and XMR
when tx has 0 confirms,
This is more of a workaround, because I have no idea
why would the cpp code not return pending transaction.

* Update preferences_key.dart [skip ci]

* minor fixes

---------

Co-authored-by: Rafael Saes <git@rafael.saes.dev>
Co-authored-by: Czarek Nakamoto <cyjan@mrcyjanek.net>
Co-authored-by: M <m@cakewallet.com>
Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
Co-authored-by: Matthew Fosse <matt@fosse.co>
This commit is contained in:
Omar Hatem
2024-07-04 22:43:17 +03:00
committed by GitHub
co-authored by Rafael Saes Czarek Nakamoto M Konstantin Ullrich Matthew Fosse
parent a319e10156
commit 36eacd8698
309 changed files with 26261 additions and 6351 deletions
+3
View File
@@ -91,6 +91,7 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.dai:
case CryptoCurrency.dash:
case CryptoCurrency.eos:
case CryptoCurrency.wow:
return '[0-9a-zA-Z]';
case CryptoCurrency.bch:
return '^(?!bitcoincash:)[0-9a-zA-Z]*\$|^(?!bitcoincash:)q|p[0-9a-zA-Z]{41}\$|^(?!bitcoincash:)q|p[0-9a-zA-Z]{42}\$|^bitcoincash:q|p[0-9a-zA-Z]{41}\$|^bitcoincash:q|p[0-9a-zA-Z]{42}\$';
@@ -139,6 +140,7 @@ class AddressValidator extends TextValidator {
switch (type) {
case CryptoCurrency.xmr:
case CryptoCurrency.wow:
return null;
case CryptoCurrency.ada:
return null;
@@ -266,6 +268,7 @@ class AddressValidator extends TextValidator {
static String? getAddressFromStringPattern(CryptoCurrency type) {
switch (type) {
case CryptoCurrency.xmr:
case CryptoCurrency.wow:
return '([^0-9a-zA-Z]|^)4[0-9a-zA-Z]{94}([^0-9a-zA-Z]|\$)'
'|([^0-9a-zA-Z]|^)8[0-9a-zA-Z]{94}([^0-9a-zA-Z]|\$)'
'|([^0-9a-zA-Z]|^)[0-9a-zA-Z]{106}([^0-9a-zA-Z]|\$)';
+8 -7
View File
@@ -4,6 +4,7 @@ import 'dart:typed_data';
import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/themes/theme_list.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cw_core/root_dir.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
@@ -76,7 +77,7 @@ class BackupService {
Future<Uint8List> _exportBackupV2(String password) async {
final zipEncoder = ZipFileEncoder();
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final now = DateTime.now();
final tmpDir = Directory('${appDir.path}/~_BACKUP_TMP');
final archivePath = '${tmpDir.path}/backup_${now.toString()}.zip';
@@ -116,7 +117,7 @@ class BackupService {
}
Future<void> _importBackupV1(Uint8List data, String password, {required String nonce}) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final decryptedData = await _decryptV1(data, password, nonce);
final zip = ZipDecoder().decodeBytes(decryptedData);
@@ -139,7 +140,7 @@ class BackupService {
}
Future<void> _importBackupV2(Uint8List data, String password) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final decryptedData = await _decryptV2(data, password);
final zip = ZipDecoder().decodeBytes(decryptedData);
@@ -172,7 +173,7 @@ class BackupService {
}
Future<Box<WalletInfo>> _reloadHiveWalletInfoBox() async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
await CakeHive.close();
CakeHive.init(appDir.path);
@@ -184,7 +185,7 @@ class BackupService {
}
Future<void> _importPreferencesDump() async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final preferencesFile = File('${appDir.path}/~_preferences_dump');
if (!preferencesFile.existsSync()) {
@@ -361,7 +362,7 @@ class BackupService {
Future<void> _importKeychainDumpV1(String password,
{required String nonce, String keychainSalt = secrets.backupKeychainSalt}) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final keychainDumpFile = File('${appDir.path}/~_keychain_dump');
final decryptedKeychainDumpFileData =
await _decryptV1(keychainDumpFile.readAsBytesSync(), '$keychainSalt$password', nonce);
@@ -387,7 +388,7 @@ class BackupService {
Future<void> _importKeychainDumpV2(String password,
{String keychainSalt = secrets.backupKeychainSalt}) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final keychainDumpFile = File('${appDir.path}/~_keychain_dump');
final decryptedKeychainDumpFileData =
await _decryptV2(keychainDumpFile.readAsBytesSync(), '$keychainSalt$password');
+4 -1
View File
@@ -8,6 +8,7 @@ import 'package:cake_wallet/nano/nano.dart';
import 'package:cake_wallet/polygon/polygon.dart';
import 'package:cake_wallet/solana/solana.dart';
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cake_wallet/utils/language_list.dart';
import 'package:cw_core/wallet_type.dart';
@@ -43,7 +44,9 @@ class SeedValidator extends Validator<MnemonicItem> {
return solana!.getSolanaWordList(language);
case WalletType.tron:
return tron!.getTronWordList(language);
default:
case WalletType.wownero:
return wownero!.getWowneroWordList(language);
case WalletType.none:
return [];
}
}
+1
View File
@@ -81,6 +81,7 @@ class WalletCreationService {
case WalletType.tron:
return true;
case WalletType.monero:
case WalletType.wownero:
case WalletType.none:
case WalletType.bitcoin:
case WalletType.litecoin:
+5 -1
View File
@@ -215,6 +215,7 @@ import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/receive_page_option.dart';
import 'package:cw_core/wallet_info.dart';
@@ -900,6 +901,7 @@ Future<void> setup({
return bitcoinCash!
.createBitcoinCashWalletService(_walletInfoSource, _unspentCoinsInfoSource);
case WalletType.nano:
case WalletType.banano:
return nano!.createNanoWalletService(_walletInfoSource);
case WalletType.polygon:
return polygon!.createPolygonWalletService(_walletInfoSource);
@@ -907,7 +909,9 @@ Future<void> setup({
return solana!.createSolanaWalletService(_walletInfoSource);
case WalletType.tron:
return tron!.createTronWalletService(_walletInfoSource);
default:
case WalletType.wownero:
return wownero!.createWowneroWalletService(_walletInfoSource, _unspentCoinsInfoSource);
case WalletType.none:
throw Exception('Unexpected token: ${param1.toString()} for generating of WalletService');
}
});
+8 -8
View File
@@ -31,8 +31,6 @@ void callbackDispatcher() {
final walletLoadingService = getIt.get<WalletLoadingService>();
final node = getIt.get<SettingsStore>().getCurrentNode(WalletType.monero);
final typeRaw = getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType);
WalletBase? wallet;
@@ -42,23 +40,25 @@ void callbackDispatcher() {
final List<WalletListItem> moneroWallets = getIt
.get<WalletListViewModel>()
.wallets
.where((element) => element.type == WalletType.monero)
.where((element) => [WalletType.monero, WalletType.wownero].contains(element.type))
.toList();
for (int i = 0; i < moneroWallets.length; i++) {
wallet = await walletLoadingService.load(WalletType.monero, moneroWallets[i].name);
wallet =
await walletLoadingService.load(moneroWallets[i].type, moneroWallets[i].name);
final node = getIt.get<SettingsStore>().getCurrentNode(moneroWallets[i].type);
await wallet.connectToNode(node: node);
await wallet.startSync();
}
} else {
/// if the user chose to sync only active wallet
/// if the current wallet is monero; sync it only
if (typeRaw == WalletType.monero.index) {
if (typeRaw == WalletType.monero.index || typeRaw == WalletType.wownero.index) {
final name =
getIt.get<SharedPreferences>().getString(PreferencesKey.currentWalletName);
wallet = await walletLoadingService.load(WalletType.monero, name!);
wallet = await walletLoadingService.load(WalletType.values[typeRaw!], name!);
final node = getIt.get<SettingsStore>().getCurrentNode(WalletType.values[typeRaw]);
await wallet.connectToNode(node: node);
await wallet.startSync();
@@ -66,7 +66,7 @@ void callbackDispatcher() {
}
if (wallet?.syncStatus.progress() == null) {
return Future.error("No Monero wallet found");
return Future.error("No Monero/Wownero wallet found");
}
for (int i = 0;; i++) {
+57 -3
View File
@@ -5,8 +5,8 @@ import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cw_core/pathForWallet.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cw_core/root_dir.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cw_core/wallet_type.dart';
@@ -39,6 +39,7 @@ const nanoDefaultPowNodeUri = 'rpc.nano.to';
const solanaDefaultNodeUri = 'rpc.ankr.com';
const tronDefaultNodeUri = 'trx.nownodes.io';
const newCakeWalletBitcoinUri = 'btc-electrum.cakewallet.com:50002';
const wowneroDefaultNodeUri = 'node3.monerodevs.org:34568';
Future<void> defaultSettingsMigration(
{required int version,
@@ -231,7 +232,8 @@ Future<void> defaultSettingsMigration(
await _switchElectRsNode(nodes, sharedPreferences);
break;
case 36:
await changeTronCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
await addWowneroNodeList(nodes: nodes);
await changeWowneroCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
break;
case 37:
await replaceTronDefaultNode(sharedPreferences: sharedPreferences, nodes: nodes);
@@ -305,7 +307,7 @@ Future<void> _updateMoneroPriority(SharedPreferences sharedPreferences) async {
Future<void> _validateWalletInfoBoxData(Box<WalletInfo> walletInfoSource) async {
try {
final root = await getApplicationDocumentsDirectory();
final root = await getAppDir();
for (var type in WalletType.values) {
if (type == WalletType.none) {
@@ -498,6 +500,32 @@ Node? getTronDefaultNode({required Box<Node> nodes}) {
nodes.values.firstWhereOrNull((node) => node.type == WalletType.tron);
}
Node getWowneroDefaultNode({required Box<Node> nodes}) {
final timeZone = DateTime.now().timeZoneOffset.inHours;
var nodeUri = '';
if (timeZone >= 1) {
// Eurasia
nodeUri = 'node2.monerodevs.org.lol:34568';
} else if (timeZone <= -4) {
// America
nodeUri = 'node3.monerodevs.org:34568';
}
if (nodeUri == '') {
return nodes.values.where((element) => element.type == WalletType.wownero).first;
}
try {
return nodes.values.firstWhere(
(Node node) => node.uriRaw == nodeUri,
orElse: () => nodes.values.where((element) => element.type == WalletType.wownero).first,
);
} catch (_) {
return nodes.values.where((element) => element.type == WalletType.wownero).first;
}
}
Future<void> insecureStorageMigration({
required SharedPreferences sharedPreferences,
required SecureStorage secureStorage,
@@ -898,6 +926,7 @@ Future<void> checkCurrentNodes(
sharedPreferences.getInt(PreferencesKey.currentBitcoinCashNodeIdKey);
final currentSolanaNodeId = sharedPreferences.getInt(PreferencesKey.currentSolanaNodeIdKey);
final currentTronNodeId = sharedPreferences.getInt(PreferencesKey.currentTronNodeIdKey);
final currentWowneroNodeId = sharedPreferences.getInt(PreferencesKey.currentWowneroNodeIdKey);
final currentMoneroNode =
nodeSource.values.firstWhereOrNull((node) => node.key == currentMoneroNodeId);
final currentBitcoinElectrumServer =
@@ -920,6 +949,8 @@ Future<void> checkCurrentNodes(
nodeSource.values.firstWhereOrNull((node) => node.key == currentSolanaNodeId);
final currentTronNodeServer =
nodeSource.values.firstWhereOrNull((node) => node.key == currentTronNodeId);
final currentWowneroNodeServer =
nodeSource.values.firstWhereOrNull((node) => node.key == currentWowneroNodeId);
if (currentMoneroNode == null) {
final newCakeWalletNode = Node(uri: newCakeWalletMoneroUri, type: WalletType.monero);
await nodeSource.add(newCakeWalletNode);
@@ -997,6 +1028,12 @@ Future<void> checkCurrentNodes(
await nodeSource.add(node);
await sharedPreferences.setInt(PreferencesKey.currentTronNodeIdKey, node.key as int);
}
if (currentWowneroNodeServer == null) {
final node = Node(uri: wowneroDefaultNodeUri, type: WalletType.wownero);
await nodeSource.add(node);
await sharedPreferences.setInt(PreferencesKey.currentWowneroNodeIdKey, node.key as int);
}
}
Future<void> resetBitcoinElectrumServer(
@@ -1063,6 +1100,23 @@ Future<void> changeEthereumCurrentNodeToDefault(
await sharedPreferences.setInt(PreferencesKey.currentEthereumNodeIdKey, nodeId);
}
Future<void> addWowneroNodeList({required Box<Node> nodes}) async {
final nodeList = await loadDefaultWowneroNodes();
for (var node in nodeList) {
if (nodes.values.firstWhereOrNull((element) => element.uriRaw == node.uriRaw) == null) {
await nodes.add(node);
}
}
}
Future<void> changeWowneroCurrentNodeToDefault(
{required SharedPreferences sharedPreferences, required Box<Node> nodes}) async {
final node = getWowneroDefaultNode(nodes: nodes);
final nodeId = node?.key as int? ?? 0;
await sharedPreferences.setInt(PreferencesKey.currentWowneroNodeIdKey, nodeId);
}
Future<void> addNanoNodeList({required Box<Node> nodes}) async {
final nodeList = await loadDefaultNanoNodes();
for (var node in nodeList) {
+12 -3
View File
@@ -63,6 +63,8 @@ class LanguageService {
static final list = <String, String>{};
static const defaultLocale = 'en';
static void loadLocaleList() {
supportedLocales.forEach((key, value) {
if (locales.contains(key)) {
@@ -72,9 +74,16 @@ class LanguageService {
}
static Future<String> localeDetection() async {
var locale = await Devicelocale.currentLocale ?? '';
locale = Intl.shortLocale(locale);
try {
var locale = await Devicelocale.currentLocale ?? '';
locale = Intl.shortLocale(locale);
return list.keys.contains(locale) ? locale : 'en';
if (list.keys.contains(locale)) {
return locale;
}
return LanguageService.defaultLocale;
} catch(_) {
return LanguageService.defaultLocale;
}
}
}
+17
View File
@@ -183,6 +183,23 @@ Future<List<Node>> loadDefaultTronNodes() async {
return nodes;
}
Future<List<Node>> loadDefaultWowneroNodes() async {
final nodesRaw = await rootBundle.loadString('assets/wownero_node_list.yml');
final loadedNodes = loadYaml(nodesRaw) as YamlList;
final nodes = <Node>[];
for (final raw in loadedNodes) {
if (raw is Map) {
final node = Node.fromMap(Map<String, Object>.from(raw));
node.type = WalletType.wownero;
nodes.add(node);
}
}
return nodes;
}
Future<void> resetToDefault(Box<Node> nodeSource) async {
final moneroNodes = await loadDefaultNodes();
final bitcoinElectrumServerList = await loadBitcoinElectrumServerList();
+2
View File
@@ -15,6 +15,7 @@ class PreferencesKey {
static const currentBitcoinCashNodeIdKey = 'current_node_id_bch';
static const currentSolanaNodeIdKey = 'current_node_id_sol';
static const currentTronNodeIdKey = 'current_node_id_trx';
static const currentWowneroNodeIdKey = 'current_node_id_wow';
static const currentTransactionPriorityKeyLegacy = 'current_fee_priority';
static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
@@ -43,6 +44,7 @@ class PreferencesKey {
static const ethereumTransactionPriority = 'current_fee_priority_ethereum';
static const polygonTransactionPriority = 'current_fee_priority_polygon';
static const bitcoinCashTransactionPriority = 'current_fee_priority_bitcoin_cash';
static const wowneroTransactionPriority = 'current_fee_priority_wownero';
static const customBitcoinFeeRate = 'custom_electrum_fee_rate';
static const silentPaymentsCardDisplay = 'silentPaymentsCardDisplay';
static const silentPaymentsAlwaysScan = 'silentPaymentsAlwaysScan';
@@ -4,6 +4,7 @@ import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/polygon/polygon.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/wallet_type.dart';
@@ -11,6 +12,8 @@ List<TransactionPriority> priorityForWalletType(WalletType type) {
switch (type) {
case WalletType.monero:
return monero!.getTransactionPriorities();
case WalletType.wownero:
return wownero!.getTransactionPriorities();
case WalletType.bitcoin:
return bitcoin!.getTransactionPriorities();
case WalletType.litecoin:
+2
View File
@@ -51,6 +51,7 @@ class ProvidersHelper {
switch (walletType) {
case WalletType.nano:
case WalletType.banano:
case WalletType.wownero:
return [ProviderType.askEachTime, ProviderType.onramper];
case WalletType.monero:
return [ProviderType.askEachTime, ProviderType.onramper, ProviderType.dfx];
@@ -114,6 +115,7 @@ class ProvidersHelper {
case WalletType.banano:
case WalletType.none:
case WalletType.haven:
case WalletType.wownero:
return [];
}
}
+5
View File
@@ -10,6 +10,7 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
static const legacy = SeedType(raw: 0, title: 'Legacy (25 words)');
static const polyseed = SeedType(raw: 1, title: 'Polyseed (16 words)');
static const wowneroSeed = SeedType(raw: 2, title: 'Wownero (14 words)');
static SeedType deserialize({required int raw}) {
switch (raw) {
@@ -17,6 +18,8 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
return legacy;
case 1:
return polyseed;
case 2:
return wowneroSeed;
default:
throw Exception('Unexpected token: $raw for SeedType deserialize');
}
@@ -29,6 +32,8 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
return S.current.seedtype_legacy;
case SeedType.polyseed:
return S.current.seedtype_polyseed;
case SeedType.wowneroSeed:
return S.current.seedtype_wownero;
default:
return '';
}
+29 -28
View File
@@ -1,45 +1,45 @@
import 'dart:async';
import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
import 'package:cake_wallet/buy/order.dart';
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/default_settings_migration.dart';
import 'package:cake_wallet/entities/get_encryption_key.dart';
import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/entities/language_service.dart';
import 'package:cake_wallet/buy/order.dart';
import 'package:cake_wallet/entities/template.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/locales/locale.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/reactions/bootstrap.dart';
import 'package:cake_wallet/router.dart' as Router;
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/root/root.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cake_wallet/view_model/link_view_model.dart';
import 'package:cw_core/address_info.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cw_core/address_info.dart';
import 'package:cw_core/cake_hive.dart';
import 'package:cw_core/hive_type_ids.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import 'package:cake_wallet/di.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/router.dart' as Router;
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/reactions/bootstrap.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/entities/get_encryption_key.dart';
import 'package:cake_wallet/entities/contact.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cake_wallet/entities/default_settings_migration.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/entities/template.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/root/root.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cw_core/cake_hive.dart';
import 'package:hive/hive.dart';
import 'package:cw_core/root_dir.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cw_core/window_size.dart';
final navigatorKey = GlobalKey<NavigatorState>();
@@ -103,7 +103,8 @@ Future<void> main() async {
}
Future<void> initializeAppConfigs() async {
final appDir = await getApplicationDocumentsDirectory();
setRootDirFromEnv();
final appDir = await getAppDir();
CakeHive.init(appDir.path);
if (!CakeHive.isAdapterRegistered(Contact.typeId)) {
+5
View File
@@ -341,4 +341,9 @@ class CWMonero extends Monero {
final moneroWallet = wallet as MoneroWallet;
await moneroWallet.updateUnspent();
}
@override
Future<int> getCurrentHeight() async {
return monero_wallet_api.getCurrentHeight();
}
}
@@ -71,6 +71,7 @@ void startCurrentWalletChangeReaction(
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
if (wallet.type == WalletType.monero ||
wallet.type == WalletType.wownero ||
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.bitcoinCash) {
+22 -1
View File
@@ -7,6 +7,7 @@ import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sideba
import 'package:cake_wallet/src/screens/dashboard/pages/cake_features_page.dart';
import 'package:cake_wallet/src/screens/wallet_connect/widgets/modals/bottom_sheet_listener.dart';
import 'package:cake_wallet/src/widgets/gradient_background.dart';
import 'package:cake_wallet/src/widgets/haven_wallet_removal_popup.dart';
import 'package:cake_wallet/src/widgets/services_updates_widget.dart';
import 'package:cake_wallet/src/widgets/vulnerable_seeds_popup.dart';
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
@@ -351,10 +352,12 @@ class _DashboardPageView extends BasePage {
_showVulnerableSeedsPopup(context);
_showHavenPopup(context);
var needToPresentYat = false;
var isInactive = false;
_onInactiveSub = rootKey.currentState!.isInactive.listen(
_onInactiveSub = rootKey.currentState?.isInactive.listen(
(inactive) {
isInactive = inactive;
@@ -428,4 +431,22 @@ class _DashboardPageView extends BasePage {
);
}
}
void _showHavenPopup(BuildContext context) async {
final List<String> havenWalletList = await dashboardViewModel.checkForHavenWallets();
if (havenWalletList.isNotEmpty) {
Future<void>.delayed(
Duration(seconds: 1),
() {
showPopUp<void>(
context: context,
builder: (BuildContext context) {
return HavenWalletRemovalPopup(havenWalletList);
},
);
},
);
}
}
}
@@ -40,6 +40,7 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
final bananoIcon = Image.asset('assets/images/nano_icon.png', height: 24, width: 24);
final solanaIcon = Image.asset('assets/images/sol_icon.png', height: 24, width: 24);
final tronIcon = Image.asset('assets/images/trx_icon.png', height: 24, width: 24);
final wowneroIcon = Image.asset('assets/images/wownero_icon.png', height: 24, width: 24);
final nonWalletTypeIcon = Image.asset('assets/images/close.png', height: 24, width: 24);
Image _newWalletImage(BuildContext context) => Image.asset(
@@ -36,7 +36,8 @@ class MenuWidgetState extends State<MenuWidget> {
this.bitcoinCashIcon = Image.asset('assets/images/bch_icon.png'),
this.polygonIcon = Image.asset('assets/images/matic_icon.png'),
this.solanaIcon = Image.asset('assets/images/sol_icon.png'),
this.tronIcon = Image.asset('assets/images/trx_icon.png');
this.tronIcon = Image.asset('assets/images/trx_icon.png'),
this.wowneroIcon = Image.asset('assets/images/wownero_icon.png');
final largeScreen = 731;
@@ -60,6 +61,7 @@ class MenuWidgetState extends State<MenuWidget> {
Image polygonIcon;
Image solanaIcon;
Image tronIcon;
Image wowneroIcon;
@override
void initState() {
@@ -236,6 +238,8 @@ class MenuWidgetState extends State<MenuWidget> {
return solanaIcon;
case WalletType.tron:
return tronIcon;
case WalletType.wownero:
return wowneroIcon;
default:
throw Exception('No icon for ${type.toString()}');
}
@@ -82,7 +82,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
void initState() {
_stateReaction ??= reaction((_) => _walletNewVM.state, (ExecutionState state) async {
if (state is ExecutedSuccessfullyState) {
Navigator.of(navigatorKey.currentContext!)
Navigator.of(navigatorKey.currentContext ?? context)
.pushNamed(Routes.preSeedPage, arguments: _walletNewVM.seedPhraseWordsLength);
}
+1
View File
@@ -33,6 +33,7 @@ class RescanPage extends BasePage {
doSingleScan: _rescanViewModel.doSingleScan,
toggleSingleScan: () =>
_rescanViewModel.doSingleScan = !_rescanViewModel.doSingleScan,
walletType: _rescanViewModel.wallet.type,
)),
Observer(
builder: (_) => LoadingPrimaryButton(
@@ -171,6 +171,7 @@ class WalletRestoreFromKeysFromState extends State<WalletRestoreFromKeysFrom> {
hasDatePicker: widget.walletRestoreViewModel.type != WalletType.haven,
onHeightChange: (_) => null,
onHeightOrDateEntered: widget.onHeightOrDateEntered,
walletType: widget.walletRestoreViewModel.type,
),
],
);
@@ -83,12 +83,17 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
}
void onSeedChange(String seed) {
if (widget.type == WalletType.monero && Polyseed.isValidSeed(seed)) {
if ((widget.type == WalletType.monero || widget.type == WalletType.wownero) &&
Polyseed.isValidSeed(seed)) {
final lang = PolyseedLang.getByPhrase(seed);
_changeSeedType(SeedType.polyseed);
_changeLanguage(lang.nameEnglish);
}
if (widget.type == WalletType.wownero && seed.split(" ").length == 14) {
_changeSeedType(SeedType.wowneroSeed);
_changeLanguage("English");
}
widget.onSeedChange?.call(seed);
}
@@ -142,14 +147,18 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
language: language,
type: widget.type,
onSeedChange: onSeedChange),
if (widget.type == WalletType.monero)
if (widget.type == WalletType.monero || widget.type == WalletType.wownero)
GestureDetector(
onTap: () async {
await showPopUp<void>(
context: context,
builder: (_) => Picker(
items: SeedType.all,
selectedAtIndex: isPolyseed ? 1 : 0,
items: _getItems(),
selectedAtIndex: isPolyseed
? 1
: seedTypeController.value.text.contains("14")
? 2
: 0,
mainAxisAlignment: MainAxisAlignment.start,
onItemSelected: _changeSeedType,
isSeparated: false,
@@ -168,7 +177,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
),
),
),
if (widget.displayLanguageSelector)
if (!seedTypeController.value.text.contains("14") && widget.displayLanguageSelector)
GestureDetector(
onTap: () async {
await showPopUp<void>(
@@ -192,12 +201,14 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
),
),
),
if (!isPolyseed && widget.displayBlockHeightSelector)
if ((!isPolyseed) && widget.displayBlockHeightSelector)
BlockchainHeightWidget(
focusNode: widget.blockHeightFocusNode,
key: blockchainHeightKey,
onHeightOrDateEntered: widget.onHeightOrDateEntered,
hasDatePicker: widget.type == WalletType.monero),
focusNode: widget.blockHeightFocusNode,
key: blockchainHeightKey,
onHeightOrDateEntered: widget.onHeightOrDateEntered,
hasDatePicker: widget.type == WalletType.monero || widget.type == WalletType.wownero,
walletType: widget.type,
),
if (widget.displayPassphrase) ...[
const SizedBox(height: 10),
BaseTextFormField(
@@ -209,7 +220,9 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
]));
}
bool get isPolyseed => widget.seedTypeViewModel.moneroSeedType == SeedType.polyseed;
bool get isPolyseed =>
widget.seedTypeViewModel.moneroSeedType == SeedType.polyseed &&
(widget.type == WalletType.monero || widget.type == WalletType.wownero);
Widget get expandIcon => Container(
padding: EdgeInsets.all(18),
@@ -223,7 +236,11 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
);
void _changeLanguage(String language) {
final setLang = isPolyseed ? "POLYSEED_$language" : language;
final setLang = isPolyseed
? "POLYSEED_$language"
: seedTypeController.value.text.contains("14")
? "WOWSEED_" + language
: language;
setState(() {
this.language = setLang;
seedWidgetStateKey.currentState!.changeSeedLanguage(setLang);
@@ -244,4 +261,15 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
void _setSeedType(SeedType item) {
seedTypeController.text = item.toString();
}
List<SeedType> _getItems() {
switch (widget.type) {
case WalletType.monero:
return [SeedType.legacy, SeedType.polyseed];
case WalletType.wownero:
return [SeedType.legacy, SeedType.polyseed, SeedType.wowneroSeed];
default:
return [SeedType.legacy];
}
}
}
@@ -20,7 +20,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:mobx/mobx.dart';
import 'package:polyseed/polyseed.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class WalletRestorePage extends BasePage {
@@ -48,8 +47,7 @@ class WalletRestorePage extends BasePage {
}
},
onSeedChange: (String seed) {
final isPolyseed =
walletRestoreViewModel.type == WalletType.monero && Polyseed.isValidSeed(seed);
final isPolyseed = walletRestoreViewModel.isPolyseed(seed);
_validateOnChange(isPolyseed: isPolyseed);
},
onLanguageChange: (String language) {
@@ -103,11 +101,11 @@ class WalletRestorePage extends BasePage {
@override
Function(BuildContext)? get pushToNextWidget => (context) {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.focusedChild?.unfocus();
}
};
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.focusedChild?.unfocus();
}
};
@override
Widget body(BuildContext context) {
@@ -253,12 +251,14 @@ class WalletRestorePage extends BasePage {
bool _isValidSeed() {
final seedPhrase =
walletRestoreFromSeedFormKey.currentState!.seedWidgetStateKey.currentState!.text;
if (walletRestoreViewModel.type == WalletType.monero && Polyseed.isValidSeed(seedPhrase))
return true;
if (walletRestoreViewModel.isPolyseed(seedPhrase)) return true;
final seedWords = seedPhrase.split(' ');
if (seedWords.length == 14 && walletRestoreViewModel.type == WalletType.wownero) return true;
if ((walletRestoreViewModel.type == WalletType.monero ||
walletRestoreViewModel.type == WalletType.wownero ||
walletRestoreViewModel.type == WalletType.haven) &&
seedWords.length != WalletRestoreViewModelBase.moneroSeedMnemonicLength) {
return false;
@@ -106,6 +106,7 @@ class WalletListBodyState extends State<WalletListBody> {
final polygonIcon = Image.asset('assets/images/matic_icon.png', height: 24, width: 24);
final solanaIcon = Image.asset('assets/images/sol_icon.png', height: 24, width: 24);
final tronIcon = Image.asset('assets/images/trx_icon.png', height: 24, width: 24);
final wowneroIcon = Image.asset('assets/images/wownero_icon.png', height: 24, width: 24);
final scrollController = ScrollController();
final double tileHeight = 60;
Flushbar<void>? _progressBar;
@@ -319,6 +320,7 @@ class WalletListBodyState extends State<WalletListBody> {
case WalletType.bitcoinCash:
return bitcoinCashIcon;
case WalletType.nano:
case WalletType.banano:
return nanoIcon;
case WalletType.polygon:
return polygonIcon;
@@ -326,7 +328,9 @@ class WalletListBodyState extends State<WalletListBody> {
return solanaIcon;
case WalletType.tron:
return tronIcon;
default:
case WalletType.wownero:
return wowneroIcon;
case WalletType.none:
return nonWalletTypeIcon;
}
}
+11 -1
View File
@@ -2,6 +2,8 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/src/widgets/standard_switch.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/utils/date_picker.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:cake_wallet/generated/i18n.dart';
@@ -18,6 +20,7 @@ class BlockchainHeightWidget extends StatefulWidget {
this.isSilentPaymentsScan = false,
this.toggleSingleScan,
this.doSingleScan = false,
required this.walletType,
}) : super(key: key);
final Function(int)? onHeightChange;
@@ -27,6 +30,7 @@ class BlockchainHeightWidget extends StatefulWidget {
final bool isSilentPaymentsScan;
final bool doSingleScan;
final Function()? toggleSingleScan;
final WalletType walletType;
@override
State<StatefulWidget> createState() => BlockchainHeightState();
@@ -160,7 +164,13 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
if (widget.isSilentPaymentsScan) {
height = bitcoin!.getHeightByDate(date: date);
} else {
height = monero!.getHeightByDate(date: date);
if (widget.walletType == WalletType.monero) {
height = monero!.getHeightByDate(date: date);
} else {
assert(widget.walletType == WalletType.wownero,
"unknown currency in BlockchainHeightWidget");
height = wownero!.getHeightByDate(date: date);
}
}
setState(() {
dateController.text = DateFormat('yyyy-MM-dd').format(date);
@@ -0,0 +1,91 @@
import 'package:cake_wallet/src/widgets/alert_background.dart';
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:flutter/material.dart';
class HavenWalletRemovalPopup extends StatelessWidget {
final List<String> affectedWalletNames;
const HavenWalletRemovalPopup(this.affectedWalletNames, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.center,
children: [
AlertBackground(
child: AlertDialog(
insetPadding: EdgeInsets.only(left: 16, right: 16, bottom: 48),
elevation: 0.0,
contentPadding: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(30))),
content: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
gradient: LinearGradient(colors: [
Theme.of(context).extension<DashboardPageTheme>()!.firstGradientBackgroundColor,
Theme.of(context)
.extension<DashboardPageTheme>()!
.secondGradientBackgroundColor,
], begin: Alignment.centerLeft, end: Alignment.centerRight)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Stack(
children: [
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Container(
alignment: Alignment.bottomCenter,
child: DefaultTextStyle(
style: TextStyle(
decoration: TextDecoration.none,
fontSize: 24.0,
fontWeight: FontWeight.bold,
fontFamily: 'Lato',
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
),
child: Text("Emergency Notice"),
),
),
),
),
SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(top: 48, bottom: 16),
child: Container(
width: double.maxFinite,
child: Column(
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.7,
),
child: Text(
"It looks like you have Haven wallets in your list. Haven is getting removed in next release of Cake Wallet, and you currently have Haven in the following wallets:\n\n[${affectedWalletNames.join(", ")}]\n\nPlease move your funds to other wallet, as you will lose access to your Haven funds in next update.\n\nFor assistance, please use the in-app support or email support@cakewallet.com",
style: TextStyle(
decoration: TextDecoration.none,
fontSize: 16.0,
fontFamily: 'Lato',
color: Theme.of(context)
.extension<DashboardPageTheme>()!
.textColor,
),
),
)
],
),
),
),
),
],
),
),
),
),
),
AlertCloseButton(bottom: 30)
],
);
}
}
+34 -1
View File
@@ -20,6 +20,7 @@ import 'package:cake_wallet/view_model/settings/sync_mode.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/themes/theme_list.dart';
@@ -27,7 +28,7 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:package_info/package_info.dart';
import 'package:cake_wallet/utils/package_info.dart';
import 'package:cake_wallet/di.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -111,6 +112,7 @@ abstract class SettingsStoreBase with Store {
required this.silentPaymentsAlwaysScan,
TransactionPriority? initialBitcoinTransactionPriority,
TransactionPriority? initialMoneroTransactionPriority,
TransactionPriority? initialWowneroTransactionPriority,
TransactionPriority? initialHavenTransactionPriority,
TransactionPriority? initialLitecoinTransactionPriority,
TransactionPriority? initialEthereumTransactionPriority,
@@ -168,6 +170,10 @@ abstract class SettingsStoreBase with Store {
priority[WalletType.monero] = initialMoneroTransactionPriority;
}
if (initialWowneroTransactionPriority != null) {
priority[WalletType.wownero] = initialWowneroTransactionPriority;
}
if (initialBitcoinTransactionPriority != null) {
priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
}
@@ -249,6 +255,7 @@ abstract class SettingsStoreBase with Store {
final String? key;
switch (change.key) {
case WalletType.monero:
case WalletType.wownero:
key = PreferencesKey.moneroTransactionPriority;
break;
case WalletType.bitcoin:
@@ -789,6 +796,7 @@ abstract class SettingsStoreBase with Store {
TransactionPriority? ethereumTransactionPriority;
TransactionPriority? polygonTransactionPriority;
TransactionPriority? bitcoinCashTransactionPriority;
TransactionPriority? wowneroTransactionPriority;
if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) {
havenTransactionPriority = monero?.deserializeMoneroTransactionPriority(
@@ -810,6 +818,10 @@ abstract class SettingsStoreBase with Store {
bitcoinCashTransactionPriority = bitcoinCash?.deserializeBitcoinCashTransactionPriority(
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority)!);
}
if (sharedPreferences.getInt(PreferencesKey.wowneroTransactionPriority) != null) {
wowneroTransactionPriority = wownero?.deserializeWowneroTransactionPriority(
raw: sharedPreferences.getInt(PreferencesKey.wowneroTransactionPriority)!);
}
moneroTransactionPriority ??= monero?.getDefaultTransactionPriority();
bitcoinTransactionPriority ??= bitcoin?.getMediumTransactionPriority();
@@ -817,6 +829,7 @@ abstract class SettingsStoreBase with Store {
litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium();
ethereumTransactionPriority ??= ethereum?.getDefaultTransactionPriority();
bitcoinCashTransactionPriority ??= bitcoinCash?.getDefaultTransactionPriority();
wowneroTransactionPriority ??= wownero?.getDefaultTransactionPriority();
polygonTransactionPriority ??= polygon?.getDefaultTransactionPriority();
final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
@@ -902,6 +915,7 @@ abstract class SettingsStoreBase with Store {
final nanoPowNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoPowNodeIdKey);
final solanaNodeId = sharedPreferences.getInt(PreferencesKey.currentSolanaNodeIdKey);
final tronNodeId = sharedPreferences.getInt(PreferencesKey.currentTronNodeIdKey);
final wowneroNodeId = sharedPreferences.getInt(PreferencesKey.currentWowneroNodeIdKey);
final moneroNode = nodeSource.get(nodeId);
final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
@@ -913,6 +927,7 @@ abstract class SettingsStoreBase with Store {
final nanoPowNode = powNodeSource.get(nanoPowNodeId);
final solanaNode = nodeSource.get(solanaNodeId);
final tronNode = nodeSource.get(tronNodeId);
final wowneroNode = nodeSource.get(wowneroNodeId);
final packageInfo = await PackageInfo.fromPlatform();
final deviceName = await _getDeviceName() ?? '';
final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
@@ -979,6 +994,10 @@ abstract class SettingsStoreBase with Store {
nodes[WalletType.tron] = tronNode;
}
if (wowneroNode != null) {
nodes[WalletType.wownero] = wowneroNode;
}
final savedSyncMode = SyncMode.all.firstWhere((element) {
return element.type.index == (sharedPreferences.getInt(PreferencesKey.syncModeKey) ?? 0);
});
@@ -1127,6 +1146,7 @@ abstract class SettingsStoreBase with Store {
silentPaymentsCardDisplay: silentPaymentsCardDisplay,
silentPaymentsAlwaysScan: silentPaymentsAlwaysScan,
initialMoneroTransactionPriority: moneroTransactionPriority,
initialWowneroTransactionPriority: wowneroTransactionPriority,
initialBitcoinTransactionPriority: bitcoinTransactionPriority,
initialHavenTransactionPriority: havenTransactionPriority,
initialLitecoinTransactionPriority: litecoinTransactionPriority,
@@ -1164,6 +1184,10 @@ abstract class SettingsStoreBase with Store {
raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!) ??
priority[WalletType.monero]!;
priority[WalletType.wownero] = wownero?.deserializeWowneroTransactionPriority(
raw: sharedPreferences.getInt(PreferencesKey.wowneroTransactionPriority)!) ??
priority[WalletType.wownero]!;
if (bitcoin != null &&
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority) != null) {
priority[WalletType.bitcoin] = bitcoin!.deserializeBitcoinTransactionPriority(
@@ -1282,6 +1306,7 @@ abstract class SettingsStoreBase with Store {
final nanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
final solanaNodeId = sharedPreferences.getInt(PreferencesKey.currentSolanaNodeIdKey);
final tronNodeId = sharedPreferences.getInt(PreferencesKey.currentTronNodeIdKey);
final wowneroNodeId = sharedPreferences.getInt(PreferencesKey.currentWowneroNodeIdKey);
final moneroNode = nodeSource.get(nodeId);
final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
@@ -1292,6 +1317,7 @@ abstract class SettingsStoreBase with Store {
final nanoNode = nodeSource.get(nanoNodeId);
final solanaNode = nodeSource.get(solanaNodeId);
final tronNode = nodeSource.get(tronNodeId);
final wowneroNode = nodeSource.get(wowneroNodeId);
if (moneroNode != null) {
nodes[WalletType.monero] = moneroNode;
}
@@ -1332,6 +1358,10 @@ abstract class SettingsStoreBase with Store {
nodes[WalletType.tron] = tronNode;
}
if (wowneroNode != null) {
nodes[WalletType.wownero] = wowneroNode;
}
// MIGRATED:
useTOTP2FA = await SecureKey.getBool(
@@ -1465,6 +1495,9 @@ abstract class SettingsStoreBase with Store {
case WalletType.tron:
await _sharedPreferences.setInt(PreferencesKey.currentTronNodeIdKey, node.key as int);
break;
case WalletType.wownero:
await _sharedPreferences.setInt(PreferencesKey.currentWowneroNodeIdKey, node.key as int);
break;
default:
break;
}
+1 -1
View File
@@ -1,5 +1,5 @@
import 'dart:io';
import 'package:package_info/package_info.dart';
import 'package:cake_wallet/utils/package_info.dart';
enum DistributionType { googleplay, github, appstore, fdroid }
+4 -4
View File
@@ -5,12 +5,12 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/main.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cw_core/root_dir.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mailer/flutter_mailer.dart';
import 'package:package_info/package_info.dart';
import 'package:path_provider/path_provider.dart';
import 'package:cake_wallet/utils/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ExceptionHandler {
@@ -20,7 +20,7 @@ class ExceptionHandler {
static void _saveException(String? error, StackTrace? stackTrace, {String? library}) async {
if (_file == null) {
final appDocDir = await getApplicationDocumentsDirectory();
final appDocDir = await getAppDir();
_file = File('${appDocDir.path}/error.txt');
}
@@ -53,7 +53,7 @@ class ExceptionHandler {
static void _sendExceptionFile() async {
try {
if (_file == null) {
final appDocDir = await getApplicationDocumentsDirectory();
final appDocDir = await getAppDir();
_file = File('${appDocDir.path}/error.txt');
}
+54
View File
@@ -0,0 +1,54 @@
import 'dart:io';
import 'package:package_info/package_info.dart' as __package_info__;
abstract class _EnvKeys {
static const kWinAppName = 'CW_WIN_APP_NAME';
static const kWinAppPackageName = 'CW_WIN_APP_PACKAGE_NAME';
static const kWinAppVersion = 'CW_WIN_APP_VERSION';
static const kWinAppBuildNumber = 'CW_WIN_APP_BUILD_NUMBER';
}
class PackageInfo {
static Future<PackageInfo> fromPlatform() async {
if (Platform.isWindows) {
return _windowsPackageInfo;
}
final packageInfo = await __package_info__.PackageInfo.fromPlatform();
return PackageInfo._(
appName: packageInfo.appName,
packageName: packageInfo.packageName,
version: packageInfo.version,
buildNumber: packageInfo.buildNumber);
}
static const _defaultCWAppName = 'Cake Wallet';
static const _defaultCWAppPackageName = 'com.cakewallet.cake_wallet';
static const _defaultCWAppVersion = '1.0.0';
static const _defaultCWAppBuildNumber = '1';
static const _windowsPackageInfo = PackageInfo._(
appName: const String
.fromEnvironment(_EnvKeys.kWinAppName,
defaultValue: _defaultCWAppName),
packageName: const String
.fromEnvironment(_EnvKeys.kWinAppPackageName,
defaultValue: _defaultCWAppPackageName),
version: const String
.fromEnvironment(_EnvKeys.kWinAppVersion,
defaultValue: _defaultCWAppVersion),
buildNumber: const String
.fromEnvironment(_EnvKeys.kWinAppBuildNumber,
defaultValue: _defaultCWAppBuildNumber));
final String appName;
final String packageName;
final String version;
final String buildNumber;
const PackageInfo._({
required this.appName,
required this.packageName,
required this.version,
required this.buildNumber});
}
@@ -41,6 +41,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
case WalletType.tron:
return true;
case WalletType.monero:
case WalletType.wownero:
case WalletType.none:
case WalletType.bitcoin:
case WalletType.litecoin:
@@ -51,7 +52,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
}
}
bool get hasSeedTypeOption => type == WalletType.monero;
bool get hasSeedTypeOption => type == WalletType.monero || type == WalletType.wownero;
@computed
bool get addCustomNode => _addCustomNode;
+4 -2
View File
@@ -4,6 +4,8 @@ import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/store/secret_store.dart';
import 'package:cw_core/root_dir.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'package:intl/intl.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
@@ -72,7 +74,7 @@ abstract class BackupViewModelBase with Store {
}
Future<String> saveBackupFileLocally(BackupExportFile backup) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final path = '${appDir.path}/${backup.name}';
final backupFile = File(path);
await backupFile.writeAsBytes(backup.content);
@@ -80,7 +82,7 @@ abstract class BackupViewModelBase with Store {
}
Future<void> removeBackupFileLocally(BackupExportFile backup) async {
final appDir = await getApplicationDocumentsDirectory();
final appDir = await getAppDir();
final path = '${appDir.path}/${backup.name}';
final backupFile = File(path);
await backupFile.delete();
@@ -125,6 +125,7 @@ abstract class BalanceViewModelBase with Store {
String get availableBalanceLabel {
switch (wallet.type) {
case WalletType.monero:
case WalletType.wownero:
case WalletType.haven:
case WalletType.ethereum:
case WalletType.polygon:
@@ -142,6 +143,7 @@ abstract class BalanceViewModelBase with Store {
String get additionalBalanceLabel {
switch (wallet.type) {
case WalletType.monero:
case WalletType.wownero:
case WalletType.haven:
case WalletType.ethereum:
case WalletType.polygon:
@@ -303,6 +303,7 @@ abstract class DashboardViewModelBase with Store {
bool get hasRescan =>
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.monero ||
wallet.type == WalletType.wownero ||
wallet.type == WalletType.haven;
@computed
@@ -532,6 +533,11 @@ abstract class DashboardViewModelBase with Store {
@action
void setSyncAll(bool value) => settingsStore.currentSyncAll = value;
Future<List<String>> checkForHavenWallets() async {
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
return walletInfoSource.values.where((element) => element.type == WalletType.haven).map((e) => e.name).toList();
}
Future<List<String>> checkAffectedWallets() async {
try {
// await load file
@@ -7,6 +7,7 @@ import 'package:cake_wallet/polygon/polygon.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/solana/solana.dart';
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:cw_core/transaction_info.dart';
@@ -55,8 +56,14 @@ class TransactionListItem extends ActionListItem with Keyable {
}
String get formattedPendingStatus {
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
return ' (${transaction.confirmations}/10)';
if (balanceViewModel.wallet.type == WalletType.monero || balanceViewModel.wallet.type == WalletType.haven) {
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
return ' (${transaction.confirmations}/10)';
}
} else if (balanceViewModel.wallet.type == WalletType.wownero) {
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
return ' (${transaction.confirmations}/3)';
}
}
return '';
}
@@ -64,6 +71,7 @@ class TransactionListItem extends ActionListItem with Keyable {
String get formattedStatus {
if (transaction.direction == TransactionDirection.incoming) {
if (balanceViewModel.wallet.type == WalletType.monero ||
balanceViewModel.wallet.type == WalletType.wownero ||
balanceViewModel.wallet.type == WalletType.haven) {
return formattedPendingStatus;
}
@@ -95,7 +103,7 @@ class TransactionListItem extends ActionListItem with Keyable {
} catch (e) {
return null;
}
return null;
}
@@ -108,6 +116,11 @@ class TransactionListItem extends ActionListItem with Keyable {
cryptoAmount: monero!.formatterMoneroAmountToDouble(amount: transaction.amount),
price: price);
break;
case WalletType.wownero:
amount = calculateFiatAmountRaw(
cryptoAmount: wownero!.formatterWowneroAmountToDouble(amount: transaction.amount),
price: price);
break;
case WalletType.bitcoin:
case WalletType.litecoin:
case WalletType.bitcoinCash:
@@ -287,6 +287,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
bool get isLowFee {
switch (wallet.type) {
case WalletType.monero:
case WalletType.wownero:
case WalletType.haven:
return transactionPriority == monero!.getMoneroTransactionPrioritySlow();
case WalletType.bitcoin:
@@ -670,6 +671,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
depositCurrency = CryptoCurrency.nano;
receiveCurrency = CryptoCurrency.xmr;
break;
case WalletType.banano:
depositCurrency = CryptoCurrency.banano;
receiveCurrency = CryptoCurrency.xmr;
break;
case WalletType.polygon:
depositCurrency = CryptoCurrency.maticpoly;
receiveCurrency = CryptoCurrency.xmr;
@@ -682,7 +687,11 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
depositCurrency = CryptoCurrency.trx;
receiveCurrency = CryptoCurrency.xmr;
break;
default:
case WalletType.wownero:
depositCurrency = CryptoCurrency.wow;
receiveCurrency = CryptoCurrency.xmr;
break;
case WalletType.none:
break;
}
}
@@ -755,6 +764,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
switch (wallet.type) {
case WalletType.monero:
case WalletType.haven:
case WalletType.wownero:
_settingsStore.priority[wallet.type] = monero!.getMoneroTransactionPriorityAutomatic();
break;
case WalletType.bitcoin:
@@ -80,6 +80,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
return true;
case WalletType.none:
case WalletType.monero:
case WalletType.wownero:
case WalletType.haven:
case WalletType.litecoin:
case WalletType.bitcoinCash:
@@ -85,6 +85,9 @@ abstract class NodeListViewModelBase with Store {
case WalletType.tron:
node = getTronDefaultNode(nodes: _nodeSource)!;
break;
case WalletType.wownero:
node = getWowneroDefaultNode(nodes: _nodeSource);
break;
default:
throw Exception('Unexpected wallet type: ${_appStore.wallet!.type}');
}
+18 -1
View File
@@ -7,6 +7,7 @@ import 'package:cake_wallet/solana/solana.dart';
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/view_model/restore/restore_mode.dart';
import 'package:cake_wallet/view_model/restore/restore_wallet.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/monero/monero.dart';
@@ -48,7 +49,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
@observable
String address;
bool get hasRestorationHeight => type == WalletType.monero;
bool get hasRestorationHeight => type == WalletType.monero || type == WalletType.wownero;
@override
WalletCredentials getCredentialsFromRestoredWallet(
@@ -74,6 +75,15 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
viewKey: restoreWallet.viewKey ?? '',
spendKey: restoreWallet.spendKey ?? '',
height: restoreWallet.height ?? 0);
case WalletType.wownero:
return wownero!.createWowneroRestoreWalletFromKeysCredentials(
name: name,
password: password,
language: 'English',
address: restoreWallet.address ?? '',
viewKey: restoreWallet.viewKey ?? '',
spendKey: restoreWallet.spendKey ?? '',
height: restoreWallet.height ?? 0);
case WalletType.bitcoin:
case WalletType.litecoin:
return bitcoin!.createBitcoinRestoreWalletFromWIFCredentials(
@@ -137,6 +147,13 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
case WalletType.tron:
return tron!.createTronRestoreWalletFromSeedCredentials(
name: name, mnemonic: restoreWallet.mnemonicSeed ?? '', password: password);
case WalletType.wownero:
return wownero!.createWowneroRestoreWalletFromSeedCredentials(
name: name,
height: restoreWallet.height ?? 0,
mnemonic: restoreWallet.mnemonicSeed ?? '',
password: password,
);
default:
throw Exception('Unexpected type: ${type.toString()}');
}
@@ -36,6 +36,9 @@ class WalletRestoreFromQRCode {
'tron': WalletType.tron,
'tron-wallet': WalletType.tron,
'tron_wallet': WalletType.tron,
'wownero': WalletType.wownero,
'wownero-wallet': WalletType.wownero,
'wownero_wallet': WalletType.wownero,
};
static bool _containsAssetSpecifier(String code) => _extractWalletType(code) != null;
@@ -57,7 +60,9 @@ class WalletRestoreFromQRCode {
RegExp _getPattern(int wordCount) =>
RegExp(r'(?<=\W|^)((?:\w+\s+){' + (wordCount - 1).toString() + r'}\w+)(?=\W|$)');
List<int> patternCounts = walletType == WalletType.monero ? [25, 16, 14, 13] : [24, 18, 12];
List<int> patternCounts = walletType == WalletType.monero || walletType == WalletType.wownero
? [25, 16, 14, 13]
: [24, 18, 12];
for (final count in patternCounts) {
final pattern = _getPattern(count);
@@ -132,7 +137,8 @@ class WalletRestoreFromQRCode {
final seedValue = credentials['seed'] as String;
final words = SeedValidator.getWordList(type: type, language: 'english');
if (type == WalletType.monero && Polyseed.isValidSeed(seedValue)) {
if ((type == WalletType.monero || type == WalletType.wownero) &&
Polyseed.isValidSeed(seedValue)) {
return WalletRestoreMode.seed;
}
+11
View File
@@ -9,6 +9,7 @@ import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/solana/solana.dart';
import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
@@ -100,6 +101,9 @@ abstract class OutputBase with Store {
case WalletType.polygon:
_amount = polygon!.formatterPolygonParseAmount(_cryptoAmount);
break;
case WalletType.wownero:
_amount = wownero!.formatterWowneroParseAmount(amount: _cryptoAmount);
break;
default:
break;
}
@@ -154,6 +158,10 @@ abstract class OutputBase with Store {
return monero!.formatterMoneroAmountToDouble(amount: fee);
}
if (_wallet.type == WalletType.wownero) {
return wownero!.formatterWowneroAmountToDouble(amount: fee);
}
if (_wallet.type == WalletType.haven) {
return haven!.formatterMoneroAmountToDouble(amount: fee);
}
@@ -287,6 +295,9 @@ abstract class OutputBase with Store {
case WalletType.tron:
maximumFractionDigits = 12;
break;
case WalletType.wownero:
maximumFractionDigits = 11;
break;
default:
break;
}
+6
View File
@@ -16,6 +16,7 @@ import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/exceptions.dart';
import 'package:cw_core/transaction_priority.dart';
import 'package:cake_wallet/view_model/send/output.dart';
@@ -244,6 +245,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
wallet.type == WalletType.bitcoin ||
wallet.type == WalletType.litecoin ||
wallet.type == WalletType.monero ||
wallet.type == WalletType.wownero ||
wallet.type == WalletType.bitcoinCash;
@computed
@@ -478,6 +480,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return monero!
.createMoneroTransactionCreationCredentials(outputs: outputs, priority: priority!);
case WalletType.wownero:
return wownero!
.createWowneroTransactionCreationCredentials(outputs: outputs, priority: priority!);
case WalletType.haven:
return haven!.createHavenTransactionCreationCredentials(
outputs: outputs, priority: priority!, assetType: selectedCryptoCurrency.title);
@@ -1,8 +1,11 @@
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/entities/provider_types.dart';
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
import 'package:cake_wallet/entities/provider_types.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/package_info.dart';
// import 'package:package_info/package_info.dart';
import 'package:collection/collection.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/transaction_info.dart';
@@ -10,19 +13,18 @@ import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
import 'package:package_info/package_info.dart';
import 'package:collection/collection.dart';
part 'other_settings_view_model.g.dart';
class OtherSettingsViewModel = OtherSettingsViewModelBase with _$OtherSettingsViewModel;
class OtherSettingsViewModel = OtherSettingsViewModelBase
with _$OtherSettingsViewModel;
abstract class OtherSettingsViewModelBase with Store {
OtherSettingsViewModelBase(this._settingsStore, this._wallet)
: walletType = _wallet.type,
currentVersion = '' {
PackageInfo.fromPlatform()
.then((PackageInfo packageInfo) => currentVersion = packageInfo.version);
PackageInfo.fromPlatform().then(
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
final priority = _settingsStore.priority[_wallet.type];
final priorities = priorityForWalletType(_wallet.type);
@@ -33,7 +35,8 @@ abstract class OtherSettingsViewModelBase with Store {
}
final WalletType walletType;
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> _wallet;
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
TransactionInfo> _wallet;
@observable
String currentVersion;
@@ -61,10 +64,12 @@ abstract class OtherSettingsViewModelBase with Store {
_wallet.type == WalletType.tron);
@computed
bool get isEnabledBuyAction => !_settingsStore.disableBuy && _wallet.type != WalletType.haven;
bool get isEnabledBuyAction =>
!_settingsStore.disableBuy && _wallet.type != WalletType.haven;
@computed
bool get isEnabledSellAction => !_settingsStore.disableSell && _wallet.type != WalletType.haven;
bool get isEnabledSellAction =>
!_settingsStore.disableSell && _wallet.type != WalletType.haven;
List<ProviderType> get availableBuyProvidersTypes {
return ProvidersHelper.getAvailableBuyProviderTypes(walletType);
@@ -74,12 +79,12 @@ abstract class OtherSettingsViewModelBase with Store {
ProvidersHelper.getAvailableSellProviderTypes(walletType);
ProviderType get buyProviderType =>
_settingsStore.defaultBuyProviders[walletType] ?? ProviderType.askEachTime;
_settingsStore.defaultBuyProviders[walletType] ??
ProviderType.askEachTime;
ProviderType get sellProviderType =>
_settingsStore.defaultSellProviders[walletType] ?? ProviderType.askEachTime;
_settingsStore.defaultSellProviders[walletType] ??
ProviderType.askEachTime;
String getDisplayPriority(dynamic priority) {
final _priority = priority as TransactionPriority;
@@ -101,7 +106,8 @@ abstract class OtherSettingsViewModelBase with Store {
_wallet.type == WalletType.litecoin ||
_wallet.type == WalletType.bitcoinCash) {
final rate = bitcoin!.getFeeRate(_wallet, _priority);
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate, customRate: customValue);
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate,
customRate: customValue);
}
return priority.toString();
@@ -124,7 +130,8 @@ abstract class OtherSettingsViewModelBase with Store {
void onDisplayPrioritySelected(TransactionPriority priority) =>
_settingsStore.priority[walletType] = priority;
void onDisplayBitcoinPrioritySelected(TransactionPriority priority, double customValue) {
void onDisplayBitcoinPrioritySelected(
TransactionPriority priority, double customValue) {
if (_wallet.type == WalletType.bitcoin) {
_settingsStore.customBitcoinFeeRate = customValue.round();
}
@@ -132,12 +139,13 @@ abstract class OtherSettingsViewModelBase with Store {
}
@computed
double get customBitcoinFeeRate => _settingsStore.customBitcoinFeeRate.toDouble();
double get customBitcoinFeeRate =>
_settingsStore.customBitcoinFeeRate.toDouble();
int? get customPriorityItemIndex {
final priorities = priorityForWalletType(walletType);
final customItem = priorities
.firstWhereOrNull((element) => element == bitcoin!.getBitcoinTransactionPriorityCustom());
final customItem = priorities.firstWhereOrNull(
(element) => element == bitcoin!.getBitcoinTransactionPriorityCustom());
return customItem != null ? priorities.indexOf(customItem) : null;
}
@@ -41,6 +41,7 @@ abstract class PrivacySettingsViewModelBase with Store {
bool get isAutoGenerateSubaddressesVisible =>
_wallet.type == WalletType.monero ||
_wallet.type == WalletType.wownero ||
_wallet.type == WalletType.bitcoin ||
_wallet.type == WalletType.litecoin ||
_wallet.type == WalletType.bitcoinCash;
@@ -1,4 +1,5 @@
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/wallet_type.dart';
@@ -75,6 +76,9 @@ abstract class TransactionDetailsViewModelBase with Store {
case WalletType.tron:
_addTronListItems(tx, dateFormat);
break;
case WalletType.wownero:
_addWowneroListItems(tx, dateFormat);
break;
default:
break;
}
@@ -166,7 +170,9 @@ abstract class TransactionDetailsViewModelBase with Store {
return 'https://solscan.io/tx/${txId}';
case WalletType.tron:
return 'https://tronscan.org/#/transaction/${txId}';
default:
case WalletType.wownero:
return 'https://explore.wownero.com/tx/${txId}';
case WalletType.none:
return '';
}
}
@@ -194,7 +200,9 @@ abstract class TransactionDetailsViewModelBase with Store {
return S.current.view_transaction_on + 'solscan.io';
case WalletType.tron:
return S.current.view_transaction_on + 'tronscan.org';
default:
case WalletType.wownero:
return S.current.view_transaction_on + 'Wownero.com';
case WalletType.none:
return '';
}
}
@@ -439,4 +447,44 @@ abstract class TransactionDetailsViewModelBase with Store {
String get pendingTransactionFeeFiatAmountFormatted => sendViewModel.isFiatDisabled
? ''
: sendViewModel.pendingTransactionFeeFiatAmount + ' ' + sendViewModel.fiat.title;
void _addWowneroListItems(TransactionInfo tx, DateFormat dateFormat) {
final key = tx.additionalInfo['key'] as String?;
final accountIndex = tx.additionalInfo['accountIndex'] as int;
final addressIndex = tx.additionalInfo['addressIndex'] as int;
final feeFormatted = tx.feeFormatted();
final _items = [
StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id),
StandartListItem(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),
StandartListItem(title: S.current.transaction_details_amount, value: tx.amountFormatted()),
if (feeFormatted != null)
StandartListItem(title: S.current.transaction_details_fee, value: feeFormatted),
if (key?.isNotEmpty ?? false) StandartListItem(title: S.current.transaction_key, value: key!),
];
if (tx.direction == TransactionDirection.incoming) {
try {
final address = wownero!.getTransactionAddress(wallet, accountIndex, addressIndex);
final label = wownero!.getSubaddressLabel(wallet, accountIndex, addressIndex);
if (address.isNotEmpty) {
isRecipientAddressShown = true;
_items.add(StandartListItem(
title: S.current.transaction_details_recipient_address,
value: address,
));
}
if (label.isNotEmpty) {
_items.add(StandartListItem(title: S.current.address_label, value: label));
}
} catch (e) {
print(e.toString());
}
}
items.addAll(_items);
}
}
@@ -2,6 +2,7 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/unspent_transaction_output.dart';
import 'package:cw_core/wallet_base.dart';
@@ -62,6 +63,8 @@ abstract class UnspentCoinsListViewModelBase with Store {
String formatAmountToString(int fullBalance) {
if (wallet.type == WalletType.monero)
return monero!.formatterMoneroAmountToString(amount: fullBalance);
if (wallet.type == WalletType.wownero)
return wownero!.formatterWowneroAmountToString(amount: fullBalance);
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
return bitcoin!.formatterBitcoinAmountToString(amount: fullBalance);
return '';
@@ -71,6 +74,9 @@ abstract class UnspentCoinsListViewModelBase with Store {
if (wallet.type == WalletType.monero) {
await monero!.updateUnspents(wallet);
}
if (wallet.type == WalletType.wownero) {
await wownero!.updateUnspents(wallet);
}
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type)) {
await bitcoin!.updateUnspents(wallet);
}
@@ -80,6 +86,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
List<Unspent> _getUnspents() {
if (wallet.type == WalletType.monero) return monero!.getUnspents(wallet);
if (wallet.type == WalletType.wownero) return wownero!.getUnspents(wallet);
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
return bitcoin!.getUnspents(wallet);
return List.empty();
@@ -17,6 +17,7 @@ import 'package:cake_wallet/utils/list_item.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
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/wownero/wownero.dart';
import 'package:cw_core/amount_converter.dart';
import 'package:cw_core/currency.dart';
import 'package:cw_core/wallet_type.dart';
@@ -191,6 +192,22 @@ class TronURI extends PaymentURI {
}
}
class WowneroURI extends PaymentURI {
WowneroURI({required String amount, required String address})
: super(amount: amount, address: address);
@override
String toString() {
var base = 'wownero:' + address;
if (amount.isNotEmpty) {
base += '?tx_amount=${amount.replaceAll(',', '.')}';
}
return base;
}
}
abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewModel with Store {
WalletAddressListViewModelBase({
required AppStore appStore,
@@ -293,6 +310,10 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
return TronURI(amount: amount, address: address.address);
}
if (wallet.type == WalletType.wownero) {
return WowneroURI(amount: amount, address: address.address);
}
throw Exception('Unexpected type: ${type.toString()}');
}
@@ -409,6 +430,20 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
}
if (wallet.type == WalletType.wownero) {
final primaryAddress = wownero!.getSubaddressList(wallet).subaddresses.first;
final addressItems = wownero!.getSubaddressList(wallet).subaddresses.map((subaddress) {
final isPrimary = subaddress == primaryAddress;
return WalletAddressListItem(
id: subaddress.id,
isPrimary: isPrimary,
name: subaddress.label,
address: subaddress.address);
});
addressList.addAll(addressItems);
}
if (searchText.isNotEmpty) {
return ObservableList.of(addressList.where((item) {
if (item is WalletAddressListItem) {
+8 -1
View File
@@ -13,6 +13,7 @@ import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/entities/generate_name.dart';
import 'package:polyseed/polyseed.dart';
part 'wallet_creation_vm.g.dart';
@@ -42,6 +43,10 @@ abstract class WalletCreationVMBase with Store {
final Box<WalletInfo> _walletInfoSource;
final AppStore _appStore;
bool isPolyseed(String seed) =>
(type == WalletType.monero || type == WalletType.wownero) &&
(Polyseed.isValidSeed(seed) || (seed.split(" ").length == 14));
bool nameExists(String name) => walletCreationService.exists(name);
bool typeExists(WalletType type) => walletCreationService.typeExists(type);
@@ -86,7 +91,9 @@ abstract class WalletCreationVMBase with Store {
getIt.get<BackgroundTasks>().registerSyncTask();
_appStore.authenticationStore.allowed();
state = ExecutedSuccessfullyState();
} catch (e) {
} catch (e, s) {
print("@@@@@@@@");
print(s);
state = FailureState(e.toString());
}
}
+114 -34
View File
@@ -4,11 +4,13 @@ import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cw_monero/api/wallet.dart' as monero_wallet;
import 'package:cw_monero/monero_wallet.dart';
import 'package:cw_wownero/wownero_wallet.dart';
import 'package:mobx/mobx.dart';
import 'package:polyseed/polyseed.dart';
@@ -32,13 +34,17 @@ abstract class WalletKeysViewModelBase with Store {
_populateItems();
});
if (_appStore.wallet!.type == WalletType.monero || _appStore.wallet!.type == WalletType.haven) {
if (_appStore.wallet!.type == WalletType.monero ||
_appStore.wallet!.type == WalletType.haven ||
_appStore.wallet!.type == WalletType.wownero) {
final accountTransactions = _getWalletTransactions(_appStore.wallet!);
if (accountTransactions.isNotEmpty) {
final incomingAccountTransactions =
accountTransactions.where((tx) => tx.direction == TransactionDirection.incoming);
final incomingAccountTransactions = accountTransactions
.where((tx) => tx.direction == TransactionDirection.incoming);
if (incomingAccountTransactions.isNotEmpty) {
incomingAccountTransactions.toList().sort((a, b) => a.date.compareTo(b.date));
incomingAccountTransactions
.toList()
.sort((a, b) => a.date.compareTo(b.date));
_restoreHeightByTransactions = _getRestoreHeightByTransactions(
_appStore.wallet!.type, incomingAccountTransactions.first.date);
}
@@ -64,29 +70,38 @@ abstract class WalletKeysViewModelBase with Store {
items.addAll([
if (keys['publicSpendKey'] != null)
StandartListItem(title: S.current.spend_key_public, value: keys['publicSpendKey']!),
StandartListItem(
title: S.current.spend_key_public,
value: keys['publicSpendKey']!),
if (keys['privateSpendKey'] != null)
StandartListItem(title: S.current.spend_key_private, value: keys['privateSpendKey']!),
StandartListItem(
title: S.current.spend_key_private,
value: keys['privateSpendKey']!),
if (keys['publicViewKey'] != null)
StandartListItem(title: S.current.view_key_public, value: keys['publicViewKey']!),
StandartListItem(
title: S.current.view_key_public, value: keys['publicViewKey']!),
if (keys['privateViewKey'] != null)
StandartListItem(title: S.current.view_key_private, value: keys['privateViewKey']!),
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
if (_appStore.wallet?.seed != null && Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
if (_appStore.wallet?.seed != null &&
Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
final lang = PolyseedLang.getByPhrase(_appStore.wallet!.seed!);
final legacyLang = _getLegacySeedLang(lang);
final legacySeed =
Polyseed.decode(_appStore.wallet!.seed!, lang, PolyseedCoin.POLYSEED_MONERO)
.toLegacySeed(legacyLang);
items.add(StandartListItem(title: S.current.wallet_seed_legacy, value: legacySeed));
items.add(StandartListItem(
title: S.current.wallet_seed_legacy,
value: (_appStore.wallet as MoneroWalletBase)
.seedLegacy(lang.nameEnglish)));
}
final restoreHeight = monero!.getRestoreHeight(_appStore.wallet!);
if (restoreHeight != null) {
items.add(StandartListItem(
title: S.current.wallet_recovery_height, value: restoreHeight.toString()));
title: S.current.wallet_recovery_height,
value: restoreHeight.toString()));
}
}
@@ -95,17 +110,58 @@ abstract class WalletKeysViewModelBase with Store {
items.addAll([
if (keys['publicSpendKey'] != null)
StandartListItem(title: S.current.spend_key_public, value: keys['publicSpendKey']!),
StandartListItem(
title: S.current.spend_key_public,
value: keys['publicSpendKey']!),
if (keys['privateSpendKey'] != null)
StandartListItem(title: S.current.spend_key_private, value: keys['privateSpendKey']!),
StandartListItem(
title: S.current.spend_key_private,
value: keys['privateSpendKey']!),
if (keys['publicViewKey'] != null)
StandartListItem(title: S.current.view_key_public, value: keys['publicViewKey']!),
StandartListItem(
title: S.current.view_key_public, value: keys['publicViewKey']!),
if (keys['privateViewKey'] != null)
StandartListItem(title: S.current.view_key_private, value: keys['privateViewKey']!),
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
}
if (_appStore.wallet!.type == WalletType.wownero) {
final keys = wownero!.getKeys(_appStore.wallet!);
items.addAll([
if (keys['publicSpendKey'] != null)
StandartListItem(
title: S.current.spend_key_public,
value: keys['publicSpendKey']!),
if (keys['privateSpendKey'] != null)
StandartListItem(
title: S.current.spend_key_private,
value: keys['privateSpendKey']!),
if (keys['publicViewKey'] != null)
StandartListItem(
title: S.current.view_key_public, value: keys['publicViewKey']!),
if (keys['privateViewKey'] != null)
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
if (_appStore.wallet?.seed != null &&
Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
final lang = PolyseedLang.getByPhrase(_appStore.wallet!.seed!);
items.add(StandartListItem(
title: S.current.wallet_seed_legacy,
value: (_appStore.wallet as WowneroWalletBase)
.seedLegacy(lang.nameEnglish)));
}
}
if (_appStore.wallet!.type == WalletType.bitcoin ||
_appStore.wallet!.type == WalletType.litecoin ||
_appStore.wallet!.type == WalletType.bitcoinCash) {
@@ -118,7 +174,8 @@ abstract class WalletKeysViewModelBase with Store {
// StandartListItem(title: S.current.private_key, value: keys['privateKey']!),
// if (keys['publicKey'] != null)
// StandartListItem(title: S.current.public_key, value: keys['publicKey']!),
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
}
@@ -127,24 +184,32 @@ abstract class WalletKeysViewModelBase with Store {
_appStore.wallet!.type == WalletType.tron) {
items.addAll([
if (_appStore.wallet!.privateKey != null)
StandartListItem(title: S.current.private_key, value: _appStore.wallet!.privateKey!),
StandartListItem(
title: S.current.private_key,
value: _appStore.wallet!.privateKey!),
if (_appStore.wallet!.seed != null)
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
}
bool nanoBased =
_appStore.wallet!.type == WalletType.nano || _appStore.wallet!.type == WalletType.banano;
bool nanoBased = _appStore.wallet!.type == WalletType.nano ||
_appStore.wallet!.type == WalletType.banano;
if (nanoBased) {
// we always have the hex version of the seed and private key:
items.addAll([
if (_appStore.wallet!.seed != null)
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
if (_appStore.wallet!.hexSeed != null)
StandartListItem(title: S.current.seed_hex_form, value: _appStore.wallet!.hexSeed!),
StandartListItem(
title: S.current.seed_hex_form,
value: _appStore.wallet!.hexSeed!),
if (_appStore.wallet!.privateKey != null)
StandartListItem(title: S.current.private_key, value: _appStore.wallet!.privateKey!),
StandartListItem(
title: S.current.private_key,
value: _appStore.wallet!.privateKey!),
]);
}
}
@@ -154,7 +219,10 @@ abstract class WalletKeysViewModelBase with Store {
return await haven!.getCurrentHeight();
}
if (_appStore.wallet!.type == WalletType.monero) {
return monero_wallet.getCurrentHeight();
return await monero!.getCurrentHeight();
}
if (_appStore.wallet!.type == WalletType.wownero) {
return await wownero!.getCurrentHeight();
}
return null;
}
@@ -183,8 +251,10 @@ abstract class WalletKeysViewModelBase with Store {
return 'solana-wallet';
case WalletType.tron:
return 'tron-wallet';
case WalletType.wownero:
return 'wownero-wallet';
default:
throw Exception('Unexpected wallet type: ${_appStore.wallet!.toString()}');
throw Exception('Unexpected wallet type: ${_appStore.wallet!.type.toString()}');
}
}
@@ -205,7 +275,8 @@ abstract class WalletKeysViewModelBase with Store {
if (_appStore.wallet!.seed != null) 'seed': _appStore.wallet!.seed!,
if (_appStore.wallet!.seed == null && _appStore.wallet!.hexSeed != null)
'hexSeed': _appStore.wallet!.hexSeed!,
if (_appStore.wallet!.seed == null && _appStore.wallet!.privateKey != null)
if (_appStore.wallet!.seed == null &&
_appStore.wallet!.privateKey != null)
'private_key': _appStore.wallet!.privateKey!,
if (restoreHeightResult != null) ...{'height': restoreHeightResult}
};
@@ -221,6 +292,12 @@ abstract class WalletKeysViewModelBase with Store {
return monero!.getTransactionHistory(wallet).transactions.values.toList();
} else if (wallet.type == WalletType.haven) {
return haven!.getTransactionHistory(wallet).transactions.values.toList();
} else if (wallet.type == WalletType.wownero) {
return wownero!
.getTransactionHistory(wallet)
.transactions
.values
.toList();
}
return [];
}
@@ -230,11 +307,14 @@ abstract class WalletKeysViewModelBase with Store {
return monero!.getHeightByDate(date: date);
} else if (type == WalletType.haven) {
return haven!.getHeightByDate(date: date);
} else if (type == WalletType.wownero) {
return wownero!.getHeightByDate(date: date);
}
return 0;
}
String getRoundedRestoreHeight(int height) => ((height / 1000).floor() * 1000).toString();
String getRoundedRestoreHeight(int height) =>
((height / 1000).floor() * 1000).toString();
LegacySeedLang _getLegacySeedLang(PolyseedLang lang) {
switch (lang.nameEnglish) {
+10 -3
View File
@@ -2,6 +2,7 @@ import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/solana/solana.dart';
import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/monero/monero.dart';
@@ -35,11 +36,13 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
@observable
String selectedMnemonicLanguage;
bool get hasLanguageSelector => type == WalletType.monero || type == WalletType.haven;
bool get hasLanguageSelector =>
type == WalletType.monero || type == WalletType.haven || type == WalletType.wownero;
int get seedPhraseWordsLength {
switch (type) {
case WalletType.monero:
case WalletType.wownero:
if (advancedPrivacySettingsViewModel.isPolySeed) {
return 16;
}
@@ -55,7 +58,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
}
}
bool get hasSeedType => type == WalletType.monero;
bool get hasSeedType => type == WalletType.monero || type == WalletType.wownero;
@override
WalletCredentials getCredentials(dynamic _options) {
@@ -76,6 +79,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
case WalletType.bitcoinCash:
return bitcoinCash!.createBitcoinCashNewWalletCredentials(name: name);
case WalletType.nano:
case WalletType.banano:
return nano!.createNanoNewWalletCredentials(name: name);
case WalletType.polygon:
return polygon!.createPolygonNewWalletCredentials(name: name);
@@ -83,7 +87,10 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
return solana!.createSolanaNewWalletCredentials(name: name);
case WalletType.tron:
return tron!.createTronNewWalletCredentials(name: name);
default:
case WalletType.wownero:
return wownero!.createWowneroNewWalletCredentials(
name: name, language: options!.first as String, isPolyseed: options.last as bool);
case WalletType.none:
throw Exception('Unexpected type: ${type.toString()}');
}
}
+32 -8
View File
@@ -2,7 +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:cw_core/nano_account_info_response.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/polygon/polygon.dart';
import 'package:cake_wallet/solana/solana.dart';
@@ -29,8 +29,10 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
WalletRestoreViewModelBase(AppStore appStore, WalletCreationService walletCreationService,
Box<WalletInfo> walletInfoSource,
{required WalletType type})
: hasSeedLanguageSelector = type == WalletType.monero || type == WalletType.haven,
hasBlockchainHeightLanguageSelector = type == WalletType.monero || type == WalletType.haven,
: hasSeedLanguageSelector =
type == WalletType.monero || type == WalletType.haven || type == WalletType.wownero,
hasBlockchainHeightLanguageSelector =
type == WalletType.monero || type == WalletType.haven || type == WalletType.wownero,
hasRestoreFromPrivateKey = type == WalletType.ethereum ||
type == WalletType.polygon ||
type == WalletType.nano ||
@@ -42,18 +44,22 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
super(appStore, walletInfoSource, walletCreationService, type: type, isRecovery: true) {
switch (type) {
case WalletType.monero:
case WalletType.haven:
case WalletType.ethereum:
case WalletType.polygon:
availableModes = WalletRestoreMode.values;
break;
case WalletType.nano:
case WalletType.banano:
case WalletType.solana:
case WalletType.tron:
case WalletType.wownero:
case WalletType.haven:
case WalletType.ethereum:
case WalletType.polygon:
availableModes = [WalletRestoreMode.seed, WalletRestoreMode.keys];
break;
default:
case WalletType.bitcoin:
case WalletType.litecoin:
case WalletType.bitcoinCash:
case WalletType.none:
availableModes = [WalletRestoreMode.seed];
break;
}
@@ -112,6 +118,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
return bitcoinCash!.createBitcoinCashRestoreWalletFromSeedCredentials(
name: name, mnemonic: seed, password: password);
case WalletType.nano:
case WalletType.banano:
return nano!.createNanoRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
@@ -136,7 +143,14 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
mnemonic: seed,
password: password,
);
default:
case WalletType.wownero:
return wownero!.createWowneroRestoreWalletFromSeedCredentials(
name: name,
mnemonic: seed,
password: password,
height: height,
);
case WalletType.none:
break;
}
}
@@ -200,6 +214,16 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
password: password,
privateKey: options['private_key'] as String,
);
case WalletType.wownero:
return wownero!.createWowneroRestoreWalletFromKeysCredentials(
name: name,
height: height,
spendKey: spendKey!,
viewKey: viewKey!,
address: address!,
password: password,
language: 'English',
);
default:
break;
}
+5 -1
View File
@@ -16,6 +16,10 @@ bool get isSingleCoin {
return availableWalletTypes.length == 1;
}
bool get hasMonero {
return availableWalletTypes.contains(WalletType.monero);
}
String get approximatedAppName {
if (isMoneroOnly) {
return 'Monero.com';
@@ -26,4 +30,4 @@ String get approximatedAppName {
}
return 'Cake Wallet';
}
}
+347
View File
@@ -0,0 +1,347 @@
part of 'wownero.dart';
class CWWowneroAccountList extends WowneroAccountList {
CWWowneroAccountList(this._wallet);
final Object _wallet;
@override
@computed
ObservableList<Account> get accounts {
final wowneroWallet = _wallet as WowneroWallet;
final accounts = wowneroWallet.walletAddresses.accountList.accounts
.map((acc) => Account(id: acc.id, label: acc.label, balance: acc.balance))
.toList();
return ObservableList<Account>.of(accounts);
}
@override
void update(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
wowneroWallet.walletAddresses.accountList.update();
}
@override
void refresh(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
wowneroWallet.walletAddresses.accountList.refresh();
}
@override
List<Account> getAll(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.walletAddresses.accountList
.getAll()
.map((acc) => Account(id: acc.id, label: acc.label, balance: acc.balance))
.toList();
}
@override
Future<void> addAccount(Object wallet, {required String label}) async {
final wowneroWallet = wallet as WowneroWallet;
await wowneroWallet.walletAddresses.accountList.addAccount(label: label);
}
@override
Future<void> setLabelAccount(Object wallet,
{required int accountIndex, required String label}) async {
final wowneroWallet = wallet as WowneroWallet;
await wowneroWallet.walletAddresses.accountList
.setLabelAccount(accountIndex: accountIndex, label: label);
}
}
class CWWowneroSubaddressList extends WowneroSubaddressList {
CWWowneroSubaddressList(this._wallet);
final Object _wallet;
@override
@computed
ObservableList<Subaddress> get subaddresses {
final wowneroWallet = _wallet as WowneroWallet;
final subAddresses = wowneroWallet.walletAddresses.subaddressList.subaddresses
.map((sub) => Subaddress(id: sub.id, address: sub.address, label: sub.label))
.toList();
return ObservableList<Subaddress>.of(subAddresses);
}
@override
void update(Object wallet, {required int accountIndex}) {
final wowneroWallet = wallet as WowneroWallet;
wowneroWallet.walletAddresses.subaddressList.update(accountIndex: accountIndex);
}
@override
void refresh(Object wallet, {required int accountIndex}) {
final wowneroWallet = wallet as WowneroWallet;
wowneroWallet.walletAddresses.subaddressList.refresh(accountIndex: accountIndex);
}
@override
List<Subaddress> getAll(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.walletAddresses.subaddressList
.getAll()
.map((sub) => Subaddress(id: sub.id, label: sub.label, address: sub.address))
.toList();
}
@override
Future<void> addSubaddress(Object wallet,
{required int accountIndex, required String label}) async {
final wowneroWallet = wallet as WowneroWallet;
await wowneroWallet.walletAddresses.subaddressList
.addSubaddress(accountIndex: accountIndex, label: label);
}
@override
Future<void> setLabelSubaddress(Object wallet,
{required int accountIndex, required int addressIndex, required String label}) async {
final wowneroWallet = wallet as WowneroWallet;
await wowneroWallet.walletAddresses.subaddressList
.setLabelSubaddress(accountIndex: accountIndex, addressIndex: addressIndex, label: label);
}
}
class CWWowneroWalletDetails extends WowneroWalletDetails {
CWWowneroWalletDetails(this._wallet);
final Object _wallet;
@computed
@override
Account get account {
final wowneroWallet = _wallet as WowneroWallet;
final acc = wowneroWallet.walletAddresses.account;
return Account(id: acc!.id, label: acc.label, balance: acc.balance);
}
@computed
@override
WowneroBalance get balance {
throw Exception('Unimplemented');
// return WowneroBalance();
//return WowneroBalance(
// fullBalance: balance.fullBalance,
// unlockedBalance: balance.unlockedBalance);
}
}
class CWWownero extends Wownero {
@override
WowneroAccountList getAccountList(Object wallet) => CWWowneroAccountList(wallet);
@override
WowneroSubaddressList getSubaddressList(Object wallet) => CWWowneroSubaddressList(wallet);
@override
TransactionHistoryBase getTransactionHistory(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.transactionHistory;
}
@override
WowneroWalletDetails getWowneroWalletDetails(Object wallet) => CWWowneroWalletDetails(wallet);
@override
int getHeightByDate({required DateTime date}) => getWowneroHeightByDate(date: date);
@override
TransactionPriority getDefaultTransactionPriority() => MoneroTransactionPriority.automatic;
@override
TransactionPriority getWowneroTransactionPrioritySlow() => MoneroTransactionPriority.slow;
@override
TransactionPriority getWowneroTransactionPriorityAutomatic() =>
MoneroTransactionPriority.automatic;
@override
TransactionPriority deserializeWowneroTransactionPriority({required int raw}) =>
MoneroTransactionPriority.deserialize(raw: raw);
@override
List<TransactionPriority> getTransactionPriorities() => MoneroTransactionPriority.all;
@override
List<String> getWowneroWordList(String language) {
if (language.startsWith("POLYSEED_")) {
final lang = language.replaceAll("POLYSEED_", "");
return PolyseedLang.getByEnglishName(lang).words;
}
if (language.startsWith("WOWSEED_")) {
final lang = language.replaceAll("WOWSEED_", "");
return PolyseedLang.getByEnglishName(lang).words;
}
switch (language.toLowerCase()) {
case 'english':
return EnglishMnemonics.words;
case 'chinese (simplified)':
return ChineseSimplifiedMnemonics.words;
case 'dutch':
return DutchMnemonics.words;
case 'german':
return GermanMnemonics.words;
case 'japanese':
return JapaneseMnemonics.words;
case 'portuguese':
return PortugueseMnemonics.words;
case 'russian':
return RussianMnemonics.words;
case 'spanish':
return SpanishMnemonics.words;
case 'french':
return FrenchMnemonics.words;
case 'italian':
return ItalianMnemonics.words;
default:
return EnglishMnemonics.words;
}
}
@override
WalletCredentials createWowneroRestoreWalletFromKeysCredentials(
{required String name,
required String spendKey,
required String viewKey,
required String address,
required String password,
required String language,
required int height}) =>
WowneroRestoreWalletFromKeysCredentials(
name: name,
spendKey: spendKey,
viewKey: viewKey,
address: address,
password: password,
language: language,
height: height);
@override
WalletCredentials createWowneroRestoreWalletFromSeedCredentials(
{required String name,
required String password,
required int height,
required String mnemonic}) =>
WowneroRestoreWalletFromSeedCredentials(
name: name, password: password, height: height, mnemonic: mnemonic);
@override
WalletCredentials createWowneroNewWalletCredentials(
{required String name,
required String language,
required bool isPolyseed,
String? password}) =>
WowneroNewWalletCredentials(
name: name, password: password, language: language, isPolyseed: isPolyseed);
@override
Map<String, String> getKeys(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
final keys = wowneroWallet.keys;
return <String, String>{
'privateSpendKey': keys.privateSpendKey,
'privateViewKey': keys.privateViewKey,
'publicSpendKey': keys.publicSpendKey,
'publicViewKey': keys.publicViewKey
};
}
@override
Object createWowneroTransactionCreationCredentials(
{required List<Output> outputs, required TransactionPriority priority}) =>
WowneroTransactionCreationCredentials(
outputs: outputs
.map((out) => OutputInfo(
fiatAmount: out.fiatAmount,
cryptoAmount: out.cryptoAmount,
address: out.address,
note: out.note,
sendAll: out.sendAll,
extractedAddress: out.extractedAddress,
isParsedAddress: out.isParsedAddress,
formattedCryptoAmount: out.formattedCryptoAmount))
.toList(),
priority: priority as MoneroTransactionPriority);
@override
Object createWowneroTransactionCreationCredentialsRaw(
{required List<OutputInfo> outputs, required TransactionPriority priority}) =>
WowneroTransactionCreationCredentials(
outputs: outputs, priority: priority as MoneroTransactionPriority);
@override
String formatterWowneroAmountToString({required int amount}) =>
wowneroAmountToString(amount: amount);
@override
double formatterWowneroAmountToDouble({required int amount}) =>
wowneroAmountToDouble(amount: amount);
@override
int formatterWowneroParseAmount({required String amount}) => wowneroParseAmount(amount: amount);
@override
Account getCurrentAccount(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
final acc = wowneroWallet.walletAddresses.account;
return Account(id: acc!.id, label: acc.label, balance: acc.balance);
}
@override
void setCurrentAccount(Object wallet, int id, String label, String? balance) {
final wowneroWallet = wallet as WowneroWallet;
wowneroWallet.walletAddresses.account =
wownero_account.Account(id: id, label: label, balance: balance);
}
@override
void onStartup() => wownero_wallet_api.onStartup();
@override
int getTransactionInfoAccountId(TransactionInfo tx) {
final wowneroTransactionInfo = tx as WowneroTransactionInfo;
return wowneroTransactionInfo.accountIndex;
}
@override
WalletService createWowneroWalletService(
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) =>
WowneroWalletService(walletInfoSource, unspentCoinSource);
@override
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.getTransactionAddress(accountIndex, addressIndex);
}
@override
String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.getSubaddressLabel(accountIndex, addressIndex);
}
@override
Map<String, String> pendingTransactionInfo(Object transaction) {
final ptx = transaction as PendingWowneroTransaction;
return {'id': ptx.id, 'hex': ptx.hex, 'key': ptx.txKey};
}
@override
List<Unspent> getUnspents(Object wallet) {
final wowneroWallet = wallet as WowneroWallet;
return wowneroWallet.unspentCoins;
}
@override
Future<void> updateUnspents(Object wallet) async {
final wowneroWallet = wallet as WowneroWallet;
await wowneroWallet.updateUnspent();
}
@override
Future<int> getCurrentHeight() async {
return wownero_wallet_api.getCurrentHeight();
}
}