diff --git a/.github/workflows/pr_test_build.yml b/.github/workflows/pr_test_build.yml index dc231df42..98f95ae88 100644 --- a/.github/workflows/pr_test_build.yml +++ b/.github/workflows/pr_test_build.yml @@ -158,6 +158,7 @@ jobs: - name: Build run: | cd /opt/android/cake_wallet + make libs flutter build apk --release --split-per-abi # - name: Push to App Center diff --git a/.metadata b/.metadata index cdddb9350..7d00ca21a 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - channel: stable + revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" + channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - - platform: macos - create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + - platform: windows + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 # User provided section diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..f09db4a9f --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +# TODO(mrcyjanek): Cleanup, this is borrowed from unnamed_monero_wallet repo. + +MONERO_C_TAG=v0.18.3.3-RC41 +LIBCPP_SHARED_SO_TAG=latest-RC1 +LIBCPP_SHARED_SO_NDKVERSION=r17c + +libs: android/app/src/main/jniLibs/arm64-v8a/libmonero_libwallet2_api_c.so +.PHONY: android/app/src/main/jniLibs/arm64-v8a/libmonero_libwallet2_api_c.so +android/app/src/main/jniLibs/arm64-v8a/libmonero_libwallet2_api_c.so: + wget -q https://static.mrcyjanek.net/monero_c/${MONERO_C_TAG}/monero/aarch64-linux-android_libwallet2_api_c.so.xz -O android/app/src/main/jniLibs/arm64-v8a/libmonero_libwallet2_api_c.so.xz + unxz android/app/src/main/jniLibs/arm64-v8a/libmonero_libwallet2_api_c.so.xz + +libs: android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so +.PHONY: android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so +android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so: + wget -q https://git.mrcyjanek.net/mrcyjanek/libcpp_shared.so/releases/download/${LIBCPP_SHARED_SO_TAG}/${LIBCPP_SHARED_SO_NDKVERSION}_arm64-v8a_libc++_shared.so -O android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so + +libs: android/app/src/main/jniLibs/armeabi-v7a/libmonero_libwallet2_api_c.so +.PHONY: android/app/src/main/jniLibs/armeabi-v7a/libmonero_libwallet2_api_c.so +android/app/src/main/jniLibs/armeabi-v7a/libmonero_libwallet2_api_c.so: + wget -q https://static.mrcyjanek.net/monero_c/${MONERO_C_TAG}/monero/arm-linux-androideabi_libwallet2_api_c.so.xz -O android/app/src/main/jniLibs/armeabi-v7a/libmonero_libwallet2_api_c.so.xz + unxz android/app/src/main/jniLibs/armeabi-v7a/libmonero_libwallet2_api_c.so.xz + +libs: android/app/src/main/jniLibs/armeabi-v7a/libc++_shared.so +.PHONY: android/app/src/main/jniLibs/armeabi-v7a/libc++_shared.so +android/app/src/main/jniLibs/armeabi-v7a/libc++_shared.so: + wget -q https://git.mrcyjanek.net/mrcyjanek/libcpp_shared.so/releases/download/${LIBCPP_SHARED_SO_TAG}/${LIBCPP_SHARED_SO_NDKVERSION}_armeabi-v7a_libc++_shared.so -O android/app/src/main/jniLibs/armeabi-v7a/libc++_shared.so + +# libs: android/app/src/main/jniLibs/x86/libmonero_libwallet2_api_c.so +# .PHONY: android/app/src/main/jniLibs/x86/libmonero_libwallet2_api_c.so +# android/app/src/main/jniLibs/x86/libmonero_libwallet2_api_c.so: +# wget -q https://static.mrcyjanek.net/monero_c/${MONERO_C_TAG}/monero/i686-linux-android_libwallet2_api_c.so.xz -O android/app/src/main/jniLibs/x86/libmonero_libwallet2_api_c.so.xz +# unxz android/app/src/main/jniLibs/x86/libmonero_libwallet2_api_c.so.xz + +libs: android/app/src/main/jniLibs/x86/libc++_shared.so +.PHONY: android/app/src/main/jniLibs/x86/libc++_shared.so +android/app/src/main/jniLibs/x86/libc++_shared.so: + wget -q https://git.mrcyjanek.net/mrcyjanek/libcpp_shared.so/releases/download/${LIBCPP_SHARED_SO_TAG}/${LIBCPP_SHARED_SO_NDKVERSION}_x86_libc++_shared.so -O android/app/src/main/jniLibs/x86/libc++_shared.so + +libs: android/app/src/main/jniLibs/x86_64/libmonero_libwallet2_api_c.so +.PHONY: android/app/src/main/jniLibs/x86_64/libmonero_libwallet2_api_c.so +android/app/src/main/jniLibs/x86_64/libmonero_libwallet2_api_c.so: + wget -q https://static.mrcyjanek.net/monero_c/${MONERO_C_TAG}/monero/x86_64-linux-android_libwallet2_api_c.so.xz -O android/app/src/main/jniLibs/x86_64/libmonero_libwallet2_api_c.so.xz + unxz android/app/src/main/jniLibs/x86_64/libmonero_libwallet2_api_c.so.xz + +libs: android/app/src/main/jniLibs/x86_64/libc++_shared.so +.PHONY: android/app/src/main/jniLibs/x86_64/libc++_shared.so +android/app/src/main/jniLibs/x86_64/libc++_shared.so: + wget -q https://git.mrcyjanek.net/mrcyjanek/libcpp_shared.so/releases/download/${LIBCPP_SHARED_SO_TAG}/${LIBCPP_SHARED_SO_NDKVERSION}_x86_64_libc++_shared.so -O android/app/src/main/jniLibs/x86_64/libc++_shared.so + +clean_libs: + -rm android/app/src/main/jniLibs/x86_64/libc++_shared.so* + -rm android/app/src/main/jniLibs/x86_64/*_libwallet2_api_c.so* + -rm android/app/src/main/jniLibs/armeabi-v7a/libc++_shared.so* + -rm android/app/src/main/jniLibs/armeabi-v7a/*_libwallet2_api_c.so* + -rm android/app/src/main/jniLibs/x86/libc++_shared.so* + -rm android/app/src/main/jniLibs/x86/*_libwallet2_api_c.so* + -rm android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so* + -rm android/app/src/main/jniLibs/arm64-v8a/*_libwallet2_api_c.so* \ No newline at end of file diff --git a/android/app/src/main/AndroidManifestBase.xml b/android/app/src/main/AndroidManifestBase.xml index eea9b5521..ba7868f9e 100644 --- a/android/app/src/main/AndroidManifestBase.xml +++ b/android/app/src/main/AndroidManifestBase.xml @@ -18,7 +18,8 @@ android:fullBackupContent="false" android:versionCode="__versionCode__" android:versionName="__versionName__" - android:requestLegacyExternalStorage="true"> + android:requestLegacyExternalStorage="true" + android:extractNativeLibs="true"> [Install Flutter](https://docs.flutter.dev/get-started/install/windows) follow this guide until `Android setup` section (it's not necessary for this build process). +> [Install adition for Flutter SDK](https://docs.flutter.dev/platform-integration/desktop#additional-windows-requirements). Then install `Desktop development with C++` packages via GUI Visual Studio 2022, or Visual Studio Build Tools 2022 including: `C++ Build Tools core features`, `C++ 2022 Redistributable Update`, `C++ core desktop features`, `MVC v143 - VS 2022 C++ x64/x86 build tools`, `C++ CMake tools for Windwos`, `Testing tools core features - Build Tools`, `C++ AddressSanitizer`. + +### 2. Pull CakeWallet source code + +You can downlaod CakeWallet source code from our [GitHub repository](github.com/cake-tech/cake_wallet) via git by following next command: +`$ git clone https://github.com/cake-tech/cake_wallet.git --branch windows` +OR you can download it as [Zip archive](https://github.com/cake-tech/cake_wallet/archive/refs/heads/windows.zip) + +### 3. Configure and build CakeWallet application +To configure the application open directory where you have downloaded or unarchived CakeWallet sources and run `cakewallet.bat`. +After execution of `cakewallet.bat` you should to get `Cake Wallet.zip` in project root directory which will contains `CakeWallet.exe` file and another needed files for run the application. Now you can extract files from `Cake Wallet.zip` archive and run the application. diff --git a/cakewallet.bat b/cakewallet.bat new file mode 100644 index 000000000..dd9b4b916 --- /dev/null +++ b/cakewallet.bat @@ -0,0 +1,47 @@ +@echo off +set cw_win_app_config=--bitcoin --ethereum +set cw_root=%cd% +set cw_archive_name=Cake Wallet.zip +set cw_archive_path=%cw_root%\%cw_archive_name% +set secrets_file_path=lib\.secrets.g.dart +set release_dir=build\windows\runner\Release +set tools_root=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Redist\MSVC\14.36.32532\x64\Microsoft.VC143.CRT + +echo === Generating pubspec.yaml === +copy /Y pubspec_description.yaml pubspec.yaml > nul +call flutter pub get > nul +call dart run tool\generate_pubspec.dart +call flutter pub get > nul +call dart run tool\configure.dart %cw_win_app_config% + +IF NOT EXIST "%secrets_file_path%" ( + echo === Generating new secrets file === + call dart run tool\generate_new_secrets.dart +) ELSE (echo === Using previously/already generated secrets file: %secrets_file_path% ===) + +echo === Generating mobx models === +for /d %%i in (cw_core cw_bitcoin cw_ethereum cw_monero .) do ( + cd %%i + call flutter pub get > nul + call dart run build_runner build --delete-conflicting-outputs > nul + cd /d %cw_root% +) + +echo === Generating localization files === +call dart run tool\generate_localization.dart + +echo === Building the application executable file === +call flutter build windows --dart-define-from-file=env.json --release + +echo === Prepare distribution actions. Copy needed files to the application bundle === +copy /Y "%tools_root%\msvcp140.dll" "%release_dir%\" > nul +copy /Y "%tools_root%\vcruntime140.dll" "%release_dir%\" > nul +copy /Y "%tools_root%\vcruntime140_1.dll" "%release_dir%\" > nul + +echo === Generate the application archive === +xcopy /s /e /v /Y "%release_dir%\*.*" "build\Cake Wallet\" > nul +tar acf "%cw_archive_name%" -C build\ "Cake Wallet" + +echo === Open Explorer with the application archive === +echo Cake Wallet created archive at: %cw_archive_path% +%SystemRoot%\explorer.exe /select, %cw_archive_path% diff --git a/cw_bitcoin/pubspec.lock b/cw_bitcoin/pubspec.lock index 86d58b9b1..e82ce59d0 100644 --- a/cw_bitcoin/pubspec.lock +++ b/cw_bitcoin/pubspec.lock @@ -217,10 +217,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" convert: dependency: transitive description: @@ -434,18 +434,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -663,10 +663,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -711,10 +711,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" timing: dependency: transitive description: diff --git a/cw_core/lib/pathForWallet.dart b/cw_core/lib/pathForWallet.dart index cfc33ef21..9aa721923 100644 --- a/cw_core/lib/pathForWallet.dart +++ b/cw_core/lib/pathForWallet.dart @@ -1,9 +1,10 @@ import 'dart:io'; +import 'package:cw_core/root_dir.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:path_provider/path_provider.dart'; Future pathForWalletDir({required String name, required WalletType type}) async { - final root = await getApplicationDocumentsDirectory(); + final root = await getAppDir(); final prefix = walletTypeToString(type).toLowerCase(); final walletsDir = Directory('${root.path}/wallets'); final walletDire = Directory('${walletsDir.path}/$prefix/$name'); @@ -20,8 +21,8 @@ Future pathForWallet({required String name, required WalletType type}) a .then((path) => path + '/$name'); Future outdatedAndroidPathForWalletDir({required String name}) async { - final directory = await getApplicationDocumentsDirectory(); + final directory = await getAppDir(); final pathDir = directory.path + '/$name'; return pathDir; -} \ No newline at end of file +} diff --git a/cw_core/lib/root_dir.dart b/cw_core/lib/root_dir.dart new file mode 100644 index 000000000..6549d0d6e --- /dev/null +++ b/cw_core/lib/root_dir.dart @@ -0,0 +1,28 @@ +import 'dart:io'; +import 'package:path_provider/path_provider.dart'; + +String? _rootDirPath; + +void setRootDirFromEnv() + => _rootDirPath = Platform.environment['CAKE_WALLET_DIR']; + +Future getAppDir({String appName = 'cake_wallet'}) async { + Directory dir; + + if (_rootDirPath != null && _rootDirPath!.isNotEmpty) { + dir = Directory.fromUri(Uri.file(_rootDirPath!)); + dir.create(recursive: true); + } else { + dir = await getApplicationDocumentsDirectory(); + + if (Platform.isWindows) { + dir = await getApplicationSupportDirectory(); + } else if (Platform.isLinux) { + final appDirPath = '${dir.path}/$appName'; + dir = Directory.fromUri(Uri.file(appDirPath)); + await dir.create(recursive: true); + } + } + + return dir; +} diff --git a/cw_core/lib/sec_random_native.dart b/cw_core/lib/sec_random_native.dart index ce251efc0..2011602bf 100644 --- a/cw_core/lib/sec_random_native.dart +++ b/cw_core/lib/sec_random_native.dart @@ -1,3 +1,5 @@ +import 'dart:io'; +import 'dart:math'; import 'dart:typed_data'; import 'package:flutter/services.dart'; @@ -6,6 +8,12 @@ const utils = const MethodChannel('com.cake_wallet/native_utils'); Future secRandom(int count) async { try { + if (Platform.isWindows || Platform.isLinux) { + // Used method to get securely generated random bytes from cake backups + const byteSize = 256; + final rng = Random.secure(); + return Uint8List.fromList(List.generate(count, (_) => rng.nextInt(byteSize))); + } return await utils.invokeMethod('sec_random', {'count': count}) ?? Uint8List.fromList([]); } on PlatformException catch (_) { return Uint8List.fromList([]); diff --git a/cw_core/pubspec.lock b/cw_core/pubspec.lock index 678e57b54..5d794d7ec 100644 --- a/cw_core/pubspec.lock +++ b/cw_core/pubspec.lock @@ -149,10 +149,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" convert: dependency: transitive description: @@ -343,18 +343,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -564,10 +564,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -612,10 +612,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" timing: dependency: transitive description: diff --git a/cw_haven/lib/api/account_list.dart b/cw_haven/lib/api/account_list.dart index a05446c8e..87f036206 100644 --- a/cw_haven/lib/api/account_list.dart +++ b/cw_haven/lib/api/account_list.dart @@ -4,7 +4,6 @@ import 'package:cw_haven/api/signatures.dart'; import 'package:cw_haven/api/types.dart'; import 'package:cw_haven/api/haven_api.dart'; import 'package:cw_haven/api/structs/account_row.dart'; -import 'package:flutter/foundation.dart'; import 'package:cw_haven/api/wallet.dart'; final accountSizeNative = havenApi @@ -72,12 +71,11 @@ void _setLabelForAccount(Map args) { } Future addAccount({required String label}) async { - await compute(_addAccount, label); + _addAccount(label); await store(); } Future setLabelForAccount({required int accountIndex, required String label}) async { - await compute( - _setLabelForAccount, {'accountIndex': accountIndex, 'label': label}); + _setLabelForAccount({'accountIndex': accountIndex, 'label': label}); await store(); } \ No newline at end of file diff --git a/cw_monero/android/.classpath b/cw_monero/android/.classpath deleted file mode 100644 index 4a04201ca..000000000 --- a/cw_monero/android/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/cw_monero/android/.gitignore b/cw_monero/android/.gitignore deleted file mode 100644 index c6cbe562a..000000000 --- a/cw_monero/android/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures diff --git a/cw_monero/android/.project b/cw_monero/android/.project deleted file mode 100644 index e0799208f..000000000 --- a/cw_monero/android/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - cw_monero - Project android created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/cw_monero/android/.settings/org.eclipse.buildship.core.prefs b/cw_monero/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index a88c4d484..000000000 --- a/cw_monero/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.0-20191016123526+0000)) -connection.project.dir=../../android -eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=true -show.console.view=true -show.executions.view=true diff --git a/cw_monero/android/CMakeLists.txt b/cw_monero/android/CMakeLists.txt deleted file mode 100644 index f9f98927c..000000000 --- a/cw_monero/android/CMakeLists.txt +++ /dev/null @@ -1,232 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) - -add_library( cw_monero - SHARED - ./jni/monero_jni.cpp - ../ios/Classes/monero_api.cpp) - - find_library( log-lib log ) - -set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../../cw_shared_external/ios/External/android) - -############ -# libsodium -############ - -add_library(sodium STATIC IMPORTED) -set_target_properties(sodium PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libsodium.a) - -############ -# OpenSSL -############ - -add_library(crypto STATIC IMPORTED) -set_target_properties(crypto PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libcrypto.a) - -add_library(ssl STATIC IMPORTED) -set_target_properties(ssl PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libssl.a) - -############ -# Boost -############ - -add_library(boost_chrono STATIC IMPORTED) -set_target_properties(boost_chrono PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_chrono.a) - -add_library(boost_date_time STATIC IMPORTED) -set_target_properties(boost_date_time PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_date_time.a) - -add_library(boost_filesystem STATIC IMPORTED) -set_target_properties(boost_filesystem PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_filesystem.a) - -add_library(boost_program_options STATIC IMPORTED) -set_target_properties(boost_program_options PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_program_options.a) - -add_library(boost_regex STATIC IMPORTED) -set_target_properties(boost_regex PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_regex.a) - -add_library(boost_serialization STATIC IMPORTED) -set_target_properties(boost_serialization PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_serialization.a) - -add_library(boost_system STATIC IMPORTED) -set_target_properties(boost_system PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_system.a) - -add_library(boost_thread STATIC IMPORTED) -set_target_properties(boost_thread PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_thread.a) - -add_library(boost_wserialization STATIC IMPORTED) -set_target_properties(boost_wserialization PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/libboost_wserialization.a) - -############# -# Monero -############# - -add_library(wallet_api STATIC IMPORTED) -set_target_properties(wallet_api PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libwallet_api.a) - -add_library(wallet STATIC IMPORTED) -set_target_properties(wallet PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libwallet.a) - -add_library(cryptonote_core STATIC IMPORTED) -set_target_properties(cryptonote_core PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcryptonote_core.a) - -add_library(cryptonote_basic STATIC IMPORTED) -set_target_properties(cryptonote_basic PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcryptonote_basic.a) - -add_library(cryptonote_format_utils_basic STATIC IMPORTED) -set_target_properties(cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcryptonote_format_utils_basic.a) - -add_library(mnemonics STATIC IMPORTED) -set_target_properties(mnemonics PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libmnemonics.a) - -add_library(common STATIC IMPORTED) -set_target_properties(common PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcommon.a) - -add_library(cncrypto STATIC IMPORTED) -set_target_properties(cncrypto PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcncrypto.a) - -add_library(ringct STATIC IMPORTED) -set_target_properties(ringct PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libringct.a) - -add_library(ringct_basic STATIC IMPORTED) -set_target_properties(ringct_basic PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libringct_basic.a) - -add_library(blockchain_db STATIC IMPORTED) -set_target_properties(blockchain_db PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libblockchain_db.a) - -add_library(lmdb STATIC IMPORTED) -set_target_properties(lmdb PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/liblmdb.a) - -add_library(easylogging STATIC IMPORTED) -set_target_properties(easylogging PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libeasylogging.a) - -add_library(unbound STATIC IMPORTED) -set_target_properties(unbound PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libunbound.a) - -add_library(epee STATIC IMPORTED) -set_target_properties(epee PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libepee.a) - -add_library(blocks STATIC IMPORTED) -set_target_properties(blocks PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libblocks.a) - -add_library(checkpoints STATIC IMPORTED) -set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libcheckpoints.a) - -add_library(device STATIC IMPORTED) -set_target_properties(device PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libdevice.a) - -add_library(device_trezor STATIC IMPORTED) -set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libdevice_trezor.a) - -add_library(multisig STATIC IMPORTED) -set_target_properties(multisig PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libmultisig.a) - -add_library(version STATIC IMPORTED) -set_target_properties(version PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libversion.a) - -add_library(net STATIC IMPORTED) -set_target_properties(net PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libnet.a) - -add_library(hardforks STATIC IMPORTED) -set_target_properties(hardforks PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libhardforks.a) - -add_library(randomx STATIC IMPORTED) -set_target_properties(randomx PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/librandomx.a) - -add_library(rpc_base STATIC IMPORTED) -set_target_properties(rpc_base PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/librpc_base.a) - -add_library(wallet-crypto STATIC IMPORTED) -set_target_properties(wallet-crypto PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/lib/monero/libwallet-crypto.a) - -set(WALLET_CRYPTO "") - -if(${ANDROID_ABI} STREQUAL "x86_64") - set(WALLET_CRYPTO "wallet-crypto") -endif() - -include_directories( ${EXTERNAL_LIBS_DIR}/${ANDROID_ABI}/include ) - -target_link_libraries( cw_monero - - wallet_api - wallet - cryptonote_core - cryptonote_basic - cryptonote_format_utils_basic - mnemonics - ringct - ringct_basic - net - common - cncrypto - blockchain_db - lmdb - easylogging - unbound - epee - blocks - checkpoints - device - device_trezor - multisig - version - randomx - hardforks - rpc_base - ${WALLET_CRYPTO} - - boost_chrono - boost_date_time - boost_filesystem - boost_program_options - boost_regex - boost_serialization - boost_system - boost_thread - boost_wserialization - - ssl - crypto - - sodium - - ${log-lib} ) \ No newline at end of file diff --git a/cw_monero/android/build.gradle b/cw_monero/android/build.gradle deleted file mode 100644 index fc4835e81..000000000 --- a/cw_monero/android/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -group 'com.cakewallet.monero' -version '1.0-SNAPSHOT' - -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -rootProject.allprojects { - repositories { - google() - jcenter() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 28 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - defaultConfig { - minSdkVersion 21 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - lintOptions { - disable 'InvalidPackage' - } - externalNativeBuild { - cmake { - path "CMakeLists.txt" - } - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/cw_monero/android/gradle.properties b/cw_monero/android/gradle.properties deleted file mode 100644 index 38c8d4544..000000000 --- a/cw_monero/android/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true -android.useAndroidX=true -android.enableJetifier=true diff --git a/cw_monero/android/gradle/wrapper/gradle-wrapper.properties b/cw_monero/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 019065d1d..000000000 --- a/cw_monero/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/cw_monero/android/jni/monero_jni.cpp b/cw_monero/android/jni/monero_jni.cpp deleted file mode 100644 index 83e06a41f..000000000 --- a/cw_monero/android/jni/monero_jni.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include -#include -#include "../../ios/Classes/monero_api.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -JNIEXPORT void JNICALL -Java_com_cakewallet_monero_MoneroApi_setNodeAddressJNI( - JNIEnv *env, - jobject inst, - jstring uri, - jstring login, - jstring password, - jboolean use_ssl, - jboolean is_light_wallet) { - const char *_uri = env->GetStringUTFChars(uri, 0); - const char *_login = ""; - const char *_password = ""; - char *error; - - if (login != NULL) { - _login = env->GetStringUTFChars(login, 0); - } - - if (password != NULL) { - _password = env->GetStringUTFChars(password, 0); - } - char *__uri = (char*) _uri; - char *__login = (char*) _login; - char *__password = (char*) _password; - bool inited = setup_node(__uri, __login, __password, false, false, error); - - if (!inited) { - env->ThrowNew(env->FindClass("java/lang/Exception"), error); - } -} - -JNIEXPORT void JNICALL -Java_com_cakewallet_monero_MoneroApi_connectToNodeJNI( - JNIEnv *env, - jobject inst) { - char *error; - bool is_connected = connect_to_node(error); - - if (!is_connected) { - env->ThrowNew(env->FindClass("java/lang/Exception"), error); - } -} - -JNIEXPORT void JNICALL -Java_com_cakewallet_monero_MoneroApi_startSyncJNI( - JNIEnv *env, - jobject inst) { - start_refresh(); -} - -JNIEXPORT void JNICALL -Java_com_cakewallet_monero_MoneroApi_loadWalletJNI( - JNIEnv *env, - jobject inst, - jstring path, - jstring password) { - char *_path = (char *) env->GetStringUTFChars(path, 0); - char *_password = (char *) env->GetStringUTFChars(password, 0); - - load_wallet(_path, _password, 0); -} - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/cw_monero/android/settings.gradle b/cw_monero/android/settings.gradle deleted file mode 100644 index 1f9e2a39d..000000000 --- a/cw_monero/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'cw_monero' diff --git a/cw_monero/android/src/main/AndroidManifest.xml b/cw_monero/android/src/main/AndroidManifest.xml deleted file mode 100644 index 8152415a2..000000000 --- a/cw_monero/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/cw_monero/android/src/main/kotlin/com/cakewallet/monero/CwMoneroPlugin.kt b/cw_monero/android/src/main/kotlin/com/cakewallet/monero/CwMoneroPlugin.kt deleted file mode 100644 index 37684a16a..000000000 --- a/cw_monero/android/src/main/kotlin/com/cakewallet/monero/CwMoneroPlugin.kt +++ /dev/null @@ -1,74 +0,0 @@ -package com.cakewallet.monero - -import android.app.Activity -import android.os.AsyncTask -import android.os.Looper -import android.os.Handler -import android.os.Process - -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.plugin.common.PluginRegistry.Registrar - -class doAsync(val handler: () -> Unit) : AsyncTask() { - override fun doInBackground(vararg params: Void?): Void? { - Process.setThreadPriority(Process.THREAD_PRIORITY_AUDIO); - handler() - return null - } -} - -class CwMoneroPlugin: MethodCallHandler { - companion object { -// val moneroApi = MoneroApi() - val main = Handler(Looper.getMainLooper()); - - init { - System.loadLibrary("cw_monero") - } - - @JvmStatic - fun registerWith(registrar: Registrar) { - val channel = MethodChannel(registrar.messenger(), "cw_monero") - channel.setMethodCallHandler(CwMoneroPlugin()) - } - } - - override fun onMethodCall(call: MethodCall, result: Result) { - if (call.method == "setupNode") { - val uri = call.argument("address") ?: "" - val login = call.argument("login") ?: "" - val password = call.argument("password") ?: "" - val useSSL = false - val isLightWallet = false -// doAsync { -// try { -// moneroApi.setNodeAddressJNI(uri, login, password, useSSL, isLightWallet) -// main.post({ -// result.success(true) -// }); -// } catch(e: Throwable) { -// main.post({ -// result.error("CONNECTION_ERROR", e.message, null) -// }); -// } -// }.execute() - } - if (call.method == "startSync") { -// doAsync { -// moneroApi.startSyncJNI() -// main.post({ -// result.success(true) -// }); -// }.execute() - } - if (call.method == "loadWallet") { - val path = call.argument("path") ?: "" - val password = call.argument("password") ?: "" -// moneroApi.loadWalletJNI(path, password) - result.success(true) - } - } -} diff --git a/cw_monero/example/.gitignore b/cw_monero/example/.gitignore deleted file mode 100644 index 24476c5d1..000000000 --- a/cw_monero/example/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release diff --git a/cw_monero/example/README.md b/cw_monero/example/README.md deleted file mode 100644 index 18cf6d109..000000000 --- a/cw_monero/example/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# cw_monero_example - -Demonstrates how to use the cw_monero plugin. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/cw_monero/example/analysis_options.yaml b/cw_monero/example/analysis_options.yaml deleted file mode 100644 index 61b6c4de1..000000000 --- a/cw_monero/example/analysis_options.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/cw_monero/example/lib/main.dart b/cw_monero/example/lib/main.dart deleted file mode 100644 index e4374f097..000000000 --- a/cw_monero/example/lib/main.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter/services.dart'; -import 'package:cw_monero/cw_monero.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - String _platformVersion = 'Unknown'; - final _cwMoneroPlugin = CwMonero(); - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - String platformVersion; - // Platform messages may fail, so we use a try/catch PlatformException. - // We also handle the message potentially returning null. - try { - platformVersion = - await _cwMoneroPlugin.getPlatformVersion() ?? 'Unknown platform version'; - } on PlatformException { - platformVersion = 'Failed to get platform version.'; - } - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. - if (!mounted) return; - - setState(() { - _platformVersion = platformVersion; - }); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Text('Running on: $_platformVersion\n'), - ), - ), - ); - } -} diff --git a/cw_monero/example/macos/.gitignore b/cw_monero/example/macos/.gitignore deleted file mode 100644 index 746adbb6b..000000000 --- a/cw_monero/example/macos/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Flutter-related -**/Flutter/ephemeral/ -**/Pods/ - -# Xcode-related -**/dgph -**/xcuserdata/ diff --git a/cw_monero/example/macos/Flutter/Flutter-Debug.xcconfig b/cw_monero/example/macos/Flutter/Flutter-Debug.xcconfig deleted file mode 100644 index 4b81f9b2d..000000000 --- a/cw_monero/example/macos/Flutter/Flutter-Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/cw_monero/example/macos/Flutter/Flutter-Release.xcconfig b/cw_monero/example/macos/Flutter/Flutter-Release.xcconfig deleted file mode 100644 index 5caa9d157..000000000 --- a/cw_monero/example/macos/Flutter/Flutter-Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/cw_monero/example/macos/Flutter/GeneratedPluginRegistrant.swift b/cw_monero/example/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index e25d64097..000000000 --- a/cw_monero/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - -import cw_monero -import path_provider_foundation - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin")) - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) -} diff --git a/cw_monero/example/macos/Podfile b/cw_monero/example/macos/Podfile deleted file mode 100644 index dade8dfad..000000000 --- a/cw_monero/example/macos/Podfile +++ /dev/null @@ -1,40 +0,0 @@ -platform :osx, '10.11' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_macos_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_macos_build_settings(target) - end -end diff --git a/cw_monero/example/macos/Podfile.lock b/cw_monero/example/macos/Podfile.lock deleted file mode 100644 index 692176b30..000000000 --- a/cw_monero/example/macos/Podfile.lock +++ /dev/null @@ -1,22 +0,0 @@ -PODS: - - FlutterMacOS (1.0.0) - - path_provider_macos (0.0.1): - - FlutterMacOS - -DEPENDENCIES: - - FlutterMacOS (from `Flutter/ephemeral`) - - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) - -EXTERNAL SOURCES: - FlutterMacOS: - :path: Flutter/ephemeral - path_provider_macos: - :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos - -SPEC CHECKSUMS: - FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 - path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19 - -PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c - -COCOAPODS: 1.11.2 diff --git a/cw_monero/example/macos/Runner.xcodeproj/project.pbxproj b/cw_monero/example/macos/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 472859e8c..000000000 --- a/cw_monero/example/macos/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,632 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 51; - objects = { - -/* Begin PBXAggregateTarget section */ - 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; - buildPhases = ( - 33CC111E2044C6BF0003C045 /* ShellScript */, - ); - dependencies = ( - ); - name = "Flutter Assemble"; - productName = FLX; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 428E7496E2068D0AB138F295 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C29B2253BA962B7A415DBA77 /* Pods_Runner.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC111A2044C6BA0003C045; - remoteInfo = FLX; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 33CC110E2044A8840003C045 /* Bundle Framework */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Bundle Framework"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* cw_monero_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = cw_monero_example.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; - 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; - 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; - 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - A9CDA1605413332AB9056C23 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - C29B2253BA962B7A415DBA77 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - E434913D71DC2682EF8E9059 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - EEF09839C86335F78056F812 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 33CC10EA2044A3C60003C045 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 428E7496E2068D0AB138F295 /* Pods_Runner.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 33BA886A226E78AF003329D5 /* Configs */ = { - isa = PBXGroup; - children = ( - 33E5194F232828860026EE4D /* AppInfo.xcconfig */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, - ); - path = Configs; - sourceTree = ""; - }; - 33CC10E42044A3C60003C045 = { - isa = PBXGroup; - children = ( - 33FAB671232836740065AC1E /* Runner */, - 33CEB47122A05771004F2AC0 /* Flutter */, - 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - 77870A4C94A9AB6EEC2EE261 /* Pods */, - ); - sourceTree = ""; - }; - 33CC10EE2044A3C60003C045 /* Products */ = { - isa = PBXGroup; - children = ( - 33CC10ED2044A3C60003C045 /* cw_monero_example.app */, - ); - name = Products; - sourceTree = ""; - }; - 33CC11242044D66E0003C045 /* Resources */ = { - isa = PBXGroup; - children = ( - 33CC10F22044A3C60003C045 /* Assets.xcassets */, - 33CC10F42044A3C60003C045 /* MainMenu.xib */, - 33CC10F72044A3C60003C045 /* Info.plist */, - ); - name = Resources; - path = ..; - sourceTree = ""; - }; - 33CEB47122A05771004F2AC0 /* Flutter */ = { - isa = PBXGroup; - children = ( - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - ); - path = Flutter; - sourceTree = ""; - }; - 33FAB671232836740065AC1E /* Runner */ = { - isa = PBXGroup; - children = ( - 33CC10F02044A3C60003C045 /* AppDelegate.swift */, - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, - 33E51913231747F40026EE4D /* DebugProfile.entitlements */, - 33E51914231749380026EE4D /* Release.entitlements */, - 33CC11242044D66E0003C045 /* Resources */, - 33BA886A226E78AF003329D5 /* Configs */, - ); - path = Runner; - sourceTree = ""; - }; - 77870A4C94A9AB6EEC2EE261 /* Pods */ = { - isa = PBXGroup; - children = ( - EEF09839C86335F78056F812 /* Pods-Runner.debug.xcconfig */, - A9CDA1605413332AB9056C23 /* Pods-Runner.release.xcconfig */, - E434913D71DC2682EF8E9059 /* Pods-Runner.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - C29B2253BA962B7A415DBA77 /* Pods_Runner.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 33CC10EC2044A3C60003C045 /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 0A239C1738C005E3F6E4DFC6 /* [CP] Check Pods Manifest.lock */, - 33CC10E92044A3C60003C045 /* Sources */, - 33CC10EA2044A3C60003C045 /* Frameworks */, - 33CC10EB2044A3C60003C045 /* Resources */, - 33CC110E2044A8840003C045 /* Bundle Framework */, - 3399D490228B24CF009A79C7 /* ShellScript */, - 0CEAA82AE8A029C31B39F234 /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 33CC11202044C79F0003C045 /* PBXTargetDependency */, - ); - name = Runner; - productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* cw_monero_example.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 33CC10E52044A3C60003C045 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 33CC10EC2044A3C60003C045 = { - CreatedOnToolsVersion = 9.2; - LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.Sandbox = { - enabled = 1; - }; - }; - }; - 33CC111A2044C6BA0003C045 = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Manual; - }; - }; - }; - buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 33CC10E42044A3C60003C045; - productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 33CC10EC2044A3C60003C045 /* Runner */, - 33CC111A2044C6BA0003C045 /* Flutter Assemble */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 33CC10EB2044A3C60003C045 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 0A239C1738C005E3F6E4DFC6 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 0CEAA82AE8A029C31B39F234 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 3399D490228B24CF009A79C7 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; - }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, - ); - inputPaths = ( - Flutter/ephemeral/tripwire, - ); - outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 33CC10E92044A3C60003C045 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; - targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 33CC10F52044A3C60003C045 /* Base */, - ); - name = MainMenu.xib; - path = Runner; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 338D0CE9231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Profile; - }; - 338D0CEA231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Profile; - }; - 338D0CEB231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Profile; - }; - 33CC10F92044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 33CC10FA2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 33CC10FC2044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 33CC10FD2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - 33CC111C2044C6BA0003C045 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 33CC111D2044C6BA0003C045 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10F92044A3C60003C045 /* Debug */, - 33CC10FA2044A3C60003C045 /* Release */, - 338D0CE9231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10FC2044A3C60003C045 /* Debug */, - 33CC10FD2044A3C60003C045 /* Release */, - 338D0CEA231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC111C2044C6BA0003C045 /* Debug */, - 33CC111D2044C6BA0003C045 /* Release */, - 338D0CEB231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 33CC10E52044A3C60003C045 /* Project object */; -} diff --git a/cw_monero/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/cw_monero/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003..000000000 --- a/cw_monero/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/cw_monero/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/cw_monero/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index 4e44b7ced..000000000 --- a/cw_monero/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cw_monero/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/cw_monero/example/macos/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 21a3cc14c..000000000 --- a/cw_monero/example/macos/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/cw_monero/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/cw_monero/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003..000000000 --- a/cw_monero/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/cw_monero/example/macos/Runner/AppDelegate.swift b/cw_monero/example/macos/Runner/AppDelegate.swift deleted file mode 100644 index d53ef6437..000000000 --- a/cw_monero/example/macos/Runner/AppDelegate.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Cocoa -import FlutterMacOS - -@NSApplicationMain -class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } -} diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index a2ec33f19..000000000 --- a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "images" : [ - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_16.png", - "scale" : "1x" - }, - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "2x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "1x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_64.png", - "scale" : "2x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_128.png", - "scale" : "1x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "2x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "1x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "2x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "1x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_1024.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png deleted file mode 100644 index 82b6f9d9a..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png deleted file mode 100644 index 13b35eba5..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png deleted file mode 100644 index 0a3f5fa40..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png deleted file mode 100644 index bdb57226d..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png deleted file mode 100644 index f083318e0..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png deleted file mode 100644 index 326c0e72c..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png deleted file mode 100644 index 2f1632cfd..000000000 Binary files a/cw_monero/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and /dev/null differ diff --git a/cw_monero/example/macos/Runner/Base.lproj/MainMenu.xib b/cw_monero/example/macos/Runner/Base.lproj/MainMenu.xib deleted file mode 100644 index 80e867a4e..000000000 --- a/cw_monero/example/macos/Runner/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cw_monero/example/macos/Runner/Configs/AppInfo.xcconfig b/cw_monero/example/macos/Runner/Configs/AppInfo.xcconfig deleted file mode 100644 index a80a25602..000000000 --- a/cw_monero/example/macos/Runner/Configs/AppInfo.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// Application-level settings for the Runner target. -// -// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the -// future. If not, the values below would default to using the project name when this becomes a -// 'flutter create' template. - -// The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = cw_monero_example - -// The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.cakewallet.cwMoneroExample - -// The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2022 com.cakewallet. All rights reserved. diff --git a/cw_monero/example/macos/Runner/Configs/Debug.xcconfig b/cw_monero/example/macos/Runner/Configs/Debug.xcconfig deleted file mode 100644 index 36b0fd946..000000000 --- a/cw_monero/example/macos/Runner/Configs/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Debug.xcconfig" -#include "Warnings.xcconfig" diff --git a/cw_monero/example/macos/Runner/Configs/Release.xcconfig b/cw_monero/example/macos/Runner/Configs/Release.xcconfig deleted file mode 100644 index dff4f4956..000000000 --- a/cw_monero/example/macos/Runner/Configs/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Release.xcconfig" -#include "Warnings.xcconfig" diff --git a/cw_monero/example/macos/Runner/Configs/Warnings.xcconfig b/cw_monero/example/macos/Runner/Configs/Warnings.xcconfig deleted file mode 100644 index 42bcbf478..000000000 --- a/cw_monero/example/macos/Runner/Configs/Warnings.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings -GCC_WARN_UNDECLARED_SELECTOR = YES -CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES -CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CLANG_WARN_PRAGMA_PACK = YES -CLANG_WARN_STRICT_PROTOTYPES = YES -CLANG_WARN_COMMA = YES -GCC_WARN_STRICT_SELECTOR_MATCH = YES -CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES -CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES -GCC_WARN_SHADOW = YES -CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/cw_monero/example/macos/Runner/DebugProfile.entitlements b/cw_monero/example/macos/Runner/DebugProfile.entitlements deleted file mode 100644 index dddb8a30c..000000000 --- a/cw_monero/example/macos/Runner/DebugProfile.entitlements +++ /dev/null @@ -1,12 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.network.server - - - diff --git a/cw_monero/example/macos/Runner/Info.plist b/cw_monero/example/macos/Runner/Info.plist deleted file mode 100644 index 4789daa6a..000000000 --- a/cw_monero/example/macos/Runner/Info.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHumanReadableCopyright - $(PRODUCT_COPYRIGHT) - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/cw_monero/example/macos/Runner/MainFlutterWindow.swift b/cw_monero/example/macos/Runner/MainFlutterWindow.swift deleted file mode 100644 index 2722837ec..000000000 --- a/cw_monero/example/macos/Runner/MainFlutterWindow.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Cocoa -import FlutterMacOS - -class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController.init() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) - - RegisterGeneratedPlugins(registry: flutterViewController) - - super.awakeFromNib() - } -} diff --git a/cw_monero/example/macos/Runner/Release.entitlements b/cw_monero/example/macos/Runner/Release.entitlements deleted file mode 100644 index 852fa1a47..000000000 --- a/cw_monero/example/macos/Runner/Release.entitlements +++ /dev/null @@ -1,8 +0,0 @@ - - - - - com.apple.security.app-sandbox - - - diff --git a/cw_monero/example/pubspec.lock b/cw_monero/example/pubspec.lock deleted file mode 100644 index ece0d4395..000000000 --- a/cw_monero/example/pubspec.lock +++ /dev/null @@ -1,443 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611" - url: "https://pub.dev" - source: hosted - version: "2.3.2" - asn1lib: - dependency: transitive - description: - name: asn1lib - sha256: ab96a1cb3beeccf8145c52e449233fe68364c9641623acd3adad66f8184f1039 - url: "https://pub.dev" - source: hosted - version: "1.4.0" - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 - url: "https://pub.dev" - source: hosted - version: "1.17.2" - convert: - dependency: transitive - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" - crypto: - dependency: transitive - description: - name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 - url: "https://pub.dev" - source: hosted - version: "3.0.2" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be - url: "https://pub.dev" - source: hosted - version: "1.0.5" - cw_core: - dependency: transitive - description: - path: "../../cw_core" - relative: true - source: path - version: "0.0.1" - cw_monero: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - encrypt: - dependency: transitive - description: - name: encrypt - sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb" - url: "https://pub.dev" - source: hosted - version: "5.0.1" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 - url: "https://pub.dev" - source: hosted - version: "2.0.1" - file: - dependency: transitive - description: - name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c - url: "https://pub.dev" - source: hosted - version: "2.0.1" - flutter_mobx: - dependency: transitive - description: - name: flutter_mobx - sha256: "0da4add0016387a7bf309a0d0c41d36c6b3ae25ed7a176409267f166509e723e" - url: "https://pub.dev" - source: hosted - version: "2.0.6+5" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - hashlib: - dependency: transitive - description: - name: hashlib - sha256: "71bf102329ddb8e50c8a995ee4645ae7f1728bb65e575c17196b4d8262121a96" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - hashlib_codecs: - dependency: transitive - description: - name: hashlib_codecs - sha256: "49e2a471f74b15f1854263e58c2ac11f2b631b5b12c836f9708a35397d36d626" - url: "https://pub.dev" - source: hosted - version: "2.2.0" - http: - dependency: transitive - description: - name: http - sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - intl: - dependency: transitive - description: - name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" - url: "https://pub.dev" - source: hosted - version: "0.18.1" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" - lints: - dependency: transitive - description: - name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" - url: "https://pub.dev" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" - source: hosted - version: "0.5.0" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - mobx: - dependency: transitive - description: - name: mobx - sha256: f1862bd92c6a903fab67338f27e2f731117c3cb9ea37cee1a487f9e4e0de314a - url: "https://pub.dev" - source: hosted - version: "2.1.3+1" - path: - dependency: transitive - description: - name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" - source: hosted - version: "1.8.3" - path_provider: - dependency: transitive - description: - name: path_provider - sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa - url: "https://pub.dev" - source: hosted - version: "2.1.1" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72 - url: "https://pub.dev" - source: hosted - version: "2.2.1" - path_provider_foundation: - dependency: transitive - description: - name: path_provider_foundation - sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" - url: "https://pub.dev" - source: hosted - version: "2.3.1" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 - url: "https://pub.dev" - source: hosted - version: "2.2.1" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" - url: "https://pub.dev" - source: hosted - version: "2.2.1" - platform: - dependency: transitive - description: - name: platform - sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" - url: "https://pub.dev" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a - url: "https://pub.dev" - source: hosted - version: "2.1.3" - pointycastle: - dependency: transitive - description: - name: pointycastle - sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" - url: "https://pub.dev" - source: hosted - version: "3.7.3" - polyseed: - dependency: transitive - description: - name: polyseed - sha256: "9b48ec535b10863f78f6354ec983b4cc0c88ca69ff48fee469d0fd1954b01d4f" - url: "https://pub.dev" - source: hosted - version: "0.0.2" - process: - dependency: transitive - description: - name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" - source: hosted - version: "4.2.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - socks5_proxy: - dependency: transitive - description: - name: socks5_proxy - sha256: "1d21b5606169654bbf4cfb904e8e6ed897e9f763358709f87310c757096d909a" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" - url: "https://pub.dev" - source: hosted - version: "0.6.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - web: - dependency: transitive - description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 - url: "https://pub.dev" - source: hosted - version: "0.1.4-beta" - win32: - dependency: transitive - description: - name: win32 - sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 - url: "https://pub.dev" - source: hosted - version: "3.1.4" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 - url: "https://pub.dev" - source: hosted - version: "0.2.0+3" -sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.7.0" diff --git a/cw_monero/example/pubspec.yaml b/cw_monero/example/pubspec.yaml deleted file mode 100644 index 2dee5337f..000000000 --- a/cw_monero/example/pubspec.yaml +++ /dev/null @@ -1,84 +0,0 @@ -name: cw_monero_example -description: Demonstrates how to use the cw_monero plugin. - -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -environment: - sdk: '>=2.18.1 <3.0.0' - -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. -dependencies: - flutter: - sdk: flutter - - cw_monero: - # When depending on this package from a real application you should use: - # cw_monero: ^x.y.z - # See https://dart.dev/tools/pub/dependencies#version-constraints - # The example app is bundled with the plugin so we use a path dependency on - # the parent directory to use the current plugin's version. - path: ../ - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^2.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/cw_monero/example/test/widget_test.dart b/cw_monero/example/test/widget_test.dart deleted file mode 100644 index b37e6313d..000000000 --- a/cw_monero/example/test/widget_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:cw_monero_example/main.dart'; - -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -} diff --git a/cw_monero/ios/.gitignore b/cw_monero/ios/.gitignore deleted file mode 100644 index aa479fd3c..000000000 --- a/cw_monero/ios/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -.idea/ -.vagrant/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -profile - -DerivedData/ -build/ -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m - -.generated/ - -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - -!default.pbxuser -!default.mode1v3 -!default.mode2v3 -!default.perspectivev3 - -xcuserdata - -*.moved-aside - -*.pyc -*sync/ -Icon? -.tags* - -/Flutter/Generated.xcconfig -/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/cw_monero/ios/Classes/CwMoneroPlugin.h b/cw_monero/ios/Classes/CwMoneroPlugin.h deleted file mode 100644 index a42018098..000000000 --- a/cw_monero/ios/Classes/CwMoneroPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface CwMoneroPlugin : NSObject -@end diff --git a/cw_monero/ios/Classes/CwMoneroPlugin.m b/cw_monero/ios/Classes/CwMoneroPlugin.m deleted file mode 100644 index eee251212..000000000 --- a/cw_monero/ios/Classes/CwMoneroPlugin.m +++ /dev/null @@ -1,8 +0,0 @@ -#import "CwMoneroPlugin.h" -#import - -@implementation CwMoneroPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftCwMoneroPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/cw_monero/ios/Classes/CwWalletListener.h b/cw_monero/ios/Classes/CwWalletListener.h deleted file mode 100644 index cbfcb0c4e..000000000 --- a/cw_monero/ios/Classes/CwWalletListener.h +++ /dev/null @@ -1,23 +0,0 @@ -#include - -struct CWMoneroWalletListener; - -typedef int8_t (*on_new_block_callback)(uint64_t height); -typedef int8_t (*on_need_to_refresh_callback)(); - -typedef struct CWMoneroWalletListener -{ - // on_money_spent_callback *on_money_spent; - // on_money_received_callback *on_money_received; - // on_unconfirmed_money_received_callback *on_unconfirmed_money_received; - // on_new_block_callback *on_new_block; - // on_updated_callback *on_updated; - // on_refreshed_callback *on_refreshed; - - on_new_block_callback on_new_block; -} CWMoneroWalletListener; - -struct TestListener { - // int8_t x; - on_new_block_callback on_new_block; -}; \ No newline at end of file diff --git a/cw_monero/ios/Classes/SwiftCwMoneroPlugin.swift b/cw_monero/ios/Classes/SwiftCwMoneroPlugin.swift deleted file mode 100644 index 4c03a3e44..000000000 --- a/cw_monero/ios/Classes/SwiftCwMoneroPlugin.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Flutter -import UIKit - -public class SwiftCwMoneroPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "cw_monero", binaryMessenger: registrar.messenger()) - let instance = SwiftCwMoneroPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - result("iOS " + UIDevice.current.systemVersion) - } -} diff --git a/cw_monero/ios/Classes/monero_api.cpp b/cw_monero/ios/Classes/monero_api.cpp deleted file mode 100644 index 87be785ac..000000000 --- a/cw_monero/ios/Classes/monero_api.cpp +++ /dev/null @@ -1,1034 +0,0 @@ -#include -#include "cstdlib" -#include -#include -#include -#include -#include -#include -#include -#include "thread" -#include "CwWalletListener.h" -#if __APPLE__ -// Fix for randomx on ios -void __clear_cache(void* start, void* end) { } -#include "../External/ios/include/wallet2_api.h" -#else -#include "../External/android/include/wallet2_api.h" -#endif - -using namespace std::chrono_literals; -#ifdef __cplusplus -extern "C" -{ -#endif - const uint64_t MONERO_BLOCK_SIZE = 1000; - - struct Utf8Box - { - char *value; - - Utf8Box(char *_value) - { - value = _value; - } - }; - - struct SubaddressRow - { - uint64_t id; - char *address; - char *label; - - SubaddressRow(std::size_t _id, char *_address, char *_label) - { - id = static_cast(_id); - address = _address; - label = _label; - } - }; - - struct AccountRow - { - uint64_t id; - char *label; - - AccountRow(std::size_t _id, char *_label) - { - id = static_cast(_id); - label = _label; - } - }; - - struct MoneroWalletListener : Monero::WalletListener - { - uint64_t m_height; - bool m_need_to_refresh; - bool m_new_transaction; - - MoneroWalletListener() - { - m_height = 0; - m_need_to_refresh = false; - m_new_transaction = false; - } - - void moneySpent(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void moneyReceived(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void newBlock(uint64_t height) - { - m_height = height; - } - - void updated() - { - m_new_transaction = true; - } - - void refreshed() - { - m_need_to_refresh = true; - } - - void resetNeedToRefresh() - { - m_need_to_refresh = false; - } - - bool isNeedToRefresh() - { - return m_need_to_refresh; - } - - bool isNewTransactionExist() - { - return m_new_transaction; - } - - void resetIsNewTransactionExist() - { - m_new_transaction = false; - } - - uint64_t height() - { - return m_height; - } - }; - - struct TransactionInfoRow - { - uint64_t amount; - uint64_t fee; - uint64_t blockHeight; - uint64_t confirmations; - uint32_t subaddrAccount; - int8_t direction; - int8_t isPending; - uint32_t subaddrIndex; - - char *hash; - char *paymentId; - - int64_t datetime; - - TransactionInfoRow(Monero::TransactionInfo *transaction) - { - amount = transaction->amount(); - fee = transaction->fee(); - blockHeight = transaction->blockHeight(); - subaddrAccount = transaction->subaddrAccount(); - std::set::iterator it = transaction->subaddrIndex().begin(); - subaddrIndex = *it; - confirmations = transaction->confirmations(); - datetime = static_cast(transaction->timestamp()); - direction = transaction->direction(); - isPending = static_cast(transaction->isPending()); - std::string *hash_str = new std::string(transaction->hash()); - hash = strdup(hash_str->c_str()); - paymentId = strdup(transaction->paymentId().c_str()); - } - }; - - struct PendingTransactionRaw - { - uint64_t amount; - uint64_t fee; - char *hash; - char *hex; - char *txKey; - Monero::PendingTransaction *transaction; - - PendingTransactionRaw(Monero::PendingTransaction *_transaction) - { - transaction = _transaction; - amount = _transaction->amount(); - fee = _transaction->fee(); - hash = strdup(_transaction->txid()[0].c_str()); - hex = strdup(_transaction->hex()[0].c_str()); - txKey = strdup(_transaction->txKey()[0].c_str()); - } - }; - - struct CoinsInfoRow - { - uint64_t blockHeight; - char *hash; - uint64_t internalOutputIndex; - uint64_t globalOutputIndex; - bool spent; - bool frozen; - uint64_t spentHeight; - uint64_t amount; - bool rct; - bool keyImageKnown; - uint64_t pkIndex; - uint32_t subaddrIndex; - uint32_t subaddrAccount; - char *address; - char *addressLabel; - char *keyImage; - uint64_t unlockTime; - bool unlocked; - char *pubKey; - bool coinbase; - char *description; - - CoinsInfoRow(Monero::CoinsInfo *coinsInfo) - { - blockHeight = coinsInfo->blockHeight(); - std::string *hash_str = new std::string(coinsInfo->hash()); - hash = strdup(hash_str->c_str()); - internalOutputIndex = coinsInfo->internalOutputIndex(); - globalOutputIndex = coinsInfo->globalOutputIndex(); - spent = coinsInfo->spent(); - frozen = coinsInfo->frozen(); - spentHeight = coinsInfo->spentHeight(); - amount = coinsInfo->amount(); - rct = coinsInfo->rct(); - keyImageKnown = coinsInfo->keyImageKnown(); - pkIndex = coinsInfo->pkIndex(); - subaddrIndex = coinsInfo->subaddrIndex(); - subaddrAccount = coinsInfo->subaddrAccount(); - address = strdup(coinsInfo->address().c_str()) ; - addressLabel = strdup(coinsInfo->addressLabel().c_str()); - keyImage = strdup(coinsInfo->keyImage().c_str()); - unlockTime = coinsInfo->unlockTime(); - unlocked = coinsInfo->unlocked(); - pubKey = strdup(coinsInfo->pubKey().c_str()); - coinbase = coinsInfo->coinbase(); - description = strdup(coinsInfo->description().c_str()); - } - - void setUnlocked(bool unlocked); - }; - - Monero::Coins *m_coins; - - Monero::Wallet *m_wallet; - Monero::TransactionHistory *m_transaction_history; - MoneroWalletListener *m_listener; - Monero::Subaddress *m_subaddress; - Monero::SubaddressAccount *m_account; - uint64_t m_last_known_wallet_height; - uint64_t m_cached_syncing_blockchain_height = 0; - std::list m_coins_info; - std::mutex store_lock; - bool is_storing = false; - - void change_current_wallet(Monero::Wallet *wallet) - { - m_wallet = wallet; - m_listener = nullptr; - - - if (wallet != nullptr) - { - m_transaction_history = wallet->history(); - } - else - { - m_transaction_history = nullptr; - } - - if (wallet != nullptr) - { - m_account = wallet->subaddressAccount(); - } - else - { - m_account = nullptr; - } - - if (wallet != nullptr) - { - m_subaddress = wallet->subaddress(); - } - else - { - m_subaddress = nullptr; - } - - m_coins_info = std::list(); - - if (wallet != nullptr) - { - m_coins = wallet->coins(); - } - else - { - m_coins = nullptr; - } - } - - Monero::Wallet *get_current_wallet() - { - return m_wallet; - } - - bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); - Monero::Wallet *wallet = walletManager->createWallet(path, password, language, _networkType); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (wallet->status() != Monero::Wallet::Status_Ok) - { - error = strdup(wallet->errorString().c_str()); - return false; - } - - change_current_wallet(wallet); - - return true; - } - - bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->recoveryWallet( - std::string(path), - std::string(password), - std::string(seed), - _networkType, - (uint64_t)restoreHeight); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( - std::string(path), - std::string(password), - std::string(language), - _networkType, - (uint64_t)restoreHeight, - std::string(address), - std::string(viewKey), - std::string(spendKey)); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool restore_wallet_from_spend_key(char *path, char *password, char *seed, char *language, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->createDeterministicWalletFromSpendKey( - std::string(path), - std::string(password), - std::string(language), - _networkType, - (uint64_t)restoreHeight, - std::string(spendKey)); - - // Cache Raw to support Polyseed - wallet->setCacheAttribute("cakewallet.seed", std::string(seed)); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool load_wallet(char *path, char *password, int32_t nettype) - { - nice(19); - Monero::NetworkType networkType = static_cast(nettype); - Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); - Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType); - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - change_current_wallet(wallet); - - return !(status != Monero::Wallet::Status_Ok || !errorString.empty()); - } - - char *error_string() { - return strdup(get_current_wallet()->errorString().c_str()); - } - - - bool is_wallet_exist(char *path) - { - return Monero::WalletManagerFactory::getWalletManager()->walletExists(std::string(path)); - } - - void close_current_wallet() - { - Monero::WalletManagerFactory::getWalletManager()->closeWallet(get_current_wallet()); - change_current_wallet(nullptr); - } - - char *get_filename() - { - return strdup(get_current_wallet()->filename().c_str()); - } - - char *secret_view_key() - { - return strdup(get_current_wallet()->secretViewKey().c_str()); - } - - char *public_view_key() - { - return strdup(get_current_wallet()->publicViewKey().c_str()); - } - - char *secret_spend_key() - { - return strdup(get_current_wallet()->secretSpendKey().c_str()); - } - - char *public_spend_key() - { - return strdup(get_current_wallet()->publicSpendKey().c_str()); - } - - char *get_address(uint32_t account_index, uint32_t address_index) - { - return strdup(get_current_wallet()->address(account_index, address_index).c_str()); - } - - - const char *seed() - { - std::string _rawSeed = get_current_wallet()->getCacheAttribute("cakewallet.seed"); - if (!_rawSeed.empty()) - { - return strdup(_rawSeed.c_str()); - } - return strdup(get_current_wallet()->seed().c_str()); - } - - uint64_t get_full_balance(uint32_t account_index) - { - return get_current_wallet()->balance(account_index); - } - - uint64_t get_unlocked_balance(uint32_t account_index) - { - return get_current_wallet()->unlockedBalance(account_index); - } - - uint64_t get_current_height() - { - return get_current_wallet()->blockChainHeight(); - } - - uint64_t get_node_height() - { - return get_current_wallet()->daemonBlockChainHeight(); - } - - bool connect_to_node(char *error) - { - nice(19); - bool is_connected = get_current_wallet()->connectToDaemon(); - - if (!is_connected) - { - error = strdup(get_current_wallet()->errorString().c_str()); - } - - return is_connected; - } - - bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *socksProxyAddress, char *error) - { - nice(19); - Monero::Wallet *wallet = get_current_wallet(); - - std::string _login = ""; - std::string _password = ""; - std::string _socksProxyAddress = ""; - - if (login != nullptr) - { - _login = std::string(login); - } - - if (password != nullptr) - { - _password = std::string(password); - } - - if (socksProxyAddress != nullptr) - { - _socksProxyAddress = std::string(socksProxyAddress); - } - - bool inited = wallet->init(std::string(address), 0, _login, _password, use_ssl, is_light_wallet, _socksProxyAddress); - - if (!inited) - { - error = strdup(wallet->errorString().c_str()); - } else if (!wallet->connectToDaemon()) { - error = strdup(wallet->errorString().c_str()); - } - - return inited; - } - - bool is_connected() - { - return get_current_wallet()->connected(); - } - - void start_refresh() - { - get_current_wallet()->refreshAsync(); - get_current_wallet()->startRefresh(); - } - - void set_refresh_from_block_height(uint64_t height) - { - get_current_wallet()->setRefreshFromBlockHeight(height); - } - - void set_recovering_from_seed(bool is_recovery) - { - get_current_wallet()->setRecoveringFromSeed(is_recovery); - } - - void store(char *path) - { - store_lock.lock(); - if (is_storing) { - return; - } - - is_storing = true; - get_current_wallet()->store(std::string(path)); - is_storing = false; - store_lock.unlock(); - } - - bool set_password(char *password, Utf8Box &error) { - bool is_changed = get_current_wallet()->setPassword(std::string(password)); - - if (!is_changed) { - error = Utf8Box(strdup(get_current_wallet()->errorString().c_str())); - } - - return is_changed; - } - - bool transaction_create(char *address, char *payment_id, char *amount, - uint8_t priority_raw, uint32_t subaddr_account, - char **preferred_inputs, uint32_t preferred_inputs_size, - Utf8Box &error, PendingTransactionRaw &pendingTransaction) - { - nice(19); - - std::set _preferred_inputs; - - for (int i = 0; i < preferred_inputs_size; i++) { - _preferred_inputs.insert(std::string(*preferred_inputs)); - preferred_inputs++; - } - - auto priority = static_cast(priority_raw); - std::string _payment_id; - Monero::PendingTransaction *transaction; - - if (payment_id != nullptr) - { - _payment_id = std::string(payment_id); - } - - if (amount != nullptr) - { - uint64_t _amount = Monero::Wallet::amountFromString(std::string(amount)); - transaction = m_wallet->createTransaction(std::string(address), _payment_id, _amount, m_wallet->defaultMixin(), priority, subaddr_account, {}, _preferred_inputs); - } - else - { - transaction = m_wallet->createTransaction(std::string(address), _payment_id, Monero::optional(), m_wallet->defaultMixin(), priority, subaddr_account, {}, _preferred_inputs); - } - - int status = transaction->status(); - - if (status == Monero::PendingTransaction::Status::Status_Error || status == Monero::PendingTransaction::Status::Status_Critical) - { - error = Utf8Box(strdup(transaction->errorString().c_str())); - return false; - } - - if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - pendingTransaction = PendingTransactionRaw(transaction); - return true; - } - - bool transaction_create_mult_dest(char **addresses, char *payment_id, char **amounts, uint32_t size, - uint8_t priority_raw, uint32_t subaddr_account, - char **preferred_inputs, uint32_t preferred_inputs_size, - Utf8Box &error, PendingTransactionRaw &pendingTransaction) - { - nice(19); - - std::vector _addresses; - std::vector _amounts; - - for (int i = 0; i < size; i++) { - _addresses.push_back(std::string(*addresses)); - _amounts.push_back(Monero::Wallet::amountFromString(std::string(*amounts))); - addresses++; - amounts++; - } - - std::set _preferred_inputs; - - for (int i = 0; i < preferred_inputs_size; i++) { - _preferred_inputs.insert(std::string(*preferred_inputs)); - preferred_inputs++; - } - - auto priority = static_cast(priority_raw); - std::string _payment_id; - Monero::PendingTransaction *transaction; - - if (payment_id != nullptr) - { - _payment_id = std::string(payment_id); - } - - transaction = m_wallet->createTransactionMultDest(_addresses, _payment_id, _amounts, m_wallet->defaultMixin(), priority, subaddr_account); - - int status = transaction->status(); - - if (status == Monero::PendingTransaction::Status::Status_Error || status == Monero::PendingTransaction::Status::Status_Critical) - { - error = Utf8Box(strdup(transaction->errorString().c_str())); - return false; - } - - if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - pendingTransaction = PendingTransactionRaw(transaction); - return true; - } - - bool transaction_commit(PendingTransactionRaw *transaction, Utf8Box &error) - { - bool committed = transaction->transaction->commit(); - - if (!committed) - { - error = Utf8Box(strdup(transaction->transaction->errorString().c_str())); - } else if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - return committed; - } - - uint64_t get_node_height_or_update(uint64_t base_eight) - { - if (m_cached_syncing_blockchain_height < base_eight) { - m_cached_syncing_blockchain_height = base_eight; - } - - return m_cached_syncing_blockchain_height; - } - - uint64_t get_syncing_height() - { - if (m_listener == nullptr) { - return 0; - } - - uint64_t height = m_listener->height(); - - if (height <= 1) { - return 0; - } - - if (height != m_last_known_wallet_height) - { - m_last_known_wallet_height = height; - } - - return height; - } - - uint64_t is_needed_to_refresh() - { - if (m_listener == nullptr) { - return false; - } - - bool should_refresh = m_listener->isNeedToRefresh(); - - if (should_refresh) { - m_listener->resetNeedToRefresh(); - } - - return should_refresh; - } - - uint8_t is_new_transaction_exist() - { - if (m_listener == nullptr) { - return false; - } - - bool is_new_transaction_exist = m_listener->isNewTransactionExist(); - - if (is_new_transaction_exist) - { - m_listener->resetIsNewTransactionExist(); - } - - return is_new_transaction_exist; - } - - void set_listener() - { - m_last_known_wallet_height = 0; - - if (m_listener != nullptr) - { - free(m_listener); - } - - m_listener = new MoneroWalletListener(); - get_current_wallet()->setListener(m_listener); - } - - int64_t *subaddrress_get_all() - { - std::vector _subaddresses = m_subaddress->getAll(); - size_t size = _subaddresses.size(); - int64_t *subaddresses = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::SubaddressRow *row = _subaddresses[i]; - SubaddressRow *_row = new SubaddressRow(row->getRowId(), strdup(row->getAddress().c_str()), strdup(row->getLabel().c_str())); - subaddresses[i] = reinterpret_cast(_row); - } - - return subaddresses; - } - - int32_t subaddrress_size() - { - std::vector _subaddresses = m_subaddress->getAll(); - return _subaddresses.size(); - } - - void subaddress_add_row(uint32_t accountIndex, char *label) - { - m_subaddress->addRow(accountIndex, std::string(label)); - } - - void subaddress_set_label(uint32_t accountIndex, uint32_t addressIndex, char *label) - { - m_subaddress->setLabel(accountIndex, addressIndex, std::string(label)); - } - - void subaddress_refresh(uint32_t accountIndex) - { - m_subaddress->refresh(accountIndex); - } - - int32_t account_size() - { - std::vector _accocunts = m_account->getAll(); - return _accocunts.size(); - } - - int64_t *account_get_all() - { - std::vector _accocunts = m_account->getAll(); - size_t size = _accocunts.size(); - int64_t *accocunts = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::SubaddressAccountRow *row = _accocunts[i]; - AccountRow *_row = new AccountRow(row->getRowId(), strdup(row->getLabel().c_str())); - accocunts[i] = reinterpret_cast(_row); - } - - return accocunts; - } - - void account_add_row(char *label) - { - m_account->addRow(std::string(label)); - } - - void account_set_label_row(uint32_t account_index, char *label) - { - m_account->setLabel(account_index, label); - } - - void account_refresh() - { - m_account->refresh(); - } - - int64_t *transactions_get_all() - { - std::vector transactions = m_transaction_history->getAll(); - size_t size = transactions.size(); - int64_t *transactionAddresses = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::TransactionInfo *row = transactions[i]; - TransactionInfoRow *tx = new TransactionInfoRow(row); - transactionAddresses[i] = reinterpret_cast(tx); - } - - return transactionAddresses; - } - - void transactions_refresh() - { - m_transaction_history->refresh(); - } - - int64_t transactions_count() - { - return m_transaction_history->count(); - } - - TransactionInfoRow* get_transaction(char * txId) - { - Monero::TransactionInfo *row = m_transaction_history->transaction(std::string(txId)); - return new TransactionInfoRow(row); - } - - int LedgerExchange( - unsigned char *command, - unsigned int cmd_len, - unsigned char *response, - unsigned int max_resp_len) - { - return -1; - } - - int LedgerFind(char *buffer, size_t len) - { - return -1; - } - - void on_startup() - { - Monero::Utils::onStartup(); - Monero::WalletManagerFactory::setLogLevel(0); - } - - void rescan_blockchain() - { - m_wallet->rescanBlockchainAsync(); - } - - char * get_tx_key(char * txId) - { - return strdup(m_wallet->getTxKey(std::string(txId)).c_str()); - } - - char *get_subaddress_label(uint32_t accountIndex, uint32_t addressIndex) - { - return strdup(get_current_wallet()->getSubaddressLabel(accountIndex, addressIndex).c_str()); - } - - void set_trusted_daemon(bool arg) - { - m_wallet->setTrustedDaemon(arg); - } - - bool trusted_daemon() - { - return m_wallet->trustedDaemon(); - } - - // Coin Control // - - CoinsInfoRow* coin(int index) - { - if (index >= 0 && index < m_coins_info.size()) { - std::list::iterator it = m_coins_info.begin(); - std::advance(it, index); - Monero::CoinsInfo* element = *it; - std::cout << "Element at index " << index << ": " << element << std::endl; - return new CoinsInfoRow(element); - } else { - std::cout << "Invalid index." << std::endl; - return nullptr; // Return a default value (nullptr) for invalid index - } - } - - void refresh_coins(uint32_t accountIndex) - { - m_coins_info.clear(); - - m_coins->refresh(); - for (const auto i : m_coins->getAll()) { - if (i->subaddrAccount() == accountIndex && !(i->spent())) { - m_coins_info.push_back(i); - } - } - } - - uint64_t coins_count() - { - return m_coins_info.size(); - } - - CoinsInfoRow** coins_from_account(uint32_t accountIndex) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinInfo = coin(i); - if (coinInfo->subaddrAccount == accountIndex) { - matchingCoins.push_back(coinInfo); - } - } - - CoinsInfoRow** result = new CoinsInfoRow*[matchingCoins.size()]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - CoinsInfoRow** coins_from_txid(const char* txid, size_t* count) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinInfo = coin(i); - if (std::string(coinInfo->hash) == txid) { - matchingCoins.push_back(coinInfo); - } - } - - *count = matchingCoins.size(); - CoinsInfoRow** result = new CoinsInfoRow*[*count]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - CoinsInfoRow** coins_from_key_image(const char** keyimages, size_t keyimageCount, size_t* count) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinsInfoRow = coin(i); - for (size_t j = 0; j < keyimageCount; j++) { - if (coinsInfoRow->keyImageKnown && std::string(coinsInfoRow->keyImage) == keyimages[j]) { - matchingCoins.push_back(coinsInfoRow); - break; - } - } - } - - *count = matchingCoins.size(); - CoinsInfoRow** result = new CoinsInfoRow*[*count]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - void freeze_coin(int index) - { - m_coins->setFrozen(index); - } - - void thaw_coin(int index) - { - m_coins->thaw(index); - } - - // Sign Messages // - - char *sign_message(char *message, char *address = "") - { - return strdup(get_current_wallet()->signMessage(std::string(message), std::string(address)).c_str()); - } - -#ifdef __cplusplus -} -#endif diff --git a/cw_monero/ios/Classes/monero_api.h b/cw_monero/ios/Classes/monero_api.h deleted file mode 100644 index fa92a038d..000000000 --- a/cw_monero/ios/Classes/monero_api.h +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include "CwWalletListener.h" - -#ifdef __cplusplus -extern "C" { -#endif - -bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error); -bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error); -bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error); -void load_wallet(char *path, char *password, int32_t nettype); -bool is_wallet_exist(char *path); - -char *get_filename(); -const char *seed(); -char *get_address(uint32_t account_index, uint32_t address_index); -uint64_t get_full_balance(uint32_t account_index); -uint64_t get_unlocked_balance(uint32_t account_index); -uint64_t get_current_height(); -uint64_t get_node_height(); - -bool is_connected(); - -bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error); -bool connect_to_node(char *error); -void start_refresh(); -void set_refresh_from_block_height(uint64_t height); -void set_recovering_from_seed(bool is_recovery); -void store(char *path); - -void set_trusted_daemon(bool arg); -bool trusted_daemon(); -char *sign_message(char *message, char *address); - -#ifdef __cplusplus -} -#endif diff --git a/cw_monero/ios/cw_monero.podspec b/cw_monero/ios/cw_monero.podspec deleted file mode 100644 index d99bba923..000000000 --- a/cw_monero/ios/cw_monero.podspec +++ /dev/null @@ -1,62 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint cw_monero.podspec' to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'cw_monero' - s.version = '0.0.2' - s.summary = 'CW Monero' - s.description = 'Cake Wallet wrapper over Monero project.' - s.homepage = 'http://cakewallet.com' - s.license = { :file => '../LICENSE' } - 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/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 = '../../../../../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 'Sodium' do |sodium| - 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 'Unbound' do |unbound| - unbound.preserve_paths = '../../../../../cw_shared_external/ios/External/ios/include/**/*.h' - unbound.vendored_libraries = '../../../../../cw_shared_external/ios/External/ios/lib/libunbound.a' - unbound.libraries = 'unbound' - unbound.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/ios/include/**" } - end - - 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 diff --git a/cw_monero/lib/api/account_list.dart b/cw_monero/lib/api/account_list.dart index 451ba5033..199896631 100644 --- a/cw_monero/lib/api/account_list.dart +++ b/cw_monero/lib/api/account_list.dart @@ -1,38 +1,28 @@ -import 'dart:ffi'; -import 'package:ffi/ffi.dart'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/types.dart'; -import 'package:cw_monero/api/monero_api.dart'; -import 'package:cw_monero/api/structs/account_row.dart'; -import 'package:flutter/foundation.dart'; import 'package:cw_monero/api/wallet.dart'; +import 'package:monero/monero.dart' as monero; -final accountSizeNative = moneroApi - .lookup>('account_size') - .asFunction(); +monero.wallet? wptr = null; -final accountRefreshNative = moneroApi - .lookup>('account_refresh') - .asFunction(); +int _wlptrForW = 0; +monero.WalletListener? _wlptr = null; -final accountGetAllNative = moneroApi - .lookup>('account_get_all') - .asFunction(); +monero.WalletListener getWlptr() { + if (wptr!.address == _wlptrForW) return _wlptr!; + _wlptrForW = wptr!.address; + _wlptr = monero.MONERO_cw_getWalletListener(wptr!); + return _wlptr!; +} -final accountAddNewNative = moneroApi - .lookup>('account_add_row') - .asFunction(); -final accountSetLabelNative = moneroApi - .lookup>('account_set_label_row') - .asFunction(); +monero.SubaddressAccount? subaddressAccount; bool isUpdating = false; void refreshAccounts() { try { isUpdating = true; - accountRefreshNative(); + subaddressAccount = monero.Wallet_subaddressAccount(wptr!); + monero.SubaddressAccount_refresh(subaddressAccount!); isUpdating = false; } catch (e) { isUpdating = false; @@ -40,26 +30,27 @@ void refreshAccounts() { } } -List getAllAccount() { - final size = accountSizeNative(); - final accountAddressesPointer = accountGetAllNative(); - final accountAddresses = accountAddressesPointer.asTypedList(size); - - return accountAddresses - .map((addr) => Pointer.fromAddress(addr).ref) - .toList(); +List getAllAccount() { + // final size = monero.Wallet_numSubaddressAccounts(wptr!); + refreshAccounts(); + int size = monero.SubaddressAccount_getAll_size(subaddressAccount!); + print("size: $size"); + if (size == 0) { + monero.Wallet_addSubaddressAccount(wptr!); + return getAllAccount(); + } + return List.generate(size, (index) { + return monero.SubaddressAccount_getAll_byIndex(subaddressAccount!, index: index); + }); } void addAccountSync({required String label}) { - final labelPointer = label.toNativeUtf8(); - accountAddNewNative(labelPointer); - calloc.free(labelPointer); + monero.Wallet_addSubaddressAccount(wptr!, label: label); } void setLabelForAccountSync({required int accountIndex, required String label}) { - final labelPointer = label.toNativeUtf8(); - accountSetLabelNative(accountIndex, labelPointer); - calloc.free(labelPointer); + // TODO(mrcyjanek): this may be wrong function? + monero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: 0, label: label); } void _addAccount(String label) => addAccountSync(label: label); @@ -72,12 +63,11 @@ void _setLabelForAccount(Map args) { } Future addAccount({required String label}) async { - await compute(_addAccount, label); + _addAccount(label); await store(); } Future setLabelForAccount({required int accountIndex, required String label}) async { - await compute( - _setLabelForAccount, {'accountIndex': accountIndex, 'label': label}); + _setLabelForAccount({'accountIndex': accountIndex, 'label': label}); await store(); } \ No newline at end of file diff --git a/cw_monero/lib/api/coins_info.dart b/cw_monero/lib/api/coins_info.dart index d7350a6e2..c1b634cc6 100644 --- a/cw_monero/lib/api/coins_info.dart +++ b/cw_monero/lib/api/coins_info.dart @@ -1,35 +1,17 @@ -import 'dart:ffi'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/structs/coins_info_row.dart'; -import 'package:cw_monero/api/types.dart'; -import 'package:cw_monero/api/monero_api.dart'; +import 'package:cw_monero/api/account_list.dart'; +import 'package:monero/monero.dart' as monero; -final refreshCoinsNative = moneroApi - .lookup>('refresh_coins') - .asFunction(); +monero.Coins? coins = null; -final coinsCountNative = moneroApi - .lookup>('coins_count') - .asFunction(); +void refreshCoins(int accountIndex) { + coins = monero.Wallet_coins(wptr!); + monero.Coins_refresh(coins!); +} -final coinNative = moneroApi - .lookup>('coin') - .asFunction(); +int countOfCoins() => monero.Coins_count(coins!); -final freezeCoinNative = moneroApi - .lookup>('freeze_coin') - .asFunction(); +monero.CoinsInfo getCoin(int index) => monero.Coins_coin(coins!, index); -final thawCoinNative = moneroApi - .lookup>('thaw_coin') - .asFunction(); +void freezeCoin(int index) => monero.Coins_setFrozen(coins!, index: index); -void refreshCoins(int accountIndex) => refreshCoinsNative(accountIndex); - -int countOfCoins() => coinsCountNative(); - -CoinsInfoRow getCoin(int index) => coinNative(index).ref; - -void freezeCoin(int index) => freezeCoinNative(index); - -void thawCoin(int index) => thawCoinNative(index); +void thawCoin(int index) => monero.Coins_thaw(coins!, index: index); diff --git a/cw_monero/lib/api/convert_utf8_to_string.dart b/cw_monero/lib/api/convert_utf8_to_string.dart deleted file mode 100644 index 41a6b648a..000000000 --- a/cw_monero/lib/api/convert_utf8_to_string.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'dart:ffi'; -import 'package:ffi/ffi.dart'; - -String convertUTF8ToString({required Pointer pointer}) { - final str = pointer.toDartString(); - calloc.free(pointer); - return str; -} \ No newline at end of file diff --git a/cw_monero/lib/api/monero_api.dart b/cw_monero/lib/api/monero_api.dart deleted file mode 100644 index 398d737d1..000000000 --- a/cw_monero/lib/api/monero_api.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'dart:ffi'; -import 'dart:io'; - -final DynamicLibrary moneroApi = Platform.isAndroid - ? DynamicLibrary.open("libcw_monero.so") - : DynamicLibrary.open("cw_monero.framework/cw_monero"); \ No newline at end of file diff --git a/cw_monero/lib/api/signatures.dart b/cw_monero/lib/api/signatures.dart deleted file mode 100644 index bc4fc9d38..000000000 --- a/cw_monero/lib/api/signatures.dart +++ /dev/null @@ -1,153 +0,0 @@ -import 'dart:ffi'; -import 'package:cw_monero/api/structs/coins_info_row.dart'; -import 'package:cw_monero/api/structs/pending_transaction.dart'; -import 'package:cw_monero/api/structs/transaction_info_row.dart'; -import 'package:cw_monero/api/structs/ut8_box.dart'; -import 'package:ffi/ffi.dart'; - -typedef create_wallet = Int8 Function( - Pointer, Pointer, Pointer, Int32, Pointer); - -typedef restore_wallet_from_seed = Int8 Function( - Pointer, Pointer, Pointer, Int32, Int64, Pointer); - -typedef restore_wallet_from_keys = Int8 Function(Pointer, Pointer, Pointer, - Pointer, Pointer, Pointer, Int32, Int64, Pointer); - -typedef restore_wallet_from_spend_key = Int8 Function(Pointer, Pointer, Pointer, - Pointer, Pointer, Int32, Int64, Pointer); - -typedef is_wallet_exist = Int8 Function(Pointer); - -typedef load_wallet = Int8 Function(Pointer, Pointer, Int8); - -typedef error_string = Pointer Function(); - -typedef get_filename = Pointer Function(); - -typedef get_seed = Pointer Function(); - -typedef get_address = Pointer Function(Int32, Int32); - -typedef get_full_balanace = Int64 Function(Int32); - -typedef get_unlocked_balanace = Int64 Function(Int32); - -typedef get_current_height = Int64 Function(); - -typedef get_node_height = Int64 Function(); - -typedef is_connected = Int8 Function(); - -typedef setup_node = Int8 Function( - Pointer, Pointer?, Pointer?, Int8, Int8, Pointer?, Pointer); - -typedef start_refresh = Void Function(); - -typedef connect_to_node = Int8 Function(); - -typedef set_refresh_from_block_height = Void Function(Int64); - -typedef set_recovering_from_seed = Void Function(Int8); - -typedef store_c = Void Function(Pointer); - -typedef set_password = Int8 Function(Pointer password, Pointer error); - -typedef set_listener = Void Function(); - -typedef get_syncing_height = Int64 Function(); - -typedef is_needed_to_refresh = Int8 Function(); - -typedef is_new_transaction_exist = Int8 Function(); - -typedef subaddrress_size = Int32 Function(); - -typedef subaddrress_refresh = Void Function(Int32); - -typedef subaddress_get_all = Pointer Function(); - -typedef subaddress_add_new = Void Function(Int32 accountIndex, Pointer label); - -typedef subaddress_set_label = Void Function( - Int32 accountIndex, Int32 addressIndex, Pointer label); - -typedef account_size = Int32 Function(); - -typedef account_refresh = Void Function(); - -typedef account_get_all = Pointer Function(); - -typedef account_add_new = Void Function(Pointer label); - -typedef account_set_label = Void Function(Int32 accountIndex, Pointer label); - -typedef transactions_refresh = Void Function(); - -typedef get_transaction = Pointer Function(Pointer txId); - -typedef get_tx_key = Pointer? Function(Pointer txId); - -typedef transactions_count = Int64 Function(); - -typedef transactions_get_all = Pointer Function(); - -typedef transaction_create = Int8 Function( - Pointer address, - Pointer paymentId, - Pointer amount, - Int8 priorityRaw, - Int32 subaddrAccount, - Pointer> preferredInputs, - Int32 preferredInputsSize, - Pointer error, - Pointer pendingTransaction); - -typedef transaction_create_mult_dest = Int8 Function( - Pointer> addresses, - Pointer paymentId, - Pointer> amounts, - Int32 size, - Int8 priorityRaw, - Int32 subaddrAccount, - Pointer> preferredInputs, - Int32 preferredInputsSize, - Pointer error, - Pointer pendingTransaction); - -typedef transaction_commit = Int8 Function(Pointer, Pointer); - -typedef secret_view_key = Pointer Function(); - -typedef public_view_key = Pointer Function(); - -typedef secret_spend_key = Pointer Function(); - -typedef public_spend_key = Pointer Function(); - -typedef close_current_wallet = Void Function(); - -typedef on_startup = Void Function(); - -typedef rescan_blockchain = Void Function(); - -typedef get_subaddress_label = Pointer Function(Int32 accountIndex, Int32 addressIndex); - -typedef set_trusted_daemon = Void Function(Int8 trusted); - -typedef trusted_daemon = Int8 Function(); - -typedef refresh_coins = Void Function(Int32 accountIndex); - -typedef coins_count = Int64 Function(); - -// typedef coins_from_txid = Pointer Function(Pointer txid); - -typedef coin = Pointer Function(Int32 index); - -typedef freeze_coin = Void Function(Int32 index); - -typedef thaw_coin = Void Function(Int32 index); - -typedef sign_message = Pointer Function(Pointer message, Pointer address); diff --git a/cw_monero/lib/api/structs/pending_transaction.dart b/cw_monero/lib/api/structs/pending_transaction.dart index 656ed333f..dc5fbddd0 100644 --- a/cw_monero/lib/api/structs/pending_transaction.dart +++ b/cw_monero/lib/api/structs/pending_transaction.dart @@ -1,25 +1,3 @@ -import 'dart:ffi'; -import 'package:ffi/ffi.dart'; - -class PendingTransactionRaw extends Struct { - @Int64() - external int amount; - - @Int64() - external int fee; - - external Pointer hash; - - external Pointer hex; - - external Pointer txKey; - - String getHash() => hash.toDartString(); - - String getHex() => hex.toDartString(); - - String getKey() => txKey.toDartString(); -} class PendingTransactionDescription { PendingTransactionDescription({ diff --git a/cw_monero/lib/api/subaddress_list.dart b/cw_monero/lib/api/subaddress_list.dart index 1c1f1253f..57edea76e 100644 --- a/cw_monero/lib/api/subaddress_list.dart +++ b/cw_monero/lib/api/subaddress_list.dart @@ -1,38 +1,23 @@ -import 'dart:ffi'; -import 'package:ffi/ffi.dart'; -import 'package:flutter/foundation.dart'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/types.dart'; -import 'package:cw_monero/api/monero_api.dart'; -import 'package:cw_monero/api/structs/subaddress_row.dart'; + +import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/wallet.dart'; - -final subaddressSizeNative = moneroApi - .lookup>('subaddrress_size') - .asFunction(); - -final subaddressRefreshNative = moneroApi - .lookup>('subaddress_refresh') - .asFunction(); - -final subaddrressGetAllNative = moneroApi - .lookup>('subaddrress_get_all') - .asFunction(); - -final subaddrressAddNewNative = moneroApi - .lookup>('subaddress_add_row') - .asFunction(); - -final subaddrressSetLabelNative = moneroApi - .lookup>('subaddress_set_label') - .asFunction(); +import 'package:monero/monero.dart' as monero; bool isUpdating = false; +class SubaddressInfoMetadata { + SubaddressInfoMetadata({ + required this.accountIndex, + }); + int accountIndex; +} + +SubaddressInfoMetadata? subaddress = null; + void refreshSubaddresses({required int accountIndex}) { try { isUpdating = true; - subaddressRefreshNative(accountIndex); + subaddress = SubaddressInfoMetadata(accountIndex: accountIndex); isUpdating = false; } catch (e) { isUpdating = false; @@ -40,28 +25,39 @@ void refreshSubaddresses({required int accountIndex}) { } } -List getAllSubaddresses() { - final size = subaddressSizeNative(); - final subaddressAddressesPointer = subaddrressGetAllNative(); - final subaddressAddresses = subaddressAddressesPointer.asTypedList(size); +class Subaddress { + Subaddress({ + required this.addressIndex, + required this.accountIndex, + }); + String get address => monero.Wallet_address( + wptr!, + accountIndex: accountIndex, + addressIndex: addressIndex, + ); + final int addressIndex; + final int accountIndex; + String get label => monero.Wallet_getSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: addressIndex); +} - return subaddressAddresses - .map((addr) => Pointer.fromAddress(addr).ref) - .toList(); +List getAllSubaddresses() { + final size = monero.Wallet_numSubaddresses(wptr!, accountIndex: subaddress!.accountIndex); + return List.generate(size, (index) { + return Subaddress( + accountIndex: subaddress!.accountIndex, + addressIndex: index, + ); + }).reversed.toList(); } void addSubaddressSync({required int accountIndex, required String label}) { - final labelPointer = label.toNativeUtf8(); - subaddrressAddNewNative(accountIndex, labelPointer); - calloc.free(labelPointer); + monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex, label: label); + refreshSubaddresses(accountIndex: accountIndex); } void setLabelForSubaddressSync( {required int accountIndex, required int addressIndex, required String label}) { - final labelPointer = label.toNativeUtf8(); - - subaddrressSetLabelNative(accountIndex, addressIndex, labelPointer); - calloc.free(labelPointer); + monero.Wallet_setSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: addressIndex, label: label); } void _addSubaddress(Map args) { @@ -81,14 +77,13 @@ void _setLabelForSubaddress(Map args) { } Future addSubaddress({required int accountIndex, required String label}) async { - await compute, void>( - _addSubaddress, {'accountIndex': accountIndex, 'label': label}); - await store(); + _addSubaddress({'accountIndex': accountIndex, 'label': label}); + await store(); } Future setLabelForSubaddress( {required int accountIndex, required int addressIndex, required String label}) async { - await compute, void>(_setLabelForSubaddress, { + _setLabelForSubaddress({ 'accountIndex': accountIndex, 'addressIndex': addressIndex, 'label': label diff --git a/cw_monero/lib/api/transaction_history.dart b/cw_monero/lib/api/transaction_history.dart index 73c8de801..c349dd312 100644 --- a/cw_monero/lib/api/transaction_history.dart +++ b/cw_monero/lib/api/transaction_history.dart @@ -1,138 +1,102 @@ + import 'dart:ffi'; +import 'dart:isolate'; -import 'package:cw_monero/api/convert_utf8_to_string.dart'; +import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/creation_transaction_exception.dart'; -import 'package:cw_monero/api/monero_api.dart'; import 'package:cw_monero/api/monero_output.dart'; -import 'package:cw_monero/api/signatures.dart'; import 'package:cw_monero/api/structs/pending_transaction.dart'; -import 'package:cw_monero/api/structs/transaction_info_row.dart'; -import 'package:cw_monero/api/structs/ut8_box.dart'; -import 'package:cw_monero/api/types.dart'; import 'package:ffi/ffi.dart'; -import 'package:flutter/foundation.dart'; +import 'package:monero/monero.dart' as monero; +import 'package:monero/src/generated_bindings_monero.g.dart' as monero_gen; -final transactionsRefreshNative = moneroApi - .lookup>('transactions_refresh') - .asFunction(); - -final transactionsCountNative = moneroApi - .lookup>('transactions_count') - .asFunction(); - -final transactionsGetAllNative = moneroApi - .lookup>('transactions_get_all') - .asFunction(); - -final transactionCreateNative = moneroApi - .lookup>('transaction_create') - .asFunction(); - -final transactionCreateMultDestNative = moneroApi - .lookup>('transaction_create_mult_dest') - .asFunction(); - -final transactionCommitNative = moneroApi - .lookup>('transaction_commit') - .asFunction(); - -final getTxKeyNative = - moneroApi.lookup>('get_tx_key').asFunction(); - -final getTransactionNative = moneroApi - .lookup>('get_transaction') - .asFunction(); String getTxKey(String txId) { - final txIdPointer = txId.toNativeUtf8(); - final keyPointer = getTxKeyNative(txIdPointer); - - calloc.free(txIdPointer); - - if (keyPointer != null) { - return convertUTF8ToString(pointer: keyPointer); - } - - return ''; + return monero.Wallet_getTxKey(wptr!, txid: txId); } -void refreshTransactions() => transactionsRefreshNative(); +monero.TransactionHistory? txhistory; -int countOfTransactions() => transactionsCountNative(); - -List getAllTransactions() { - final size = transactionsCountNative(); - final transactionsPointer = transactionsGetAllNative(); - final transactionsAddresses = transactionsPointer.asTypedList(size); - - return transactionsAddresses - .map((addr) => Pointer.fromAddress(addr).ref) - .toList(); +void refreshTransactions() { + txhistory = monero.Wallet_history(wptr!); + monero.TransactionHistory_refresh(txhistory!); } -TransactionInfoRow getTransaction(String txId) { - final txIdPointer = txId.toNativeUtf8(); - return getTransactionNative(txIdPointer).ref; +int countOfTransactions() => monero.TransactionHistory_count(txhistory!); + +List getAllTransactions() { + final size = countOfTransactions(); + + return List.generate(size, (index) => Transaction(txInfo: monero.TransactionHistory_transaction(txhistory!, index: index))); } -PendingTransactionDescription createTransactionSync( +// TODO(mrcyjanek): ... +Transaction getTransaction(String txId) { + return Transaction(txInfo: monero.TransactionHistory_transactionById(txhistory!, txid: txId)); +} + +Future createTransactionSync( {required String address, required String paymentId, required int priorityRaw, String? amount, int accountIndex = 0, - List preferredInputs = const []}) { - final addressPointer = address.toNativeUtf8(); - final paymentIdPointer = paymentId.toNativeUtf8(); - final amountPointer = amount != null ? amount.toNativeUtf8() : nullptr; + List preferredInputs = const []}) async { - final int preferredInputsSize = preferredInputs.length; - final List> preferredInputsPointers = - preferredInputs.map((output) => output.toNativeUtf8()).toList(); - final Pointer> preferredInputsPointerPointer = calloc(preferredInputsSize); + final amt = amount == null ? 0 : monero.Wallet_amountFromString(amount); + + final address_ = address.toNativeUtf8(); + final paymentId_ = paymentId.toNativeUtf8(); + final preferredInputs_ = preferredInputs.join(monero.defaultSeparatorStr).toNativeUtf8(); - for (int i = 0; i < preferredInputsSize; i++) { - preferredInputsPointerPointer[i] = preferredInputsPointers[i]; - } + final waddr = wptr!.address; + final addraddr = address_.address; + final paymentIdAddr = paymentId_.address; + final preferredInputsAddr = preferredInputs_.address; + final spaddr = monero.defaultSeparator.address; + final pendingTx = Pointer.fromAddress(await Isolate.run(() { + final tx = monero_gen.MoneroC(DynamicLibrary.open(monero.libPath)).MONERO_Wallet_createTransaction( + Pointer.fromAddress(waddr), + Pointer.fromAddress(addraddr).cast(), + Pointer.fromAddress(paymentIdAddr).cast(), + amt, + 1, + priorityRaw, + accountIndex, + Pointer.fromAddress(preferredInputsAddr).cast(), + Pointer.fromAddress(spaddr), + ); + return tx.address; + })); + calloc.free(address_); + calloc.free(paymentId_); + calloc.free(preferredInputs_); + final String? error = (() { + final status = monero.PendingTransaction_status(pendingTx); + if (status == 0) { + return null; + } + return monero.PendingTransaction_errorString(pendingTx); + })(); - final errorMessagePointer = calloc(); - final pendingTransactionRawPointer = calloc(); - final created = transactionCreateNative( - addressPointer, - paymentIdPointer, - amountPointer, - priorityRaw, - accountIndex, - preferredInputsPointerPointer, - preferredInputsSize, - errorMessagePointer, - pendingTransactionRawPointer) != - 0; - - calloc.free(preferredInputsPointerPointer); - - preferredInputsPointers.forEach((element) => calloc.free(element)); - - calloc.free(addressPointer); - calloc.free(paymentIdPointer); - - if (amountPointer != nullptr) { - calloc.free(amountPointer); - } - - if (!created) { - final message = errorMessagePointer.ref.getValue(); - calloc.free(errorMessagePointer); + if (error != null) { + final message = error; throw CreationTransactionException(message: message); } + final rAmt = monero.PendingTransaction_amount(pendingTx); + final rFee = monero.PendingTransaction_fee(pendingTx); + final rHash = monero.PendingTransaction_txid(pendingTx, ''); + final rTxKey = rHash; + return PendingTransactionDescription( - amount: pendingTransactionRawPointer.ref.amount, - fee: pendingTransactionRawPointer.ref.fee, - hash: pendingTransactionRawPointer.ref.getHash(), - hex: pendingTransactionRawPointer.ref.getHex(), - txKey: pendingTransactionRawPointer.ref.getKey(), - pointerAddress: pendingTransactionRawPointer.address); + amount: rAmt, + fee: rFee, + hash: rHash, + hex: '', + txKey: rTxKey, + pointerAddress: pendingTx.address, + ); } PendingTransactionDescription createTransactionMultDestSync( @@ -141,84 +105,50 @@ PendingTransactionDescription createTransactionMultDestSync( required int priorityRaw, int accountIndex = 0, List preferredInputs = const []}) { - final int size = outputs.length; - final List> addressesPointers = - outputs.map((output) => output.address.toNativeUtf8()).toList(); - final Pointer> addressesPointerPointer = calloc(size); - final List> amountsPointers = - outputs.map((output) => output.amount.toNativeUtf8()).toList(); - final Pointer> amountsPointerPointer = calloc(size); - - for (int i = 0; i < size; i++) { - addressesPointerPointer[i] = addressesPointers[i]; - amountsPointerPointer[i] = amountsPointers[i]; + + final txptr = monero.Wallet_createTransactionMultDest( + wptr!, + dstAddr: outputs.map((e) => e.address).toList(), + isSweepAll: false, + amounts: outputs.map((e) => monero.Wallet_amountFromString(e.amount)).toList(), + mixinCount: 0, + pendingTransactionPriority: priorityRaw, + subaddr_account: accountIndex, + ); + if (monero.PendingTransaction_status(txptr) != 0) { + throw CreationTransactionException(message: monero.PendingTransaction_errorString(txptr)); } - - final int preferredInputsSize = preferredInputs.length; - final List> preferredInputsPointers = - preferredInputs.map((output) => output.toNativeUtf8()).toList(); - final Pointer> preferredInputsPointerPointer = calloc(preferredInputsSize); - - for (int i = 0; i < preferredInputsSize; i++) { - preferredInputsPointerPointer[i] = preferredInputsPointers[i]; - } - - final paymentIdPointer = paymentId.toNativeUtf8(); - final errorMessagePointer = calloc(); - final pendingTransactionRawPointer = calloc(); - final created = transactionCreateMultDestNative( - addressesPointerPointer, - paymentIdPointer, - amountsPointerPointer, - size, - priorityRaw, - accountIndex, - preferredInputsPointerPointer, - preferredInputsSize, - errorMessagePointer, - pendingTransactionRawPointer) != - 0; - - calloc.free(addressesPointerPointer); - calloc.free(amountsPointerPointer); - calloc.free(preferredInputsPointerPointer); - - addressesPointers.forEach((element) => calloc.free(element)); - amountsPointers.forEach((element) => calloc.free(element)); - preferredInputsPointers.forEach((element) => calloc.free(element)); - - calloc.free(paymentIdPointer); - - if (!created) { - final message = errorMessagePointer.ref.getValue(); - calloc.free(errorMessagePointer); - throw CreationTransactionException(message: message); - } - return PendingTransactionDescription( - amount: pendingTransactionRawPointer.ref.amount, - fee: pendingTransactionRawPointer.ref.fee, - hash: pendingTransactionRawPointer.ref.getHash(), - hex: pendingTransactionRawPointer.ref.getHex(), - txKey: pendingTransactionRawPointer.ref.getKey(), - pointerAddress: pendingTransactionRawPointer.address); + amount: monero.PendingTransaction_amount(txptr), + fee: monero.PendingTransaction_fee(txptr), + hash: monero.PendingTransaction_txid(txptr, ''), + hex: monero.PendingTransaction_txid(txptr, ''), + txKey: monero.PendingTransaction_txid(txptr, ''), + pointerAddress: txptr.address, + ); } void commitTransactionFromPointerAddress({required int address}) => - commitTransaction(transactionPointer: Pointer.fromAddress(address)); + commitTransaction(transactionPointer: monero.PendingTransaction.fromAddress(address)); -void commitTransaction({required Pointer transactionPointer}) { - final errorMessagePointer = calloc(); - final isCommited = transactionCommitNative(transactionPointer, errorMessagePointer) != 0; +void commitTransaction({required monero.PendingTransaction transactionPointer}) { + + final txCommit = monero.PendingTransaction_commit(transactionPointer, filename: '', overwrite: false); - if (!isCommited) { - final message = errorMessagePointer.ref.getValue(); - calloc.free(errorMessagePointer); - throw CreationTransactionException(message: message); + final String? error = (() { + final status = monero.PendingTransaction_status(transactionPointer.cast()); + if (status == 0) { + return null; + } + return monero.Wallet_errorString(wptr!); + })(); + + if (error != null) { + throw CreationTransactionException(message: error); } } -PendingTransactionDescription _createTransactionSync(Map args) { +Future _createTransactionSync(Map args) async { final address = args['address'] as String; final paymentId = args['paymentId'] as String; final amount = args['amount'] as String?; @@ -256,8 +186,8 @@ Future createTransaction( String? amount, String paymentId = '', int accountIndex = 0, - List preferredInputs = const []}) => - compute(_createTransactionSync, { + List preferredInputs = const []}) async => + _createTransactionSync({ 'address': address, 'paymentId': paymentId, 'amount': amount, @@ -271,11 +201,79 @@ Future createTransactionMultDest( required int priorityRaw, String paymentId = '', int accountIndex = 0, - List preferredInputs = const []}) => - compute(_createTransactionMultDestSync, { + List preferredInputs = const []}) async => + _createTransactionMultDestSync({ 'outputs': outputs, 'paymentId': paymentId, 'priorityRaw': priorityRaw, 'accountIndex': accountIndex, 'preferredInputs': preferredInputs }); + + +class Transaction { + final String displayLabel; + String subaddressLabel = monero.Wallet_getSubaddressLabel(wptr!, accountIndex: 0, addressIndex: 0); + late final String address = monero.Wallet_address( + wptr!, + accountIndex: 0, + addressIndex: 0, + ); + final String description; + final int fee; + final int confirmations; + late final bool isPending = confirmations < 10; + final int blockheight; + final int addressIndex = 0; + final int accountIndex; + final String paymentId; + final int amount; + final bool isSpend; + late DateTime timeStamp; + late final bool isConfirmed = !isPending; + final String hash; + final String key; + + Map toJson() { + return { + "displayLabel": displayLabel, + "subaddressLabel": subaddressLabel, + "address": address, + "description": description, + "fee": fee, + "confirmations": confirmations, + "isPending": isPending, + "blockheight": blockheight, + "accountIndex": accountIndex, + "addressIndex": addressIndex, + "paymentId": paymentId, + "amount": amount, + "isSpend": isSpend, + "timeStamp": timeStamp.toIso8601String(), + "isConfirmed": isConfirmed, + "hash": hash, + }; + } + + // S finalubAddress? subAddress; + // List transfers = []; + // final int txIndex; + final monero.TransactionInfo txInfo; + Transaction({ + required this.txInfo, + }) : displayLabel = monero.TransactionInfo_label(txInfo), + hash = monero.TransactionInfo_hash(txInfo), + timeStamp = DateTime.fromMillisecondsSinceEpoch( + monero.TransactionInfo_timestamp(txInfo) * 1000, + ), + isSpend = monero.TransactionInfo_direction(txInfo) == + monero.TransactionInfo_Direction.Out, + amount = monero.TransactionInfo_amount(txInfo), + paymentId = monero.TransactionInfo_paymentId(txInfo), + accountIndex = monero.TransactionInfo_subaddrAccount(txInfo), + blockheight = monero.TransactionInfo_blockHeight(txInfo), + confirmations = monero.TransactionInfo_confirmations(txInfo), + fee = monero.TransactionInfo_fee(txInfo), + description = monero.TransactionInfo_description(txInfo), + key = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo)); +} \ No newline at end of file diff --git a/cw_monero/lib/api/types.dart b/cw_monero/lib/api/types.dart deleted file mode 100644 index 40a1e0321..000000000 --- a/cw_monero/lib/api/types.dart +++ /dev/null @@ -1,153 +0,0 @@ -import 'dart:ffi'; -import 'package:cw_monero/api/structs/coins_info_row.dart'; -import 'package:cw_monero/api/structs/pending_transaction.dart'; -import 'package:cw_monero/api/structs/transaction_info_row.dart'; -import 'package:cw_monero/api/structs/ut8_box.dart'; -import 'package:ffi/ffi.dart'; - -typedef CreateWallet = int Function( - Pointer, Pointer, Pointer, int, Pointer); - -typedef RestoreWalletFromSeed = int Function( - Pointer, Pointer, Pointer, int, int, Pointer); - -typedef RestoreWalletFromKeys = int Function(Pointer, Pointer, - Pointer, Pointer, Pointer, Pointer, int, int, Pointer); - -typedef RestoreWalletFromSpendKey = int Function(Pointer, Pointer, Pointer, - Pointer, Pointer, int, int, Pointer); - -typedef IsWalletExist = int Function(Pointer); - -typedef LoadWallet = int Function(Pointer, Pointer, int); - -typedef ErrorString = Pointer Function(); - -typedef GetFilename = Pointer Function(); - -typedef GetSeed = Pointer Function(); - -typedef GetAddress = Pointer Function(int, int); - -typedef GetFullBalance = int Function(int); - -typedef GetUnlockedBalance = int Function(int); - -typedef GetCurrentHeight = int Function(); - -typedef GetNodeHeight = int Function(); - -typedef IsConnected = int Function(); - -typedef SetupNode = int Function( - Pointer, Pointer?, Pointer?, int, int, Pointer?, Pointer); - -typedef StartRefresh = void Function(); - -typedef ConnectToNode = int Function(); - -typedef SetRefreshFromBlockHeight = void Function(int); - -typedef SetRecoveringFromSeed = void Function(int); - -typedef Store = void Function(Pointer); - -typedef SetPassword = int Function(Pointer password, Pointer error); - -typedef SetListener = void Function(); - -typedef GetSyncingHeight = int Function(); - -typedef IsNeededToRefresh = int Function(); - -typedef IsNewTransactionExist = int Function(); - -typedef SubaddressSize = int Function(); - -typedef SubaddressRefresh = void Function(int); - -typedef SubaddressGetAll = Pointer Function(); - -typedef SubaddressAddNew = void Function(int accountIndex, Pointer label); - -typedef SubaddressSetLabel = void Function( - int accountIndex, int addressIndex, Pointer label); - -typedef AccountSize = int Function(); - -typedef AccountRefresh = void Function(); - -typedef AccountGetAll = Pointer Function(); - -typedef AccountAddNew = void Function(Pointer label); - -typedef AccountSetLabel = void Function(int accountIndex, Pointer label); - -typedef TransactionsRefresh = void Function(); - -typedef GetTransaction = Pointer Function(Pointer txId); - -typedef GetTxKey = Pointer? Function(Pointer txId); - -typedef TransactionsCount = int Function(); - -typedef TransactionsGetAll = Pointer Function(); - -typedef TransactionCreate = int Function( - Pointer address, - Pointer paymentId, - Pointer amount, - int priorityRaw, - int subaddrAccount, - Pointer> preferredInputs, - int preferredInputsSize, - Pointer error, - Pointer pendingTransaction); - -typedef TransactionCreateMultDest = int Function( - Pointer> addresses, - Pointer paymentId, - Pointer> amounts, - int size, - int priorityRaw, - int subaddrAccount, - Pointer> preferredInputs, - int preferredInputsSize, - Pointer error, - Pointer pendingTransaction); - -typedef TransactionCommit = int Function(Pointer, Pointer); - -typedef SecretViewKey = Pointer Function(); - -typedef PublicViewKey = Pointer Function(); - -typedef SecretSpendKey = Pointer Function(); - -typedef PublicSpendKey = Pointer Function(); - -typedef CloseCurrentWallet = void Function(); - -typedef OnStartup = void Function(); - -typedef RescanBlockchainAsync = void Function(); - -typedef GetSubaddressLabel = Pointer Function( - int accountIndex, - int addressIndex); - -typedef SetTrustedDaemon = void Function(int); - -typedef TrustedDaemon = int Function(); - -typedef RefreshCoins = void Function(int); - -typedef CoinsCount = int Function(); - -typedef GetCoin = Pointer Function(int); - -typedef FreezeCoin = void Function(int); - -typedef ThawCoin = void Function(int); - -typedef SignMessage = Pointer Function(Pointer, Pointer); diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index ffa5fe13b..9e37268ad 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -1,160 +1,53 @@ import 'dart:async'; -import 'dart:ffi'; -import 'package:ffi/ffi.dart'; -import 'package:cw_monero/api/structs/ut8_box.dart'; -import 'package:cw_monero/api/convert_utf8_to_string.dart'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/types.dart'; -import 'package:cw_monero/api/monero_api.dart'; + +import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart'; -import 'package:flutter/foundation.dart'; +import 'package:monero/monero.dart' as monero; -int _boolToInt(bool value) => value ? 1 : 0; +int getSyncingHeight() { + // final height = monero.MONERO_cw_WalletListener_height(getWlptr()); + final h2 = monero.Wallet_blockChainHeight(wptr!); + // print("height: $height / $h2"); + return h2; +} +bool isNeededToRefresh() { + final ret = monero.MONERO_cw_WalletListener_isNeedToRefresh(getWlptr()); + monero.MONERO_cw_WalletListener_resetNeedToRefresh(getWlptr()); + return ret; +} -final getFileNameNative = moneroApi - .lookup>('get_filename') - .asFunction(); +bool isNewTransactionExist() { + final ret = monero.MONERO_cw_WalletListener_isNewTransactionExist(getWlptr()); + monero.MONERO_cw_WalletListener_resetIsNewTransactionExist(getWlptr()); + return ret; +} +String getFilename() => monero.Wallet_filename(wptr!); -final getSeedNative = - moneroApi.lookup>('seed').asFunction(); +String getSeed() { + // monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); + final cakepolyseed = monero.Wallet_getCacheAttribute(wptr!, key: "cakewallet.seed"); + if (cakepolyseed != "") { + return cakepolyseed; + } + final polyseed = monero.Wallet_getPolyseed(wptr!, passphrase: ''); + if (polyseed != "") { + return polyseed; + } + final legacy = monero.Wallet_seed(wptr!, seedOffset: ''); + return legacy; +} -final getAddressNative = moneroApi - .lookup>('get_address') - .asFunction(); +String getAddress({int accountIndex = 0, int addressIndex = 1}) => monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex); -final getFullBalanceNative = moneroApi - .lookup>('get_full_balance') - .asFunction(); +int getFullBalance({int accountIndex = 0}) => monero.Wallet_balance(wptr!, accountIndex: accountIndex); -final getUnlockedBalanceNative = moneroApi - .lookup>('get_unlocked_balance') - .asFunction(); +int getUnlockedBalance({int accountIndex = 0}) => monero.Wallet_unlockedBalance(wptr!, accountIndex: accountIndex); -final getCurrentHeightNative = moneroApi - .lookup>('get_current_height') - .asFunction(); +int getCurrentHeight() => monero.Wallet_blockChainHeight(wptr!); -final getNodeHeightNative = moneroApi - .lookup>('get_node_height') - .asFunction(); +int getNodeHeightSync() => monero.Wallet_daemonBlockChainHeight(wptr!); -final isConnectedNative = moneroApi - .lookup>('is_connected') - .asFunction(); - -final setupNodeNative = moneroApi - .lookup>('setup_node') - .asFunction(); - -final startRefreshNative = moneroApi - .lookup>('start_refresh') - .asFunction(); - -final connecToNodeNative = moneroApi - .lookup>('connect_to_node') - .asFunction(); - -final setRefreshFromBlockHeightNative = moneroApi - .lookup>( - 'set_refresh_from_block_height') - .asFunction(); - -final setRecoveringFromSeedNative = moneroApi - .lookup>( - 'set_recovering_from_seed') - .asFunction(); - -final storeNative = - moneroApi.lookup>('store').asFunction(); - -final setPasswordNative = - moneroApi.lookup>('set_password').asFunction(); - -final setListenerNative = moneroApi - .lookup>('set_listener') - .asFunction(); - -final getSyncingHeightNative = moneroApi - .lookup>('get_syncing_height') - .asFunction(); - -final isNeededToRefreshNative = moneroApi - .lookup>('is_needed_to_refresh') - .asFunction(); - -final isNewTransactionExistNative = moneroApi - .lookup>( - 'is_new_transaction_exist') - .asFunction(); - -final getSecretViewKeyNative = moneroApi - .lookup>('secret_view_key') - .asFunction(); - -final getPublicViewKeyNative = moneroApi - .lookup>('public_view_key') - .asFunction(); - -final getSecretSpendKeyNative = moneroApi - .lookup>('secret_spend_key') - .asFunction(); - -final getPublicSpendKeyNative = moneroApi - .lookup>('public_spend_key') - .asFunction(); - -final closeCurrentWalletNative = moneroApi - .lookup>('close_current_wallet') - .asFunction(); - -final onStartupNative = moneroApi - .lookup>('on_startup') - .asFunction(); - -final rescanBlockchainAsyncNative = moneroApi - .lookup>('rescan_blockchain') - .asFunction(); - -final getSubaddressLabelNative = moneroApi - .lookup>('get_subaddress_label') - .asFunction(); - -final setTrustedDaemonNative = moneroApi - .lookup>('set_trusted_daemon') - .asFunction(); - -final trustedDaemonNative = moneroApi - .lookup>('trusted_daemon') - .asFunction(); - -final signMessageNative = moneroApi - .lookup>('sign_message') - .asFunction(); - -int getSyncingHeight() => getSyncingHeightNative(); - -bool isNeededToRefresh() => isNeededToRefreshNative() != 0; - -bool isNewTransactionExist() => isNewTransactionExistNative() != 0; - -String getFilename() => convertUTF8ToString(pointer: getFileNameNative()); - -String getSeed() => convertUTF8ToString(pointer: getSeedNative()); - -String getAddress({int accountIndex = 0, int addressIndex = 0}) => - convertUTF8ToString(pointer: getAddressNative(accountIndex, addressIndex)); - -int getFullBalance({int accountIndex = 0}) => - getFullBalanceNative(accountIndex); - -int getUnlockedBalance({int accountIndex = 0}) => - getUnlockedBalanceNative(accountIndex); - -int getCurrentHeight() => getCurrentHeightNative(); - -int getNodeHeightSync() => getNodeHeightNative(); - -bool isConnectedSync() => isConnectedNative() != 0; +bool isConnectedSync() => monero.Wallet_connected(wptr!) != 0; bool setupNodeSync( {required String address, @@ -163,96 +56,75 @@ bool setupNodeSync( bool useSSL = false, bool isLightWallet = false, String? socksProxyAddress}) { - final addressPointer = address.toNativeUtf8(); - Pointer? loginPointer; - Pointer? socksProxyAddressPointer; - Pointer? passwordPointer; + print(''' +{ + wptr!, + daemonAddress: $address, + useSsl: $useSSL, + proxyAddress: $socksProxyAddress ?? '', + daemonUsername: $login ?? '', + daemonPassword: $password ?? '' +} +'''); + monero.Wallet_init( + wptr!, + daemonAddress: address, + useSsl: useSSL, + proxyAddress: socksProxyAddress ?? '', + daemonUsername: login ?? '', + daemonPassword: password ?? '' + ); + // monero.Wallet_init3(wptr!, argv0: '', defaultLogBaseName: 'moneroc', console: true); + + final status = monero.Wallet_status(wptr!); - if (login != null) { - loginPointer = login.toNativeUtf8(); + if (status != 0) { + final error = monero.Wallet_errorString(wptr!); + print("error: $error"); + throw SetupWalletException(message: error); } - if (password != null) { - passwordPointer = password.toNativeUtf8(); - } - - if (socksProxyAddress != null) { - socksProxyAddressPointer = socksProxyAddress.toNativeUtf8(); - } - - final errorMessagePointer = ''.toNativeUtf8(); - final isSetupNode = setupNodeNative( - addressPointer, - loginPointer, - passwordPointer, - _boolToInt(useSSL), - _boolToInt(isLightWallet), - socksProxyAddressPointer, - errorMessagePointer) != - 0; - - calloc.free(addressPointer); - - if (loginPointer != null) { - calloc.free(loginPointer); - } - - if (passwordPointer != null) { - calloc.free(passwordPointer); - } - - if (!isSetupNode) { - throw SetupWalletException( - message: convertUTF8ToString(pointer: errorMessagePointer)); - } - - return isSetupNode; + return status == 0; } -void startRefreshSync() => startRefreshNative(); +void startRefreshSync() { + monero.Wallet_refreshAsync(wptr!); + monero.Wallet_startRefresh(wptr!); +} -Future connectToNode() async => connecToNodeNative() != 0; +Future connectToNode() async { + return true; +} -void setRefreshFromBlockHeight({required int height}) => - setRefreshFromBlockHeightNative(height); +void setRefreshFromBlockHeight({required int height}) => monero.Wallet_setRefreshFromBlockHeight(wptr!, refresh_from_block_height: height); -void setRecoveringFromSeed({required bool isRecovery}) => - setRecoveringFromSeedNative(_boolToInt(isRecovery)); +void setRecoveringFromSeed({required bool isRecovery}) => monero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery); void storeSync() { - final pathPointer = ''.toNativeUtf8(); - storeNative(pathPointer); - calloc.free(pathPointer); + monero.Wallet_store(wptr!); } void setPasswordSync(String password) { - final passwordPointer = password.toNativeUtf8(); - final errorMessagePointer = calloc(); - final changed = setPasswordNative(passwordPointer, errorMessagePointer) != 0; - calloc.free(passwordPointer); - - if (!changed) { - final message = errorMessagePointer.ref.getValue(); - calloc.free(errorMessagePointer); - throw Exception(message); - } + monero.Wallet_setPassword(wptr!, password: password); - calloc.free(errorMessagePointer); + + final status = monero.Wallet_status(wptr!); + if (status == 0) { + throw Exception(monero.Wallet_errorString(wptr!)); + } } -void closeCurrentWallet() => closeCurrentWalletNative(); +void closeCurrentWallet() { + monero.Wallet_stop(wptr!); +} -String getSecretViewKey() => - convertUTF8ToString(pointer: getSecretViewKeyNative()); +String getSecretViewKey() => monero.Wallet_secretViewKey(wptr!); -String getPublicViewKey() => - convertUTF8ToString(pointer: getPublicViewKeyNative()); +String getPublicViewKey() => monero.Wallet_publicViewKey(wptr!); -String getSecretSpendKey() => - convertUTF8ToString(pointer: getSecretSpendKeyNative()); +String getSecretSpendKey() => monero.Wallet_secretSpendKey(wptr!); -String getPublicSpendKey() => - convertUTF8ToString(pointer: getPublicSpendKeyNative()); +String getPublicSpendKey() => monero.Wallet_publicSpendKey(wptr!); class SyncListener { SyncListener(this.onNewBlock, this.onNewTransaction) @@ -324,11 +196,11 @@ class SyncListener { SyncListener setListeners(void Function(int, int, double) onNewBlock, void Function() onNewTransaction) { final listener = SyncListener(onNewBlock, onNewTransaction); - setListenerNative(); + // setListenerNative(); return listener; } -void onStartup() => onStartupNative(); +void onStartup() {} void _storeSync(Object _) => storeSync(); @@ -361,8 +233,8 @@ Future setupNode( String? password, bool useSSL = false, String? socksProxyAddress, - bool isLightWallet = false}) => - compute, void>(_setupNodeSync, { + bool isLightWallet = false}) async => + _setupNodeSync({ 'address': address, 'login': login , 'password': password, @@ -371,29 +243,22 @@ Future setupNode( 'socksProxyAddress': socksProxyAddress }); -Future store() => compute(_storeSync, 0); +Future store() async => _storeSync(0); -Future isConnected() => compute(_isConnected, 0); +Future isConnected() async => _isConnected(0); -Future getNodeHeight() => compute(_getNodeHeight, 0); +Future getNodeHeight() async => _getNodeHeight(0); -void rescanBlockchainAsync() => rescanBlockchainAsyncNative(); +void rescanBlockchainAsync() => monero.Wallet_rescanBlockchainAsync(wptr!); String getSubaddressLabel(int accountIndex, int addressIndex) { - return convertUTF8ToString(pointer: getSubaddressLabelNative(accountIndex, addressIndex)); + return monero.Wallet_getSubaddressLabel(wptr!, accountIndex: accountIndex, addressIndex: addressIndex); } -Future setTrustedDaemon(bool trusted) async => setTrustedDaemonNative(_boolToInt(trusted)); +Future setTrustedDaemon(bool trusted) async => monero.Wallet_setTrustedDaemon(wptr!, arg: trusted); -Future trustedDaemon() async => trustedDaemonNative() != 0; +Future trustedDaemon() async => monero.Wallet_trustedDaemon(wptr!); String signMessage(String message, {String address = ""}) { - final messagePointer = message.toNativeUtf8(); - final addressPointer = address.toNativeUtf8(); - - final signature = convertUTF8ToString(pointer: signMessageNative(messagePointer, addressPointer)); - calloc.free(messagePointer); - calloc.free(addressPointer); - - return signature; + return monero.Wallet_signMessage(wptr!, message: message, address: address); } diff --git a/cw_monero/lib/api/wallet_manager.dart b/cw_monero/lib/api/wallet_manager.dart index 0aa694e9a..e441d7406 100644 --- a/cw_monero/lib/api/wallet_manager.dart +++ b/cw_monero/lib/api/wallet_manager.dart @@ -1,80 +1,45 @@ + import 'dart:ffi'; -import 'package:cw_monero/api/convert_utf8_to_string.dart'; +import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_restore_from_keys_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_restore_from_seed_exception.dart'; -import 'package:cw_monero/api/monero_api.dart'; -import 'package:cw_monero/api/signatures.dart'; -import 'package:cw_monero/api/types.dart'; import 'package:cw_monero/api/wallet.dart'; -import 'package:ffi/ffi.dart'; -import 'package:flutter/foundation.dart'; +import 'package:monero/monero.dart' as monero; -final createWalletNative = moneroApi - .lookup>('create_wallet') - .asFunction(); - -final restoreWalletFromSeedNative = moneroApi - .lookup>( - 'restore_wallet_from_seed') - .asFunction(); - -final restoreWalletFromKeysNative = moneroApi - .lookup>( - 'restore_wallet_from_keys') - .asFunction(); - -final restoreWalletFromSpendKeyNative = moneroApi - .lookup>( - 'restore_wallet_from_spend_key') - .asFunction(); - -final isWalletExistNative = moneroApi - .lookup>('is_wallet_exist') - .asFunction(); - -final loadWalletNative = moneroApi - .lookup>('load_wallet') - .asFunction(); - -final errorStringNative = moneroApi - .lookup>('error_string') - .asFunction(); +monero.WalletManager? _wmPtr; +final monero.WalletManager wmPtr = Pointer.fromAddress((() { + try { + monero.printStarts = true; + _wmPtr ??= monero.WalletManagerFactory_getWalletManager(); + print("ptr: $_wmPtr"); + } catch (e) { + print(e); + } + return _wmPtr!.address; +})()); void createWalletSync( {required String path, required String password, required String language, int nettype = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final languagePointer = language.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - final isWalletCreated = createWalletNative(pathPointer, passwordPointer, - languagePointer, nettype, errorMessagePointer) != - 0; + wptr = monero.WalletManager_createWallet(wmPtr, path: path, password: password, language: language, networkType: 0); - calloc.free(pathPointer); - calloc.free(passwordPointer); - calloc.free(languagePointer); - - if (!isWalletCreated) { - throw WalletCreationException( - message: convertUTF8ToString(pointer: errorMessagePointer)); + final status = monero.Wallet_status(wptr!); + if (status != 0) { + throw WalletCreationException(message: monero.Wallet_errorString(wptr!)); } + monero.Wallet_store(wptr!, path: path); + // is the line below needed? // setupNodeSync(address: "node.moneroworld.com:18089"); } bool isWalletExistSync({required String path}) { - final pathPointer = path.toNativeUtf8(); - final isExist = isWalletExistNative(pathPointer) != 0; - - calloc.free(pathPointer); - - return isExist; + return monero.WalletManager_walletExists(wmPtr, path); } void restoreWalletFromSeedSync( @@ -83,26 +48,22 @@ void restoreWalletFromSeedSync( required String seed, int nettype = 0, int restoreHeight = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final seedPointer = seed.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - final isWalletRestored = restoreWalletFromSeedNative( - pathPointer, - passwordPointer, - seedPointer, - nettype, - restoreHeight, - errorMessagePointer) != - 0; - calloc.free(pathPointer); - calloc.free(passwordPointer); - calloc.free(seedPointer); + wptr = monero.WalletManager_recoveryWallet( + wmPtr, + path: path, + password: password, + mnemonic: seed, + restoreHeight: restoreHeight, + seedOffset: '', + networkType: 0, + ); + + final status = monero.Wallet_status(wptr!); - if (!isWalletRestored) { - throw WalletRestoreFromSeedException( - message: convertUTF8ToString(pointer: errorMessagePointer)); + if (status != 0) { + final error = monero.Wallet_errorString(wptr!); + throw WalletRestoreFromSeedException(message: error); } } @@ -115,35 +76,21 @@ void restoreWalletFromKeysSync( required String spendKey, int nettype = 0, int restoreHeight = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final languagePointer = language.toNativeUtf8(); - final addressPointer = address.toNativeUtf8(); - final viewKeyPointer = viewKey.toNativeUtf8(); - final spendKeyPointer = spendKey.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - final isWalletRestored = restoreWalletFromKeysNative( - pathPointer, - passwordPointer, - languagePointer, - addressPointer, - viewKeyPointer, - spendKeyPointer, - nettype, - restoreHeight, - errorMessagePointer) != - 0; - calloc.free(pathPointer); - calloc.free(passwordPointer); - calloc.free(languagePointer); - calloc.free(addressPointer); - calloc.free(viewKeyPointer); - calloc.free(spendKeyPointer); - - if (!isWalletRestored) { - throw WalletRestoreFromKeysException( - message: convertUTF8ToString(pointer: errorMessagePointer)); + wptr = monero.WalletManager_createWalletFromKeys( + wmPtr, + path: path, + password: password, + restoreHeight: restoreHeight, + addressString: address, + viewKeyString: viewKey, + spendKeyString: spendKey, + nettype: 0, + ); + + final status = monero.Wallet_status(wptr!); + if (status != 0) { + throw WalletRestoreFromKeysException(message: monero.Wallet_errorString(wptr!)); } } @@ -155,49 +102,63 @@ void restoreWalletFromSpendKeySync( required String spendKey, int nettype = 0, int restoreHeight = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final seedPointer = seed.toNativeUtf8(); - final languagePointer = language.toNativeUtf8(); - final spendKeyPointer = spendKey.toNativeUtf8(); - final errorMessagePointer = ''.toNativeUtf8(); - final isWalletRestored = restoreWalletFromSpendKeyNative( - pathPointer, - passwordPointer, - seedPointer, - languagePointer, - spendKeyPointer, - nettype, - restoreHeight, - errorMessagePointer) != - 0; - calloc.free(pathPointer); - calloc.free(passwordPointer); - calloc.free(languagePointer); - calloc.free(spendKeyPointer); + // wptr = monero.WalletManager_createWalletFromKeys( + // wmPtr, + // path: path, + // password: password, + // restoreHeight: restoreHeight, + // addressString: '', + // spendKeyString: spendKey, + // viewKeyString: '', + // nettype: 0, + // ); + + wptr = monero.WalletManager_createDeterministicWalletFromSpendKey( + wmPtr, + path: path, + password: password, + language: language, + spendKeyString: spendKey, + newWallet: true, // TODO(mrcyjanek): safe to remove + restoreHeight: restoreHeight, + ); + + final status = monero.Wallet_status(wptr!); + + if (status != 0) { + final err = monero.Wallet_errorString(wptr!); + print("err: $err"); + throw WalletRestoreFromKeysException(message: err); + } + + monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); storeSync(); - - if (!isWalletRestored) { - throw WalletRestoreFromKeysException( - message: convertUTF8ToString(pointer: errorMessagePointer)); - } } +String _lastOpenedWallet = ""; + void loadWallet({ required String path, required String password, int nettype = 0}) { - final pathPointer = path.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - final loaded = loadWalletNative(pathPointer, passwordPointer, nettype) != 0; - calloc.free(pathPointer); - calloc.free(passwordPointer); - - if (!loaded) { - throw WalletOpeningException( - message: convertUTF8ToString(pointer: errorStringNative())); + try { + if (wptr == null || path != _lastOpenedWallet) { + if (wptr != null) { + monero.Wallet_store(wptr!); + } + wptr = monero.WalletManager_openWallet(wmPtr, path: path, password: password); + _lastOpenedWallet = path; + } + } catch (e) { + print(e); + } + final status = monero.Wallet_status(wptr!); + if (status != 0) { + final err = monero.Wallet_errorString(wptr!); + print(err); + throw WalletOpeningException(message: err); } } @@ -258,20 +219,20 @@ void _restoreFromSpendKey(Map args) { Future _openWallet(Map args) async => loadWallet(path: args['path'] as String, password: args['password'] as String); -bool _isWalletExist(String path) => isWalletExistSync(path: path); +Future _isWalletExist(String path) async => isWalletExistSync(path: path); void openWallet({required String path, required String password, int nettype = 0}) async => loadWallet(path: path, password: password, nettype: nettype); Future openWalletAsync(Map args) async => - compute(_openWallet, args); + _openWallet(args); Future createWallet( {required String path, required String password, required String language, int nettype = 0}) async => - compute(_createWallet, { + _createWallet({ 'path': path, 'password': password, 'language': language, @@ -284,7 +245,7 @@ Future restoreFromSeed( required String seed, int nettype = 0, int restoreHeight = 0}) async => - compute, void>(_restoreFromSeed, { + _restoreFromSeed({ 'path': path, 'password': password, 'seed': seed, @@ -301,7 +262,7 @@ Future restoreFromKeys( required String spendKey, int nettype = 0, int restoreHeight = 0}) async => - compute, void>(_restoreFromKeys, { + _restoreFromKeys({ 'path': path, 'password': password, 'language': language, @@ -320,7 +281,7 @@ Future restoreFromSpendKey( required String spendKey, int nettype = 0, int restoreHeight = 0}) async => - compute, void>(_restoreFromSpendKey, { + _restoreFromSpendKey({ 'path': path, 'password': password, 'seed': seed, @@ -330,4 +291,4 @@ Future restoreFromSpendKey( 'restoreHeight': restoreHeight }); -Future isWalletExist({required String path}) => compute(_isWalletExist, path); +Future isWalletExist({required String path}) => _isWalletExist(path); diff --git a/cw_monero/lib/monero_account_list.dart b/cw_monero/lib/monero_account_list.dart index 2fd11b3ba..29d096efd 100644 --- a/cw_monero/lib/monero_account_list.dart +++ b/cw_monero/lib/monero_account_list.dart @@ -2,7 +2,7 @@ import 'package:cw_core/monero_amount_format.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/account.dart'; import 'package:cw_monero/api/account_list.dart' as account_list; -import 'package:cw_monero/api/wallet.dart' as monero_wallet; +import 'package:monero/monero.dart' as monero; part 'monero_account_list.g.dart'; @@ -44,13 +44,12 @@ abstract class MoneroAccountListBase with Store { } List getAll() => account_list.getAllAccount().map((accountRow) { - final accountIndex = accountRow.getId(); - final balance = monero_wallet.getFullBalance(accountIndex: accountIndex); + final balance = monero.SubaddressAccountRow_getUnlockedBalance(accountRow); return Account( - id: accountRow.getId(), - label: accountRow.getLabel(), - balance: moneroAmountToString(amount: balance), + id: monero.SubaddressAccountRow_getRowId(accountRow), + label: monero.SubaddressAccountRow_getLabel(accountRow), + balance: moneroAmountToString(amount: monero.Wallet_amountFromString(balance)), ); }).toList(); diff --git a/cw_monero/lib/monero_subaddress_list.dart b/cw_monero/lib/monero_subaddress_list.dart index dbd1a89ae..676a9536c 100644 --- a/cw_monero/lib/monero_subaddress_list.dart +++ b/cw_monero/lib/monero_subaddress_list.dart @@ -1,8 +1,8 @@ -import 'package:flutter/services.dart'; -import 'package:mobx/mobx.dart'; +import 'package:cw_core/subaddress.dart'; import 'package:cw_monero/api/coins_info.dart'; import 'package:cw_monero/api/subaddress_list.dart' as subaddress_list; -import 'package:cw_core/subaddress.dart'; +import 'package:flutter/services.dart'; +import 'package:mobx/mobx.dart'; part 'monero_subaddress_list.g.dart'; @@ -50,19 +50,22 @@ abstract class MoneroSubaddressListBase with Store { subaddresses = [primary] + rest.toList(); } - return subaddresses.map((subaddressRow) { + return subaddresses.map((s) { + final address = s.address; + final label = s.label; + final id = s.addressIndex; final hasDefaultAddressName = - subaddressRow.getLabel().toLowerCase() == 'Primary account'.toLowerCase() || - subaddressRow.getLabel().toLowerCase() == 'Untitled account'.toLowerCase(); - final isPrimaryAddress = subaddressRow.getId() == 0 && hasDefaultAddressName; + label.toLowerCase() == 'Primary account'.toLowerCase() || + label.toLowerCase() == 'Untitled account'.toLowerCase(); + final isPrimaryAddress = id == 0 && hasDefaultAddressName; return Subaddress( - id: subaddressRow.getId(), - address: subaddressRow.getAddress(), + id: id, + address: address, label: isPrimaryAddress ? 'Primary address' : hasDefaultAddressName ? '' - : subaddressRow.getLabel()); + : label); }).toList(); } @@ -121,8 +124,8 @@ abstract class MoneroSubaddressListBase with Store { Future> _getAllUnusedAddresses( {required int accountIndex, required String label}) async { final allAddresses = subaddress_list.getAllSubaddresses(); - - if (allAddresses.isEmpty || _usedAddresses.contains(allAddresses.last.getAddress())) { + final lastAddress = allAddresses.last.address; + if (allAddresses.isEmpty || _usedAddresses.contains(lastAddress)) { final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label); if (!isAddressUnused) { return await _getAllUnusedAddresses(accountIndex: accountIndex, label: label); @@ -130,13 +133,18 @@ abstract class MoneroSubaddressListBase with Store { } return allAddresses - .map((subaddressRow) => Subaddress( - id: subaddressRow.getId(), - address: subaddressRow.getAddress(), - label: subaddressRow.getId() == 0 && - subaddressRow.getLabel().toLowerCase() == 'Primary account'.toLowerCase() + .map((s) { + final id = s.addressIndex; + final address = s.address; + final label = s.label; + return Subaddress( + id: id, + address: address, + label: id == 0 && + label.toLowerCase() == 'Primary account'.toLowerCase() ? 'Primary address' - : subaddressRow.getLabel())) + : label); + }) .toList(); } @@ -145,7 +153,10 @@ abstract class MoneroSubaddressListBase with Store { return subaddress_list .getAllSubaddresses() - .where((subaddressRow) => !_usedAddresses.contains(subaddressRow.getAddress())) + .where((s) { + final address = s.address; + return !_usedAddresses.contains(address); + }) .isNotEmpty; } } diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index d00a54c8f..86c18d470 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -12,6 +12,7 @@ import 'package:cw_core/node.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/sync_status.dart'; +import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/wallet_base.dart'; @@ -32,6 +33,7 @@ import 'package:cw_monero/pending_monero_transaction.dart'; import 'package:flutter/foundation.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; +import 'package:monero/monero.dart' as monero; part 'monero_wallet.g.dart'; @@ -417,10 +419,18 @@ abstract class MoneroWalletBase final coinCount = countOfCoins(); for (var i = 0; i < coinCount; i++) { final coin = getCoin(i); - if (coin.spent == 0) { - final unspent = MoneroUnspent.fromCoinsInfoRow(coin); + final coinSpent = monero.CoinsInfo_spent(coin); + if (coinSpent == 0) { + final unspent = MoneroUnspent( + monero.CoinsInfo_address(coin), + monero.CoinsInfo_hash(coin), + monero.CoinsInfo_keyImage(coin), + monero.CoinsInfo_amount(coin), + monero.CoinsInfo_frozen(coin), + monero.CoinsInfo_unlocked(coin), + ); if (unspent.hash.isNotEmpty) { - unspent.isChange = transaction_history.getTransaction(unspent.hash).direction == 1; + unspent.isChange = transaction_history.getTransaction(unspent.hash) == 1; } unspentCoins.add(unspent); } @@ -541,7 +551,24 @@ abstract class MoneroWalletBase List _getAllTransactionsOfAccount(int? accountIndex) => transaction_history .getAllTransactions() - .map((row) => MoneroTransactionInfo.fromRow(row)) + .map((row) => MoneroTransactionInfo( + row.hash, + row.blockheight, + row.isSpend ? TransactionDirection.outgoing : TransactionDirection.incoming, + row.timeStamp, + row.isPending, + row.amount, + row.accountIndex, + 0, + row.fee, + row.confirmations, + + )..additionalInfo = { + 'key': row.key, + 'accountIndex': row.accountIndex, + 'addressIndex': row.addressIndex + }, + ) .where((element) => element.accountIndex == (accountIndex ?? 0)) .toList(); diff --git a/cw_monero/macos/Classes/CwMoneroPlugin.swift b/cw_monero/macos/Classes/CwMoneroPlugin.swift deleted file mode 100644 index d4ff81e1c..000000000 --- a/cw_monero/macos/Classes/CwMoneroPlugin.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Cocoa -import FlutterMacOS - -public class CwMoneroPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "cw_monero", binaryMessenger: registrar.messenger) - let instance = CwMoneroPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - switch call.method { - case "getPlatformVersion": - result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) - default: - result(FlutterMethodNotImplemented) - } - } -} diff --git a/cw_monero/macos/Classes/CwWalletListener.h b/cw_monero/macos/Classes/CwWalletListener.h deleted file mode 100644 index cbfcb0c4e..000000000 --- a/cw_monero/macos/Classes/CwWalletListener.h +++ /dev/null @@ -1,23 +0,0 @@ -#include - -struct CWMoneroWalletListener; - -typedef int8_t (*on_new_block_callback)(uint64_t height); -typedef int8_t (*on_need_to_refresh_callback)(); - -typedef struct CWMoneroWalletListener -{ - // on_money_spent_callback *on_money_spent; - // on_money_received_callback *on_money_received; - // on_unconfirmed_money_received_callback *on_unconfirmed_money_received; - // on_new_block_callback *on_new_block; - // on_updated_callback *on_updated; - // on_refreshed_callback *on_refreshed; - - on_new_block_callback on_new_block; -} CWMoneroWalletListener; - -struct TestListener { - // int8_t x; - on_new_block_callback on_new_block; -}; \ No newline at end of file diff --git a/cw_monero/macos/Classes/monero_api.cpp b/cw_monero/macos/Classes/monero_api.cpp deleted file mode 100644 index fe75dea98..000000000 --- a/cw_monero/macos/Classes/monero_api.cpp +++ /dev/null @@ -1,1032 +0,0 @@ -#include -#include "cstdlib" -#include -#include -#include -#include -#include -#include -#include -#include "thread" -#include "CwWalletListener.h" -#if __APPLE__ -// Fix for randomx on ios -void __clear_cache(void* start, void* end) { } -#include "../External/macos/include/wallet2_api.h" -#else -#include "../External/android/include/wallet2_api.h" -#endif - -using namespace std::chrono_literals; -#ifdef __cplusplus -extern "C" -{ -#endif - const uint64_t MONERO_BLOCK_SIZE = 1000; - - struct Utf8Box - { - char *value; - - Utf8Box(char *_value) - { - value = _value; - } - }; - - struct SubaddressRow - { - uint64_t id; - char *address; - char *label; - - SubaddressRow(std::size_t _id, char *_address, char *_label) - { - id = static_cast(_id); - address = _address; - label = _label; - } - }; - - struct AccountRow - { - uint64_t id; - char *label; - - AccountRow(std::size_t _id, char *_label) - { - id = static_cast(_id); - label = _label; - } - }; - - struct MoneroWalletListener : Monero::WalletListener - { - uint64_t m_height; - bool m_need_to_refresh; - bool m_new_transaction; - - MoneroWalletListener() - { - m_height = 0; - m_need_to_refresh = false; - m_new_transaction = false; - } - - void moneySpent(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void moneyReceived(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) - { - m_new_transaction = true; - } - - void newBlock(uint64_t height) - { - m_height = height; - } - - void updated() - { - m_new_transaction = true; - } - - void refreshed() - { - m_need_to_refresh = true; - } - - void resetNeedToRefresh() - { - m_need_to_refresh = false; - } - - bool isNeedToRefresh() - { - return m_need_to_refresh; - } - - bool isNewTransactionExist() - { - return m_new_transaction; - } - - void resetIsNewTransactionExist() - { - m_new_transaction = false; - } - - uint64_t height() - { - return m_height; - } - }; - - struct TransactionInfoRow - { - uint64_t amount; - uint64_t fee; - uint64_t blockHeight; - uint64_t confirmations; - uint32_t subaddrAccount; - int8_t direction; - int8_t isPending; - uint32_t subaddrIndex; - - char *hash; - char *paymentId; - - int64_t datetime; - - TransactionInfoRow(Monero::TransactionInfo *transaction) - { - amount = transaction->amount(); - fee = transaction->fee(); - blockHeight = transaction->blockHeight(); - subaddrAccount = transaction->subaddrAccount(); - std::set::iterator it = transaction->subaddrIndex().begin(); - subaddrIndex = *it; - confirmations = transaction->confirmations(); - datetime = static_cast(transaction->timestamp()); - direction = transaction->direction(); - isPending = static_cast(transaction->isPending()); - std::string *hash_str = new std::string(transaction->hash()); - hash = strdup(hash_str->c_str()); - paymentId = strdup(transaction->paymentId().c_str()); - } - }; - - struct PendingTransactionRaw - { - uint64_t amount; - uint64_t fee; - char *hash; - char *hex; - char *txKey; - Monero::PendingTransaction *transaction; - - PendingTransactionRaw(Monero::PendingTransaction *_transaction) - { - transaction = _transaction; - amount = _transaction->amount(); - fee = _transaction->fee(); - hash = strdup(_transaction->txid()[0].c_str()); - hex = strdup(_transaction->hex()[0].c_str()); - txKey = strdup(_transaction->txKey()[0].c_str()); - } - }; - - struct CoinsInfoRow - { - uint64_t blockHeight; - char *hash; - uint64_t internalOutputIndex; - uint64_t globalOutputIndex; - bool spent; - bool frozen; - uint64_t spentHeight; - uint64_t amount; - bool rct; - bool keyImageKnown; - uint64_t pkIndex; - uint32_t subaddrIndex; - uint32_t subaddrAccount; - char *address; - char *addressLabel; - char *keyImage; - uint64_t unlockTime; - bool unlocked; - char *pubKey; - bool coinbase; - char *description; - - CoinsInfoRow(Monero::CoinsInfo *coinsInfo) - { - blockHeight = coinsInfo->blockHeight(); - std::string *hash_str = new std::string(coinsInfo->hash()); - hash = strdup(hash_str->c_str()); - internalOutputIndex = coinsInfo->internalOutputIndex(); - globalOutputIndex = coinsInfo->globalOutputIndex(); - spent = coinsInfo->spent(); - frozen = coinsInfo->frozen(); - spentHeight = coinsInfo->spentHeight(); - amount = coinsInfo->amount(); - rct = coinsInfo->rct(); - keyImageKnown = coinsInfo->keyImageKnown(); - pkIndex = coinsInfo->pkIndex(); - subaddrIndex = coinsInfo->subaddrIndex(); - subaddrAccount = coinsInfo->subaddrAccount(); - address = strdup(coinsInfo->address().c_str()) ; - addressLabel = strdup(coinsInfo->addressLabel().c_str()); - keyImage = strdup(coinsInfo->keyImage().c_str()); - unlockTime = coinsInfo->unlockTime(); - unlocked = coinsInfo->unlocked(); - pubKey = strdup(coinsInfo->pubKey().c_str()); - coinbase = coinsInfo->coinbase(); - description = strdup(coinsInfo->description().c_str()); - } - - void setUnlocked(bool unlocked); - }; - - Monero::Coins *m_coins; - - Monero::Wallet *m_wallet; - Monero::TransactionHistory *m_transaction_history; - MoneroWalletListener *m_listener; - Monero::Subaddress *m_subaddress; - Monero::SubaddressAccount *m_account; - uint64_t m_last_known_wallet_height; - uint64_t m_cached_syncing_blockchain_height = 0; - std::list m_coins_info; - std::mutex store_lock; - bool is_storing = false; - - void change_current_wallet(Monero::Wallet *wallet) - { - m_wallet = wallet; - m_listener = nullptr; - - - if (wallet != nullptr) - { - m_transaction_history = wallet->history(); - } - else - { - m_transaction_history = nullptr; - } - - if (wallet != nullptr) - { - m_account = wallet->subaddressAccount(); - } - else - { - m_account = nullptr; - } - - if (wallet != nullptr) - { - m_subaddress = wallet->subaddress(); - } - else - { - m_subaddress = nullptr; - } - - m_coins_info = std::list(); - - if (wallet != nullptr) - { - m_coins = wallet->coins(); - } - else - { - m_coins = nullptr; - } - } - - Monero::Wallet *get_current_wallet() - { - return m_wallet; - } - - bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); - Monero::Wallet *wallet = walletManager->createWallet(path, password, language, _networkType); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (wallet->status() != Monero::Wallet::Status_Ok) - { - error = strdup(wallet->errorString().c_str()); - return false; - } - - change_current_wallet(wallet); - - return true; - } - - bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->recoveryWallet( - std::string(path), - std::string(password), - std::string(seed), - _networkType, - (uint64_t)restoreHeight); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( - std::string(path), - std::string(password), - std::string(language), - _networkType, - (uint64_t)restoreHeight, - std::string(address), - std::string(viewKey), - std::string(spendKey)); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool restore_wallet_from_spend_key(char *path, char *password, char *seed, char *language, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error) - { - Monero::NetworkType _networkType = static_cast(networkType); - Monero::Wallet *wallet = Monero::WalletManagerFactory::getWalletManager()->createDeterministicWalletFromSpendKey( - std::string(path), - std::string(password), - std::string(language), - _networkType, - (uint64_t)restoreHeight, - std::string(spendKey)); - - // Cache Raw to support Polyseed - wallet->setCacheAttribute("cakewallet.seed", std::string(seed)); - - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - - if (status != Monero::Wallet::Status_Ok || !errorString.empty()) - { - error = strdup(errorString.c_str()); - return false; - } - - change_current_wallet(wallet); - return true; - } - - bool load_wallet(char *path, char *password, int32_t nettype) - { - nice(19); - Monero::NetworkType networkType = static_cast(nettype); - Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); - Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType); - int status; - std::string errorString; - - wallet->statusWithErrorString(status, errorString); - change_current_wallet(wallet); - - return !(status != Monero::Wallet::Status_Ok || !errorString.empty()); - } - - char *error_string() { - return strdup(get_current_wallet()->errorString().c_str()); - } - - - bool is_wallet_exist(char *path) - { - return Monero::WalletManagerFactory::getWalletManager()->walletExists(std::string(path)); - } - - void close_current_wallet() - { - Monero::WalletManagerFactory::getWalletManager()->closeWallet(get_current_wallet()); - change_current_wallet(nullptr); - } - - char *get_filename() - { - return strdup(get_current_wallet()->filename().c_str()); - } - - char *secret_view_key() - { - return strdup(get_current_wallet()->secretViewKey().c_str()); - } - - char *public_view_key() - { - return strdup(get_current_wallet()->publicViewKey().c_str()); - } - - char *secret_spend_key() - { - return strdup(get_current_wallet()->secretSpendKey().c_str()); - } - - char *public_spend_key() - { - return strdup(get_current_wallet()->publicSpendKey().c_str()); - } - - char *get_address(uint32_t account_index, uint32_t address_index) - { - return strdup(get_current_wallet()->address(account_index, address_index).c_str()); - } - - - const char *seed() - { - std::string _rawSeed = get_current_wallet()->getCacheAttribute("cakewallet.seed"); - if (!_rawSeed.empty()) - { - return strdup(_rawSeed.c_str()); - } - return strdup(get_current_wallet()->seed().c_str()); - } - - uint64_t get_full_balance(uint32_t account_index) - { - return get_current_wallet()->balance(account_index); - } - - uint64_t get_unlocked_balance(uint32_t account_index) - { - return get_current_wallet()->unlockedBalance(account_index); - } - - uint64_t get_current_height() - { - return get_current_wallet()->blockChainHeight(); - } - - uint64_t get_node_height() - { - return get_current_wallet()->daemonBlockChainHeight(); - } - - bool connect_to_node(char *error) - { - nice(19); - bool is_connected = get_current_wallet()->connectToDaemon(); - - if (!is_connected) - { - error = strdup(get_current_wallet()->errorString().c_str()); - } - - return is_connected; - } - - bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *socksProxyAddress, char *error) - { - nice(19); - Monero::Wallet *wallet = get_current_wallet(); - - std::string _login = ""; - std::string _password = ""; - std::string _socksProxyAddress = ""; - - if (login != nullptr) - { - _login = std::string(login); - } - - if (password != nullptr) - { - _password = std::string(password); - } - - if (socksProxyAddress != nullptr) - { - _socksProxyAddress = std::string(socksProxyAddress); - } - - bool inited = wallet->init(std::string(address), 0, _login, _password, use_ssl, is_light_wallet, _socksProxyAddress); - - if (!inited) - { - error = strdup(wallet->errorString().c_str()); - } else if (!wallet->connectToDaemon()) { - error = strdup(wallet->errorString().c_str()); - } - - return inited; - } - - bool is_connected() - { - return get_current_wallet()->connected(); - } - - void start_refresh() - { - get_current_wallet()->refreshAsync(); - get_current_wallet()->startRefresh(); - } - - void set_refresh_from_block_height(uint64_t height) - { - get_current_wallet()->setRefreshFromBlockHeight(height); - } - - void set_recovering_from_seed(bool is_recovery) - { - get_current_wallet()->setRecoveringFromSeed(is_recovery); - } - - void store(char *path) - { - store_lock.lock(); - if (is_storing) { - return; - } - - is_storing = true; - get_current_wallet()->store(std::string(path)); - is_storing = false; - store_lock.unlock(); - } - - bool set_password(char *password, Utf8Box &error) { - bool is_changed = get_current_wallet()->setPassword(std::string(password)); - - if (!is_changed) { - error = Utf8Box(strdup(get_current_wallet()->errorString().c_str())); - } - - return is_changed; - } - - bool transaction_create(char *address, char *payment_id, char *amount, - uint8_t priority_raw, uint32_t subaddr_account, - char **preferred_inputs, uint32_t preferred_inputs_size, - Utf8Box &error, PendingTransactionRaw &pendingTransaction) - { - nice(19); - - std::set _preferred_inputs; - - for (int i = 0; i < preferred_inputs_size; i++) { - _preferred_inputs.insert(std::string(*preferred_inputs)); - preferred_inputs++; - } - - auto priority = static_cast(priority_raw); - std::string _payment_id; - Monero::PendingTransaction *transaction; - - if (payment_id != nullptr) - { - _payment_id = std::string(payment_id); - } - - if (amount != nullptr) - { - uint64_t _amount = Monero::Wallet::amountFromString(std::string(amount)); - transaction = m_wallet->createTransaction(std::string(address), _payment_id, _amount, m_wallet->defaultMixin(), priority, subaddr_account, {}, _preferred_inputs); - } - else - { - transaction = m_wallet->createTransaction(std::string(address), _payment_id, Monero::optional(), m_wallet->defaultMixin(), priority, subaddr_account, {}, _preferred_inputs); - } - - int status = transaction->status(); - - if (status == Monero::PendingTransaction::Status::Status_Error || status == Monero::PendingTransaction::Status::Status_Critical) - { - error = Utf8Box(strdup(transaction->errorString().c_str())); - return false; - } - - if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - pendingTransaction = PendingTransactionRaw(transaction); - return true; - } - - bool transaction_create_mult_dest(char **addresses, char *payment_id, char **amounts, uint32_t size, - uint8_t priority_raw, uint32_t subaddr_account, - char **preferred_inputs, uint32_t preferred_inputs_size, - Utf8Box &error, PendingTransactionRaw &pendingTransaction) - { - nice(19); - - std::vector _addresses; - std::vector _amounts; - - for (int i = 0; i < size; i++) { - _addresses.push_back(std::string(*addresses)); - _amounts.push_back(Monero::Wallet::amountFromString(std::string(*amounts))); - addresses++; - amounts++; - } - - std::set _preferred_inputs; - - for (int i = 0; i < preferred_inputs_size; i++) { - _preferred_inputs.insert(std::string(*preferred_inputs)); - preferred_inputs++; - } - - auto priority = static_cast(priority_raw); - std::string _payment_id; - Monero::PendingTransaction *transaction; - - if (payment_id != nullptr) - { - _payment_id = std::string(payment_id); - } - - transaction = m_wallet->createTransactionMultDest(_addresses, _payment_id, _amounts, m_wallet->defaultMixin(), priority, subaddr_account); - - int status = transaction->status(); - - if (status == Monero::PendingTransaction::Status::Status_Error || status == Monero::PendingTransaction::Status::Status_Critical) - { - error = Utf8Box(strdup(transaction->errorString().c_str())); - return false; - } - - if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - pendingTransaction = PendingTransactionRaw(transaction); - return true; - } - - bool transaction_commit(PendingTransactionRaw *transaction, Utf8Box &error) - { - bool committed = transaction->transaction->commit(); - - if (!committed) - { - error = Utf8Box(strdup(transaction->transaction->errorString().c_str())); - } else if (m_listener != nullptr) { - m_listener->m_new_transaction = true; - } - - return committed; - } - - uint64_t get_node_height_or_update(uint64_t base_eight) - { - if (m_cached_syncing_blockchain_height < base_eight) { - m_cached_syncing_blockchain_height = base_eight; - } - - return m_cached_syncing_blockchain_height; - } - - uint64_t get_syncing_height() - { - if (m_listener == nullptr) { - return 0; - } - - uint64_t height = m_listener->height(); - - if (height <= 1) { - return 0; - } - - if (height != m_last_known_wallet_height) - { - m_last_known_wallet_height = height; - } - - return height; - } - - uint64_t is_needed_to_refresh() - { - if (m_listener == nullptr) { - return false; - } - - bool should_refresh = m_listener->isNeedToRefresh(); - - if (should_refresh) { - m_listener->resetNeedToRefresh(); - } - - return should_refresh; - } - - uint8_t is_new_transaction_exist() - { - if (m_listener == nullptr) { - return false; - } - - bool is_new_transaction_exist = m_listener->isNewTransactionExist(); - - if (is_new_transaction_exist) - { - m_listener->resetIsNewTransactionExist(); - } - - return is_new_transaction_exist; - } - - void set_listener() - { - m_last_known_wallet_height = 0; - - if (m_listener != nullptr) - { - free(m_listener); - } - - m_listener = new MoneroWalletListener(); - get_current_wallet()->setListener(m_listener); - } - - int64_t *subaddrress_get_all() - { - std::vector _subaddresses = m_subaddress->getAll(); - size_t size = _subaddresses.size(); - int64_t *subaddresses = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::SubaddressRow *row = _subaddresses[i]; - SubaddressRow *_row = new SubaddressRow(row->getRowId(), strdup(row->getAddress().c_str()), strdup(row->getLabel().c_str())); - subaddresses[i] = reinterpret_cast(_row); - } - - return subaddresses; - } - - int32_t subaddrress_size() - { - std::vector _subaddresses = m_subaddress->getAll(); - return _subaddresses.size(); - } - - void subaddress_add_row(uint32_t accountIndex, char *label) - { - m_subaddress->addRow(accountIndex, std::string(label)); - } - - void subaddress_set_label(uint32_t accountIndex, uint32_t addressIndex, char *label) - { - m_subaddress->setLabel(accountIndex, addressIndex, std::string(label)); - } - - void subaddress_refresh(uint32_t accountIndex) - { - m_subaddress->refresh(accountIndex); - } - - int32_t account_size() - { - std::vector _accocunts = m_account->getAll(); - return _accocunts.size(); - } - - int64_t *account_get_all() - { - std::vector _accocunts = m_account->getAll(); - size_t size = _accocunts.size(); - int64_t *accocunts = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::SubaddressAccountRow *row = _accocunts[i]; - AccountRow *_row = new AccountRow(row->getRowId(), strdup(row->getLabel().c_str())); - accocunts[i] = reinterpret_cast(_row); - } - - return accocunts; - } - - void account_add_row(char *label) - { - m_account->addRow(std::string(label)); - } - - void account_set_label_row(uint32_t account_index, char *label) - { - m_account->setLabel(account_index, label); - } - - void account_refresh() - { - m_account->refresh(); - } - - int64_t *transactions_get_all() - { - std::vector transactions = m_transaction_history->getAll(); - size_t size = transactions.size(); - int64_t *transactionAddresses = (int64_t *)malloc(size * sizeof(int64_t)); - - for (int i = 0; i < size; i++) - { - Monero::TransactionInfo *row = transactions[i]; - TransactionInfoRow *tx = new TransactionInfoRow(row); - transactionAddresses[i] = reinterpret_cast(tx); - } - - return transactionAddresses; - } - - void transactions_refresh() - { - m_transaction_history->refresh(); - } - - int64_t transactions_count() - { - return m_transaction_history->count(); - } - - TransactionInfoRow* get_transaction(char * txId) - { - Monero::TransactionInfo *row = m_transaction_history->transaction(std::string(txId)); - return new TransactionInfoRow(row); - } - - int LedgerExchange( - unsigned char *command, - unsigned int cmd_len, - unsigned char *response, - unsigned int max_resp_len) - { - return -1; - } - - int LedgerFind(char *buffer, size_t len) - { - return -1; - } - - void on_startup() - { - Monero::Utils::onStartup(); - Monero::WalletManagerFactory::setLogLevel(0); - } - - void rescan_blockchain() - { - m_wallet->rescanBlockchainAsync(); - } - - char * get_tx_key(char * txId) - { - return strdup(m_wallet->getTxKey(std::string(txId)).c_str()); - } - - char *get_subaddress_label(uint32_t accountIndex, uint32_t addressIndex) - { - return strdup(get_current_wallet()->getSubaddressLabel(accountIndex, addressIndex).c_str()); - } - - void set_trusted_daemon(bool arg) - { - m_wallet->setTrustedDaemon(arg); - } - - bool trusted_daemon() - { - return m_wallet->trustedDaemon(); - } - - CoinsInfoRow* coin(int index) - { - if (index >= 0 && index < m_coins_info.size()) { - std::list::iterator it = m_coins_info.begin(); - std::advance(it, index); - Monero::CoinsInfo* element = *it; - std::cout << "Element at index " << index << ": " << element << std::endl; - return new CoinsInfoRow(element); - } else { - std::cout << "Invalid index." << std::endl; - return nullptr; // Return a default value (nullptr) for invalid index - } - } - - void refresh_coins(uint32_t accountIndex) - { - m_coins_info.clear(); - - m_coins->refresh(); - for (const auto i : m_coins->getAll()) { - if (i->subaddrAccount() == accountIndex && !(i->spent())) { - m_coins_info.push_back(i); - } - } - } - - uint64_t coins_count() - { - return m_coins_info.size(); - } - - CoinsInfoRow** coins_from_account(uint32_t accountIndex) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinInfo = coin(i); - if (coinInfo->subaddrAccount == accountIndex) { - matchingCoins.push_back(coinInfo); - } - } - - CoinsInfoRow** result = new CoinsInfoRow*[matchingCoins.size()]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - CoinsInfoRow** coins_from_txid(const char* txid, size_t* count) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinInfo = coin(i); - if (std::string(coinInfo->hash) == txid) { - matchingCoins.push_back(coinInfo); - } - } - - *count = matchingCoins.size(); - CoinsInfoRow** result = new CoinsInfoRow*[*count]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - CoinsInfoRow** coins_from_key_image(const char** keyimages, size_t keyimageCount, size_t* count) - { - std::vector matchingCoins; - - for (int i = 0; i < coins_count(); i++) { - CoinsInfoRow* coinsInfoRow = coin(i); - for (size_t j = 0; j < keyimageCount; j++) { - if (coinsInfoRow->keyImageKnown && std::string(coinsInfoRow->keyImage) == keyimages[j]) { - matchingCoins.push_back(coinsInfoRow); - break; - } - } - } - - *count = matchingCoins.size(); - CoinsInfoRow** result = new CoinsInfoRow*[*count]; - std::copy(matchingCoins.begin(), matchingCoins.end(), result); - return result; - } - - void freeze_coin(int index) - { - m_coins->setFrozen(index); - } - - void thaw_coin(int index) - { - m_coins->thaw(index); - } - - // Sign Messages // - - char *sign_message(char *message, char *address = "") - { - return strdup(get_current_wallet()->signMessage(std::string(message), std::string(address)).c_str()); - } - -#ifdef __cplusplus -} -#endif diff --git a/cw_monero/macos/Classes/monero_api.h b/cw_monero/macos/Classes/monero_api.h deleted file mode 100644 index fa92a038d..000000000 --- a/cw_monero/macos/Classes/monero_api.h +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include "CwWalletListener.h" - -#ifdef __cplusplus -extern "C" { -#endif - -bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error); -bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error); -bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error); -void load_wallet(char *path, char *password, int32_t nettype); -bool is_wallet_exist(char *path); - -char *get_filename(); -const char *seed(); -char *get_address(uint32_t account_index, uint32_t address_index); -uint64_t get_full_balance(uint32_t account_index); -uint64_t get_unlocked_balance(uint32_t account_index); -uint64_t get_current_height(); -uint64_t get_node_height(); - -bool is_connected(); - -bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error); -bool connect_to_node(char *error); -void start_refresh(); -void set_refresh_from_block_height(uint64_t height); -void set_recovering_from_seed(bool is_recovery); -void store(char *path); - -void set_trusted_daemon(bool arg); -bool trusted_daemon(); -char *sign_message(char *message, char *address); - -#ifdef __cplusplus -} -#endif diff --git a/cw_monero/macos/cw_monero_base.podspec b/cw_monero/macos/cw_monero_base.podspec deleted file mode 100644 index aac972c0f..000000000 --- a/cw_monero/macos/cw_monero_base.podspec +++ /dev/null @@ -1,56 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint cw_monero.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'cw_monero' - s.version = '0.0.1' - s.summary = 'CW Monero' - s.description = 'Cake Wallet wrapper over Monero project.' - s.homepage = 'http://cakewallet.com' - s.license = { :file => '../LICENSE' } - s.author = { 'CakeWallet' => 'support@cakewallet.com' } - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'FlutterMacOS' - s.public_header_files = 'Classes/**/*.h, Classes/*.h, External/macos/libs/monero/include/External/ios/**/*.h' - s.platform = :osx, '10.11' - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => '#___VALID_ARCHS___#', 'ENABLE_BITCODE' => 'NO' } - s.swift_version = '5.0' - s.libraries = 'iconv' - - s.subspec 'OpenSSL' do |openssl| - openssl.preserve_paths = '../../../../../cw_shared_external/ios/External/macos/include/**/*.h' - openssl.vendored_libraries = '../../../../../cw_shared_external/ios/External/macos/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/macos/include/**" } - end - - s.subspec 'Sodium' do |sodium| - sodium.preserve_paths = '../../../../../cw_shared_external/ios/External/macos/include/**/*.h' - sodium.vendored_libraries = '../../../../../cw_shared_external/ios/External/macos/lib/libsodium.a' - sodium.libraries = 'sodium' - sodium.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/macos/include/**" } - end - - s.subspec 'Unbound' do |unbound| - unbound.preserve_paths = '../../../../../cw_shared_external/ios/External/macos/include/**/*.h' - unbound.vendored_libraries = '../../../../../cw_shared_external/ios/External/macos/lib/libunbound.a' - unbound.libraries = 'unbound' - unbound.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/macos/include/**" } - end - - s.subspec 'Boost' do |boost| - boost.preserve_paths = '../../../../../cw_shared_external/ios/External/macos/include/**/*.h', - boost.vendored_libraries = '../../../../../cw_shared_external/ios/External/macos/lib/libboost.a', - boost.libraries = 'boost' - boost.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/macos/include/**" } - end - - s.subspec 'Monero' do |monero| - monero.preserve_paths = 'External/macos/include/**/*.h' - monero.vendored_libraries = 'External/macos/lib/libmonero.a' - monero.libraries = 'monero' - monero.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/External/macos/include" } - end -end diff --git a/cw_monero/pubspec.lock b/cw_monero/pubspec.lock index b736f80cb..b82c43c15 100644 --- a/cw_monero/pubspec.lock +++ b/cw_monero/pubspec.lock @@ -69,10 +69,10 @@ packages: dependency: transitive description: name: build_daemon - sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "3.1.0" build_resolvers: dependency: "direct dev" description: @@ -85,10 +85,10 @@ packages: dependency: "direct dev" description: name: build_runner - sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22" + sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 url: "https://pub.dev" source: hosted - version: "2.4.9" + version: "2.3.3" build_runner_core: dependency: transitive description: @@ -204,10 +204,10 @@ packages: dependency: "direct main" description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" file: dependency: transitive description: @@ -410,6 +410,15 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + monero: + dependency: "direct main" + description: + path: "." + ref: "57e075ee67d16aa0f3f75fba67d79529fbc73a6c" + resolved-ref: "57e075ee67d16aa0f3f75fba67d79529fbc73a6c" + url: "https://git.mrcyjanek.net/mrcyjanek/monero.dart" + source: git + version: "0.0.0" package_config: dependency: transitive description: @@ -664,13 +673,13 @@ packages: source: hosted version: "2.1.4" watcher: - dependency: "direct overridden" + dependency: transitive description: name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.0.2" web: dependency: transitive description: @@ -712,5 +721,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.0.6 <4.0.0" flutter: ">=3.7.0" diff --git a/cw_monero/pubspec.yaml b/cw_monero/pubspec.yaml index a6fe7f967..ce0415909 100644 --- a/cw_monero/pubspec.yaml +++ b/cw_monero/pubspec.yaml @@ -6,7 +6,7 @@ author: Cake Wallet homepage: https://cakewallet.com environment: - sdk: ">=2.17.5 <3.0.0" + sdk: ">=2.19.0 <3.0.0" flutter: ">=1.20.0" dependencies: @@ -22,6 +22,10 @@ dependencies: polyseed: ^0.0.2 cw_core: path: ../cw_core + monero: + git: + url: https://git.mrcyjanek.net/mrcyjanek/monero.dart + ref: 57e075ee67d16aa0f3f75fba67d79529fbc73a6c dev_dependencies: flutter_test: @@ -40,16 +44,7 @@ flutter: # The androidPackage and pluginClass identifiers should not ordinarily # be modified. They are used by the tooling to maintain consistency when # adding or updating assets for this project. - plugin: - platforms: - android: - package: com.cakewallet.monero - pluginClass: CwMoneroPlugin - ios: - pluginClass: CwMoneroPlugin - macos: - pluginClass: CwMoneroPlugin # To add assets to your plugin package, add an assets section, like this: # assets: diff --git a/cw_monero/test/cw_monero_method_channel_test.dart b/cw_monero/test/cw_monero_method_channel_test.dart deleted file mode 100644 index 8c1f329f0..000000000 --- a/cw_monero/test/cw_monero_method_channel_test.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:cw_monero/cw_monero_method_channel.dart'; - -void main() { - MethodChannelCwMonero platform = MethodChannelCwMonero(); - const MethodChannel channel = MethodChannel('cw_monero'); - - TestWidgetsFlutterBinding.ensureInitialized(); - - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return '42'; - }); - }); - - tearDown(() { - channel.setMockMethodCallHandler(null); - }); - - test('getPlatformVersion', () async { - expect(await platform.getPlatformVersion(), '42'); - }); -} diff --git a/cw_monero/test/cw_monero_test.dart b/cw_monero/test/cw_monero_test.dart deleted file mode 100644 index 1eb8d6f79..000000000 --- a/cw_monero/test/cw_monero_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:cw_monero/cw_monero.dart'; -import 'package:cw_monero/cw_monero_platform_interface.dart'; -import 'package:cw_monero/cw_monero_method_channel.dart'; -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; - -class MockCwMoneroPlatform - with MockPlatformInterfaceMixin - implements CwMoneroPlatform { - - @override - Future getPlatformVersion() => Future.value('42'); -} - -void main() { - final CwMoneroPlatform initialPlatform = CwMoneroPlatform.instance; - - test('$MethodChannelCwMonero is the default instance', () { - expect(initialPlatform, isInstanceOf()); - }); - - test('getPlatformVersion', () async { - CwMonero cwMoneroPlugin = CwMonero(); - MockCwMoneroPlatform fakePlatform = MockCwMoneroPlatform(); - CwMoneroPlatform.instance = fakePlatform; - - expect(await cwMoneroPlugin.getPlatformVersion(), '42'); - }); -} diff --git a/env.json b/env.json new file mode 100644 index 000000000..33a4bc52b --- /dev/null +++ b/env.json @@ -0,0 +1,6 @@ +{ + "CW_WIN_APP_NAME":"Cake Wallet", + "CW_WIN_APP_PACKAGE_NAME": "com.cakewallet.cake_wallet", + "CW_WIN_APP_VERSION": "1.0.0", + "CW_WIN_APP_BUILD_NUMBER": "1" +} diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 2ec5f293d..98b7100ce 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'dart:typed_data'; 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 _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 _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 _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> _reloadHiveWalletInfoBox() async { - final appDir = await getApplicationDocumentsDirectory(); + final appDir = await getAppDir(); await CakeHive.close(); CakeHive.init(appDir.path); @@ -184,7 +185,7 @@ class BackupService { } Future _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 _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); @@ -389,7 +390,7 @@ class BackupService { Future _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'); diff --git a/lib/entities/language_service.dart b/lib/entities/language_service.dart index cfb850889..23d27dd38 100644 --- a/lib/entities/language_service.dart +++ b/lib/entities/language_service.dart @@ -63,6 +63,8 @@ class LanguageService { static final list = {}; + static const defaultLocale = 'en'; + static void loadLocaleList() { supportedLocales.forEach((key, value) { if (locales.contains(key)) { @@ -72,9 +74,16 @@ class LanguageService { } static Future 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; + } } } diff --git a/lib/locales/hausa_intl.dart b/lib/locales/hausa_intl.dart index 749d39a4d..972c2b4cd 100644 --- a/lib/locales/hausa_intl.dart +++ b/lib/locales/hausa_intl.dart @@ -751,6 +751,27 @@ class HaMaterialLocalizations extends GlobalMaterialLocalizations { @override String get scrimOnTapHintRaw => "Scrip on Tap"; + + @override + String get collapsedHint => 'Expanded'; + + @override + String get expandedHint => 'Collapsed'; + + @override + String get expansionTileCollapsedHint => 'double tap to expand'; + + @override + String get expansionTileCollapsedTapHint => 'Expand for more details'; + + @override + String get expansionTileExpandedHint => 'double tap to collapse'; + + @override + String get expansionTileExpandedTapHint => 'Collapse'; + + @override + String get scanTextButtonLabel => 'Scan'; } /// Cupertino Support diff --git a/lib/locales/yoruba_intl.dart b/lib/locales/yoruba_intl.dart index f16188529..e998f0320 100644 --- a/lib/locales/yoruba_intl.dart +++ b/lib/locales/yoruba_intl.dart @@ -751,6 +751,27 @@ String get keyboardKeyMetaWindows => 'Windows'; @override String get scrimOnTapHintRaw => "Scrip on Tap"; + + @override + String get collapsedHint => 'Expanded'; + + @override + String get expandedHint => 'Collapsed'; + + @override + String get expansionTileCollapsedHint => 'double tap to expand'; + + @override + String get expansionTileCollapsedTapHint => 'Expand for more details'; + + @override + String get expansionTileExpandedHint => 'double tap to collapse'; + + @override + String get expansionTileExpandedTapHint => 'Collapse'; + + @override + String get scanTextButtonLabel => 'Scan'; } /// Cupertino Support diff --git a/lib/main.dart b/lib/main.dart index ff5b0e5c0..ecfaabee0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,46 +1,48 @@ import 'dart:async'; + import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart'; -import 'package:cake_wallet/core/auth_service.dart'; -import 'package:cake_wallet/entities/language_service.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/entities/language_service.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/store/yat/yat_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: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_secure_storage/flutter_secure_storage.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:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:hive/hive.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:cw_core/root_dir.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:uni_links/uni_links.dart'; -import 'package:cw_core/unspent_coins_info.dart'; -import 'package:cake_wallet/monero/monero.dart'; -import 'package:cw_core/cake_hive.dart'; final navigatorKey = GlobalKey(); final rootKey = GlobalKey(); @@ -71,7 +73,8 @@ Future main() async { } Future initializeAppConfigs() async { - final appDir = await getApplicationDocumentsDirectory(); + setRootDirFromEnv(); + final appDir = await getAppDir(); CakeHive.init(appDir.path); if (!CakeHive.isAdapterRegistered(Contact.typeId)) { diff --git a/lib/monero/cw_monero.dart b/lib/monero/cw_monero.dart index 959ae92ce..003ab920c 100644 --- a/lib/monero/cw_monero.dart +++ b/lib/monero/cw_monero.dart @@ -335,4 +335,9 @@ class CWMonero extends Monero { final moneroWallet = wallet as MoneroWallet; await moneroWallet.updateUnspent(); } + + @override + Future getCurrentHeight() async { + return monero_wallet_api.getCurrentHeight(); + } } diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 165c72242..200415631 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -28,7 +28,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.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'; diff --git a/lib/utils/distribution_info.dart b/lib/utils/distribution_info.dart index 859c507a3..5a2cb8e9d 100644 --- a/lib/utils/distribution_info.dart +++ b/lib/utils/distribution_info.dart @@ -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 } diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 6e93fc5cd..fffe6a770 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -5,11 +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:cake_wallet/utils/package_info.dart'; import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -52,8 +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'); } diff --git a/lib/utils/package_info.dart b/lib/utils/package_info.dart new file mode 100644 index 000000000..8b911f887 --- /dev/null +++ b/lib/utils/package_info.dart @@ -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 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}); +} diff --git a/lib/view_model/backup_view_model.dart b/lib/view_model/backup_view_model.dart index 8cc651b17..3e713e709 100644 --- a/lib/view_model/backup_view_model.dart +++ b/lib/view_model/backup_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/core/backup_service.dart'; import 'package:cake_wallet/core/execution_state.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:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:mobx/mobx.dart'; @@ -73,7 +74,7 @@ abstract class BackupViewModelBase with Store { } Future 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); @@ -81,7 +82,7 @@ abstract class BackupViewModelBase with Store { } Future 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(); diff --git a/lib/view_model/settings/other_settings_view_model.dart b/lib/view_model/settings/other_settings_view_model.dart index 0493acf81..f4c817b32 100644 --- a/lib/view_model/settings/other_settings_view_model.dart +++ b/lib/view_model/settings/other_settings_view_model.dart @@ -12,6 +12,7 @@ import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; import 'package:package_info/package_info.dart'; import 'package:collection/collection.dart'; +import 'package:cake_wallet/utils/package_info.dart'; part 'other_settings_view_model.g.dart'; diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index c33c85504..9c44c6510 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -148,7 +148,7 @@ abstract class WalletKeysViewModelBase with Store { return await haven!.getCurrentHeight(); } if (_appStore.wallet!.type == WalletType.monero) { - return monero_wallet.getCurrentHeight(); + return await monero!.getCurrentHeight(); } return null; } diff --git a/lib/wallet_type_utils.dart b/lib/wallet_type_utils.dart index 5ed78dc64..459ca992b 100644 --- a/lib/wallet_type_utils.dart +++ b/lib/wallet_type_utils.dart @@ -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'; -} \ No newline at end of file +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 75a78404f..5ed5fe848 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,6 @@ import FlutterMacOS import Foundation import connectivity_plus -import cw_monero import device_info_plus import devicelocale import flutter_inappwebview_macos @@ -22,7 +21,6 @@ import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) - CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin")) InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index b82513de2..f83e18c40 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -106,7 +106,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747 - cw_monero: ec03de55a19c4a2b174ea687e0f4202edc716fa4 + cw_monero: f8b7f104508efba2591548e76b5c058d05cba3f0 device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225 flutter_inappwebview_macos: 9600c9df9fdb346aaa8933812009f8d94304203d diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 911fa9fcc..7bf0cd5e8 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -59,7 +59,7 @@ 2A820A13B0719E9E0CD6686F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* Cake Wallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cake Wallet.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* Monero.com.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Monero.com.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -116,7 +116,7 @@ 33CC10EE2044A3C60003C045 /* Products */ = { isa = PBXGroup; children = ( - 33CC10ED2044A3C60003C045 /* Cake Wallet.app */, + 33CC10ED2044A3C60003C045 /* Monero.com.app */, ); name = Products; sourceTree = ""; @@ -197,7 +197,7 @@ ); name = Runner; productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* Cake Wallet.app */; + productReference = 33CC10ED2044A3C60003C045 /* Monero.com.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -421,15 +421,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 10; - DEVELOPMENT_TEAM = 32J6BB6VUS; + DEVELOPMENT_TEAM = X7J2Z37ZUL; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; @@ -555,15 +554,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 10; - DEVELOPMENT_TEAM = 32J6BB6VUS; + DEVELOPMENT_TEAM = X7J2Z37ZUL; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; @@ -583,15 +581,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 10; - DEVELOPMENT_TEAM = 32J6BB6VUS; + DEVELOPMENT_TEAM = X7J2Z37ZUL; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8536e9a81..1f89f6835 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ @@ -54,7 +54,7 @@ @@ -71,7 +71,7 @@ diff --git a/run-android.sh b/run-android.sh index bdacef392..880d86b6f 100755 --- a/run-android.sh +++ b/run-android.sh @@ -4,8 +4,7 @@ get_current_branch() { if git rev-parse --git-dir > /dev/null 2>&1; then branch=$(git rev-parse --abbrev-ref HEAD) - branch=${branch//[-]/_} # Replace all dashes with underscores - echo "$branch" + echo "$branch" | tr '-' '_' else echo "Error: Not a git repository." return 1 @@ -16,6 +15,7 @@ get_current_branch() { update_app_properties() { local branch=$1 local file_path="./android/app.properties" + sed -i "s/^id=.*/id=com.cakewallet.$branch/" "$file_path" sed -i "s/^name=.*/name=$branch-Cake Wallet/" "$file_path" } @@ -27,4 +27,4 @@ if [[ $? -eq 0 ]]; then fi # run the app -flutter run \ No newline at end of file +flutter run diff --git a/scripts/android/build_monero.sh b/scripts/android/build_monero.sh deleted file mode 100755 index fb596e452..000000000 --- a/scripts/android/build_monero.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -. ./config.sh -MONERO_BRANCH=release-v0.18.3.2-android -MONERO_SRC_DIR=${WORKDIR}/monero - -git clone https://github.com/cake-tech/monero.git ${MONERO_SRC_DIR} --branch ${MONERO_BRANCH} -cd $MONERO_SRC_DIR -git submodule update --init --force - -for arch in "aarch" "aarch64" "i686" "x86_64" -do -FLAGS="" -PREFIX=${WORKDIR}/prefix_${arch} -DEST_LIB_DIR=${PREFIX}/lib/monero -DEST_INCLUDE_DIR=${PREFIX}/include/monero -export CMAKE_INCLUDE_PATH="${PREFIX}/include" -export CMAKE_LIBRARY_PATH="${PREFIX}/lib" -ANDROID_STANDALONE_TOOLCHAIN_PATH="${TOOLCHAIN_BASE_DIR}_${arch}" -PATH="${ANDROID_STANDALONE_TOOLCHAIN_PATH}/bin:${ORIGINAL_PATH}" - -mkdir -p $DEST_LIB_DIR -mkdir -p $DEST_INCLUDE_DIR - -case $arch in - "aarch" ) - CLANG=arm-linux-androideabi-clang - CXXLANG=arm-linux-androideabi-clang++ - BUILD_64=OFF - TAG="android-armv7" - ARCH="armv7-a" - ARCH_ABI="armeabi-v7a" - FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";; - "aarch64" ) - CLANG=aarch64-linux-androideabi-clang - CXXLANG=aarch64-linux-androideabi-clang++ - BUILD_64=ON - TAG="android-armv8" - ARCH="armv8-a" - ARCH_ABI="arm64-v8a";; - "i686" ) - CLANG=i686-linux-androideabi-clang - CXXLANG=i686-linux-androideabi-clang++ - BUILD_64=OFF - TAG="android-x86" - ARCH="i686" - ARCH_ABI="x86";; - "x86_64" ) - CLANG=x86_64-linux-androideabi-clang - CXXLANG=x86_64-linux-androideabi-clang++ - BUILD_64=ON - TAG="android-x86_64" - ARCH="x86-64" - ARCH_ABI="x86_64";; -esac - -cd $MONERO_SRC_DIR -rm -rf ./build/release -mkdir -p ./build/release -cd ./build/release -CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} -D MANUAL_SUBMODULES=1 $FLAGS ../.. - -make wallet_api -j$THREADS -find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \; - -cp -r ./lib/* $DEST_LIB_DIR -cp ../../src/wallet/api/wallet2_api.h $DEST_INCLUDE_DIR -done diff --git a/scripts/android/build_monero_all.sh b/scripts/android/build_monero_all.sh index 69ec37b5f..f683d5d27 100755 --- a/scripts/android/build_monero_all.sh +++ b/scripts/android/build_monero_all.sh @@ -1,9 +1,48 @@ #!/bin/bash -./build_iconv.sh -./build_boost.sh -./build_openssl.sh -./build_sodium.sh -./build_unbound.sh -./build_zmq.sh -./build_monero.sh +# Usage: env USE_DOCKER= ./build_all.sh + +set -x -e + +cd "$(dirname "$0")" + +NPROC="-j$(nproc)" + +if [[ "x$(uname)" == "xDarwin" ]]; +then + USE_DOCKER="ON" + NPROC="-j1" +fi + +../prepare_moneroc.sh + +# NOTE: -j1 is intentional. Otherwise you will run into weird behaviour on macos +if [[ ! "x$USE_DOCKER" == "x" ]]; +then + for COIN in monero; + do + pushd ../monero_c + docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc g++ libtinfo5 gperf; ./build_single.sh ${COIN} x86_64-linux-android $NPROC" + # docker run --platform linux/amd64 -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc g++ libtinfo5 gperf; ./build_single.sh ${COIN} i686-linux-android $NPROC" + docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc g++ libtinfo5 gperf; ./build_single.sh ${COIN} arm-linux-androideabi $NPROC" + docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc g++ libtinfo5 gperf; ./build_single.sh ${COIN} aarch64-linux-android $NPROC" + popd + done +else + for COIN in monero; + do + pushd ../monero_c + ./build_single.sh ${COIN} x86_64-linux-android $NPROC + # ./build_single.sh ${COIN} i686-linux-android $NPROC + ./build_single.sh ${COIN} arm-linux-androideabi $NPROC + ./build_single.sh ${COIN} aarch64-linux-android $NPROC + popd + done +fi + +unxz -f ../monero_c/release/monero/x86_64-linux-android_libwallet2_api_c.so.xz +unxz -f ../monero_c/release/wownero/x86_64-linux-android_libwallet2_api_c.so.xz +unxz -f ../monero_c/release/monero/arm-linux-androideabi_libwallet2_api_c.so.xz +unxz -f ../monero_c/release/wownero/arm-linux-androideabi_libwallet2_api_c.so.xz +unxz -f ../monero_c/release/monero/aarch64-linux-android_libwallet2_api_c.so.xz +unxz -f ../monero_c/release/wownero/aarch64-linux-android_libwallet2_api_c.so.xz \ No newline at end of file diff --git a/scripts/android/build_openssl.sh b/scripts/android/build_openssl.sh index aa668e6bf..b67479464 100755 --- a/scripts/android/build_openssl.sh +++ b/scripts/android/build_openssl.sh @@ -24,9 +24,8 @@ echo $OPENSSL_SHA256 $OPENSSL_FILE_PATH | sha256sum -c - || exit 1 for arch in "aarch" "aarch64" "i686" "x86_64" do PREFIX=$WORKDIR/prefix_${arch} -TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64 +TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/darwin-x86_64 PATH="${TOOLCHAIN}/bin:${ORIGINAL_PATH}" - case $arch in "aarch") X_ARCH="android-arm";; "aarch64") X_ARCH="android-arm64";; diff --git a/scripts/android/build_unbound.sh b/scripts/android/build_unbound.sh index 8786b0f2b..fe3549f07 100755 --- a/scripts/android/build_unbound.sh +++ b/scripts/android/build_unbound.sh @@ -9,12 +9,12 @@ EXPAT_SRC_DIR=$WORKDIR/libexpat for arch in "aarch" "aarch64" "i686" "x86_64" do PREFIX=$WORKDIR/prefix_${arch} -TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64 +TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/darwin-x86_64 PATH="${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}" cd $WORKDIR rm -rf $EXPAT_SRC_DIR -git clone https://github.com/libexpat/libexpat.git -b ${EXPAT_VERSION} ${EXPAT_SRC_DIR} +git clone https://github.com/libexpat/libexpat.git --depth=1 -b ${EXPAT_VERSION} ${EXPAT_SRC_DIR} cd $EXPAT_SRC_DIR test `git rev-parse HEAD` = ${EXPAT_HASH} || exit 1 cd $EXPAT_SRC_DIR/expat @@ -38,7 +38,7 @@ UNBOUND_SRC_DIR=$WORKDIR/unbound-1.16.2 for arch in "aarch" "aarch64" "i686" "x86_64" do PREFIX=$WORKDIR/prefix_${arch} -TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64 +TOOLCHAIN=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/darwin-x86_64 case $arch in "aarch") TOOLCHAIN_BIN_PATH=${TOOLCHAIN_BASE_DIR}_${arch}/arm-linux-androideabi/bin;; @@ -49,7 +49,7 @@ PATH="${TOOLCHAIN_BIN_PATH}:${TOOLCHAIN_BASE_DIR}_${arch}/bin:${ORIGINAL_PATH}" echo $PATH cd $WORKDIR rm -rf $UNBOUND_SRC_DIR -git clone https://github.com/NLnetLabs/unbound.git -b ${UNBOUND_VERSION} ${UNBOUND_SRC_DIR} +git clone https://github.com/NLnetLabs/unbound.git --depth=1 -b ${UNBOUND_VERSION} ${UNBOUND_SRC_DIR} cd $UNBOUND_SRC_DIR test `git rev-parse HEAD` = ${UNBOUND_HASH} || exit 1 diff --git a/scripts/android/init_boost.sh b/scripts/android/init_boost.sh index 13120c910..7579acdd7 100755 --- a/scripts/android/init_boost.sh +++ b/scripts/android/init_boost.sh @@ -17,6 +17,6 @@ echo $BOOST_SHA256 $BOOST_FILE_PATH | sha256sum -c - || exit 1 cd $WORKDIR rm -rf $BOOST_SRC_DIR rm -rf $PREFIX/include/boost -tar -xvf $BOOST_FILE_PATH -C $WORKDIR +tar -xf $BOOST_FILE_PATH -C $WORKDIR cd $BOOST_SRC_DIR -./bootstrap.sh --prefix=${PREFIX} +./bootstrap.sh --prefix=${PREFIX} --with-toolset=gcc diff --git a/scripts/android/inject_app_details.sh b/scripts/android/inject_app_details.sh index 27b7efa39..3e6e2915d 100755 --- a/scripts/android/inject_app_details.sh +++ b/scripts/android/inject_app_details.sh @@ -6,6 +6,7 @@ if [ -z "$APP_ANDROID_TYPE" ]; then fi cd ../.. +set -x sed -i "0,/version:/{s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/}" ./pubspec.yaml sed -i "0,/version:/{s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/}" ./android/app/src/main/AndroidManifest.xml sed -i "0,/__APP_SCHEME__/s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/" ./android/app/src/main/AndroidManifest.xml diff --git a/scripts/android/install_ndk.sh b/scripts/android/install_ndk.sh index bee72abad..4ec794371 100755 --- a/scripts/android/install_ndk.sh +++ b/scripts/android/install_ndk.sh @@ -8,9 +8,9 @@ TOOLCHAIN_x86_DIR=${TOOLCHAIN_DIR}_i686 TOOLCHAIN_x86_64_DIR=${TOOLCHAIN_DIR}_x86_64 ANDROID_NDK_SHA256="3f541adbd0330a9205ba12697f6d04ec90752c53d6b622101a2a8a856e816589" -curl https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip -o ${ANDROID_NDK_ZIP} -echo $ANDROID_NDK_SHA256 $ANDROID_NDK_ZIP | sha256sum -c || exit 1 -unzip $ANDROID_NDK_ZIP -d $WORKDIR +# curl https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip -o ${ANDROID_NDK_ZIP} +# echo $ANDROID_NDK_SHA256 $ANDROID_NDK_ZIP | sha256sum -c || exit 1 +# unzip $ANDROID_NDK_ZIP -d $WORKDIR ${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch arm64 --api $API --install-dir ${TOOLCHAIN_A64_DIR} --stl=libc++ ${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch arm --api $API --install-dir ${TOOLCHAIN_A32_DIR} --stl=libc++ diff --git a/scripts/docker/.gitignore b/scripts/docker/.gitignore index ea1472ec1..c39e9d9f7 100644 --- a/scripts/docker/.gitignore +++ b/scripts/docker/.gitignore @@ -1 +1,2 @@ output/ +cache/ \ No newline at end of file diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile old mode 100644 new mode 100755 index eef09a323..a352cdc71 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -4,23 +4,59 @@ LABEL authors="konsti" ENV MONERO_BRANCH=release-v0.18.2.2-android RUN apt-get update && \ echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ - apt-get install -y dialog apt-utils curl unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake clang + apt-get install -y dialog apt-utils curl unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake clang bison ccache RUN mkdir /opt/android/ -COPY . /opt/android/cakewallet/ - WORKDIR /opt/android/cakewallet/ +# build_all.sh +# build_boost.sh +# build_haven.sh +# build_haven_all.sh +# build_iconv.sh +# build_monero.sh +# build_openssl.sh +# build_sodium.sh +# build_unbound.sh +# build_zmq.sh +# config.sh +# copy_haven_deps.sh +# copy_monero_deps.sh +# docker-compose.yml +# entrypoint.sh +# finish_boost.sh +# init_boost.sh +# install_ndk.sh +COPY config.sh /opt/android/cakewallet/ +COPY install_ndk.sh /opt/android/cakewallet/ RUN ./install_ndk.sh +COPY build_iconv.sh /opt/android/cakewallet/ RUN ./build_iconv.sh + +COPY build_boost.sh /opt/android/cakewallet/ +COPY init_boost.sh /opt/android/cakewallet/ +COPY finish_boost.sh /opt/android/cakewallet/ RUN ./build_boost.sh + +COPY build_openssl.sh /opt/android/cakewallet/ RUN ./build_openssl.sh + +COPY build_sodium.sh /opt/android/cakewallet/ RUN ./build_sodium.sh + +COPY build_unbound.sh /opt/android/cakewallet/ RUN ./build_unbound.sh + +COPY build_zmq.sh /opt/android/cakewallet/ RUN ./build_zmq.sh +COPY entrypoint.sh /opt/android/cakewallet/ +COPY build_monero.sh /opt/android/cakewallet/ +COPY copy_monero_deps.sh /opt/android/cakewallet/ +COPY build_haven.sh /opt/android/cakewallet/ +COPY copy_haven_deps.sh /opt/android/cakewallet/ ENTRYPOINT ["./entrypoint.sh"] diff --git a/scripts/docker/build_all.sh b/scripts/docker/build_all.sh old mode 100644 new mode 100755 index 0acb7fcde..a4163c3f4 --- a/scripts/docker/build_all.sh +++ b/scripts/docker/build_all.sh @@ -1 +1,17 @@ -#!/bin/sh if [ -z "$APP_ANDROID_TYPE" ]; then echo "Please set APP_ANDROID_TYPE" exit 1 fi DIR=$(dirname "$0") case $APP_ANDROID_TYPE in "monero.com") $DIR/build_monero_all.sh ;; "cakewallet") $DIR/build_monero_all.sh $DIR/build_haven.sh ;; "haven") $DIR/build_haven_all.sh ;; esac \ No newline at end of file +#!/bin/sh + +set -x -e + +if [ -z "$APP_ANDROID_TYPE" ]; then + echo "Please set APP_ANDROID_TYPE" + exit 1 +fi + +DIR=$(dirname "$0") + +case $APP_ANDROID_TYPE in + "monero.com") $DIR/build_monero_all.sh ;; + "cakewallet") $DIR/build_monero_all.sh + $DIR/build_haven.sh ;; + "haven") $DIR/build_haven_all.sh ;; +esac diff --git a/scripts/docker/build_boost.sh b/scripts/docker/build_boost.sh old mode 100644 new mode 100755 index 2c98afab5..97333bbee --- a/scripts/docker/build_boost.sh +++ b/scripts/docker/build_boost.sh @@ -1,5 +1,5 @@ #!/bin/bash - +set -x -e . ./config.sh BOOST_SRC_DIR=$WORKDIR/boost_1_72_0 BOOST_FILENAME=boost_1_72_0.tar.bz2 diff --git a/scripts/docker/build_haven.sh b/scripts/docker/build_haven.sh old mode 100644 new mode 100755 index 7927c5102..1cfb16265 --- a/scripts/docker/build_haven.sh +++ b/scripts/docker/build_haven.sh @@ -1 +1,71 @@ -#!/bin/sh . ./config.sh HAVEN_VERSION=tags/v3.0.7 HAVEN_SRC_DIR=${WORKDIR}/haven git clone https://github.com/haven-protocol-org/haven-main.git ${HAVEN_SRC_DIR} git checkout ${HAVEN_VERSION} cd $HAVEN_SRC_DIR git submodule init git submodule update for arch in "aarch" "aarch64" "i686" "x86_64" do FLAGS="" PREFIX=${WORKDIR}/prefix_${arch} DEST_LIB_DIR=${PREFIX}/lib/haven DEST_INCLUDE_DIR=${PREFIX}/include/haven export CMAKE_INCLUDE_PATH="${PREFIX}/include" export CMAKE_LIBRARY_PATH="${PREFIX}/lib" ANDROID_STANDALONE_TOOLCHAIN_PATH="${TOOLCHAIN_BASE_DIR}_${arch}" PATH="${ANDROID_STANDALONE_TOOLCHAIN_PATH}/bin:${ORIGINAL_PATH}" mkdir -p $DEST_LIB_DIR mkdir -p $DEST_INCLUDE_DIR case $arch in "aarch" ) CLANG=arm-linux-androideabi-clang CXXLANG=arm-linux-androideabi-clang++ BUILD_64=OFF TAG="android-armv7" ARCH="armv7-a" ARCH_ABI="armeabi-v7a" FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";; "aarch64" ) CLANG=aarch64-linux-androideabi-clang CXXLANG=aarch64-linux-androideabi-clang++ BUILD_64=ON TAG="android-armv8" ARCH="armv8-a" ARCH_ABI="arm64-v8a";; "i686" ) CLANG=i686-linux-androideabi-clang CXXLANG=i686-linux-androideabi-clang++ BUILD_64=OFF TAG="android-x86" ARCH="i686" ARCH_ABI="x86";; "x86_64" ) CLANG=x86_64-linux-androideabi-clang CXXLANG=x86_64-linux-androideabi-clang++ BUILD_64=ON TAG="android-x86_64" ARCH="x86-64" ARCH_ABI="x86_64";; esac cd $HAVEN_SRC_DIR rm -rf ./build/release mkdir -p ./build/release cd ./build/release CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} $FLAGS ../.. make wallet_api -j$THREADS find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \; cp -r ./lib/* $DEST_LIB_DIR cp ../../src/wallet/api/wallet2_api.h $DEST_INCLUDE_DIR done \ No newline at end of file +#!/bin/sh +set -x -e + +. ./config.sh +HAVEN_VERSION=tags/v3.0.7 +HAVEN_SRC_DIR=${WORKDIR}/haven + +git clone https://github.com/haven-protocol-org/haven-main.git ${HAVEN_SRC_DIR} +cd $HAVEN_SRC_DIR +git checkout ${HAVEN_VERSION} +git submodule init +git submodule update + +for arch in "aarch" "aarch64" "i686" "x86_64" +do +FLAGS="" +PREFIX=${WORKDIR}/prefix_${arch} +DEST_LIB_DIR=${PREFIX}/lib/haven +DEST_INCLUDE_DIR=${PREFIX}/include/haven +export CMAKE_INCLUDE_PATH="${PREFIX}/include" +export CMAKE_LIBRARY_PATH="${PREFIX}/lib" +ANDROID_STANDALONE_TOOLCHAIN_PATH="${TOOLCHAIN_BASE_DIR}_${arch}" +PATH="${ANDROID_STANDALONE_TOOLCHAIN_PATH}/bin:${ORIGINAL_PATH}" + +mkdir -p $DEST_LIB_DIR +mkdir -p $DEST_INCLUDE_DIR + +case $arch in + "aarch" ) + CLANG=arm-linux-androideabi-clang + CXXLANG=arm-linux-androideabi-clang++ + BUILD_64=OFF + TAG="android-armv7" + ARCH="armv7-a" + ARCH_ABI="armeabi-v7a" + FLAGS="-D CMAKE_ANDROID_ARM_MODE=ON -D NO_AES=true";; + "aarch64" ) + CLANG=aarch64-linux-androideabi-clang + CXXLANG=aarch64-linux-androideabi-clang++ + BUILD_64=ON + TAG="android-armv8" + ARCH="armv8-a" + ARCH_ABI="arm64-v8a";; + "i686" ) + CLANG=i686-linux-androideabi-clang + CXXLANG=i686-linux-androideabi-clang++ + BUILD_64=OFF + TAG="android-x86" + ARCH="i686" + ARCH_ABI="x86";; + "x86_64" ) + CLANG=x86_64-linux-androideabi-clang + CXXLANG=x86_64-linux-androideabi-clang++ + BUILD_64=ON + TAG="android-x86_64" + ARCH="x86-64" + ARCH_ABI="x86_64";; +esac + +cd $HAVEN_SRC_DIR +rm -rf ./build/release +mkdir -p ./build/release +cd ./build/release +CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} $FLAGS ../.. + +make wallet_api -j$THREADS +find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \; + +cp -r ./lib/* $DEST_LIB_DIR +cp ../../src/wallet/api/wallet2_api.h $DEST_INCLUDE_DIR +done diff --git a/scripts/docker/build_haven_all.sh b/scripts/docker/build_haven_all.sh old mode 100644 new mode 100755 index 4b33ad077..ce8eb3f0e --- a/scripts/docker/build_haven_all.sh +++ b/scripts/docker/build_haven_all.sh @@ -1 +1,9 @@ -#!/bin/bash ./build_iconv.sh ./build_boost.sh ./build_openssl.sh ./build_sodium.sh ./build_zmq.sh ./build_haven.sh \ No newline at end of file +#!/bin/bash +set -x -e + +./build_iconv.sh +./build_boost.sh +./build_openssl.sh +./build_sodium.sh +./build_zmq.sh +./build_haven.sh diff --git a/scripts/docker/build_iconv.sh b/scripts/docker/build_iconv.sh old mode 100644 new mode 100755 index 9edac26b3..e55686fec --- a/scripts/docker/build_iconv.sh +++ b/scripts/docker/build_iconv.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e . ./config.sh export ICONV_FILENAME=libiconv-1.16.tar.gz diff --git a/scripts/docker/build_monero.sh b/scripts/docker/build_monero.sh old mode 100644 new mode 100755 index d663f5288..04162f0f8 --- a/scripts/docker/build_monero.sh +++ b/scripts/docker/build_monero.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e . ./config.sh diff --git a/scripts/docker/build_openssl.sh b/scripts/docker/build_openssl.sh old mode 100644 new mode 100755 index 685d0a1be..233e64a7c --- a/scripts/docker/build_openssl.sh +++ b/scripts/docker/build_openssl.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e set -e diff --git a/scripts/docker/build_sodium.sh b/scripts/docker/build_sodium.sh old mode 100644 new mode 100755 index a934d641b..c911814d9 --- a/scripts/docker/build_sodium.sh +++ b/scripts/docker/build_sodium.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e . ./config.sh SODIUM_SRC_DIR=${WORKDIR}/libsodium diff --git a/scripts/docker/build_unbound.sh b/scripts/docker/build_unbound.sh old mode 100644 new mode 100755 index 8786b0f2b..2d1efdea2 --- a/scripts/docker/build_unbound.sh +++ b/scripts/docker/build_unbound.sh @@ -1,7 +1,7 @@ #!/bin/bash +set -x -e . ./config.sh - EXPAT_VERSION=R_2_4_8 EXPAT_HASH="3bab6c09bbe8bf42d84b81563ddbcf4cca4be838" EXPAT_SRC_DIR=$WORKDIR/libexpat diff --git a/scripts/docker/build_zmq.sh b/scripts/docker/build_zmq.sh old mode 100644 new mode 100755 index bbff9e41b..19bb99172 --- a/scripts/docker/build_zmq.sh +++ b/scripts/docker/build_zmq.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e . ./config.sh ZMQ_SRC_DIR=$WORKDIR/libzmq diff --git a/scripts/docker/config.sh b/scripts/docker/config.sh old mode 100644 new mode 100755 index c5067f2c3..a9b691688 --- a/scripts/docker/config.sh +++ b/scripts/docker/config.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e export API=21 export WORKDIR=/opt/android diff --git a/scripts/docker/copy_haven_deps.sh b/scripts/docker/copy_haven_deps.sh old mode 100644 new mode 100755 index d59e9d7f0..cef644701 --- a/scripts/docker/copy_haven_deps.sh +++ b/scripts/docker/copy_haven_deps.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x WORKDIR=/opt/android CW_DIR=${WORKDIR}/cake_wallet diff --git a/scripts/docker/copy_monero_deps.sh b/scripts/docker/copy_monero_deps.sh old mode 100644 new mode 100755 index e4392186c..1c2394c0d --- a/scripts/docker/copy_monero_deps.sh +++ b/scripts/docker/copy_monero_deps.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x WORKDIR=/opt/android CW_EXRTERNAL_DIR=${WORKDIR}/output/android diff --git a/scripts/docker/docker-compose.yml b/scripts/docker/docker-compose.yml old mode 100644 new mode 100755 index eaeea0f5b..00f24ce2e --- a/scripts/docker/docker-compose.yml +++ b/scripts/docker/docker-compose.yml @@ -7,3 +7,5 @@ services: MONERO_BRANCH: release-v0.18.2.2-android volumes: - ./output:/opt/android/output + - ./cache/dotcache:/root/.cache + - ./cache/dotccache:/root/.ccache diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.sh old mode 100644 new mode 100755 index e4bdc017c..14f02a1f8 --- a/scripts/docker/entrypoint.sh +++ b/scripts/docker/entrypoint.sh @@ -1,4 +1,11 @@ #!/bin/bash +set -x -e + +ls /opt/android + +rm -rf monero haven ./build_monero.sh +./build_haven.sh ./copy_monero_deps.sh +./copy_haven_deps.sh diff --git a/scripts/docker/finish_boost.sh b/scripts/docker/finish_boost.sh old mode 100644 new mode 100755 index e3f195276..774c65d77 --- a/scripts/docker/finish_boost.sh +++ b/scripts/docker/finish_boost.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e ARCH=$1 PREFIX=$2 diff --git a/scripts/docker/init_boost.sh b/scripts/docker/init_boost.sh old mode 100644 new mode 100755 index ffb7a1416..068647e1f --- a/scripts/docker/init_boost.sh +++ b/scripts/docker/init_boost.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -x -e + ARCH=$1 PREFIX=$2 @@ -17,6 +19,6 @@ echo $BOOST_SHA256 $BOOST_FILE_PATH | sha256sum -c - || exit 1 cd $WORKDIR rm -rf $BOOST_SRC_DIR rm -rf $PREFIX/include/boost -tar -xvf $BOOST_FILE_PATH -C $WORKDIR +tar -xf $BOOST_FILE_PATH -C $WORKDIR cd $BOOST_SRC_DIR -./bootstrap.sh --prefix=${PREFIX} +./bootstrap.sh --prefix=${PREFIX} --with-toolset=gcc diff --git a/scripts/docker/install_ndk.sh b/scripts/docker/install_ndk.sh old mode 100644 new mode 100755 index 5f97751e3..94373954c --- a/scripts/docker/install_ndk.sh +++ b/scripts/docker/install_ndk.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x -e . ./config.sh TOOLCHAIN_DIR=${WORKDIR}/toolchain diff --git a/scripts/prepare_moneroc.sh b/scripts/prepare_moneroc.sh new file mode 100755 index 000000000..0ae270588 --- /dev/null +++ b/scripts/prepare_moneroc.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -x -e + +cd "$(dirname "$0")" + + + +if [[ ! -d "monero_c" ]]; +then + git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip + cd monero_c + git checkout cd90f3bcd0349759030751ec7ce84eec6ee80c43 + git reset --hard + git submodule update --init --force --recursive + ./apply_patches.sh monero + ./apply_patches.sh wownero +else + cd monero_c +fi + +if [[ ! -f "monero/.patch-applied" ]]; +then + ./apply_patches.sh monero +fi + +if [[ ! -f "wownero/.patch-applied" ]]; +then + ./apply_patches.sh wownero +fi +cd .. + +echo "monero_c source prepared". diff --git a/tool/configure.dart b/tool/configure.dart index ceb0c9ccc..8c77f16e9 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -207,7 +207,6 @@ Future generateMonero(bool hasImplementation) async { const moneroCommonHeaders = """ import 'package:cw_core/unspent_transaction_output.dart'; import 'package:cw_core/unspent_coins_info.dart'; -import 'package:cw_monero/monero_unspent.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -224,6 +223,7 @@ import 'package:polyseed/polyseed.dart';"""; import 'package:cw_core/get_height_by_date.dart'; import 'package:cw_core/monero_amount_format.dart'; import 'package:cw_core/monero_transaction_priority.dart'; +import 'package:cw_monero/monero_unspent.dart'; import 'package:cw_monero/monero_wallet_service.dart'; import 'package:cw_monero/monero_wallet.dart'; import 'package:cw_monero/monero_transaction_info.dart'; @@ -320,6 +320,8 @@ abstract class Monero { List getUnspents(Object wallet); Future updateUnspents(Object wallet); + Future getCurrentHeight(); + WalletCredentials createMoneroRestoreWalletFromKeysCredentials({ required String name, required String spendKey, @@ -1085,8 +1087,10 @@ Future generatePubspec( final inputFile = File(pubspecOutputPath); final inputText = await inputFile.readAsString(); final inputLines = inputText.split('\n'); - final dependenciesIndex = - inputLines.indexWhere((line) => line.toLowerCase().contains('dependencies:')); + final dependenciesIndex = inputLines.indexWhere( + (line) => Platform.isWindows + ? line.toLowerCase() == 'dependencies:\r' // On Windows it could contains `\r` (Carriage Return) + : line.toLowerCase() == 'dependencies:'); var output = cwCore; if (hasMonero) { diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 000000000..d492d0d98 --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 000000000..76256dc45 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,102 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(cake_wallet LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "CakeWallet") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 000000000..930d2071a --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 000000000..565f9eec5 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,29 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + FlutterSecureStorageWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); + LocalAuthPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("LocalAuthPlugin")); + PermissionHandlerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + PlatformDeviceIdWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 000000000..dc139d85a --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 000000000..74f32ec52 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,29 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + connectivity_plus_windows + flutter_secure_storage_windows + local_auth_windows + permission_handler_windows + platform_device_id_windows + url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 000000000..394917c05 --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 000000000..0a899f86e --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.cakewallet.cake_wallet" "\0" + VALUE "FileDescription", "Cake Wallet" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "Cake Wallet" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 Cake Wallet. All rights reserved." "\0" + VALUE "OriginalFilename", "Cake Wallet.exe" "\0" + VALUE "ProductName", "Cake Wallet" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 000000000..955ee3038 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 000000000..6da0652f0 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 000000000..a7eecbf9c --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"Cake Wallet", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 000000000..66a65d1e4 --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 000000000..242fb9cb5 Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 000000000..a42ea7687 --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 000000000..b2b08734d --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 000000000..3879d5475 --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 000000000..60608d0fe --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 000000000..e901dde68 --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_