Skip to content

Commit 34fa29a

Browse files
authored
Merge pull request #21 from cypherstack/xmr-prewindows
Pre-Windows XMR
2 parents ad2cc43 + 201ebc2 commit 34fa29a

31 files changed

Lines changed: 43 additions & 1801 deletions

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,4 @@ assets/images/app_logo.png
137137

138138
build/
139139
scripts/android/downloads
140-
lib/git_versions.dart
141-
scripts/windows/cache/
142-
143-
scripts/mingw64/build/
144-
scripts/mingw64/cache/
145-
scripts/mingw64/cmakefiles/x86_64/CMakeLists.txt
146-
scripts/mingw64/cmakefiles/aarch64/CMakeLists.txt
140+
lib/git_versions.dart

cw_core/lib/pathForWallet.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Future<Directory> applicationRootDirectory() async {
4141
} else if (Platform.isLinux) {
4242
appDirectory = Directory("${Platform.environment['HOME']}/.stackwallet");
4343
} else if (Platform.isWindows) {
44-
appDirectory = await getApplicationSupportDirectory();
44+
// TODO: windows root .stackwallet dir location
45+
throw Exception("Unsupported platform");
4546
} else if (Platform.isMacOS) {
4647
// currently run in ipad mode??
4748
throw Exception("Unsupported platform");

cw_monero/ios/Classes/monero_api.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,7 @@ extern "C"
315315

316316
bool load_wallet(char *path, char *password, int32_t nettype)
317317
{
318-
#ifndef _WIN32
319318
nice(19);
320-
#endif
321319
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
322320
Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager();
323321
Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType);
@@ -404,9 +402,7 @@ extern "C"
404402

405403
bool connect_to_node(char *error)
406404
{
407-
#ifndef _WIN32
408405
nice(19);
409-
#endif
410406
bool is_connected = get_current_wallet()->connectToDaemon();
411407

412408
if (!is_connected)
@@ -419,9 +415,7 @@ extern "C"
419415

420416
bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error)
421417
{
422-
#ifndef _WIN32
423418
nice(19);
424-
#endif
425419
Monero::Wallet *wallet = get_current_wallet();
426420

427421
std::string _login = "";
@@ -500,9 +494,7 @@ extern "C"
500494
bool transaction_create(char *address, char *payment_id, char *amount,
501495
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
502496
{
503-
#ifndef _WIN32
504497
nice(19);
505-
#endif
506498

507499
auto priority = static_cast<Monero::PendingTransaction::Priority>(priority_raw);
508500
std::string _payment_id;
@@ -542,9 +534,7 @@ extern "C"
542534
bool transaction_create_mult_dest(char **addresses, char *payment_id, char **amounts, uint32_t size,
543535
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
544536
{
545-
#ifndef _WIN32
546537
nice(19);
547-
#endif
548538

549539
std::vector<std::string> _addresses;
550540
std::vector<uint64_t> _amounts;

cw_monero/lib/api/monero_api.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ DynamicLibrary get moneroApi {
1717
// DynamicLibrary.open(
1818
// 'scripts/linux/build/libsecret/_build/libsecret/libsecret-1.so.0.0.0');
1919

20-
return Platform.isWindows
21-
? DynamicLibrary.open("libcw_monero.dll")
22-
: Platform.isAndroid || Platform.isLinux
23-
? DynamicLibrary.open('crypto_plugins/flutter_libmonero/scripts/linux/build/libcw_monero.so')
24-
: DynamicLibrary.open("cw_monero.framework/cw_monero");
20+
return DynamicLibrary.open(
21+
'crypto_plugins/flutter_libmonero/scripts/linux/build/libcw_monero.so');
2522
}
26-
return Platform.isWindows
27-
? DynamicLibrary.open("libcw_monero.dll")
28-
: Platform.isAndroid || Platform.isLinux
29-
? DynamicLibrary.open("libcw_monero.so")
30-
: DynamicLibrary.open("cw_monero.framework/cw_monero");
23+
return Platform.isAndroid || Platform.isLinux
24+
? DynamicLibrary.open("libcw_monero.so")
25+
: DynamicLibrary.open("cw_monero.framework/cw_monero");
3126
}

cw_monero/lib/api/wallet_manager.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import 'dart:ffi';
2-
import 'package:ffi/ffi.dart';
3-
import 'package:flutter/foundation.dart';
2+
43
import 'package:cw_monero/api/convert_utf8_to_string.dart';
5-
import 'package:cw_monero/api/signatures.dart';
6-
import 'package:cw_monero/api/types.dart';
7-
import 'package:cw_monero/api/monero_api.dart';
8-
import 'package:cw_monero/api/wallet.dart';
9-
import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart';
104
import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart';
5+
import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart';
116
import 'package:cw_monero/api/exceptions/wallet_restore_from_keys_exception.dart';
127
import 'package:cw_monero/api/exceptions/wallet_restore_from_seed_exception.dart';
8+
import 'package:cw_monero/api/monero_api.dart';
9+
import 'package:cw_monero/api/signatures.dart';
10+
import 'package:cw_monero/api/types.dart';
11+
import 'package:ffi/ffi.dart';
1312
import 'package:ffi/ffi.dart' as pkgffi;
13+
import 'package:flutter/foundation.dart';
1414

1515
final createWalletNative = moneroApi
1616
.lookup<NativeFunction<create_wallet>>('create_wallet')
@@ -39,7 +39,10 @@ final errorStringNative = moneroApi
3939
.asFunction<ErrorString>();
4040

4141
void createWalletSync(
42-
{required String path, required String password, required String language, int nettype = 0}) {
42+
{required String path,
43+
required String password,
44+
required String language,
45+
int nettype = 0}) {
4346
final pathPointer = path.toNativeUtf8();
4447
final passwordPointer = password.toNativeUtf8();
4548
final languagePointer = language.toNativeUtf8();
@@ -142,7 +145,8 @@ void restoreWalletFromKeysSync(
142145
}
143146
}
144147

145-
void loadWallet({required String path, required String password, int nettype = 0}) {
148+
void loadWallet(
149+
{required String path, required String password, int nettype = 0}) {
146150
final pathPointer = path.toNativeUtf8();
147151
final passwordPointer = password.toNativeUtf8();
148152
final loaded = loadWalletNative(pathPointer, passwordPointer, nettype) != 0;
@@ -197,7 +201,8 @@ Future<void> _openWallet(Map<String, String> args) async =>
197201

198202
bool _isWalletExist(String? path) => isWalletExistSync(path: path!);
199203

200-
void openWallet({required String path, required String password, int nettype = 0}) async =>
204+
void openWallet(
205+
{required String path, required String password, int nettype = 0}) =>
201206
loadWallet(path: path, password: password, nettype: nettype);
202207

203208
Future<void> openWalletAsync(Map<String, String> args) async =>

cw_wownero/ios/Classes/wownero_api.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ extern "C"
410410

411411
bool load_wallet(char *path, char *password, int32_t nettype)
412412
{
413-
#ifndef _WIN32
414413
nice(19);
415-
#endif
416414
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
417415
Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager();
418416
Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType);
@@ -504,9 +502,7 @@ extern "C"
504502

505503
bool connect_to_node(char *error)
506504
{
507-
#ifndef _WIN32
508505
nice(19);
509-
#endif
510506
bool is_connected = get_current_wallet()->connectToDaemon();
511507

512508
if (!is_connected)
@@ -519,9 +515,7 @@ extern "C"
519515

520516
bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error)
521517
{
522-
#ifndef _WIN32
523518
nice(19);
524-
#endif
525519
Monero::Wallet *wallet = get_current_wallet();
526520

527521
std::string _login = "";
@@ -591,9 +585,7 @@ extern "C"
591585
bool transaction_create(char *address, char *payment_id, char *amount,
592586
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
593587
{
594-
#ifndef _WIN32
595588
nice(19);
596-
#endif
597589

598590
auto priority = static_cast<Monero::PendingTransaction::Priority>(priority_raw);
599591
std::string _payment_id;
@@ -633,9 +625,7 @@ extern "C"
633625
bool transaction_create_mult_dest(char **addresses, char *payment_id, char **amounts, uint32_t size,
634626
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
635627
{
636-
#ifndef _WIN32
637628
nice(19);
638-
#endif
639629

640630
std::vector<std::string> _addresses;
641631
std::vector<uint64_t> _amounts;

cw_wownero/lib/api/wownero_api.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@ import 'dart:io';
33

44
DynamicLibrary get wowneroApi {
55
if (Platform.environment.containsKey('FLUTTER_TEST')) {
6-
return Platform.isWindows
7-
? DynamicLibrary.open("libcw_wownero.dll")
8-
: Platform.isAndroid || Platform.isLinux
9-
? DynamicLibrary.open('crypto_plugins/flutter_libmonero/scripts/linux/build/libcw_wownero.so')
10-
: DynamicLibrary.open("cw_wownero.framework/cw_wownero");
6+
return DynamicLibrary.open(
7+
'crypto_plugins/flutter_libmonero/scripts/linux/build/libcw_wownero.so');
118
}
12-
return Platform.isWindows
13-
? DynamicLibrary.open("libcw_wownero.dll")
14-
: Platform.isAndroid || Platform.isLinux
15-
? DynamicLibrary.open("libcw_wownero.so")
16-
: DynamicLibrary.open("cw_wownero.framework/cw_wownero");
9+
return Platform.isAndroid || Platform.isLinux
10+
? DynamicLibrary.open("libcw_wownero.so")
11+
: DynamicLibrary.open("cw_wownero.framework/cw_wownero");
1712
}

cw_wownero/lib/wownero_wallet.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import 'package:cw_wownero/wownero_transaction_creation_exception.dart';
2626
import 'package:cw_wownero/wownero_transaction_history.dart';
2727
import 'package:cw_wownero/wownero_transaction_info.dart';
2828
import 'package:cw_wownero/wownero_wallet_addresses.dart';
29-
import 'package:flutter/foundation.dart';
3029
import 'package:mobx/mobx.dart';
3130

3231
part 'wownero_wallet.g.dart';
@@ -90,6 +89,10 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
9089
late bool _hasSyncAfterStartup;
9190
Timer? _autoSaveTimer;
9291

92+
void Function()? onNewBlock;
93+
void Function()? onNewTransaction;
94+
void Function()? syncStatusChanged;
95+
9396
Future<void> init() async {
9497
await walletAddresses.init();
9598
balance = ObservableMap<CryptoCurrency?, WowneroBalance>.of(<
@@ -112,8 +115,8 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
112115
}
113116
}
114117

115-
_autoSaveTimer = Timer.periodic(
116-
Duration(seconds: _autoSaveInterval), (_) async => await save());
118+
// _autoSaveTimer = Timer.periodic(
119+
// Duration(seconds: _autoSaveInterval), (_) async => await save());
117120
}
118121

119122
@override
@@ -127,15 +130,18 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
127130
Future<void> connectToNode({required Node node}) async {
128131
try {
129132
syncStatus = ConnectingSyncStatus();
133+
syncStatusChanged?.call();
130134
await wownero_wallet.setupNode(
131135
address: node.uri.toString(),
132136
login: node.login,
133137
password: node.password,
134138
useSSL: node.isSSL,
135139
isLightWallet: false); // FIXME: hardcoded value
136140
syncStatus = ConnectedSyncStatus();
141+
syncStatusChanged?.call();
137142
} catch (e) {
138143
syncStatus = FailedSyncStatus();
144+
syncStatusChanged?.call();
139145
print(e);
140146
}
141147
}
@@ -151,8 +157,10 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
151157
wownero_wallet.startRefresh();
152158
_setListeners();
153159
_listener?.start();
160+
syncStatusChanged?.call();
154161
} catch (e) {
155162
syncStatus = FailedSyncStatus();
163+
syncStatusChanged?.call();
156164
print(e);
157165
rethrow;
158166
}
@@ -408,6 +416,7 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
408416
_askForUpdateBalance();
409417
walletAddresses.accountList.update();
410418
syncStatus = SyncedSyncStatus();
419+
syncStatusChanged?.call();
411420

412421
if (!_hasSyncAfterStartup) {
413422
_hasSyncAfterStartup = true;
@@ -419,10 +428,12 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
419428
}
420429
} else {
421430
syncStatus = SyncingSyncStatus(blocksLeft, ptc, height);
431+
syncStatusChanged?.call();
422432
}
423433
} catch (e) {
424434
print(e.toString());
425435
}
436+
onNewBlock?.call();
426437
}
427438

428439
void _onNewTransaction() async {
@@ -433,5 +444,6 @@ abstract class WowneroWalletBase extends WalletBase<WowneroBalance,
433444
} catch (e) {
434445
print(e.toString());
435446
}
447+
onNewTransaction?.call();
436448
}
437449
}

scripts/windows/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/windows/build_all.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)