mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
@@ -7,8 +7,6 @@ add_library( cw_monero
|
||||
|
||||
find_library( log-lib log )
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../ios/External/android)
|
||||
|
||||
############
|
||||
|
||||
@@ -38,12 +38,10 @@ android {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
externalNativeBuild {
|
||||
// Encapsulates your CMake build configurations.
|
||||
cmake {
|
||||
// Provides a relative path to your CMake build script.
|
||||
path "CMakeLists.txt"
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -12,43 +12,44 @@ Pod::Spec.new do |s|
|
||||
s.author = { 'CakeWallet' => 'support@cakewallet.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/ios/libs/monero/include/src/**/*.h, External/ios/libs/monero/include/contrib/**/*.h, External/ios/libs/monero/include/External/ios/**/*.h'
|
||||
s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/ios/libs/monero/include/External/ios/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
s.dependency 'cw_shared_external'
|
||||
s.platform = :ios, '10.0'
|
||||
s.swift_version = '4.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'arm64', 'ENABLE_BITCODE' => 'NO' }
|
||||
s.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Classes/*.h" }
|
||||
|
||||
s.subspec 'OpenSSL' do |openssl|
|
||||
openssl.preserve_paths = 'External/ios/include/*.h'
|
||||
openssl.vendored_libraries = 'External/ios/lib/libcrypto.a', 'External/ios/lib/libssl.a'
|
||||
openssl.preserve_paths = '../../../../../cw_shared_external/ios/External/ios/include/**/*.h'
|
||||
openssl.vendored_libraries = '../../../../../cw_shared_external/ios/External/ios/lib/libcrypto.a', '../../../../../cw_shared_external/ios/External/ios/lib/libssl.a'
|
||||
openssl.libraries = 'ssl', 'crypto'
|
||||
openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Monero' do |monero|
|
||||
monero.preserve_paths = 'External/ios/include/**/*.h'
|
||||
monero.vendored_libraries = 'External/ios/lib/libeasylogging.a', 'External/ios/lib/libepee.a', 'External/ios/lib/liblmdb.a', 'External/ios/lib/librandomx.a', 'External/ios/lib/libunbound.a', 'External/ios/lib/libwallet_merged.a', 'libcryptonote_basic.a', 'libcryptonote_format_utils_basic.a'
|
||||
monero.libraries = 'easylogging', 'epee', 'unbound', 'wallet_merged', 'lmdb', 'randomx', 'cryptonote_basic', 'cryptonote_format_utils_basic'
|
||||
monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include" }
|
||||
end
|
||||
|
||||
s.subspec 'Boost' do |boost|
|
||||
boost.preserve_paths = 'External/ios/include/**/*.h', 'External/ios/include/**/*.h'
|
||||
boost.vendored_libraries = 'External/ios/lib/libboost_chrono.a', 'External/ios/lib/libboost_date_time.a', 'External/ios/lib/libboost_filesystem.a', 'External/ios/lib/libboost_graph.a', 'External/ios/lib/libboost_locale.a', 'External/ios/lib/libboost_program_options.a', 'External/ios/lib/libboost_random.a', 'External/ios/lib/libboost_regex.a', 'External/ios/lib/libboost_serialization.a', 'External/ios/lib/libboost_system.a', 'External/ios/lib/libboost_thread.a', 'External/ios/lib/libboost_wserialization.a'
|
||||
boost.libraries = 'boost_wserialization', 'boost_thread', 'boost_system', 'boost_serialization', 'boost_regex', 'boost_random', 'boost_program_options', 'boost_locale', 'boost_graph', 'boost_filesystem', 'boost_date_time', 'boost_chrono'
|
||||
boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Sodium' do |sodium|
|
||||
sodium.preserve_paths = 'External/ios/include/**/*.h'
|
||||
sodium.vendored_libraries = 'External/ios/lib/libsodium.a'
|
||||
sodium.preserve_paths = '../../../../../cw_shared_external/ios/External/ios/include/**/*.h'
|
||||
sodium.vendored_libraries = '../../../../../cw_shared_external/ios/External/ios/lib/libsodium.a'
|
||||
sodium.libraries = 'sodium'
|
||||
sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'lmdb' do |lmdb|
|
||||
lmdb.vendored_libraries = 'External/ios/lib/liblmdb.a'
|
||||
lmdb.libraries = 'lmdb'
|
||||
s.subspec 'Boost' do |boost|
|
||||
boost.preserve_paths = '../../../../../cw_shared_external/ios/External/ios/include/**/*.h',
|
||||
boost.vendored_libraries = '../../../../../cw_shared_external/ios/External/ios/lib/libboost.a',
|
||||
boost.libraries = 'boost'
|
||||
boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" }
|
||||
end
|
||||
|
||||
s.subspec 'Monero' do |monero|
|
||||
monero.preserve_paths = 'External/ios/include/**/*.h'
|
||||
monero.vendored_libraries = 'External/ios/lib/libmonero.a'
|
||||
monero.libraries = 'monero'
|
||||
monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include" }
|
||||
end
|
||||
|
||||
# s.subspec 'lmdb' do |lmdb|
|
||||
# lmdb.vendored_libraries = 'External/ios/lib/liblmdb.a'
|
||||
# lmdb.libraries = 'lmdb'
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import 'package:cw_monero/api/structs/account_row.dart';
|
||||
|
||||
class Account {
|
||||
Account({this.id, this.label});
|
||||
|
||||
Account.fromMap(Map map)
|
||||
: this.id = map['id'] == null ? 0 : int.parse(map['id'] as String),
|
||||
this.label = (map['label'] ?? '') as String;
|
||||
|
||||
Account.fromRow(AccountRow row)
|
||||
: this.id = row.getId(),
|
||||
this.label = row.getLabel();
|
||||
|
||||
final int id;
|
||||
final String label;
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// FIXME: Hardcoded values; Works only for monero
|
||||
|
||||
final dateFormat = DateFormat('yyyy-MM');
|
||||
final dates = {
|
||||
"2014-5": 18844,
|
||||
"2014-6": 65406,
|
||||
"2014-7": 108882,
|
||||
"2014-8": 153594,
|
||||
"2014-9": 198072,
|
||||
"2014-10": 241088,
|
||||
"2014-11": 285305,
|
||||
"2014-12": 328069,
|
||||
"2015-1": 372369,
|
||||
"2015-2": 416505,
|
||||
"2015-3": 456631,
|
||||
"2015-4": 501084,
|
||||
"2015-5": 543973,
|
||||
"2015-6": 588326,
|
||||
"2015-7": 631187,
|
||||
"2015-8": 675484,
|
||||
"2015-9": 719725,
|
||||
"2015-10": 762463,
|
||||
"2015-11": 806528,
|
||||
"2015-12": 849041,
|
||||
"2016-1": 892866,
|
||||
"2016-2": 936736,
|
||||
"2016-3": 977691,
|
||||
"2016-4": 1015848,
|
||||
"2016-5": 1037417,
|
||||
"2016-6": 1059651,
|
||||
"2016-7": 1081269,
|
||||
"2016-8": 1103630,
|
||||
"2016-9": 1125983,
|
||||
"2016-10": 1147617,
|
||||
"2016-11": 1169779,
|
||||
"2016-12": 1191402,
|
||||
"2017-1": 1213861,
|
||||
"2017-2": 1236197,
|
||||
"2017-3": 1256358,
|
||||
"2017-4": 1278622,
|
||||
"2017-5": 1300239,
|
||||
"2017-6": 1322564,
|
||||
"2017-7": 1344225,
|
||||
"2017-8": 1366664,
|
||||
"2017-9": 1389113,
|
||||
"2017-10": 1410738,
|
||||
"2017-11": 1433039,
|
||||
"2017-12": 1454639,
|
||||
"2018-1": 1477201,
|
||||
"2018-2": 1499599,
|
||||
"2018-3": 1519796,
|
||||
"2018-4": 1542067,
|
||||
"2018-5": 1562861,
|
||||
"2018-6": 1585135,
|
||||
"2018-7": 1606715,
|
||||
"2018-8": 1629017,
|
||||
"2018-9": 1651347,
|
||||
"2018-10": 1673031,
|
||||
"2018-11": 1695128,
|
||||
"2018-12": 1716687,
|
||||
"2019-1": 1738923,
|
||||
"2019-2": 1761435,
|
||||
"2019-3": 1781681,
|
||||
"2019-4": 1803081,
|
||||
"2019-5": 1824671,
|
||||
"2019-6": 1847005,
|
||||
"2019-7": 1868590,
|
||||
"2019-8": 1890552,
|
||||
"2019-9": 1912212,
|
||||
"2019-10": 1932200,
|
||||
"2019-11": 1957040,
|
||||
"2019-12": 1978090,
|
||||
"2020-1": 2001290,
|
||||
"2020-2": 2022688,
|
||||
"2020-3": 2043987,
|
||||
"2020-4": 2066536,
|
||||
"2020-5": 2090797,
|
||||
"2020-6": 2111633,
|
||||
"2020-7": 2131433,
|
||||
"2020-8": 2153983,
|
||||
"2020-9": 2176466,
|
||||
"2020-10": 2198453,
|
||||
"2020-11": 2220000
|
||||
};
|
||||
|
||||
int getMoneroHeigthByDate({DateTime date}) {
|
||||
final raw = '${date.year}' + '-' + '${date.month}';
|
||||
final lastHeight = dates.values.last;
|
||||
int startHeight;
|
||||
int endHeight;
|
||||
int height = 0;
|
||||
|
||||
try {
|
||||
if ((dates[raw] == null)||(dates[raw] == lastHeight)) {
|
||||
startHeight = dates.values.toList()[dates.length - 2];
|
||||
endHeight = dates.values.toList()[dates.length - 1];
|
||||
final heightPerDay = (endHeight - startHeight) / 31;
|
||||
final endDateRaw = dates.keys.toList()[dates.length - 1].split('-');
|
||||
final endYear = int.parse(endDateRaw[0]);
|
||||
final endMonth = int.parse(endDateRaw[1]);
|
||||
final endDate = DateTime(endYear, endMonth);
|
||||
final differenceInDays = date.difference(endDate).inDays;
|
||||
final daysHeight = (differenceInDays * heightPerDay).round();
|
||||
height = endHeight + daysHeight;
|
||||
} else {
|
||||
startHeight = dates[raw];
|
||||
final index = dates.values.toList().indexOf(startHeight);
|
||||
endHeight = dates.values.toList()[index + 1];
|
||||
final heightPerDay = ((endHeight - startHeight) / 31).round();
|
||||
final daysHeight = (date.day - 1) * heightPerDay;
|
||||
height = startHeight + daysHeight - heightPerDay;
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_monero/account.dart';
|
||||
import 'package:cw_core/account.dart';
|
||||
import 'package:cw_monero/api/account_list.dart' as account_list;
|
||||
|
||||
part 'monero_account_list.g.dart';
|
||||
@@ -44,7 +44,9 @@ abstract class MoneroAccountListBase with Store {
|
||||
|
||||
List<Account> getAll() => account_list
|
||||
.getAllAccount()
|
||||
.map((accountRow) => Account.fromRow(accountRow))
|
||||
.map((accountRow) => Account(
|
||||
id: accountRow.getId(),
|
||||
label: accountRow.getLabel()))
|
||||
.toList();
|
||||
|
||||
Future addAccount({String label}) async {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
|
||||
const moneroAmountLength = 12;
|
||||
const moneroAmountDivider = 1000000000000;
|
||||
final moneroAmountFormat = NumberFormat()
|
||||
..maximumFractionDigits = moneroAmountLength
|
||||
..minimumFractionDigits = 1;
|
||||
|
||||
String moneroAmountToString({int amount}) => moneroAmountFormat
|
||||
.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider));
|
||||
|
||||
double moneroAmountToDouble({int amount}) =>
|
||||
cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);
|
||||
|
||||
int moneroParseAmount({String amount}) =>
|
||||
(double.parse(amount) * moneroAmountDivider).toInt();
|
||||
@@ -1,30 +0,0 @@
|
||||
import 'package:cw_core/balance.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_monero/monero_amount_format.dart';
|
||||
|
||||
class MoneroBalance extends Balance {
|
||||
MoneroBalance({@required this.fullBalance, @required this.unlockedBalance})
|
||||
: formattedFullBalance = moneroAmountToString(amount: fullBalance),
|
||||
formattedUnlockedBalance =
|
||||
moneroAmountToString(amount: unlockedBalance),
|
||||
super(unlockedBalance, fullBalance);
|
||||
|
||||
MoneroBalance.fromString(
|
||||
{@required this.formattedFullBalance,
|
||||
@required this.formattedUnlockedBalance})
|
||||
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
|
||||
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
|
||||
super(moneroParseAmount(amount: formattedUnlockedBalance),
|
||||
moneroParseAmount(amount: formattedFullBalance));
|
||||
|
||||
final int fullBalance;
|
||||
final int unlockedBalance;
|
||||
final String formattedFullBalance;
|
||||
final String formattedUnlockedBalance;
|
||||
|
||||
@override
|
||||
String get formattedAvailableBalance => formattedUnlockedBalance;
|
||||
|
||||
@override
|
||||
String get formattedAdditionalBalance => formattedFullBalance;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'package:cw_monero/api/structs/subaddress_row.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_monero/api/subaddress_list.dart' as subaddress_list;
|
||||
import 'package:cw_monero/subaddress.dart';
|
||||
import 'package:cw_core/subaddress.dart';
|
||||
|
||||
part 'monero_subaddress_list.g.dart';
|
||||
|
||||
@@ -49,7 +49,13 @@ abstract class MoneroSubaddressListBase with Store {
|
||||
}
|
||||
|
||||
return subaddresses
|
||||
.map((subaddressRow) => Subaddress.fromRow(subaddressRow))
|
||||
.map((subaddressRow) => Subaddress(
|
||||
id: subaddressRow.getId(),
|
||||
address: subaddressRow.getAddress(),
|
||||
label: subaddressRow.getId() == 0 &&
|
||||
subaddressRow.getLabel().toLowerCase() == 'Primary account'.toLowerCase()
|
||||
? 'Primary address'
|
||||
: subaddressRow.getLabel()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//import 'package:cake_wallet/entities/transaction_creation_credentials.dart';
|
||||
import 'package:cw_monero/monero_transaction_priority.dart';
|
||||
//import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/output_info.dart';
|
||||
|
||||
class MoneroTransactionCreationCredentials {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_monero/monero_amount_format.dart';
|
||||
import 'package:cw_core/monero_amount_format.dart';
|
||||
import 'package:cw_monero/api/structs/transaction_info_row.dart';
|
||||
import 'package:cw_core/parseBoolFromString.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
//import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cw_core/enumerable_item.dart';
|
||||
|
||||
class MoneroTransactionPriority extends TransactionPriority {
|
||||
const MoneroTransactionPriority({String title, int raw})
|
||||
: super(title: title, raw: raw);
|
||||
|
||||
static const all = [
|
||||
MoneroTransactionPriority.slow,
|
||||
MoneroTransactionPriority.regular,
|
||||
MoneroTransactionPriority.medium,
|
||||
MoneroTransactionPriority.fast,
|
||||
MoneroTransactionPriority.fastest
|
||||
];
|
||||
static const slow = MoneroTransactionPriority(title: 'Slow', raw: 0);
|
||||
static const regular = MoneroTransactionPriority(title: 'Regular', raw: 1);
|
||||
static const medium = MoneroTransactionPriority(title: 'Medium', raw: 2);
|
||||
static const fast = MoneroTransactionPriority(title: 'Fast', raw: 3);
|
||||
static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4);
|
||||
static const standard = slow;
|
||||
|
||||
|
||||
static List<MoneroTransactionPriority> forWalletType(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
return MoneroTransactionPriority.all;
|
||||
case WalletType.bitcoin:
|
||||
return [
|
||||
MoneroTransactionPriority.slow,
|
||||
MoneroTransactionPriority.regular,
|
||||
MoneroTransactionPriority.fast
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
static MoneroTransactionPriority deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
return slow;
|
||||
case 1:
|
||||
return regular;
|
||||
case 2:
|
||||
return medium;
|
||||
case 3:
|
||||
return fast;
|
||||
case 4:
|
||||
return fastest;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case MoneroTransactionPriority.slow:
|
||||
return 'Slow'; // S.current.transaction_priority_slow;
|
||||
case MoneroTransactionPriority.regular:
|
||||
return 'Regular'; // S.current.transaction_priority_regular;
|
||||
case MoneroTransactionPriority.medium:
|
||||
return 'Medium'; // S.current.transaction_priority_medium;
|
||||
case MoneroTransactionPriority.fast:
|
||||
return 'Fast'; // S.current.transaction_priority_fast;
|
||||
case MoneroTransactionPriority.fastest:
|
||||
return 'Fastest'; // S.current.transaction_priority_fastest;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cw_monero/monero_amount_format.dart';
|
||||
import 'package:cw_core/monero_amount_format.dart';
|
||||
import 'package:cw_monero/monero_transaction_creation_exception.dart';
|
||||
import 'package:cw_monero/monero_transaction_info.dart';
|
||||
import 'package:cw_monero/monero_wallet_addresses.dart';
|
||||
import 'package:cw_monero/monero_wallet_utils.dart';
|
||||
import 'package:cw_core/monero_wallet_utils.dart';
|
||||
import 'package:cw_monero/api/structs/pending_transaction.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
@@ -16,16 +16,17 @@ import 'package:cw_monero/api/transaction_history.dart' as transaction_history;
|
||||
import 'package:cw_monero/api/monero_output.dart';
|
||||
import 'package:cw_monero/monero_transaction_creation_credentials.dart';
|
||||
import 'package:cw_monero/pending_monero_transaction.dart';
|
||||
import 'package:cw_monero/monero_wallet_keys.dart';
|
||||
import 'package:cw_monero/monero_balance.dart';
|
||||
import 'package:cw_core/monero_wallet_keys.dart';
|
||||
import 'package:cw_core/monero_balance.dart';
|
||||
import 'package:cw_monero/monero_transaction_history.dart';
|
||||
import 'package:cw_monero/account.dart';
|
||||
import 'package:cw_core/account.dart';
|
||||
import 'package:cw_core/pending_transaction.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/sync_status.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_monero/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
|
||||
part 'monero_wallet.g.dart';
|
||||
|
||||
@@ -38,18 +39,23 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
||||
MoneroWalletBase({WalletInfo walletInfo})
|
||||
: super(walletInfo) {
|
||||
transactionHistory = MoneroTransactionHistory();
|
||||
balance = MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: 0),
|
||||
unlockedBalance: monero_wallet.getFullBalance(accountIndex: 0));
|
||||
balance = ObservableMap<CryptoCurrency, MoneroBalance>.of({
|
||||
CryptoCurrency.xmr: MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: 0),
|
||||
unlockedBalance: monero_wallet.getFullBalance(accountIndex: 0))
|
||||
});
|
||||
_isTransactionUpdating = false;
|
||||
_hasSyncAfterStartup = false;
|
||||
walletAddresses = MoneroWalletAddresses(walletInfo);
|
||||
_onAccountChangeReaction = reaction((_) => walletAddresses.account,
|
||||
(Account account) {
|
||||
balance = MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: account.id),
|
||||
unlockedBalance:
|
||||
monero_wallet.getUnlockedBalance(accountIndex: account.id));
|
||||
balance = ObservableMap<CryptoCurrency, MoneroBalance>.of(
|
||||
<CryptoCurrency, MoneroBalance>{
|
||||
currency: MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: account.id),
|
||||
unlockedBalance:
|
||||
monero_wallet.getUnlockedBalance(accountIndex: account.id))
|
||||
});
|
||||
walletAddresses.updateSubaddressList(accountIndex: account.id);
|
||||
});
|
||||
}
|
||||
@@ -65,7 +71,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
||||
|
||||
@override
|
||||
@observable
|
||||
MoneroBalance balance;
|
||||
ObservableMap<CryptoCurrency, MoneroBalance> balance;
|
||||
|
||||
@override
|
||||
String get seed => monero_wallet.getSeed();
|
||||
@@ -85,10 +91,12 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
||||
|
||||
Future<void> init() async {
|
||||
await walletAddresses.init();
|
||||
balance = MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: walletAddresses.account.id),
|
||||
unlockedBalance:
|
||||
monero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account.id));
|
||||
balance = ObservableMap<CryptoCurrency, MoneroBalance>.of(
|
||||
<CryptoCurrency, MoneroBalance>{
|
||||
currency: MoneroBalance(
|
||||
fullBalance: monero_wallet.getFullBalance(accountIndex: walletAddresses.account.id),
|
||||
unlockedBalance: monero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account.id))
|
||||
});
|
||||
_setListeners();
|
||||
await updateTransactions();
|
||||
|
||||
@@ -355,9 +363,9 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
||||
final unlockedBalance = _getUnlockedBalance();
|
||||
final fullBalance = _getFullBalance();
|
||||
|
||||
if (balance.fullBalance != fullBalance ||
|
||||
balance.unlockedBalance != unlockedBalance) {
|
||||
balance = MoneroBalance(
|
||||
if (balance[currency].fullBalance != fullBalance ||
|
||||
balance[currency].unlockedBalance != unlockedBalance) {
|
||||
balance[currency] = MoneroBalance(
|
||||
fullBalance: fullBalance, unlockedBalance: unlockedBalance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:cw_core/wallet_addresses.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_monero/account.dart';
|
||||
import 'package:cw_core/account.dart';
|
||||
import 'package:cw_monero/monero_account_list.dart';
|
||||
import 'package:cw_monero/monero_subaddress_list.dart';
|
||||
import 'package:cw_monero/subaddress.dart';
|
||||
import 'package:cw_core/subaddress.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'monero_wallet_addresses.g.dart';
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
class MoneroWalletKeys {
|
||||
const MoneroWalletKeys(
|
||||
{this.privateSpendKey,
|
||||
this.privateViewKey,
|
||||
this.publicSpendKey,
|
||||
this.publicViewKey});
|
||||
|
||||
final String publicViewKey;
|
||||
final String privateViewKey;
|
||||
final String publicSpendKey;
|
||||
final String privateSpendKey;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_monero/monero_wallet_utils.dart';
|
||||
import 'package:cw_core/monero_wallet_utils.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cw_monero/api/wallet_manager.dart' as monero_wallet_manager;
|
||||
import 'package:cw_monero/api/wallet.dart' as monero_wallet;
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
import 'dart:io';
|
||||
import 'package:cw_core/pathForWallet.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
||||
String backupFileName(String originalPath) {
|
||||
final pathParts = originalPath.split('/');
|
||||
final newName = '#_${pathParts.last}';
|
||||
pathParts.removeLast();
|
||||
pathParts.add(newName);
|
||||
return pathParts.join('/');
|
||||
}
|
||||
|
||||
Future<void> backupWalletFiles(String name) async {
|
||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||
final cacheFile = File(path);
|
||||
final keysFile = File('$path.keys');
|
||||
final addressListFile = File('$path.address.txt');
|
||||
final newCacheFilePath = backupFileName(cacheFile.path);
|
||||
final newKeysFilePath = backupFileName(keysFile.path);
|
||||
final newAddressListFilePath = backupFileName(addressListFile.path);
|
||||
|
||||
if (cacheFile.existsSync()) {
|
||||
await cacheFile.copy(newCacheFilePath);
|
||||
}
|
||||
|
||||
if (keysFile.existsSync()) {
|
||||
await keysFile.copy(newKeysFilePath);
|
||||
}
|
||||
|
||||
if (addressListFile.existsSync()) {
|
||||
await addressListFile.copy(newAddressListFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> restoreWalletFiles(String name) async {
|
||||
final walletDirPath = await pathForWalletDir(name: name, type: WalletType.monero);
|
||||
final cacheFilePath = '$walletDirPath/$name';
|
||||
final keysFilePath = '$walletDirPath/$name.keys';
|
||||
final addressListFilePath = '$walletDirPath/$name.address.txt';
|
||||
final backupCacheFile = File(backupFileName(cacheFilePath));
|
||||
final backupKeysFile = File(backupFileName(keysFilePath));
|
||||
final backupAddressListFile = File(backupFileName(addressListFilePath));
|
||||
|
||||
if (backupCacheFile.existsSync()) {
|
||||
await backupCacheFile.copy(cacheFilePath);
|
||||
}
|
||||
|
||||
if (backupKeysFile.existsSync()) {
|
||||
await backupKeysFile.copy(keysFilePath);
|
||||
}
|
||||
|
||||
if (backupAddressListFile.existsSync()) {
|
||||
await backupAddressListFile.copy(addressListFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> backupWalletFilesExists(String name) async {
|
||||
final walletDirPath = await pathForWalletDir(name: name, type: WalletType.monero);
|
||||
final cacheFilePath = '$walletDirPath/$name';
|
||||
final keysFilePath = '$walletDirPath/$name.keys';
|
||||
final addressListFilePath = '$walletDirPath/$name.address.txt';
|
||||
final backupCacheFile = File(backupFileName(cacheFilePath));
|
||||
final backupKeysFile = File(backupFileName(keysFilePath));
|
||||
final backupAddressListFile = File(backupFileName(addressListFilePath));
|
||||
|
||||
return backupCacheFile.existsSync()
|
||||
&& backupKeysFile.existsSync()
|
||||
&& backupAddressListFile.existsSync();
|
||||
}
|
||||
|
||||
Future<void> removeCache(String name) async {
|
||||
final path = await pathForWallet(name: name, type: WalletType.monero);
|
||||
final cacheFile = File(path);
|
||||
|
||||
if (cacheFile.existsSync()) {
|
||||
cacheFile.deleteSync();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> restoreOrResetWalletFiles(String name) async {
|
||||
final backupsExists = await backupWalletFilesExists(name);
|
||||
|
||||
if (backupsExists) {
|
||||
await restoreWalletFiles(name);
|
||||
}
|
||||
|
||||
removeCache(name);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'package:cw_monero/api/structs/subaddress_row.dart';
|
||||
|
||||
class Subaddress {
|
||||
Subaddress({this.id, this.address, this.label});
|
||||
|
||||
Subaddress.fromMap(Map map)
|
||||
: this.id = map['id'] == null ? 0 : int.parse(map['id'] as String),
|
||||
this.address = (map['address'] ?? '') as String,
|
||||
this.label = (map['label'] ?? '') as String;
|
||||
|
||||
Subaddress.fromRow(SubaddressRow row)
|
||||
: this.id = row.getId(),
|
||||
this.address = row.getAddress(),
|
||||
this.label = row.getId() == 0 &&
|
||||
row.getLabel().toLowerCase() == 'Primary account'.toLowerCase()
|
||||
? 'Primary address'
|
||||
: row.getLabel();
|
||||
|
||||
final int id;
|
||||
final String address;
|
||||
final String label;
|
||||
}
|
||||
Reference in New Issue
Block a user