├── .gitattributes
├── .gitignore
├── .gitlab-ci.yml
├── .npmignore
├── CHANGELOG.md
├── README.md
├── RNFastCrypto.podspec
├── android
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── co
│ └── airbitz
│ └── fastcrypto
│ ├── MoneroAsyncTask.java
│ ├── RNFastCryptoModule.java
│ ├── RNFastCryptoPackage.java
│ └── ReadSettingsAsyncTask.java
├── build-deps
├── docs
└── model.md
├── generate-sums.sh
├── index.js
├── install.sh
├── ios
├── Headers
│ └── native-crypto.h
├── NSArray+Map.h
├── NSArray+Map.m
├── RNFastCrypto.h
├── RNFastCrypto.m
└── RNFastCrypto.xcodeproj
│ └── project.pbxproj
├── native-libs
├── .gitignore
├── Makefile
├── deps
│ ├── .gitignore
│ ├── Makefile
│ ├── classes
│ │ ├── android
│ │ ├── android.toolchain.cmake
│ │ ├── common
│ │ ├── ios
│ │ ├── ios.toolchain.cmake
│ │ ├── lib
│ │ ├── native
│ │ ├── native.cmake
│ │ ├── osx
│ │ └── osx.toolchain.cmake
│ ├── documentation.md
│ ├── recipes
│ │ ├── boost
│ │ │ ├── boost.recipe
│ │ │ ├── fix-asio-android.patch
│ │ │ ├── operations.cpp.patch
│ │ │ └── user-config.jam
│ │ ├── jni-bridge
│ │ │ ├── CMakeLists.txt
│ │ │ └── jni-bridge.recipe
│ │ ├── monerocorecustom
│ │ │ └── monerocorecustom.recipe
│ │ ├── mymonerocorecpp
│ │ │ ├── CMakeLists.txt
│ │ │ └── mymonerocorecpp.recipe
│ │ ├── nativecrypto
│ │ │ └── nativecrypto.recipe
│ │ └── ndk
│ │ │ ├── langinfo.h
│ │ │ └── ndk.recipe
│ └── run.sh
├── jni-bridge
│ └── crypto_bridge.cpp
├── src
│ ├── .gitignore
│ ├── native-crypto.cpp
│ └── native-crypto.h
└── test
│ ├── README.md
│ ├── input
│ ├── blocks.json.gzip
│ ├── d.bin
│ └── input.json
│ └── main.cpp
├── package.json
└── shasums.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # OSX
3 | #
4 | .DS_Store
5 |
6 | # node.js
7 | #
8 | node_modules/
9 | npm-debug.log
10 | yarn-error.log
11 |
12 |
13 | # Xcode
14 | #
15 | build/
16 | build*/
17 | *.pbxuser
18 | !default.pbxuser
19 | *.mode1v3
20 | !default.mode1v3
21 | *.mode2v3
22 | !default.mode2v3
23 | *.perspectivev3
24 | !default.perspectivev3
25 | xcuserdata
26 | *.xccheckout
27 | *.moved-aside
28 | DerivedData
29 | *.hmap
30 | *.ipa
31 | *.xcuserstate
32 | project.xcworkspace
33 |
34 |
35 | # Android/IntelliJ
36 | #
37 | build/
38 | .idea
39 | .gradle
40 | local.properties
41 | *.iml
42 | android/.cxx
43 | android/.externalNativeBuild
44 |
45 | # BUCK
46 | buck-out/
47 | \.buckd/
48 | *.keystore
49 |
50 | # Binaries
51 | ios/Libraries/
52 | ios/Frameworks/
53 | android/jni/libs/
54 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | build:
2 | image: node:10.15.3
3 | tags:
4 | - mac-runner
5 | when: manual
6 | script:
7 | - ./build-deps
8 | - shasum -a 256 ios/Libraries/* android/jni/libs/*/* > shasums.txt
9 | - cat shasums.txt
10 | artifacts:
11 | paths:
12 | - ./android
13 | - ./ios
14 | - ./native-libs/deps/classes
15 | - ./native-libs/deps/recipes
16 | - ./native-libs/deps/.gitignore
17 | - ./native-libs/deps/Makefile
18 | - ./native-libs/deps/documentation.md
19 | - ./native-libs/deps/run.sh
20 | - ./native-libs/src
21 | - ./native-libs/.gitignore
22 | - ./native-libs/Makefile
23 | - ./.gitattributes
24 | - ./.gitignore
25 | - ./.gitlab-ci.yml
26 | - ./.npmignore
27 | - ./CHANGELOG.md
28 | - ./README.md
29 | - ./build-deps
30 | - ./index.js
31 | - ./package.json
32 | - ./shasums.txt
33 | expire_in: 1 week
34 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 |
2 | # OSX
3 | #
4 | .DS_Store
5 |
6 | # node.js
7 | #
8 | node_modules/
9 | npm-debug.log
10 | yarn-error.log
11 |
12 |
13 | # Xcode
14 | #
15 | build/
16 | *.pbxuser
17 | !default.pbxuser
18 | *.mode1v3
19 | !default.mode1v3
20 | *.mode2v3
21 | !default.mode2v3
22 | *.perspectivev3
23 | !default.perspectivev3
24 | xcuserdata
25 | *.xccheckout
26 | *.moved-aside
27 | DerivedData
28 | *.hmap
29 | *.ipa
30 | *.xcuserstate
31 | project.xcworkspace
32 |
33 |
34 | # Android/IntelliJ
35 | #
36 | build/
37 | .idea
38 | .gradle
39 | local.properties
40 | *.iml
41 |
42 | # BUCK
43 | buck-out/
44 | \.buckd/
45 | *.keystore
46 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # react-native-fast-crypto
2 |
3 | ## 1.8.1 (2019-04-22)
4 |
5 | - Fix compatibility with React Native v0.59.
6 |
7 | ## 1.8.0 (2019-04-03)
8 |
9 | - Add a podspec file.
10 | - Add 64-bit builds for Android.
11 |
12 | ## 1.7.0 (2019-03-07)
13 |
14 | - Upgrade `mymonero-core-cpp` for the v0.14.0 hard fork.
15 | - Remove inappropriate logging in Android.
16 | - Clarify the `peerDependencies` version range for react-native.
17 |
18 | ## 1.6.0
19 |
20 | * Add support for monero core libaries
21 | *
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-fast-crypto
2 |
3 | This library implements fast, fully native crypto routines for React Native under iOS and Android. Fully built binaries are committed for both platforms but can also be built from scratch.
4 |
5 | ## Getting started
6 |
7 | `npm install react-native-fast-crypto --save`
8 |
9 | ### Mostly automatic installation
10 |
11 | `react-native link react-native-fast-crypto`
12 |
13 | ### Manual installation
14 |
15 | #### Install in iOS app
16 |
17 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
18 | 2. Go to `node_modules` ➜ `react-native-fast-crypto` and add `RNFastCrypto.xcodeproj`
19 | 3. In XCode, in the project navigator, select your project. Add `libRNFastCrypto.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
20 | 4. Run your project (`Cmd+R`)<
21 |
22 | #### Install in Android app
23 |
24 | 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25 |
26 | - Add `import com.reactlibrary.RNFastCryptoPackage;` to the imports at the top of the file
27 | - Add `new RNFastCryptoPackage()` to the list returned by the `getPackages()` method
28 |
29 | 2. Append the following lines to `android/settings.gradle`:
30 | ```
31 | include ':react-native-fast-crypto'
32 | project(':react-native-fast-crypto').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-crypto/android')
33 | ```
34 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
35 | ```
36 | compile project(':react-native-fast-crypto')
37 | ```
38 |
39 | ## Build the C/C++ binaries from scratch (optional)
40 |
41 | ### Prerequisites
42 |
43 | - Xcode (13.3 or later should work)
44 | - brew
45 |
46 | ### Setup
47 |
48 | ```bash
49 | sudo xcode-select --switch /Applications/Xcode.app
50 | sudo xcodebuild -license
51 |
52 | brew install autoconf automake cmake git pkgconfig protobuf python zlib
53 |
54 | sudo mkdir -p /usr/local/bin
55 | sudo ln -sf $(brew --prefix python)/bin/python3 /usr/local/bin/python
56 | ```
57 |
58 | ### Build
59 |
60 | 1. Build binaries
61 |
62 | ```bash
63 | rm -rf /tmp/react-native-fast-crypto
64 | git clone git@github.com:ExodusMovement/react-native-fast-crypto.git /tmp/react-native-fast-crypto
65 | cd /tmp/react-native-fast-crypto
66 | yarn build
67 | ```
68 |
69 | (if you're building on Apple arm, M1 & M2, you can use `arch -x86_64 yarn build` instead of `yarn build`)
70 |
--------------------------------------------------------------------------------
/RNFastCrypto.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = "RNFastCrypto"
7 | s.version = package['version']
8 | s.summary = "RNFastCrypto"
9 | s.description = package['description']
10 | s.homepage = "https://github.com/ExodusMovement/react-native-fast-crypto"
11 | s.license = "MIT"
12 | s.author = { "Paul Puey" => "paul@airbitz.co" }
13 | s.platform = :ios, "7.0"
14 | s.source = { :git => "https://github.com/ExodusMovement/react-native-fast-crypto.git", :tag => "v#{s.version}" }
15 | s.source_files = "ios/**/*.{h,m}"
16 | s.requires_arc = true
17 | s.vendored_frameworks = "ios/Frameworks/*.xcframework"
18 |
19 | s.dependency "React-Core"
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | react-native-fast-crypto
4 | Project react-native-fast-crypto created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
25 | 1668329318660
26 |
27 | 30
28 |
29 | org.eclipse.core.resources.regexFilterMatcher
30 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | #Sun Aug 06 08:29:54 PDT 2017
2 | connection.project.dir=../../../android
3 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.4.0'
10 | }
11 | }
12 |
13 | apply plugin: 'com.android.library'
14 |
15 | def safeExtGet(prop, fallback) {
16 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
17 | }
18 |
19 | android {
20 | compileSdkVersion safeExtGet('compileSdkVersion', 26)
21 | buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')
22 |
23 | defaultConfig {
24 | minSdkVersion safeExtGet('minSdkVersion', 19)
25 | targetSdkVersion safeExtGet('targetSdkVersion', 26)
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 |
30 | lintOptions {
31 | abortOnError false
32 | }
33 |
34 | // If you want Gradle to package prebuilt native libraries
35 | // with your APK, modify the default source set configuration
36 | // to include the directory of your prebuilt .so files as follows.
37 | sourceSets {
38 | main {
39 | jniLibs.srcDirs 'jni/libs/'
40 | }
41 | }
42 | }
43 |
44 | repositories {
45 | mavenCentral()
46 | google()
47 | }
48 |
49 | dependencies {
50 | implementation 'com.facebook.react:react-native:+'
51 | }
52 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ExodusMovement/react-native-fast-crypto/4e3cf8723118b40f79fdb878a419654a794607d9/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue May 12 17:54:55 CEST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/src/main/java/co/airbitz/fastcrypto/MoneroAsyncTask.java:
--------------------------------------------------------------------------------
1 | package co.airbitz.fastcrypto;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 |
6 | import com.facebook.react.bridge.Promise;
7 |
8 | import org.json.JSONObject;
9 |
10 | import java.io.BufferedInputStream;
11 | import java.io.ByteArrayOutputStream;
12 | import java.io.DataInputStream;
13 | import java.io.InputStream;
14 | import java.io.IOException;
15 | import java.io.OutputStream;
16 | import java.io.InputStreamReader;
17 | import java.net.HttpURLConnection;
18 | import java.net.URL;
19 | import java.nio.ByteBuffer;
20 | import java.util.concurrent.atomic.AtomicBoolean;
21 | import java.util.function.BiFunction;
22 |
23 | public class MoneroAsyncTask extends android.os.AsyncTask {
24 | final long MAX_BYTES = 100L * 1024L * 1024L; // 100 MB
25 |
26 | static {
27 |
28 | // this loads the library when the class is loaded
29 | System.loadLibrary("nativecrypto");
30 | System.loadLibrary("crypto_bridge"); // this loads the library when the class is loaded
31 | }
32 |
33 | private final String method;
34 | private final String jsonParams;
35 | private final String userAgent;
36 | private final Promise promise;
37 | private final AtomicBoolean isStopped;
38 |
39 | public MoneroAsyncTask(String method, String jsonParams, String userAgent, AtomicBoolean isStopped,
40 | Promise promise) {
41 | this.method = method;
42 | this.jsonParams = jsonParams;
43 | this.userAgent = userAgent;
44 | this.promise = promise;
45 | this.isStopped = isStopped;
46 | }
47 |
48 | public native String moneroCoreJNI(String method, String jsonParams);
49 |
50 | public native int moneroCoreCreateRequest(ByteBuffer requestBuffer, int height);
51 |
52 | public native String extractUtxosFromBlocksResponse(ByteBuffer buffer, String jsonParams);
53 |
54 | public native String extractUtxosFromClarityBlocksResponse(ByteBuffer buffer, String jsonParams);
55 |
56 | public native String getTransactionPoolHashes(ByteBuffer buffer);
57 |
58 | @Override
59 | protected Void doInBackground(Void... voids) {
60 | if (method.equals("download_and_process")) {
61 | HttpURLConnection connection = null;
62 | try {
63 | JSONObject params = new JSONObject(jsonParams);
64 | String addr = params.getString("url");
65 | int startHeight = params.getInt("start_height");
66 | ByteBuffer requestBuffer = ByteBuffer.allocateDirect(1000);
67 | int requestLength = moneroCoreCreateRequest(requestBuffer, startHeight);
68 |
69 | if (requestLength == -1) {
70 | throw new Exception("Invalid ByteBuffer passed to native method.");
71 | } else if (requestLength == -2) {
72 | throw new Exception("Failed to get ByteBuffer capacity.");
73 | } else if (requestLength == -3) {
74 | throw new Exception("Failed to create blocks request.");
75 | } else if (requestLength == -4) {
76 | throw new Exception("Buffer capacity is too small for the generated request.");
77 | }
78 |
79 | URL url = new URL(addr);
80 | connection = (HttpURLConnection) url.openConnection();
81 | connection.setRequestMethod("POST");
82 | connection.setRequestProperty("Content-Type", "application/octet-stream");
83 | connection.setRequestProperty("User-Agent", userAgent);
84 | connection.setConnectTimeout(10000);
85 | connection.setReadTimeout(4 * 60 * 1000);
86 | connection.setDoOutput(true);
87 | try (OutputStream outputStream = connection.getOutputStream()) {
88 | for (int i = 0; i < requestLength; i++) {
89 | if (isStopped.get()) {
90 | throw new Exception("Operations are stopped");
91 | }
92 | outputStream.write(requestBuffer.get(i));
93 | }
94 | }
95 | connection.connect();
96 |
97 | String contentLengthStr = connection.getHeaderField("Content-Length");
98 | int responseLength = validateContentLengthHeader(contentLengthStr);
99 | try (DataInputStream dataInputStream = new DataInputStream(connection.getInputStream())) {
100 | String out = readAndProcessBinaryData(dataInputStream, responseLength,
101 | this::extractUtxosFromBlocksResponse);
102 | promise.resolve(out);
103 | }
104 | } catch (Exception e) {
105 | String detailedError = String.format(
106 | "{\"err_msg\":\"Exception occurred: %s\"}",
107 | e.getMessage() != null ? e.getMessage() : "Unknown exception");
108 | promise.resolve(detailedError);
109 | } finally {
110 | if (connection != null) {
111 | connection.disconnect();
112 | }
113 | }
114 | return null;
115 | } else if (method.equals("download_from_clarity_and_process")) {
116 | HttpURLConnection connection = null;
117 | try {
118 | // Parse the JSON parameters
119 | JSONObject params = new JSONObject(jsonParams);
120 | String addr = params.getString("url");
121 | URL url = new URL(addr);
122 |
123 | // Set up the HTTP connection
124 | connection = (HttpURLConnection) url.openConnection();
125 | connection.setRequestMethod("GET");
126 | connection.setRequestProperty("User-Agent", userAgent);
127 | connection.setConnectTimeout(10000);
128 | connection.setReadTimeout(4 * 60 * 1000);
129 |
130 | connection.connect();
131 |
132 | // Check the response code
133 | int responseCode = connection.getResponseCode();
134 | if (responseCode != HttpURLConnection.HTTP_OK) {
135 | // Read the error stream if available
136 | String errorMessage = readErrorStreamAsString(connection);
137 | String detailedError = String.format(
138 | "{\"err_msg\":\"[Clarity] HTTP Error %d: %s\"}",
139 | responseCode,
140 | errorMessage.isEmpty() ? "Unknown error" : errorMessage);
141 | promise.resolve(detailedError);
142 | return null;
143 | }
144 |
145 | try (InputStream inputStream = new BufferedInputStream(connection.getInputStream(), 8192)) {
146 | String result = readAndProcessJsonData(inputStream, this::extractUtxosFromClarityBlocksResponse);
147 |
148 | if (result == null) {
149 | throw new Exception("Processing failed");
150 | } else {
151 | promise.resolve(result);
152 | }
153 | }
154 | } catch (Exception e) {
155 | String detailedError = String.format(
156 | "{\"err_msg\":\"Exception occurred: %s\"}",
157 | e.getMessage() != null ? e.getMessage() : "Unknown exception");
158 | promise.resolve(detailedError);
159 | } finally {
160 | if (connection != null) {
161 | connection.disconnect();
162 | }
163 | }
164 | return null;
165 | } else if (method.equals("get_transaction_pool_hashes")) {
166 | try {
167 | JSONObject params = new JSONObject(jsonParams);
168 | String addr = params.getString("url");
169 | URL url = new URL(addr);
170 | HttpURLConnection connection = (HttpURLConnection) url.openConnection();
171 | connection.setRequestMethod("POST");
172 | connection.setRequestProperty("User-Agent", userAgent);
173 | connection.setConnectTimeout(5000);
174 | connection.setReadTimeout(5000);
175 | connection.connect();
176 | try (DataInputStream dataInputStream = new DataInputStream(connection.getInputStream())) {
177 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();
178 |
179 | int totalBytes = 0;
180 | byte[] tmp = new byte[8192];
181 |
182 | int nRead = 0;
183 | while ((nRead = dataInputStream.read(tmp, 0, tmp.length)) != -1) {
184 | buffer.write(tmp, 0, nRead);
185 | totalBytes += nRead;
186 | }
187 |
188 | ByteBuffer responseBuffer = ByteBuffer.allocateDirect(totalBytes);
189 | responseBuffer.put(buffer.toByteArray(), 0, totalBytes);
190 | String out = getTransactionPoolHashes(responseBuffer);
191 | promise.resolve(out);
192 | }
193 | } catch (Exception e) {
194 | promise.reject("Err", e);
195 | }
196 | return null;
197 | }
198 | try {
199 | String reply = moneroCoreJNI(method, jsonParams); // test response from JNI
200 | promise.resolve(reply);
201 | } catch (Exception e) {
202 | promise.reject("Err", e);
203 | }
204 | return null;
205 | }
206 |
207 | private int validateContentLengthHeader(String contentLengthStr) throws Exception {
208 | if (contentLengthStr == null) {
209 | throw new Exception("Missing Content-Length header");
210 | }
211 |
212 | try {
213 | int contentLength = Integer.parseInt(contentLengthStr);
214 | if (contentLength < 0) {
215 | throw new Exception("Invalid Content-Length header");
216 | }
217 | if (contentLength > MAX_BYTES) {
218 | throw new Exception("Content-Length exceeds allowed maximum of 100 MB");
219 | }
220 | return contentLength;
221 | } catch (NumberFormatException e) {
222 | throw new Exception("Cannot parse Content-Length header");
223 | }
224 | }
225 |
226 | private String readAndProcessBinaryData(DataInputStream dataInputStream, int responseLength,
227 | BiFunction extractUtxos) throws Exception {
228 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();
229 | byte[] tmp = new byte[8192];
230 |
231 | int nRead = 0;
232 | while (buffer.size() < responseLength) {
233 | if (isStopped.get()) {
234 | throw new Exception("Downloading stopped by user");
235 | }
236 | nRead = dataInputStream.read(tmp, 0, Math.min(tmp.length, responseLength - buffer.size()));
237 | if (nRead == -1) {
238 | throw new Exception("Unexpected end of stream");
239 | }
240 | buffer.write(tmp, 0, nRead);
241 | }
242 |
243 | // Check for cancellation after download is complete
244 | if (isStopped.get()) {
245 | throw new Exception("Processing stopped by user");
246 | }
247 |
248 | ByteBuffer responseBuffer = null;
249 | try {
250 | responseBuffer = ByteBuffer.allocateDirect(responseLength);
251 | responseBuffer.put(buffer.toByteArray(), 0, responseLength);
252 |
253 | String out = extractUtxos.apply(responseBuffer, jsonParams);
254 | if (out == null) {
255 | throw new Exception("Internal error: Memory allocation failed");
256 | }
257 |
258 | if (isStopped.get()) {
259 | throw new Exception("Operations are stopped");
260 | }
261 |
262 | return out;
263 | } finally {
264 | if (responseBuffer != null) {
265 | responseBuffer.clear();
266 | }
267 | }
268 | }
269 |
270 | private String readAndProcessJsonData(InputStream inputStream, BiFunction extractUtxos)
271 | throws Exception {
272 | try {
273 | byte[] jsonBytes = readInputStreamAsBytes(inputStream);
274 |
275 | // Convert JSON string to ByteBuffer
276 | ByteBuffer responseBuffer = ByteBuffer.allocateDirect(jsonBytes.length);
277 | responseBuffer.put(jsonBytes);
278 | responseBuffer.flip(); // Prepare the buffer for reading
279 |
280 | // Process the JSON data
281 | String out = extractUtxos.apply(responseBuffer, jsonParams);
282 | if (out == null) {
283 | throw new Exception("Internal error: Memory allocation failed");
284 | }
285 |
286 | return out;
287 | } catch (IOException e) {
288 | throw new Exception("Error reading JSON data: " + e.getMessage(), e);
289 | }
290 | }
291 |
292 | /**
293 | * Reads an InputStream fully and converts it to a byte array.
294 | */
295 | private byte[] readInputStreamAsBytes(InputStream inputStream) throws IOException {
296 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8192);
297 | byte[] buffer = new byte[8192]; // 8 KB read buffer
298 | int bytesRead;
299 | long totalBytesRead = 0;
300 |
301 | while ((bytesRead = inputStream.read(buffer)) != -1) {
302 | if (isStopped.get()) {
303 | throw new IOException("Downloading stopped by user");
304 | }
305 | totalBytesRead += bytesRead;
306 | if (totalBytesRead > MAX_BYTES) {
307 | throw new IOException("Input stream exceeded maximum allowed size of 100 MB");
308 | }
309 |
310 | byteArrayOutputStream.write(buffer, 0, bytesRead);
311 | }
312 | return byteArrayOutputStream.toByteArray();
313 | }
314 |
315 | /**
316 | * Reads the error stream from the HTTP connection and converts it to a String.
317 | */
318 | private String readErrorStreamAsString(HttpURLConnection connection) {
319 | try (InputStream errorStream = connection.getErrorStream()) {
320 | if (errorStream != null) {
321 | return new String(readInputStreamAsBytes(errorStream), "UTF-8");
322 | }
323 | } catch (IOException e) {
324 | return "Failed to read error stream";
325 | }
326 | return "";
327 | }
328 | };
329 |
--------------------------------------------------------------------------------
/android/src/main/java/co/airbitz/fastcrypto/RNFastCryptoModule.java:
--------------------------------------------------------------------------------
1 |
2 | package co.airbitz.fastcrypto;
3 |
4 | import android.os.AsyncTask;
5 |
6 | import com.facebook.react.bridge.Promise;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
9 | import com.facebook.react.bridge.ReactMethod;
10 | import java.util.concurrent.atomic.AtomicBoolean;
11 | import java.util.Arrays;
12 |
13 | public class RNFastCryptoModule extends ReactContextBaseJavaModule {
14 |
15 | private final ReactApplicationContext reactContext;
16 | private final String userAgent;
17 | private AtomicBoolean isStopped = new AtomicBoolean(false);
18 |
19 | public RNFastCryptoModule(ReactApplicationContext reactContext, String userAgent) {
20 | super(reactContext);
21 | this.reactContext = reactContext;
22 | this.userAgent = userAgent;
23 | }
24 |
25 | @Override
26 | public String getName() {
27 | return "RNFastCrypto";
28 | }
29 |
30 | @ReactMethod
31 | public void moneroCore(
32 | final String method,
33 | final String jsonParams,
34 | final Promise promise) {
35 | if ("stop_processing_task".equals(method)) {
36 | isStopped.set(true);
37 | promise.resolve("{\"success\":true}");
38 | } else {
39 | if (Arrays.asList("download_and_process", "download_from_clarity_and_process").contains(method)) {
40 | isStopped.set(false);
41 | }
42 | AsyncTask task = new MoneroAsyncTask(method, jsonParams, userAgent, isStopped, promise);
43 | task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
44 | }
45 | }
46 |
47 | @ReactMethod
48 | public void readSettings(final String directory, final String filePrefix, final Promise promise) {
49 | AsyncTask task = new ReadSettingsAsyncTask(directory, filePrefix, promise);
50 | task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/android/src/main/java/co/airbitz/fastcrypto/RNFastCryptoPackage.java:
--------------------------------------------------------------------------------
1 |
2 | package co.airbitz.fastcrypto;
3 |
4 | import java.util.Arrays;
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | import com.facebook.react.ReactPackage;
9 | import com.facebook.react.bridge.NativeModule;
10 | import com.facebook.react.bridge.ReactApplicationContext;
11 | import com.facebook.react.uimanager.ViewManager;
12 | import com.facebook.react.bridge.JavaScriptModule;
13 | public class RNFastCryptoPackage implements ReactPackage {
14 | private final String userAgent;
15 |
16 | public RNFastCryptoPackage(String userAgent) {
17 | this.userAgent = userAgent;
18 | }
19 |
20 | @Override
21 | public List createNativeModules(ReactApplicationContext reactContext) {
22 | return Arrays.asList(new RNFastCryptoModule(reactContext, userAgent));
23 | }
24 |
25 | public List> createJSModules() {
26 | return Collections.emptyList();
27 | }
28 |
29 | @Override
30 | public List createViewManagers(ReactApplicationContext reactContext) {
31 | return Collections.emptyList();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/android/src/main/java/co/airbitz/fastcrypto/ReadSettingsAsyncTask.java:
--------------------------------------------------------------------------------
1 | package co.airbitz.fastcrypto;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import com.facebook.react.bridge.Arguments;
6 | import com.facebook.react.bridge.Promise;
7 | import com.facebook.react.bridge.WritableMap;
8 |
9 | import java.io.File;
10 | import java.util.ArrayList;
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | public class ReadSettingsAsyncTask extends AsyncTask {
15 | private final String directory;
16 | private final String filePrefix;
17 | private final Promise promise;
18 |
19 | public ReadSettingsAsyncTask(String directory, String filePrefix, Promise promise) {
20 | this.directory = directory;
21 | this.filePrefix = filePrefix;
22 | this.promise = promise;
23 | }
24 |
25 | @Override
26 | protected Void doInBackground(Void... voids) {
27 | try {
28 | File file = new File(directory);
29 |
30 | if (!file.exists()) throw new Exception("Folder does not exist");
31 |
32 | File[] files = file.listFiles();
33 |
34 | List values = new ArrayList<>();
35 |
36 | for (File childFile : files) {
37 | String fileName = childFile.getName();
38 | if (!fileName.startsWith(filePrefix) || !fileName.endsWith(".json") || fileName.contains("enabled")) continue;
39 |
40 | String name = fileName.replace(filePrefix, "").replace(".json", "");
41 |
42 | values.add(Integer.parseInt(name));
43 | }
44 |
45 | WritableMap responseMap = Arguments.createMap();
46 |
47 | if (values.size() == 0) {
48 | promise.resolve(responseMap);
49 | return null;
50 | }
51 |
52 | responseMap.putInt("size", values.size());
53 | responseMap.putInt("oldest", Collections.min(values));
54 | responseMap.putInt("latest", Collections.max(values));
55 |
56 | promise.resolve(responseMap);
57 | } catch (Exception ex) {
58 | ex.printStackTrace();
59 | promise.reject("Err", ex);
60 | }
61 |
62 | return null;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/build-deps:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export ZERO_AR_DATE=1
3 | export SOURCE_DATE_EPOCH=0
4 |
5 | NATIVE_TESTS=$NATIVE_TESTS
6 |
7 | # List of dependencies that should be rebuilt.
8 | # If you specify dependency source that doesn't change (local directory)
9 | # add this dependency there so new files are copied during a build.
10 | reactive_deps=(
11 | nativecrypto
12 | jni-bridge
13 | )
14 |
15 | set -u
16 | set -e
17 |
18 | echo Build Started
19 | date
20 |
21 | if [ Darwin = $(uname -s) ]; then
22 | MACOSV=$(sw_vers -productVersion)
23 | XCODEV=$(xcodebuild -version)
24 |
25 | echo "macOS $MACOSV - $XCODEV"
26 | fi
27 |
28 | # Pick up the current directory:
29 | CURRENT_DIR=$(pwd)
30 | export BUILD_DIR=$CURRENT_DIR/native-libs/deps/build
31 | #if [ -z ${BUILD_DIR+x} ]; then
32 | # export BUILD_DIR=${BUILD_DIR:-$CURRENT_DIR/native-libs/deps/build};
33 | #fi
34 |
35 | # Do the build:
36 |
37 | for dep in "${reactive_deps[@]}"; do
38 | touch native-libs/deps/recipes/$dep/$dep.recipe
39 | done
40 |
41 | (
42 | targets=""
43 |
44 | if [[ "$NATIVE_TESTS" -eq "1" ]]; then
45 | targets="$targets nativecrypto.build-native"
46 | else
47 | if [ Darwin = $(uname -s) ]; then
48 | targets="$targets nativecrypto.package-ios-universal"
49 | fi
50 |
51 | targets="$targets jni-bridge.build-android-arm"
52 | targets="$targets jni-bridge.build-android-arm64"
53 | targets="$targets jni-bridge.build-android-x86"
54 | targets="$targets jni-bridge.build-android-x86_64"
55 | fi
56 |
57 | cd native-libs/deps
58 | make $targets $@
59 | )
60 |
61 | if [[ "$NATIVE_TESTS" -eq "1" ]]; then
62 | cd native-libs
63 | make check V=1 T=1
64 | echo "Finished running tests."
65 | exit 0
66 | fi
67 |
68 | # Copy the results locally:
69 | if [ Darwin = $(uname -s) ]; then
70 | mkdir -m 0775 -p ios/Headers
71 | mkdir -m 0775 -p ios/Frameworks
72 | cp -aL $BUILD_DIR/nativecrypto/nativecrypto-ios-universal/include/* ios/Headers
73 | cp -a $BUILD_DIR/nativecrypto/nativecrypto-ios-universal/*.xcframework ios/Frameworks
74 | fi
75 |
76 | BASE="./android"
77 | JNI_DIR="$BASE/jni"
78 | JNI_BUILD_DIR="$JNI_DIR/libs"
79 | ANDROID_PATH="$BASE/src/main"
80 |
81 | rm -rf $JNI_BUILD_DIR
82 | mkdir -p $JNI_BUILD_DIR/armeabi-v7a
83 | mkdir -p $JNI_BUILD_DIR/arm64-v8a
84 | mkdir -p $JNI_BUILD_DIR/x86
85 | mkdir -p $JNI_BUILD_DIR/x86_64
86 |
87 | # Copy Android libraries:
88 | copy_so() {
89 | echo cp $BUILD_DIR/nativecrypto/android-$1/libnativecrypto.so $JNI_BUILD_DIR/$2/
90 | cp $BUILD_DIR/nativecrypto/android-$1/libnativecrypto.so $JNI_BUILD_DIR/$2/
91 |
92 | echo cp $BUILD_DIR/jni-bridge/android-$1/build/libcrypto_bridge.so $JNI_BUILD_DIR/$2/
93 | cp $BUILD_DIR/jni-bridge/android-$1/build/libcrypto_bridge.so $JNI_BUILD_DIR/$2/
94 | }
95 | copy_so arm armeabi-v7a
96 | copy_so arm64 arm64-v8a
97 | copy_so x86 x86
98 | copy_so x86_64 x86_64
99 |
100 | echo Build Finished
101 | date
102 |
--------------------------------------------------------------------------------
/docs/model.md:
--------------------------------------------------------------------------------
1 | # Models
2 |
3 | ## download_and_process
4 |
5 | ### Introduce
6 | We call this method at [Monero asset lib](https://github.com/ExodusMovement/assets/blob/main/monero/monero-lib/src/monero-interface.js#L65-L73)
7 | ```
8 | const resp = await this.send(method ?? 'download_and_process', {
9 | url,
10 | start_height: cursor,
11 | storage_path: storageSettings.path,
12 | storage_percent: storageSettings.percent,
13 | latest: storageSettings.latest,
14 | oldest: Number.isFinite(storageSettings.oldest) ? storageSettings.oldest : 1_099_511_627_776,
15 | size: storageSettings.size,
16 | params_by_wallet_account: nativeParams,
17 | })
18 | ```
19 |
20 | ### Model of jsonParams
21 |
22 | #### Fields definition
23 | - url: string
24 | - start_height: number
25 | - storage_path: string
26 | - storage_percent: number
27 | - latest: number
28 | - oldest: number
29 | - size: number
30 | - params_by_wallet_account: object
31 |
32 |
33 | #### Example
34 | ```json
35 | {
36 | "url": "https://xmr-d.a.exodus.io/get_blocks.bin",
37 | "start_height": 3120123,
38 | "storage_path": "/tmp",
39 | "storage_percent": 10,
40 | "latest": 2077262,
41 | "oldest": 2075072,
42 | "size": 330,
43 | "params_by_wallet_account": {
44 | "exodus_0": {
45 | "subaddresses": 200,
46 | "key_images": [],
47 | "sec_viewKey_string": "12de640c5e8e7e318ee701ca4801287f13c657b8290073338b57caa44b21c505",
48 | "pub_spendKey_string": "df9cee70033050334f5b1b94b180fa2c08c96149354df0c5337c251b78f01d3a",
49 | "sec_spendKey_string": "f3be56ce634c13d47f8170e4f44f9643d4072a28a73d9dc080a5b0dc2ee4a90b"
50 | }
51 | }
52 | }
53 | ```
54 |
55 |
--------------------------------------------------------------------------------
/generate-sums.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | FILE=shasums.txt
4 |
5 | rm -rf $FILE
6 | shasum -a 256 ios/Frameworks/*/*/* >> $FILE 2>/dev/null
7 | shasum -a 256 android/jni/libs/*/* >> $FILE 2>/dev/null
8 |
9 | exit 0
10 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | import { NativeModules } from 'react-native'
2 |
3 | const { RNFastCrypto } = NativeModules
4 |
5 | const normalizeFilePath = (path: string) => (path.startsWith('file://') ? path.slice(7) : path);
6 |
7 | export async function methodByString(method: string, jsonParams: string) {
8 | const result = await RNFastCrypto.moneroCore(method, jsonParams)
9 | return result
10 | }
11 |
12 | export async function readSettings(dirpath: string, filePrefix: string) {
13 | return await RNFastCrypto.readSettings(normalizeFilePath(dirpath), filePrefix);
14 | }
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DST=$1
4 |
5 | rm -rf "$DST/android" "$DST/ios" "$DST/index.js"
6 |
7 | cp -R android "$DST"
8 | cp -R ios "$DST"
9 | cp index.js "$DST"
10 |
--------------------------------------------------------------------------------
/ios/Headers/native-crypto.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, Airbitz
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms are permitted provided that
6 | * the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this
9 | * list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. Redistribution or use of modified source code requires the express written
14 | * permission of Airbitz Inc.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | *
27 | * The views and conclusions contained in the software and documentation are those
28 | * of the authors and should not be interpreted as representing official policies,
29 | * either expressed or implied, of the Airbitz Project.
30 | */
31 | /**
32 | * @file
33 | * AirBitz public API. The wallet only calls functions found in this file.
34 | */
35 |
36 | #ifndef native_crypto_h
37 | #define native_crypto_h
38 |
39 | #include
40 | #include
41 | #include
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | const char *create_blocks_request(int height, size_t *length);
48 | void extract_utxos_from_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult);
49 | void extract_utxos_from_clarity_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult);
50 | void get_transaction_pool_hashes(const char *buffer, size_t length, char **pszResult);
51 |
52 | void fast_crypto_monero_core(const char *szMethod, const char *szJsonParams, char **pszResult);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif // native_crypto_h
59 |
--------------------------------------------------------------------------------
/ios/NSArray+Map.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Map.h
3 | // RNFS
4 | //
5 | // taken from http://stackoverflow.com/questions/6127638/nsarray-equivalent-of-map
6 |
7 | #import
8 |
9 | @interface NSArray (Map)
10 |
11 | - (NSArray *)rnfs_mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block;
12 |
13 | @end
--------------------------------------------------------------------------------
/ios/NSArray+Map.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Map.m
3 | // RNFS
4 |
5 | #import "NSArray+Map.h"
6 |
7 | @implementation NSArray (Map)
8 |
9 | - (NSArray *)rnfs_mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block
10 | {
11 | NSMutableArray *result = [NSMutableArray arrayWithCapacity:[self count]];
12 |
13 | [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
14 | [result addObject:block(obj, idx)];
15 | }];
16 |
17 | return result;
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/ios/RNFastCrypto.h:
--------------------------------------------------------------------------------
1 |
2 | #if __has_include()
3 | #import
4 | #else
5 | #import "RCTBridgeModule.h"
6 | #endif
7 |
8 | @interface RNFastCrypto : NSObject
9 |
10 | @end
11 |
12 |
--------------------------------------------------------------------------------
/ios/RNFastCrypto.m:
--------------------------------------------------------------------------------
1 |
2 | #import "RNFastCrypto.h"
3 | #import "native-crypto.h"
4 | #import "NSArray+Map.h"
5 | #import
6 |
7 | #include
8 | #include
9 |
10 | @implementation RNFastCrypto
11 |
12 | static NSOperationQueue *_processingQueue = nil;
13 | static BOOL _stopProcessing = NO; // Flag to control operation cancellation
14 | static NSDictionary *_qosMapping;
15 |
16 | + (BOOL)shouldStopProcessing {
17 | return _stopProcessing;
18 | }
19 |
20 | + (NSOperationQueue *)processingQueue {
21 | static dispatch_once_t onceToken;
22 | dispatch_once(&onceToken, ^{
23 | _processingQueue = [[NSOperationQueue alloc] init];
24 | _processingQueue.name = @"io.exodus.RNFastCrypto.ProcessingQueue";
25 | _processingQueue.maxConcurrentOperationCount = 1;
26 | });
27 | return _processingQueue;
28 | }
29 |
30 | + (NSDictionary *)qosMapping {
31 | static dispatch_once_t onceToken;
32 | dispatch_once(&onceToken, ^{
33 | _qosMapping = @{
34 | @"user_interactive": @(NSQualityOfServiceUserInteractive),
35 | @"user_initiated": @(NSQualityOfServiceUserInitiated),
36 | @"utility": @(NSQualityOfServiceUtility),
37 | @"background": @(NSQualityOfServiceBackground)
38 | };
39 | });
40 | return _qosMapping;
41 | }
42 |
43 | - (dispatch_queue_t)methodQueue
44 | {
45 | dispatch_queue_attr_t qosAttribute = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_BACKGROUND, 0);
46 | return dispatch_queue_create("io.exodus.RNFastCrypto.MainQueue", qosAttribute);
47 | }
48 |
49 | + (void) handleGetTransactionPoolHashes:(NSString*) method
50 | :(NSString*) params
51 | :(RCTPromiseResolveBlock) resolve
52 | :(RCTPromiseRejectBlock) reject {
53 | NSData *paramsData = [params dataUsingEncoding:NSUTF8StringEncoding];
54 | NSError *jsonError;
55 | NSDictionary *jsonParams = [NSJSONSerialization JSONObjectWithData:paramsData options:kNilOptions error:&jsonError];
56 |
57 | NSString *addr = jsonParams[@"url"];
58 | NSURL *url = [NSURL URLWithString:addr];
59 |
60 | NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
61 | [urlRequest setHTTPMethod:@"POST"];
62 | [urlRequest setTimeoutInterval: 5];
63 |
64 | NSURLSession *session = [NSURLSession sharedSession];
65 |
66 | NSURLSessionDataTask *task = [session dataTaskWithRequest:urlRequest completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
67 | if (error) {
68 | resolve(@"{\"err_msg\":\"Network request failed\"}");
69 | return;
70 | }
71 |
72 | char *pszResult = NULL;
73 |
74 | get_transaction_pool_hashes(data.bytes, data.length, &pszResult);
75 |
76 | NSString *jsonResult = [NSString stringWithUTF8String:pszResult];
77 | free(pszResult);
78 | resolve(jsonResult);
79 | }];
80 | [task resume];
81 | }
82 |
83 | + (void) handleDownloadAndProcess:(NSString*) method
84 | :(NSString*) params
85 | :(RCTPromiseResolveBlock) resolve
86 | :(RCTPromiseRejectBlock) reject {
87 |
88 | NSData *paramsData = [params dataUsingEncoding:NSUTF8StringEncoding];
89 | NSError *jsonError;
90 | NSDictionary *jsonParams = [NSJSONSerialization JSONObjectWithData:paramsData options:kNilOptions error:&jsonError];
91 | _stopProcessing = NO; // Reset the flag
92 |
93 | if (jsonError) {
94 | NSString *errorJSON = @"{\"err_msg\":\"Failed to parse JSON parameters\"}";
95 | resolve(errorJSON);
96 | return;
97 | }
98 |
99 | NSString *addr = jsonParams[@"url"];
100 | NSString *startHeight = jsonParams[@"start_height"];
101 |
102 |
103 | size_t length = 0;
104 | const char *m_body = create_blocks_request([startHeight intValue], &length);
105 |
106 | NSURL *url = [NSURL URLWithString:addr];
107 | NSData *binaryData = [NSData dataWithBytes:m_body length:length];
108 | free((void *)m_body);
109 |
110 | NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
111 | [urlRequest setHTTPMethod:@"POST"];
112 | [urlRequest setHTTPBody:binaryData];
113 | [urlRequest setTimeoutInterval: 4 * 60];
114 | [urlRequest setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];
115 |
116 | NSBlockOperation *processOperation = [NSBlockOperation blockOperationWithBlock:^{
117 | NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
118 | NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
119 |
120 | NSURLSessionDataTask *task = [session dataTaskWithRequest:urlRequest completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
121 | if (error) {
122 | NSString *errorJSON = [NSString stringWithFormat:@"{\"err_msg\":\"Network request failed: %@\"}", error.localizedDescription];
123 | resolve(errorJSON);
124 | return;
125 | }
126 |
127 | if ([RNFastCrypto shouldStopProcessing]) {
128 | resolve(@"{\"err_msg\":\"Processing stopped\"}");
129 | return;
130 | }
131 |
132 | char *pszResult = NULL;
133 |
134 | extract_utxos_from_blocks_response(data.bytes, data.length, [params UTF8String], &pszResult);
135 |
136 | if (pszResult == NULL) {
137 | NSString *errorJSON = @"{\"err_msg\":\"Internal error: Memory allocation failed\"}";
138 | resolve(errorJSON);
139 | return;
140 | }
141 |
142 | NSString *jsonResult = [NSString stringWithUTF8String:pszResult];
143 | free(pszResult);
144 |
145 | if ([RNFastCrypto shouldStopProcessing]) {
146 | resolve(@"{\"err_msg\":\"Operations are stopped\"}");
147 | return;
148 | }
149 |
150 | resolve(jsonResult);
151 | }];
152 | [task resume];
153 | }];
154 | if (@available(iOS 8.0, *)) {
155 | NSString *qosString = jsonParams[@"qos"];
156 | processOperation.qualityOfService = [RNFastCrypto convertToQosFromString:qosString];
157 | }
158 | [[RNFastCrypto processingQueue] addOperation:processOperation];
159 | }
160 |
161 | + (void) handleDownloadFromClarityAndProcess:(NSString*) method
162 | :(NSString*) params
163 | :(RCTPromiseResolveBlock) resolve
164 | :(RCTPromiseRejectBlock) reject {
165 |
166 | NSData *paramsData = [params dataUsingEncoding:NSUTF8StringEncoding];
167 | NSError *jsonError;
168 | NSDictionary *jsonParams = [NSJSONSerialization JSONObjectWithData:paramsData options:kNilOptions error:&jsonError];
169 | _stopProcessing = NO; // Reset the flag
170 |
171 | if (jsonError) {
172 | NSString *errorJSON = @"{\"err_msg\":\"Failed to parse JSON parameters\"}";
173 | resolve(errorJSON);
174 | return;
175 | }
176 |
177 | NSString *addr = jsonParams[@"url"];
178 | NSURL *url = [NSURL URLWithString:addr];
179 |
180 | NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
181 | [urlRequest setHTTPMethod:@"GET"];
182 | [urlRequest setTimeoutInterval: 4 * 60];
183 |
184 | NSBlockOperation *processOperation = [NSBlockOperation blockOperationWithBlock:^{
185 | NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
186 | NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
187 | NSURLSessionDataTask *downloadTask = [session dataTaskWithRequest:urlRequest completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
188 | if (error) {
189 | NSString *errorJSON = [NSString stringWithFormat:@"{\"err_msg\":\"[Clarity] Network request failed: %@\"}", error.localizedDescription];
190 | resolve(errorJSON);
191 | return;
192 | }
193 |
194 | NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
195 | if (httpResponse.statusCode != 200) {
196 | NSString *errorMsg = @"Unknown error";
197 | if (data != nil) {
198 | NSDictionary *errorResponse = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
199 | if (errorResponse && [errorResponse objectForKey:@"message"]) {
200 | errorMsg = errorResponse[@"message"];
201 | }
202 | }
203 |
204 | NSString *errorJSON = [NSString stringWithFormat:@"{\"err_msg\":\"[Clarity] HTTP Error %ld: %@\"}", (long)httpResponse.statusCode, errorMsg];
205 | resolve(errorJSON);
206 | return;
207 | }
208 |
209 | if ([RNFastCrypto shouldStopProcessing]) {
210 | resolve(@"{\"err_msg\":\"Processing stopped\"}");
211 | return;
212 | }
213 |
214 | char *pszResult = NULL;
215 |
216 | extract_utxos_from_clarity_blocks_response(data.bytes, data.length, [params UTF8String], &pszResult);
217 |
218 | if (pszResult == NULL) {
219 | NSString *errorJSON = @"{\"err_msg\":\"Internal error: Memory allocation failed\"}";
220 | resolve(errorJSON);
221 | return;
222 | }
223 |
224 | NSString *jsonResult = [NSString stringWithUTF8String:pszResult];
225 | free(pszResult);
226 |
227 | if ([RNFastCrypto shouldStopProcessing]) {
228 | resolve(@"{\"err_msg\":\"Operations are stopped\"}");
229 | return;
230 | }
231 |
232 | resolve(jsonResult);
233 | }];
234 | [downloadTask resume];
235 | }];
236 |
237 | if (@available(iOS 8.0, *)) {
238 | NSString *qosString = jsonParams[@"qos"];
239 | processOperation.qualityOfService = [RNFastCrypto convertToQosFromString:qosString];
240 | }
241 |
242 | [[RNFastCrypto processingQueue] addOperation:processOperation];
243 | }
244 |
245 | + (void) handleDefault:(NSString*) method
246 | :(NSString*) params
247 | :(RCTPromiseResolveBlock) resolve
248 | :(RCTPromiseRejectBlock) reject {
249 | char *pszResult = NULL;
250 |
251 | fast_crypto_monero_core([method UTF8String], [params UTF8String], &pszResult);
252 |
253 | if (pszResult == NULL) {
254 | resolve(NULL);
255 | return;
256 | }
257 |
258 | NSString *jsonResult = [NSString stringWithUTF8String:pszResult];
259 | free(pszResult);
260 | resolve(jsonResult);
261 | }
262 |
263 | RCT_EXPORT_MODULE()
264 |
265 | RCT_REMAP_METHOD(moneroCore, :(NSString*) method
266 | :(NSString*) params
267 | :(RCTPromiseResolveBlock) resolve
268 | :(RCTPromiseRejectBlock) reject)
269 | {
270 | if ([method isEqualToString:@"download_and_process"]) {
271 | [RNFastCrypto handleDownloadAndProcess:method :params :resolve :reject];
272 | } else if ([method isEqualToString:@"download_from_clarity_and_process"]) {
273 | [RNFastCrypto handleDownloadFromClarityAndProcess:method :params :resolve :reject];
274 | } else if ([method isEqualToString:@"get_transaction_pool_hashes"]) {
275 | [RNFastCrypto handleGetTransactionPoolHashes:method :params :resolve :reject];
276 | } else if ([method isEqualToString:@"stop_processing_task"]) {
277 | [RNFastCrypto stopProcessingTasks];
278 | resolve(@"{\"success\":true}");
279 | } else {
280 | [RNFastCrypto handleDefault:method :params :resolve :reject];
281 | }
282 | }
283 |
284 | + (void)allowProcessingTasks {
285 | _stopProcessing = NO; // Reset the flag
286 | }
287 |
288 | + (void)stopProcessingTasks {
289 | _stopProcessing = YES;
290 | [[RNFastCrypto processingQueue] cancelAllOperations];
291 | [[RNFastCrypto processingQueue] waitUntilAllOperationsAreFinished];
292 | }
293 |
294 | + (NSQualityOfService)convertToQosFromString:(NSString *)qosString {
295 | NSNumber *qosValue = [RNFastCrypto qosMapping][qosString];
296 | if (qosValue) {
297 | return qosValue.integerValue;
298 | }
299 |
300 | // Default value
301 | return NSQualityOfServiceUtility;
302 | }
303 |
304 | RCT_EXPORT_METHOD(readSettings:(NSString *)dirPath
305 | prefix:(NSString *)filePrefix
306 | resolver:(RCTPromiseResolveBlock)resolve
307 | rejecter:(RCTPromiseRejectBlock)reject)
308 | {
309 | NSFileManager *fileManager = [NSFileManager defaultManager];
310 | NSError *error = nil;
311 |
312 | NSArray *contents = [fileManager contentsOfDirectoryAtPath:dirPath error:&error];
313 |
314 | if (error) {
315 | reject(@"error", @"can't read settings file", error);
316 | return;
317 | }
318 |
319 | NSPredicate *predicateHasPrefix = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH %@", filePrefix];
320 | NSArray *filteredArray = [contents filteredArrayUsingPredicate:predicateHasPrefix];
321 |
322 | NSArray *values = [filteredArray rnfs_mapObjectsUsingBlock:^id(NSString *obj, NSUInteger idx) {
323 | NSString *name = [obj stringByReplacingOccurrencesOfString:@".json" withString:@""];
324 | NSArray *components = [name componentsSeparatedByString:filePrefix];
325 |
326 | if ([components count] != 2 || [components[1] isEqual:@"enabled"]) return [NSNumber numberWithInt:0];
327 |
328 | return [NSNumber numberWithInteger: [components[1] integerValue]];
329 | }];
330 |
331 | NSPredicate *predicateNotNil = [NSPredicate predicateWithFormat:@"SELF != 0"];
332 | NSArray *valuesClean = [values filteredArrayUsingPredicate:predicateNotNil];
333 |
334 | if (valuesClean.count == 0) {
335 | resolve(@{});
336 | return;
337 | }
338 |
339 | NSDictionary *r = @{
340 | @"size": [NSNumber numberWithInteger:valuesClean.count],
341 | @"oldest": [valuesClean valueForKeyPath:@"@min.self"],
342 | @"latest": [valuesClean valueForKeyPath:@"@max.self"],
343 | };
344 |
345 | resolve(r);
346 | }
347 | @end
348 |
--------------------------------------------------------------------------------
/ios/RNFastCrypto.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 52;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 35AC74C6246B0B12005374EB /* NSArray+Map.m in Sources */ = {isa = PBXBuildFile; fileRef = 35AC74C5246B0B12005374EB /* NSArray+Map.m */; };
11 | 3A0B07D4281AFDED00874E20 /* libnativecrypto.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07CE281AFDED00874E20 /* libnativecrypto.a.xcframework */; };
12 | 3A0B07D5281AFDED00874E20 /* libboost_regex.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07CF281AFDED00874E20 /* libboost_regex.a.xcframework */; };
13 | 3A0B07D6281AFDED00874E20 /* libboost_system.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07D0281AFDED00874E20 /* libboost_system.a.xcframework */; };
14 | 3A0B07D7281AFDED00874E20 /* libmymonerocorecpp.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07D1281AFDED00874E20 /* libmymonerocorecpp.a.xcframework */; };
15 | 3A0B07D8281AFDED00874E20 /* libboost_atomic.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07D2281AFDED00874E20 /* libboost_atomic.a.xcframework */; };
16 | 3A0B07D9281AFDED00874E20 /* libboost_thread.a.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0B07D3281AFDED00874E20 /* libboost_thread.a.xcframework */; };
17 | B3E7B58A1CC2AC0600A0062D /* RNFastCrypto.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNFastCrypto.m */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXCopyFilesBuildPhase section */
21 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
22 | isa = PBXCopyFilesBuildPhase;
23 | buildActionMask = 2147483647;
24 | dstPath = "include/$(PRODUCT_NAME)";
25 | dstSubfolderSpec = 16;
26 | files = (
27 | );
28 | runOnlyForDeploymentPostprocessing = 0;
29 | };
30 | /* End PBXCopyFilesBuildPhase section */
31 |
32 | /* Begin PBXFileReference section */
33 | 134814201AA4EA6300B7C361 /* libRNFastCrypto.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFastCrypto.a; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 35AC74C4246B0B12005374EB /* NSArray+Map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Map.h"; sourceTree = ""; };
35 | 35AC74C5246B0B12005374EB /* NSArray+Map.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Map.m"; sourceTree = ""; };
36 | 3A0B07CE281AFDED00874E20 /* libnativecrypto.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libnativecrypto.a.xcframework; path = Frameworks/libnativecrypto.a.xcframework; sourceTree = ""; };
37 | 3A0B07CF281AFDED00874E20 /* libboost_regex.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libboost_regex.a.xcframework; path = Frameworks/libboost_regex.a.xcframework; sourceTree = ""; };
38 | 3A0B07D0281AFDED00874E20 /* libboost_system.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libboost_system.a.xcframework; path = Frameworks/libboost_system.a.xcframework; sourceTree = ""; };
39 | 3A0B07D1281AFDED00874E20 /* libmymonerocorecpp.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libmymonerocorecpp.a.xcframework; path = Frameworks/libmymonerocorecpp.a.xcframework; sourceTree = ""; };
40 | 3A0B07D2281AFDED00874E20 /* libboost_atomic.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libboost_atomic.a.xcframework; path = Frameworks/libboost_atomic.a.xcframework; sourceTree = ""; };
41 | 3A0B07D3281AFDED00874E20 /* libboost_thread.a.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libboost_thread.a.xcframework; path = Frameworks/libboost_thread.a.xcframework; sourceTree = ""; };
42 | B3E7B5881CC2AC0600A0062D /* RNFastCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFastCrypto.h; sourceTree = ""; };
43 | B3E7B5891CC2AC0600A0062D /* RNFastCrypto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFastCrypto.m; sourceTree = ""; };
44 | DAE53E761F0E153B00E466B0 /* native-crypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "native-crypto.h"; path = "Headers/native-crypto.h"; sourceTree = ""; };
45 | /* End PBXFileReference section */
46 |
47 | /* Begin PBXFrameworksBuildPhase section */
48 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
49 | isa = PBXFrameworksBuildPhase;
50 | buildActionMask = 2147483647;
51 | files = (
52 | 3A0B07D7281AFDED00874E20 /* libmymonerocorecpp.a.xcframework in Frameworks */,
53 | 3A0B07D8281AFDED00874E20 /* libboost_atomic.a.xcframework in Frameworks */,
54 | 3A0B07D9281AFDED00874E20 /* libboost_thread.a.xcframework in Frameworks */,
55 | 3A0B07D6281AFDED00874E20 /* libboost_system.a.xcframework in Frameworks */,
56 | 3A0B07D5281AFDED00874E20 /* libboost_regex.a.xcframework in Frameworks */,
57 | 3A0B07D4281AFDED00874E20 /* libnativecrypto.a.xcframework in Frameworks */,
58 | );
59 | runOnlyForDeploymentPostprocessing = 0;
60 | };
61 | /* End PBXFrameworksBuildPhase section */
62 |
63 | /* Begin PBXGroup section */
64 | 134814211AA4EA7D00B7C361 /* Products */ = {
65 | isa = PBXGroup;
66 | children = (
67 | 134814201AA4EA6300B7C361 /* libRNFastCrypto.a */,
68 | );
69 | name = Products;
70 | sourceTree = "";
71 | };
72 | 359708BB2386D00900011D93 /* Frameworks */ = {
73 | isa = PBXGroup;
74 | children = (
75 | 3A0B07D2281AFDED00874E20 /* libboost_atomic.a.xcframework */,
76 | 3A0B07CF281AFDED00874E20 /* libboost_regex.a.xcframework */,
77 | 3A0B07D0281AFDED00874E20 /* libboost_system.a.xcframework */,
78 | 3A0B07D3281AFDED00874E20 /* libboost_thread.a.xcframework */,
79 | 3A0B07D1281AFDED00874E20 /* libmymonerocorecpp.a.xcframework */,
80 | 3A0B07CE281AFDED00874E20 /* libnativecrypto.a.xcframework */,
81 | );
82 | name = Frameworks;
83 | sourceTree = "";
84 | };
85 | 58B511D21A9E6C8500147676 = {
86 | isa = PBXGroup;
87 | children = (
88 | DAE53E751F0E152200E466B0 /* Headers */,
89 | DAE53E6A1F0E14FB00E466B0 /* Libraries */,
90 | B3E7B5881CC2AC0600A0062D /* RNFastCrypto.h */,
91 | B3E7B5891CC2AC0600A0062D /* RNFastCrypto.m */,
92 | 35AC74C4246B0B12005374EB /* NSArray+Map.h */,
93 | 35AC74C5246B0B12005374EB /* NSArray+Map.m */,
94 | 134814211AA4EA7D00B7C361 /* Products */,
95 | 359708BB2386D00900011D93 /* Frameworks */,
96 | );
97 | sourceTree = "";
98 | };
99 | DAE53E6A1F0E14FB00E466B0 /* Libraries */ = {
100 | isa = PBXGroup;
101 | children = (
102 | );
103 | name = Libraries;
104 | sourceTree = "";
105 | };
106 | DAE53E751F0E152200E466B0 /* Headers */ = {
107 | isa = PBXGroup;
108 | children = (
109 | DAE53E761F0E153B00E466B0 /* native-crypto.h */,
110 | );
111 | name = Headers;
112 | sourceTree = "";
113 | };
114 | /* End PBXGroup section */
115 |
116 | /* Begin PBXNativeTarget section */
117 | 58B511DA1A9E6C8500147676 /* RNFastCrypto */ = {
118 | isa = PBXNativeTarget;
119 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFastCrypto" */;
120 | buildPhases = (
121 | 58B511D71A9E6C8500147676 /* Sources */,
122 | 58B511D81A9E6C8500147676 /* Frameworks */,
123 | 58B511D91A9E6C8500147676 /* CopyFiles */,
124 | );
125 | buildRules = (
126 | );
127 | dependencies = (
128 | );
129 | name = RNFastCrypto;
130 | productName = RCTDataManager;
131 | productReference = 134814201AA4EA6300B7C361 /* libRNFastCrypto.a */;
132 | productType = "com.apple.product-type.library.static";
133 | };
134 | /* End PBXNativeTarget section */
135 |
136 | /* Begin PBXProject section */
137 | 58B511D31A9E6C8500147676 /* Project object */ = {
138 | isa = PBXProject;
139 | attributes = {
140 | LastUpgradeCheck = 0610;
141 | ORGANIZATIONNAME = Facebook;
142 | TargetAttributes = {
143 | 58B511DA1A9E6C8500147676 = {
144 | CreatedOnToolsVersion = 6.1.1;
145 | };
146 | };
147 | };
148 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFastCrypto" */;
149 | compatibilityVersion = "Xcode 3.2";
150 | developmentRegion = English;
151 | hasScannedForEncodings = 0;
152 | knownRegions = (
153 | English,
154 | en,
155 | );
156 | mainGroup = 58B511D21A9E6C8500147676;
157 | productRefGroup = 58B511D21A9E6C8500147676;
158 | projectDirPath = "";
159 | projectRoot = "";
160 | targets = (
161 | 58B511DA1A9E6C8500147676 /* RNFastCrypto */,
162 | );
163 | };
164 | /* End PBXProject section */
165 |
166 | /* Begin PBXSourcesBuildPhase section */
167 | 58B511D71A9E6C8500147676 /* Sources */ = {
168 | isa = PBXSourcesBuildPhase;
169 | buildActionMask = 2147483647;
170 | files = (
171 | B3E7B58A1CC2AC0600A0062D /* RNFastCrypto.m in Sources */,
172 | 35AC74C6246B0B12005374EB /* NSArray+Map.m in Sources */,
173 | );
174 | runOnlyForDeploymentPostprocessing = 0;
175 | };
176 | /* End PBXSourcesBuildPhase section */
177 |
178 | /* Begin XCBuildConfiguration section */
179 | 58B511ED1A9E6C8500147676 /* Debug */ = {
180 | isa = XCBuildConfiguration;
181 | buildSettings = {
182 | ALWAYS_SEARCH_USER_PATHS = NO;
183 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
184 | CLANG_CXX_LIBRARY = "libc++";
185 | CLANG_ENABLE_MODULES = YES;
186 | CLANG_ENABLE_OBJC_ARC = YES;
187 | CLANG_WARN_BOOL_CONVERSION = YES;
188 | CLANG_WARN_CONSTANT_CONVERSION = YES;
189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
190 | CLANG_WARN_EMPTY_BODY = YES;
191 | CLANG_WARN_ENUM_CONVERSION = YES;
192 | CLANG_WARN_INT_CONVERSION = YES;
193 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194 | CLANG_WARN_UNREACHABLE_CODE = YES;
195 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
196 | COPY_PHASE_STRIP = NO;
197 | ENABLE_STRICT_OBJC_MSGSEND = YES;
198 | GCC_C_LANGUAGE_STANDARD = gnu99;
199 | GCC_DYNAMIC_NO_PIC = NO;
200 | GCC_OPTIMIZATION_LEVEL = 0;
201 | GCC_PREPROCESSOR_DEFINITIONS = (
202 | "DEBUG=1",
203 | "$(inherited)",
204 | );
205 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
206 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
207 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
208 | GCC_WARN_UNDECLARED_SELECTOR = YES;
209 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
210 | GCC_WARN_UNUSED_FUNCTION = YES;
211 | GCC_WARN_UNUSED_VARIABLE = YES;
212 | HEADER_SEARCH_PATHS = Headers/;
213 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
214 | MTL_ENABLE_DEBUG_INFO = YES;
215 | ONLY_ACTIVE_ARCH = YES;
216 | SDKROOT = iphoneos;
217 | };
218 | name = Debug;
219 | };
220 | 58B511EE1A9E6C8500147676 /* Release */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | ALWAYS_SEARCH_USER_PATHS = NO;
224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
225 | CLANG_CXX_LIBRARY = "libc++";
226 | CLANG_ENABLE_MODULES = YES;
227 | CLANG_ENABLE_OBJC_ARC = YES;
228 | CLANG_WARN_BOOL_CONVERSION = YES;
229 | CLANG_WARN_CONSTANT_CONVERSION = YES;
230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
231 | CLANG_WARN_EMPTY_BODY = YES;
232 | CLANG_WARN_ENUM_CONVERSION = YES;
233 | CLANG_WARN_INT_CONVERSION = YES;
234 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
235 | CLANG_WARN_UNREACHABLE_CODE = YES;
236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
237 | COPY_PHASE_STRIP = YES;
238 | ENABLE_NS_ASSERTIONS = NO;
239 | ENABLE_STRICT_OBJC_MSGSEND = YES;
240 | GCC_C_LANGUAGE_STANDARD = gnu99;
241 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
242 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
243 | GCC_WARN_UNDECLARED_SELECTOR = YES;
244 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
245 | GCC_WARN_UNUSED_FUNCTION = YES;
246 | GCC_WARN_UNUSED_VARIABLE = YES;
247 | HEADER_SEARCH_PATHS = Headers/;
248 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
249 | MTL_ENABLE_DEBUG_INFO = NO;
250 | SDKROOT = iphoneos;
251 | VALIDATE_PRODUCT = YES;
252 | };
253 | name = Release;
254 | };
255 | 58B511F01A9E6C8500147676 /* Debug */ = {
256 | isa = XCBuildConfiguration;
257 | buildSettings = {
258 | HEADER_SEARCH_PATHS = (
259 | "$(inherited)",
260 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
261 | "$(SRCROOT)/../../react-native/Libraries/**",
262 | "$(SRCROOT)/../../react-native/React/**",
263 | "$(SRCROOT)/../../../react-native/React/**",
264 | );
265 | LIBRARY_SEARCH_PATHS = (
266 | "$(inherited)",
267 | "$(PROJECT_DIR)/Libraries",
268 | );
269 | OTHER_LDFLAGS = "-ObjC";
270 | PRODUCT_NAME = RNFastCrypto;
271 | SKIP_INSTALL = YES;
272 | };
273 | name = Debug;
274 | };
275 | 58B511F11A9E6C8500147676 /* Release */ = {
276 | isa = XCBuildConfiguration;
277 | buildSettings = {
278 | HEADER_SEARCH_PATHS = (
279 | "$(inherited)",
280 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
281 | "$(SRCROOT)/../../react-native/Libraries/**",
282 | "$(SRCROOT)/../../react-native/React/**",
283 | "$(SRCROOT)/../../../react-native/React",
284 | );
285 | LIBRARY_SEARCH_PATHS = (
286 | "$(inherited)",
287 | "$(PROJECT_DIR)/Libraries",
288 | );
289 | OTHER_LDFLAGS = "-ObjC";
290 | PRODUCT_NAME = RNFastCrypto;
291 | SKIP_INSTALL = YES;
292 | };
293 | name = Release;
294 | };
295 | /* End XCBuildConfiguration section */
296 |
297 | /* Begin XCConfigurationList section */
298 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFastCrypto" */ = {
299 | isa = XCConfigurationList;
300 | buildConfigurations = (
301 | 58B511ED1A9E6C8500147676 /* Debug */,
302 | 58B511EE1A9E6C8500147676 /* Release */,
303 | );
304 | defaultConfigurationIsVisible = 0;
305 | defaultConfigurationName = Release;
306 | };
307 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFastCrypto" */ = {
308 | isa = XCConfigurationList;
309 | buildConfigurations = (
310 | 58B511F01A9E6C8500147676 /* Debug */,
311 | 58B511F11A9E6C8500147676 /* Release */,
312 | );
313 | defaultConfigurationIsVisible = 0;
314 | defaultConfigurationName = Release;
315 | };
316 | /* End XCConfigurationList section */
317 | };
318 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
319 | }
320 |
--------------------------------------------------------------------------------
/native-libs/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | test/
3 |
--------------------------------------------------------------------------------
/native-libs/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: check clean
2 |
3 | # Build settings:
4 | WORK_DIR ?= build
5 | PREFIX = deps/build/prefix
6 |
7 | # Compiler options:
8 | CFLAGS += -D_GNU_SOURCE -DDEBUG -g -Wall -fPIC -std=c99
9 | CXXFLAGS += -D_GNU_SOURCE -DDEBUG -g -Wall -fPIC -std=c++11
10 | LIBS := -lmymonerocorecpp \
11 | -lboost_thread \
12 | -lboost_system \
13 | -lboost_regex \
14 | -lm \
15 | -lz # Adding zlib explicitly
16 |
17 | # Do not use -lpthread on Android:
18 | ifneq (,$(findstring android,$(CC)))
19 | CFLAGS += -DANDROID
20 | CXXFLAGS += -DANDROID
21 | LIBS := $(filter-out -lpthread,$(LIBS)) -llog
22 | endif
23 |
24 | # Test-only setup
25 | T ?= 0
26 | ifeq ($T, 1)
27 | CXXFLAGS += -I$(PREFIX)/native/include
28 | LDFLAGS += -L$(PREFIX)/native/lib -lz -lcurl
29 |
30 | ifeq ($(shell uname -s),Linux)
31 | LIBS += -lbsd
32 | endif
33 | endif
34 |
35 | # Source files:
36 | abc_sources = $(wildcard src/*.cpp)
37 | test_sources = $(wildcard test/*.cpp)
38 |
39 | # Objects:
40 | abc_objects = $(addprefix $(WORK_DIR)/, $(addsuffix .o, $(basename $(abc_sources))))
41 | test_objects = $(addprefix $(WORK_DIR)/, $(addsuffix .o, $(basename $(test_sources))))
42 |
43 | # Adjustable verbosity:
44 | V ?= 0
45 | ifeq ($V,0)
46 | RUN = @echo Making $@...;
47 | endif
48 |
49 | # Targets:
50 | libnativecrypto.a: $(WORK_DIR)/libnativecrypto.a
51 | libnativecrypto.so: $(WORK_DIR)/libnativecrypto.so
52 |
53 | $(WORK_DIR)/libnativecrypto.a: $(abc_objects)
54 | $(RUN) $(RM) $@; $(AR) rcs $@ $^
55 |
56 | $(WORK_DIR)/libnativecrypto.so: $(abc_objects)
57 | $(RUN) $(CXX) -shared -Wl,-soname=libnativecrypto.so -o $@ $^ $(LDFLAGS) $(LIBS)
58 |
59 | $(WORK_DIR)/abc-test: $(test_objects)
60 | $(RUN) $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS)
61 |
62 | check: $(WORK_DIR)/abc-test
63 | $(RUN) $<
64 |
65 | clean:
66 | $(RM) -r $(WORK_DIR)
67 |
68 | # Automatic dependency rules:
69 | $(WORK_DIR)/%.o: %.c
70 | @mkdir -p $(dir $@)
71 | $(RUN) $(CC) -c -MD $(CFLAGS) -o $@ $<
72 |
73 | $(WORK_DIR)/%.o: %.cpp
74 | @mkdir -p $(dir $@)
75 | $(RUN) $(CXX) -c -MD $(CXXFLAGS) -o $@ $<
76 |
77 | include $(wildcard $(WORK_DIR)/*/*.d $(WORK_DIR)/*/*/*.d $(WORK_DIR)/*/*/*/*.d)
78 | %.h: ;
79 | %.hpp: ;
80 |
81 |
--------------------------------------------------------------------------------
/native-libs/deps/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | download/
3 |
--------------------------------------------------------------------------------
/native-libs/deps/Makefile:
--------------------------------------------------------------------------------
1 | BUILD_DIR ?= build
2 |
3 | default: native-crypto
4 |
5 | $(BUILD_DIR)/%/tasks.mk: recipes/%
6 | @ ./run.sh $* write-tasks
7 | -include $(patsubst recipes/%,$(BUILD_DIR)/%/tasks.mk,$(wildcard recipes/*))
8 |
9 | clean:
10 | rm -rf $(BUILD_DIR)
11 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/android:
--------------------------------------------------------------------------------
1 | inherit common
2 |
3 | # Builds a library using the Andorid NDK.
4 | # $1 arch name for toolchain, work_dir and install_dir.
5 | # $2 cross-compiler prefix.
6 | build_android() {
7 | # Put the source in the working directory:
8 | work_dir=$work_dir/android-$1
9 | mkdir -p $work_dir
10 | unpack
11 |
12 | # Establish expected variables:
13 | target=android-$1
14 | install_dir=$build_dir/prefix/android/$1
15 |
16 | cross=$2
17 | export AR="${cross}-ar"
18 | export AS="${cross}-as"
19 | export CC="${cross}-clang"
20 | export CCLD="${cross}-clang"
21 | export CPP="${cross}-clang -E"
22 | export CXX="${cross}-clang++"
23 | export LD="${cross}-ld"
24 | export NM="${cross}-nm"
25 | export OBJCOPY="${cross}-objcopy"
26 | export OBJDUMP="${cross}-objdump"
27 | export RANLIB="${cross}-ranlib"
28 | export STRINGS="${cross}-strings"
29 | export STRIP="${cross}-strip"
30 |
31 | export CFLAGS="-isystem${install_dir}/include -fPIC -O2"
32 | export CXXFLAGS="-isystem${install_dir}/include -fPIC -O2"
33 | export LDFLAGS="-L${install_dir}/lib -fPIC"
34 |
35 | if [ $1 = "arm" ]; then
36 | export CFLAGS="$CFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb"
37 | export CXXFLAGS="$CXXFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb"
38 | export LDFLAGS="$LDFLAGS -march=armv7-a -Wl,--fix-cortex-a8"
39 | else
40 | export CFLAGS="$CFLAGS -maes"
41 | export CXXFLAGS="$CXXFLAGS -maes"
42 | fi
43 |
44 | export PATH=$build_dir/ndk/$1/bin:$PATH
45 | export PKG_CONFIG_PATH=$install_dir/lib/pkgconfig
46 |
47 | cd $work_dir
48 | build
49 | }
50 | build_android_arm() {
51 | build_android arm arm-linux-androideabi
52 | }
53 | build_android_arm64() {
54 | build_android arm64 aarch64-linux-android
55 | }
56 | build_android_x86() {
57 | build_android x86 i686-linux-android
58 | }
59 | build_android_x86_64() {
60 | build_android x86_64 x86_64-linux-android
61 | }
62 |
63 | for arch in arm arm64 x86 x86_64; do
64 | deps="download ndk.setup-$arch"
65 | for dep in $depends; do
66 | deps="$deps $dep.build-android-$arch"
67 | done
68 | task build-android-$arch $deps
69 | done
70 | default=build-android-arm
71 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/android.toolchain.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME Linux)
2 | set(CMAKE_SYSTEM_VERSION 1)
3 |
4 | # Where is the target environment:
5 | set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}")
6 |
7 | # Search for programs in the build host directories:
8 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
9 |
10 | # Search for libraries and headers in the target directories:
11 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/common:
--------------------------------------------------------------------------------
1 | # Common variables
2 | download_dir=${DOWNLOAD_DIR:-$base_dir/download}
3 |
4 | # Common tasks
5 |
6 | # Downloads all the source files mentioned in $source
7 | download() {
8 | mkdir -p $download_dir
9 | for s in $source; do
10 | url=${s%#*} # Remove hash part
11 | path=$download_dir/${url##*/}
12 | path=${path%%\?*} # Remove query part
13 | hash=${s##*#}
14 | hash=${hash%"$url"}
15 |
16 | # Download:
17 | if [ -e $s ]; then
18 | if [ -e $path ]; then
19 | rm -rf $path
20 | fi
21 |
22 | cp -a $s $path
23 | elif [ $path != ${path%.git} ]; then
24 | if [ -e "$path" ]; then
25 | git --git-dir="$path" fetch -f "$url" +refs/heads/*:refs/heads/*
26 | else
27 | git clone --bare "$url" "$path"
28 | fi
29 | else
30 | if [ ! -e "$path" ]; then
31 | curl -L "$url" > "$path"
32 | fi
33 |
34 | # Checksum:
35 | output=$(shasum "$path")
36 | output="${output%% *}"
37 | if [ -n "$hash" -a "$hash" != "$output" ]; then
38 | echo "error: checksum failed on $(relative path): expected $hash, got $output"
39 | echo "moving $(relative $path) to $(relative $path).fail"
40 | mv "$path" "$path.fail"
41 | return 1
42 | else
43 | echo "SHA1 $(relative $path) = $output"
44 | fi
45 | fi
46 | done
47 | }
48 | task download
49 |
50 | # Unpacks the source files mentioned in $source with the .tar.* extension
51 | unpack() {
52 | for s in $source; do
53 | url=${s%#*} # Remove hash part
54 | path=$download_dir/${url##*/}
55 | path=${path%%\?*} # Remove query part
56 | hash=${s##*#}
57 | hash=${hash%"$url"}
58 |
59 | # Unpack:
60 | if [ -e $s ]; then
61 | if [ -e $work_dir ]; then
62 | rm -rf $work_dir
63 | fi
64 |
65 | cp -a $path $work_dir
66 | elif [ $path != ${path%.git} ]; then
67 | # Check out using git:
68 | for i in {0..7}; do
69 | # Parallel checkouts will fail, so wait:
70 | if [ -e "$path/index.lock" ]; then sleep 1; fi
71 | done
72 | git --git-dir="$path" --work-tree="$work_dir" reset --hard "${hash:-master}"
73 | elif [ $path != ${path%.tar*} -o $path != ${path%.tgz} ]; then
74 | # Unpack using tar:
75 | echo "Unpacking $(relative $path) to $(relative $work_dir)..."
76 | tar -C "$work_dir" -xmf "$path"
77 | fi
78 | done
79 | }
80 | task unpack download
81 |
82 | # Writes the full (recursive) dependency list for a package
83 | write_deps() {
84 | for dep in $depends; do
85 | echo $dep
86 | cat $build_dir/$dep/depends
87 | done | sort | uniq > depends
88 | }
89 | task write-deps $(for dep in $depends; do echo $dep.write-deps; done)
90 |
91 | clean() {
92 | rm -rf $work_dir
93 | }
94 | task clean
95 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/ios:
--------------------------------------------------------------------------------
1 | inherit common
2 |
3 | # Performs an iOS-style build.
4 | # $1 arch name for compiler, work_dir and install_dir.
5 | # $2 platform (either iPhoneOS or iPhoneSimulator)
6 | build_ios() {
7 | # Put the source in the working directory:
8 | top_work_dir=$work_dir
9 | work_dir=$work_dir/ios-$1_$2
10 | mkdir -p $work_dir
11 | unpack
12 |
13 | # Establish expected variables:
14 | target=ios-$1-$2
15 | install_dir=$build_dir/prefix/ios/$1_$2
16 |
17 | case $1 in
18 | arm*) cross=arm-apple-darwin10 ;;
19 | i386) cross=i386-apple-darwin10 ;;
20 | x86_64) cross=x86_64-apple-darwin10 ;;
21 | esac
22 |
23 | # Locate Xcode build tools:
24 | xcode_dir=$(xcode-select -print-path | sed -e 's@/$@@')
25 | platform_dir=$xcode_dir/Platforms/${2}.platform/Developer
26 |
27 | export AR="ar"
28 | export CC="clang"
29 | export CCLD="clang"
30 | export CPP="clang -E"
31 | export CXX="clang++"
32 |
33 | case $2 in
34 | iPhoneSimulator) version_flag='-mios-simulator-version-min=10.0' ;;
35 | *) version_flag='-miphoneos-version-min=10.0' ;;
36 | esac
37 |
38 |
39 | platform_sdk="$platform_dir/SDKs/${2}.sdk"
40 | sdk_flags="-arch $1 -isysroot $platform_sdk $version_flag -O2 -maes"
41 | export SDKROOT=$platform_sdk # https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html
42 | export CFLAGS="$sdk_flags -isystem${install_dir}/include -Werror=partial-availability"
43 | export CXXFLAGS="$sdk_flags -isystem${install_dir}/include -Werror=partial-availability"
44 | export LDFLAGS="$sdk_flags -L${install_dir}/lib"
45 |
46 | export PATH=$xcode_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin:$xcode_dir/usr/bin:$PATH
47 | export PKG_CONFIG_PATH=$install_dir/lib/pkgconfig
48 |
49 | cd $work_dir
50 | build
51 |
52 | unset SDKROOT
53 |
54 | # File lists:
55 | ([ -n "$lib" ] && (cd $install_dir; find $lib -type f) || true) > \
56 | $top_work_dir/lib-${target}.txt
57 | ([ -n "$include" ] && (cd $install_dir; find $include -type f) || true) > \
58 | $top_work_dir/include-${target}.txt
59 | }
60 | build_ios_armv7_iPhoneOS() {
61 | build_ios armv7 iPhoneOS
62 | }
63 | build_ios_armv7s_iPhoneOS() {
64 | build_ios armv7s iPhoneOS
65 | }
66 | build_ios_arm64_iPhoneOS() {
67 | build_ios arm64 iPhoneOS
68 | }
69 | build_ios_arm64_iPhoneSimulator() {
70 | build_ios arm64 iPhoneSimulator
71 | }
72 | build_ios_i386_iPhoneSimulator() {
73 | build_ios i386 iPhoneSimulator
74 | }
75 | build_ios_x86_64_iPhoneSimulator() {
76 | build_ios x86_64 iPhoneSimulator
77 | }
78 |
79 | architectures="i386 x86_64 arm64 armv7 armv7s"
80 | platforms="iPhoneOS iPhoneSimulator"
81 |
82 | simulatorTarges="arm64_iPhoneSimulator i386_iPhoneSimulator x86_64_iPhoneSimulator"
83 | iosTargets="armv7_iPhoneOS armv7s_iPhoneOS arm64_iPhoneOS"
84 | arches="$iosTargets $simulatorTarges"
85 |
86 | for arch in $arches ; do
87 | deps="download"
88 | for dep in $depends; do
89 | deps="$deps $dep.build-ios-$arch"
90 | done
91 | task build-ios-$arch $deps
92 | done
93 |
94 | package_ios_universal() {
95 | package_dir=${recipe}-ios-universal
96 | rm -rf $package_dir
97 | mkdir $package_dir
98 | depends=$(cat depends)
99 |
100 | in_libs=$(echo $build_dir/prefix/ios/arm64_iPhoneOS/lib/*.a)
101 | for l in $in_libs; do
102 | filename=$(basename $l)
103 | rm -rf $package_dir/$filename.xcframework
104 | for platform in $platforms; do
105 | opts=""
106 | for arch in $architectures; do
107 | [[ -e $build_dir/prefix/ios/"$arch"_$platform/lib/$filename ]] && opts+="$build_dir/prefix/ios/"$arch"_$platform/lib/$filename "
108 | done
109 | mkdir -p $package_dir/$platform
110 | lipo -create $opts -output $package_dir/$platform/$filename
111 | done
112 |
113 | xcodebuildOpts=""
114 | for platform in $platforms; do
115 | xcodebuildOpts+="-library $package_dir/$platform/$filename "
116 | done
117 |
118 | xcodebuild -create-xcframework $xcodebuildOpts -output $package_dir/$filename.xcframework
119 | done
120 |
121 | # Gather headers:
122 | for f in $(cat include-ios-arm64-iPhoneOS.txt); do
123 | mkdir -p $(dirname $package_dir/$f)
124 | ln -vs $build_dir/prefix/ios/arm64_iPhoneOS/$f $package_dir/$f
125 | done
126 |
127 | # Make the archive:
128 | zip -r $recipe-ios-universal-$(date +%Y-%m-%d) $package_dir
129 | }
130 | task package-ios-universal write-deps $(for arch in $arches; do echo build-ios-$arch; done)
131 |
132 | default=package-ios-universal
133 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/ios.toolchain.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME Darwin)
2 | set(CMAKE_SYSTEM_VERSION 1)
3 |
4 | # Where is the target environment:
5 | set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}")
6 |
7 | # Search for programs in the build host directories:
8 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
9 |
10 | # Search for libraries and headers in the target directories:
11 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/lib:
--------------------------------------------------------------------------------
1 | inherit android
2 | if [ Darwin = $(uname -s) ]; then
3 | inherit osx
4 | inherit ios
5 | fi
6 | inherit native
7 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/native:
--------------------------------------------------------------------------------
1 | inherit common
2 |
3 | # Builds a library using the native tools
4 | build_native() {
5 | # Put the source in the working directory:
6 | work_dir=$work_dir/native
7 | mkdir -p $work_dir
8 | unpack
9 |
10 | # Establish expected variables:
11 | target=native
12 | install_dir=$build_dir/prefix/native/$1
13 | cross=""
14 |
15 | export AR=ar
16 | export CC=clang
17 | export CXX="clang++"
18 |
19 | export CFLAGS="-g -fPIC -I${install_dir}/include"
20 | export CXXFLAGS="-g -fPIC -I${install_dir}/include"
21 | export LDFLAGS="-L${install_dir}/lib"
22 |
23 | export PKG_CONFIG_PATH="$install_dir/lib/pkgconfig:$install_dir/lib64/pkgconfig"
24 |
25 | cd $work_dir
26 | build
27 | }
28 |
29 | deps="download"
30 | for dep in $depends; do
31 | deps="$deps $dep.build-native"
32 | done
33 | task build-native $deps
34 | default=build-native
35 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/native.cmake:
--------------------------------------------------------------------------------
1 | # Where is the target environment:
2 | set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}")
3 |
4 | # Search for programs in the build host directories:
5 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
6 |
7 | # Search for libraries and headers in the target directories:
8 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
9 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
10 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/osx:
--------------------------------------------------------------------------------
1 | inherit common
2 |
3 | # Performs an iOS-style build.
4 | # $1 arch name for compiler, work_dir and install_dir.
5 | build_osx() {
6 | # Put the source in the working directory:
7 | top_work_dir=$work_dir
8 | work_dir=$work_dir/osx-$1
9 | mkdir -p $work_dir
10 | unpack
11 |
12 | # Establish expected variables:
13 | target=osx-$1
14 | install_dir=$build_dir/prefix/osx/$1
15 | cross=""
16 |
17 | # Locate Xcode build tools:
18 | xcode_dir=$(xcode-select -print-path | sed -e 's@/$@@')
19 | platform_dir=$xcode_dir/Platforms/MacOSX.platform/Developer
20 |
21 | export AR="ar"
22 | export CC="clang"
23 | export CCLD="clang"
24 | export CPP="clang -E"
25 | export CXX="clang++"
26 |
27 | platform_sdk="$platform_dir/SDKs/MacOSX.sdk"
28 | sdk_flags="-arch $1 -isysroot $platform_sdk -mmacosx-version-min=10.9 -O2"
29 | export CFLAGS="$sdk_flags -isystem${install_dir}/include"
30 | export CXXFLAGS="$sdk_flags -isystem${install_dir}/include"
31 | export LDFLAGS="$sdk_flags -L${install_dir}/lib"
32 |
33 | export PATH=$xcode_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin:$xcode_dir/usr/bin:$PATH
34 | export PKG_CONFIG_PATH=$install_dir/lib/pkgconfig
35 |
36 | cd $work_dir
37 | build
38 |
39 | # File lists:
40 | ([ -n "$lib" ] && (cd $install_dir; find $lib -type f) || true) > \
41 | $top_work_dir/lib-${target}.txt
42 | ([ -n "$include" ] && (cd $install_dir; find $include -type f) || true) > \
43 | $top_work_dir/include-${target}.txt
44 | }
45 | build_osx_i386() {
46 | build_osx i386
47 | }
48 | build_osx_x86_64() {
49 | build_osx x86_64
50 | }
51 |
52 | arches="i386 x86_64"
53 |
54 | for arch in $arches ; do
55 | deps="download"
56 | for dep in $depends; do
57 | deps="$deps $dep.build-osx-$arch"
58 | done
59 | task build-osx-$arch $deps
60 | done
61 |
62 | # Creates a universal binary from the various platform-specific files
63 | osx_universal() {
64 | # Expand wildcards:
65 | libs=$(cd $build_dir/prefix/osx/i386; echo $lib)
66 | for l in $libs; do
67 | in_libs=$(echo $build_dir/prefix/osx/*/$l)
68 | out_name=$work_dir/osx-universal/$l
69 | mkdir -p $(dirname $out_name)
70 | echo "lipo -create $in_libs -output $out_name"
71 | lipo -create $in_libs -output $out_name
72 | done
73 | }
74 | task osx-universal $(for arch in $arches; do echo build-osx-$arch; done) \
75 | $(for dep in $depends; do echo $dep.osx-universal; done)
76 |
77 | package_osx_universal() {
78 | package_dir=${recipe}-osx-universal
79 | rm -rf $package_dir
80 | mkdir $package_dir
81 | depends=$(cat depends)
82 |
83 | # Gather universal libraries:
84 | cp -rv osx-universal/* $package_dir
85 | for dep in $depends; do
86 | cp -rv $build_dir/$dep/osx-universal/* $package_dir
87 | done
88 |
89 | # Gather headers:
90 | for f in $(cat include-osx-i386.txt); do
91 | mkdir -p $(dirname $package_dir/$f)
92 | ln -vs $build_dir/prefix/osx/i386/$f $package_dir/$f
93 | done
94 |
95 | # Make the archive:
96 | zip -r $recipe-osx-universal-$(date +%Y-%m-%d) $package_dir
97 | }
98 | task package-osx-universal write-deps osx-universal
99 |
100 | default=package-osx-universal
101 |
--------------------------------------------------------------------------------
/native-libs/deps/classes/osx.toolchain.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME Darwin)
2 | set(CMAKE_SYSTEM_VERSION 1)
3 |
4 | # Where is the target environment:
5 | set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}")
6 |
7 | # Search for programs in the build host directories:
8 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
9 |
10 | # Search for libraries and headers in the target directories:
11 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
12 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
13 |
--------------------------------------------------------------------------------
/native-libs/deps/documentation.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | The build system consists of recipe files and classes. Recipe files typically contain instructions for building a specific piece of software, while classes typically contain more general information like "how to build something for Android." Both recipes and classes are written in the shell scripting language.
4 |
5 | Recipes exist to define "tasks", which are simply functions that can be invoked from the outer build script. Tasks can have dependencies, which the build script will run before running the task itself. The script remembers which tasks have been run successfully, and will not run them again unless the recipe has changed, the task has been cleaned, or a dependency has been updated.
6 |
7 | The `inherit` keyword allows a recipe to pull in a class. Any code that exists in the class becomes part of the recipe. Most recipes do not include task definitions themselves, but instead rely on one or more classes to provide common tasks such as `download`, `clean`, or `build-android-arm`. The recipes then customize these tasks with various variable or function definitions. For example, defining a `source` variable tells the `download` task which files to get.
8 |
9 | # Running the script
10 |
11 | The build script integrates with the standard `make` tool. The command for building a specific library is often just as simple as `make library-name`. The script will automatically download the necessary source files, set up the toolchains, and build the library along with any other libraries it depends on.
12 |
13 | To run a specific task defined in a recipe, the syntax is `make recipe.task`. Omitting the task name runs the default task for the recipe, if there is one. It is also possible to specify more than one task at once. Standard make options like `-j` should also work as expected.
14 |
15 | To change the directory where the build script places its work, define the environment variable `BUILD_DIR`. For more information, see the "Common directory names" section.
16 |
17 | # Writing Recipes
18 |
19 | ## Keywords
20 |
21 | ### inherit
22 |
23 | The `inherit` keyword pulls in a class, similar to how the shell's `source` keyword works. The `inherit` keyword provides built-in multiple-include protection to avoid reading a common base class more than once.
24 |
25 | ### task
26 |
27 | The `task` keyword defines a task to be run. The first parameter is the name of the task, and the recipe must provide a shell function with the same name. It is traditional for task names to use hyphens, but these are not valid characters for shell function names. Therefore, the build script automatically converts hyphens to underscores when it looks for the corresponding function.
28 |
29 | The remaining parameters to the `task` keyword are a list of dependencies. To specify a task from a specific recipe, use the "recipe.task" naming convention. Dependencies without a recipe name are assumed to come from the current task.
30 |
31 | ## Common directory names
32 |
33 | The build script provides variables with these paths:
34 |
35 | * base_dir - The location "make" is run from.
36 | * build_dir - The "build" directory where all work takes place.
37 | * download_dir - The "download" directory where all sources are downloaded.
38 | * work_dir - The per-recipe working directory. The run script switches to this directory before running tasks. The unpack task writes its output here, and the "build" tasks should run inside this directory.
39 | * recipe_dir - The directory where the recipe file is located.
40 |
41 | Every recipe has a work directory. The top-level script is responsible for creating this directory, and `cd`'s into the directory prior to running any recipe tasks. The build script also places its own per-recipe state information into the work directory, including logs, task-done state files, and makefile fragments. These files have the extensions `.log`, `.done`, and `.mk`, respectively, so the recipe itself should avoid creating files with similar names. Instead, the recipe should probably create its own working directory under the work directory, where it unpacks and builds its source code.
42 |
43 | The per-recipe work directories live inside the build directory. By default, the build directory is called `build` an lives in the same directory as the build script. Setting the `BUILD_DIR` environment variable moves the work directory, making it possible to place the build artifacts in a different location than the build script. The `BUILD_DIR` environment variable must be an absolute path name if it is set; a relative path name will not work.
44 |
45 | The `common` class provides a `download` task, which places its output in the `download_dir` directory.
46 |
47 | ## Common variables
48 |
49 | * default - If defined, this sets the default task for the current recipe.
50 |
51 | ## Specific tasks
52 |
53 | ### download
54 |
55 | The download task expects a `source` variable to be defined, which contains a space-separated list of URL's to download. The class defines a variable called `download_dir`, which contains the location of the downloaded files. To change the download directory, define an environment variable called `DOWNLOAD_DIR`.
56 |
57 | If the URL ends with `.git`, the download task will use git to download the source code.
58 |
59 | ### unpack
60 |
61 | The unpack task will search the same `source` variable used by the `download` task for files named `*.tar.*`. If it finds any, it unpacks them inside the work directory.
62 |
63 | Likewise, if the unpack task finds any URL's ending with `.git`, it will checkout the contents into the work directory.
64 |
65 | ### clean
66 |
67 | The clean task simply deletes the work directory and all its contents.
68 |
69 | ### build-*
70 |
71 | There are a whole family of `build` tasks for different platform and architecture combinations:
72 |
73 | * android-arm
74 | * android-arm64
75 | * android-x86
76 | * android-x86_64
77 | * ios-armv7
78 | * ios-armv7s
79 | * ios-arm64
80 | * ios-i386
81 | * ios-x86_64
82 |
83 | All these tasks expect the recipe to define a single `build` function, which should contain platform-independent build instructions. If some platform-specific adjustments are necessary, the build tasks define a `target` variable corresponding to one of the names in the list above.
84 |
85 | Besides the `target` variable, the build tasks also define a `cross` variable, which contains a target triplet suitable for passing to GNU autoconf.
86 |
87 | After building, the build function should install its files to the location given in the `install_dir` variable.
88 |
89 | The `depends` variable lists the names of recipes which must be built first before building the current recipe.
90 |
91 | The build function can expect common environment variables such as `CFLAGS` to be correctly configured for the current platform.
92 |
93 | ### ios-universal
94 |
95 | The ios-universal task combines iOS libraries for the various platforms into a single universal library. The list of libraries to combine in this way should be given in the `lib` variable.
96 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/boost/boost.recipe:
--------------------------------------------------------------------------------
1 | inherit lib
2 |
3 | version="1_62_0"
4 | source="https://github.com/ExodusMovement/react-native-fast-crypto/releases/download/v17.3.3/boost_1_62_0.tar.bz2#5fd97433c3f859d8cbab1eaed4156d3068ae3648"
5 |
6 | build_bjam() {
7 | echo "Building BJAM manually"
8 |
9 | xcode_dir=$(xcode-select -print-path | sed -e 's@/$@@')
10 | platform_dir="$xcode_dir/Platforms/MacOSX.platform/Developer"
11 | platform_sdk="$platform_dir/SDKs/MacOSX.sdk"
12 |
13 | # We need to build bjam using MacOSX toolchain
14 | PREV_CC=$CC
15 | PREV_PATH=$PATH
16 | PREV_CFLAGS=$CFLAGS
17 | export CC="clang"
18 | export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
19 | export CFLAGS="-isysroot $platform_sdk -Wno-implicit-function-declaration"
20 |
21 | echo "STARTING X"
22 |
23 | env
24 |
25 | (cd tools/build/src/engine && ./build.sh cc) > bootstrap.log 2>&1
26 | echo "ENDING"
27 | if [ $? -ne 0 ]; then
28 | echo
29 | echo "Failed to build Boost.Build build engine"
30 | echo "Consult 'bootstrap.log' for more details"
31 | exit 1
32 | fi
33 | cd "$pwd"
34 | arch=`cd tools/build/src/engine && ./bootstrap/jam0 -d0 -f build.jam --toolset=darwin --toolset-root= --show-locate-target && cd ..`
35 | cp "tools/build/src/engine/$arch/b2" .
36 | cp "tools/build/src/engine/$arch/bjam" .
37 |
38 | export CC=$CC
39 | export PATH=$PREV_PATH
40 | export CFLAGS=$PREV_CFLAGS
41 | }
42 |
43 | build() {
44 | LIBRARIES=--with-libraries=system,thread,regex
45 |
46 | cd boost_$version
47 |
48 | echo Patching boost for Android...
49 | if [[ $target == android* ]]
50 | then
51 | patch libs/filesystem/src/operations.cpp $recipe_dir/operations.cpp.patch
52 | patch -p1 < $recipe_dir/fix-asio-android.patch
53 | fi
54 | cp $recipe_dir/user-config.jam tools/build/src/user-config.jam
55 |
56 | build_bjam
57 |
58 | echo Bootstrapping boost...
59 | ./bootstrap.sh --prefix=$install_dir --with-bjam=bjam $LIBRARIES
60 |
61 | echo Building boost...
62 | export NO_BZIP2=1
63 | ./bjam -q -d+2 toolset=gcc-env link=static threading=multi install
64 | }
65 |
66 | include="include/boost/*"
67 | lib="lib/libboost_*.a"
68 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/boost/fix-asio-android.patch:
--------------------------------------------------------------------------------
1 | --- a/boost/config/user.hpp
2 | +++ b/boost/config/user.hpp
3 | @@ -131,3 +131,5 @@
4 | // to ensure the correct libraries are selected at link time.
5 | // #define BOOST_LIB_BUILDID amd64
6 |
7 | +#define BOOST_ASIO_DISABLE_SERIAL_PORT 1
8 | +
9 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/boost/operations.cpp.patch:
--------------------------------------------------------------------------------
1 | --- operations.cpp 2018-11-03 09:30:36.000000000 -0700
2 | +++ operations.new.cpp 2018-11-03 09:31:01.000000000 -0700
3 | @@ -12,10 +12,11 @@
4 |
5 | // define 64-bit offset macros BEFORE including boost/config.hpp (see ticket #5355)
6 | #if !(defined(__HP_aCC) && defined(_ILP32) && !defined(_STATVFS_ACPP_PROBLEMS_FIXED))
7 | -#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect,
8 | +// #define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect,
9 | #endif
10 | #if !defined(__PGI)
11 | -#define __USE_FILE_OFFSET64 // but that is harmless on Windows and on POSIX
12 | +
13 | +// #define __USE_FILE_OFFSET64 // but that is harmless on Windows and on POSIX
14 | // 64-bit systems or on 32-bit systems which don't have files larger
15 | // than can be represented by a traditional POSIX/UNIX off_t type.
16 | // OTOH, defining them should kick in 64-bit off_t's (and thus
17 | @@ -26,7 +27,8 @@
18 | // That is required at least on Solaris, and possibly on other
19 | // systems as well.
20 | #else
21 | -#define _FILE_OFFSET_BITS 64
22 | +// #define _FILE_OFFSET_BITS 64
23 | +
24 | #endif
25 |
26 | // define BOOST_FILESYSTEM_SOURCE so that knows
27 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/boost/user-config.jam:
--------------------------------------------------------------------------------
1 | import os ;
2 | local AR = [ os.environ AR ] ;
3 | local CXX = [ os.environ CXX ] ;
4 | local CFLAGS = [ os.environ CFLAGS ] ;
5 | local RANLIB = [ os.environ RANLIB ] ;
6 |
7 | # We aren't necessarily using GCC, but the "gcc" toolchain lets us specify
8 | # our own binaries for everything. The final toolchain name is "gcc-env":
9 | using gcc : env : $(CXX) :
10 | $(AR)
11 | $(RANLIB)
12 | $(CFLAGS)
13 | -fvisibility=hidden
14 | -fvisibility-inlines-hidden
15 | -D_REENTRANT
16 | -D_GLIBCXX__PTHREADS
17 | ;
18 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/jni-bridge/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Sets the minimum version of CMake required to build your native library.
2 | # This ensures that a certain set of CMake features is available to
3 | # your build.
4 |
5 | cmake_minimum_required(VERSION 3.4.1)
6 |
7 | add_library(crypto_bridge SHARED
8 | crypto_bridge.cpp)
9 |
10 | add_library(nativecrypto
11 | SHARED
12 | IMPORTED)
13 |
14 | set_target_properties(nativecrypto
15 | PROPERTIES IMPORTED_LOCATION
16 | ${INSTALL_DIR}/lib/libnativecrypto.so)
17 |
18 | # Include libraries needed for crypto_bridge lib
19 | target_link_libraries(crypto_bridge nativecrypto android log)
20 |
21 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/jni-bridge/jni-bridge.recipe:
--------------------------------------------------------------------------------
1 | depends="nativecrypto"
2 | inherit lib
3 |
4 | source="../../../jni-bridge"
5 |
6 | build() {
7 | case $target in
8 | android-*) cmakeflags="-DCMAKE_TOOLCHAIN_FILE=$recipe_dir/../../classes/android.toolchain.cmake -DANDROID=1" ;;
9 | *) cmakeflags="-C$recipe_dir/../../classes/native.cmake" ;;
10 | esac
11 |
12 | # Replace CMakeLists.txt
13 | cp -f $recipe_dir/CMakeLists.txt .
14 |
15 | export CFLAGS="$CFLAGS -O2"
16 | export CXXFLAGS="$CXXFLAGS -O2"
17 |
18 | mkdir -p build
19 | cd build
20 |
21 | args="${cmakeflags} \
22 | -DCMAKE_INSTALL_PREFIX=${install_dir} \
23 | -DINSTALL_DIR:STRING=${install_dir} \
24 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
25 | -DBUILD_SHARED_LIBS:BOOL=FALSE"
26 |
27 | cmake .. $args
28 |
29 | make
30 | }
31 |
32 | lib="lib/libcrypto_bridge.a"
33 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/monerocorecustom/monerocorecustom.recipe:
--------------------------------------------------------------------------------
1 | inherit lib
2 |
3 | version="7a9839da54995b25974a04f607855f7b4f748d5b"
4 | source="https://github.com/ExodusMovement/monero-core-custom.git#${version}"
5 |
6 | build() {
7 | rm -rf $install_dir/repos/monero-core-custom
8 | mkdir -p $install_dir/repos/monero-core-custom
9 | cp -a . $install_dir/repos/monero-core-custom/
10 | }
11 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/mymonerocorecpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden")
4 | SET(INSTALL_DIR "" CACHE STRING "build/prefix install dir")
5 |
6 | project(mymonerocorecpp C CXX)
7 | #
8 | include_directories("${INSTALL_DIR}/include/") #
9 | #
10 | #include_directories("src")
11 | #
12 | set(MYMONERO_CORE_CPP ".")
13 | set(MYMONERO_CORE_CPP_SRC "${MYMONERO_CORE_CPP}/src")
14 | include_directories("${MYMONERO_CORE_CPP}/src")
15 | #
16 | set(MONERO_SRC "${MYMONERO_CORE_CPP}/contrib/monero-core-custom")
17 | include_directories(${MONERO_SRC})
18 | include_directories("${MONERO_SRC}/epee/include")
19 | include_directories("${MONERO_SRC}/common")
20 | include_directories("${MONERO_SRC}/crypto")
21 | include_directories("${MONERO_SRC}/cryptonote_basic")
22 | include_directories("${MONERO_SRC}/multisig")
23 | include_directories("${MONERO_SRC}/cryptonote_core")
24 | include_directories("${MONERO_SRC}/cryptonote_protocol")
25 | include_directories("${MONERO_SRC}/wallet")
26 | include_directories("${MONERO_SRC}/mnemonics")
27 | include_directories("${MONERO_SRC}/contrib/libsodium/include") # support sodium/… paths
28 | include_directories("${MONERO_SRC}/contrib/libsodium/include/sodium")
29 | #
30 | # keeping test files in a separate source directory
31 | # file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/test_*.cpp)
32 | #
33 | set(
34 | SRC_FILES
35 | #
36 | #src/index.cpp
37 | #
38 | ${MYMONERO_CORE_CPP_SRC}/main.cpp
39 | ${MYMONERO_CORE_CPP_SRC}/extend_helpers.cpp
40 | ${MYMONERO_CORE_CPP_SRC}/extend_helpers.hpp
41 | ${MYMONERO_CORE_CPP_SRC}/monero_address_utils.hpp
42 | ${MYMONERO_CORE_CPP_SRC}/monero_address_utils.cpp
43 | ${MYMONERO_CORE_CPP_SRC}/monero_paymentID_utils.hpp
44 | ${MYMONERO_CORE_CPP_SRC}/monero_paymentID_utils.cpp
45 | ${MYMONERO_CORE_CPP_SRC}/monero_key_image_utils.hpp
46 | ${MYMONERO_CORE_CPP_SRC}/monero_key_image_utils.cpp
47 | ${MYMONERO_CORE_CPP_SRC}/monero_fee_utils.hpp
48 | ${MYMONERO_CORE_CPP_SRC}/monero_fee_utils.cpp
49 | ${MYMONERO_CORE_CPP_SRC}/monero_transfer_utils.hpp
50 | ${MYMONERO_CORE_CPP_SRC}/monero_transfer_utils.cpp
51 | ${MYMONERO_CORE_CPP_SRC}/monero_send_routine.hpp
52 | ${MYMONERO_CORE_CPP_SRC}/monero_send_routine.cpp
53 | ${MYMONERO_CORE_CPP_SRC}/monero_fork_rules.hpp
54 | ${MYMONERO_CORE_CPP_SRC}/monero_fork_rules.cpp
55 | ${MYMONERO_CORE_CPP_SRC}/monero_wallet_utils.hpp
56 | ${MYMONERO_CORE_CPP_SRC}/monero_wallet_utils.cpp
57 | ${MYMONERO_CORE_CPP_SRC}/serial_bridge_index.hpp
58 | ${MYMONERO_CORE_CPP_SRC}/serial_bridge_index.cpp
59 | ${MYMONERO_CORE_CPP_SRC}/serial_bridge_utils.hpp
60 | ${MYMONERO_CORE_CPP_SRC}/serial_bridge_utils.cpp
61 | ${MYMONERO_CORE_CPP_SRC}/tools__ret_vals.hpp
62 | ${MYMONERO_CORE_CPP_SRC}/tools__ret_vals.cpp
63 | #
64 | ${MONERO_SRC}/cryptonote_basic/cryptonote_basic_impl.cpp
65 | ${MONERO_SRC}/cryptonote_basic/account.cpp
66 | ${MONERO_SRC}/cryptonote_basic/cryptonote_format_utils.cpp
67 | ${MONERO_SRC}/cryptonote_basic/cryptonote_format_utils_basic.cpp
68 | ${MONERO_SRC}/crypto/crypto.cpp
69 | ${MONERO_SRC}/crypto/hash.c
70 | ${MONERO_SRC}/crypto/slow-hash-dummied.cpp
71 | ${MONERO_SRC}/crypto/crypto-ops.c
72 | ${MONERO_SRC}/crypto/crypto-ops-data.c
73 | ${MONERO_SRC}/crypto/keccak.c
74 | ${MONERO_SRC}/crypto/chacha.c
75 | ${MONERO_SRC}/crypto/random.c
76 | ${MONERO_SRC}/crypto/tree-hash.c
77 | ${MONERO_SRC}/cryptonote_core/cryptonote_tx_utils.cpp
78 | ${MONERO_SRC}/common/base58.cpp
79 | ${MONERO_SRC}/common/aligned.c
80 | ${MONERO_SRC}/common/threadpool.cpp
81 | ${MONERO_SRC}/common/util.cpp
82 | ${MONERO_SRC}/epee/src/hex.cpp
83 | ${MONERO_SRC}/epee/src/int-util.cpp
84 | ${MONERO_SRC}/epee/src/string_tools.cpp
85 | ${MONERO_SRC}/epee/src/memwipe.c
86 | ${MONERO_SRC}/epee/src/mlocker.cpp
87 | ${MONERO_SRC}/epee/src/wipeable_string.cpp
88 | ${MONERO_SRC}/device/device.cpp
89 | ${MONERO_SRC}/device/device_default.cpp
90 | ${MONERO_SRC}/ringct/rctOps.cpp
91 | ${MONERO_SRC}/ringct/rctTypes.cpp
92 | ${MONERO_SRC}/ringct/rctCryptoOps.c
93 | ${MONERO_SRC}/ringct/rctSigs.cpp
94 | ${MONERO_SRC}/ringct/bulletproofs.cc
95 | ${MONERO_SRC}/ringct/bulletproofs_plus.cc
96 | ${MONERO_SRC}/ringct/multiexp.cc
97 | ${MONERO_SRC}/mnemonics/electrum-words.cpp
98 | ${MONERO_SRC}/crypto/rx-slow-hash-dummied.cpp
99 | ${MONERO_SRC}/contrib/libsodium/src/crypto_verify/verify.c
100 | )
101 |
102 | FILE(WRITE ${MYMONERO_CORE_CPP_SRC}/main.cpp
103 | "int main(void){return 0;}\n"
104 | )
105 |
106 | set(boost_DIR ${install_dir})
107 |
108 | add_library(boost_chrono STATIC IMPORTED)
109 | set_target_properties(
110 | boost_chrono PROPERTIES IMPORTED_LOCATION
111 | ${boost_DIR}/lib/libboost_chrono.a
112 | )
113 | add_library(boost_system STATIC IMPORTED)
114 | set_target_properties(
115 | boost_system PROPERTIES IMPORTED_LOCATION
116 | ${boost_DIR}/lib/libboost_system.a
117 | )
118 | add_library(boost_thread STATIC IMPORTED)
119 | set_target_properties(
120 | boost_thread PROPERTIES IMPORTED_LOCATION
121 | ${boost_DIR}/lib/libboost_thread.a
122 | )
123 |
124 | add_library(boost_regex STATIC IMPORTED)
125 | set_target_properties(
126 | boost_regex PROPERTIES IMPORTED_LOCATION
127 | ${boost_DIR}/lib/libboost_regex.a
128 | )
129 | add_library(mymonerocorecpp STATIC ${SRC_FILES})
130 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/mymonerocorecpp/mymonerocorecpp.recipe:
--------------------------------------------------------------------------------
1 | depends="boost monerocorecustom"
2 | inherit lib
3 |
4 | version="db133d3eda862e4d3879628e9a2b9ac68f077895"
5 | source="https://github.com/ExodusMovement/mymonero-core-cpp.git#${version}"
6 |
7 | build() {
8 | case $target in
9 | ios-*) cmakeflags="-DCMAKE_TOOLCHAIN_FILE=$recipe_dir/../../classes/ios.toolchain.cmake" ;;
10 | android-*) cmakeflags="-DCMAKE_TOOLCHAIN_FILE=$recipe_dir/../../classes/android.toolchain.cmake -DANDROID=1" ;;
11 | *) cmakeflags="-C$recipe_dir/../../classes/native.cmake" ;;
12 | esac
13 |
14 | # echo Patching...
15 | # patch -p1 < $recipe_dir/ios-build.patch
16 | # patch -p1 < $recipe_dir/timeout.patch
17 |
18 | rm -rf contrib/monero-core-custom
19 | cp -a $install_dir/repos/monero-core-custom/. contrib/monero-core-custom/
20 |
21 | # HACK: Remove duplicate files from prefix
22 | rm -rf \
23 | $install_dir/include/common \
24 | $install_dir/include/crypto \
25 | $install_dir/include/cryptonote_basic \
26 | $install_dir/include/cryptonote_protocol \
27 | $install_dir/include/device \
28 | $install_dir/include/ringct \
29 | $install_dir/include/rpc \
30 | $install_dir/include/serialization \
31 | $install_dir/include/sodium \
32 | $install_dir/include/storages \
33 | $install_dir/include/fnv1.h \
34 | $install_dir/include/hex.h \
35 | $install_dir/include/include_base_utils.h \
36 | $install_dir/include/memwipe.h \
37 | $install_dir/include/misc_language.h \
38 | $install_dir/include/misc_log_ex.h \
39 | $install_dir/include/mlocker.h \
40 | $install_dir/include/pragma_comp_defs.h \
41 | $install_dir/include/span.h \
42 | $install_dir/include/string_tools.h \
43 | $install_dir/include/warnings.h \
44 | $install_dir/include/wipeable_string.h \
45 | $install_dir/include/byte_slice.h \
46 | $install_dir/include/int-util.h \
47 | $install_dir/include/cryptonote_config.h
48 |
49 | # Replace CMakeLists.txt
50 | cp -f $recipe_dir/CMakeLists.txt .
51 |
52 | export CFLAGS="$CFLAGS -O2"
53 | export CXXFLAGS="$CXXFLAGS -O2"
54 |
55 | mkdir -p build
56 | cd build
57 |
58 | args="${cmakeflags} \
59 | -DCMAKE_INSTALL_PREFIX=${install_dir} \
60 | -DINSTALL_DIR:STRING=${install_dir} \
61 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
62 | -DBUILD_SHARED_LIBS:BOOL=FALSE"
63 |
64 | echo $args
65 |
66 | cmake .. $args || true # Run once to clear error
67 | cmake .. $args
68 |
69 | make
70 |
71 | cd ..
72 |
73 | # Copy top level directories
74 | cp -R contrib/monero-core-custom/common $install_dir/include/
75 | cp -R contrib/monero-core-custom/crypto $install_dir/include/
76 | cp -R contrib/monero-core-custom/cryptonote_basic $install_dir/include/
77 | cp -R contrib/monero-core-custom/cryptonote_protocol $install_dir/include/
78 | cp -R contrib/monero-core-custom/device $install_dir/include/
79 | cp -R contrib/monero-core-custom/ringct $install_dir/include/
80 | cp -R contrib/monero-core-custom/rpc $install_dir/include
81 | cp -R contrib/monero-core-custom/serialization $install_dir/include/
82 |
83 | # Copy contrib directories
84 | cp -R contrib/monero-core-custom/contrib/libsodium/include/sodium $install_dir/include/
85 |
86 | # Copy epee files
87 | cp -f contrib/monero-core-custom/epee/include/serialization/* $install_dir/include/serialization
88 | cp -R contrib/monero-core-custom/epee/include/storages $install_dir/include
89 | cp -f contrib/monero-core-custom/epee/include/fnv1.h $install_dir/include/
90 | cp -f contrib/monero-core-custom/epee/include/hex.h $install_dir/include/
91 | cp -f contrib/monero-core-custom/epee/include/include_base_utils.h $install_dir/include/
92 | cp -f contrib/monero-core-custom/epee/include/memwipe.h $install_dir/include/
93 | cp -f contrib/monero-core-custom/epee/include/misc_language.h $install_dir/include/
94 | cp -f contrib/monero-core-custom/epee/include/misc_log_ex.h $install_dir/include/
95 | cp -f contrib/monero-core-custom/epee/include/mlocker.h $install_dir/include/
96 | cp -f contrib/monero-core-custom/epee/include/pragma_comp_defs.h $install_dir/include/
97 | cp -f contrib/monero-core-custom/epee/include/span.h $install_dir/include/
98 | cp -f contrib/monero-core-custom/epee/include/string_tools.h $install_dir/include/
99 | cp -f contrib/monero-core-custom/epee/include/warnings.h $install_dir/include/
100 | cp -f contrib/monero-core-custom/epee/include/wipeable_string.h $install_dir/include/
101 | cp -f contrib/monero-core-custom/epee/include/byte_slice.h $install_dir/include/
102 | cp -f contrib/monero-core-custom/epee/include/int-util.h $install_dir/include/
103 |
104 | # Copy other
105 | cp -f contrib/monero-core-custom/cryptonote_config.h $install_dir/include/
106 | cp -f src/serial_bridge_index.hpp $install_dir/include/
107 | cp -f build/libmymonerocorecpp.a $install_dir/lib/
108 | }
109 |
110 | include="include/*"
111 | lib="lib/libmymonerocorecpp.a"
112 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/nativecrypto/nativecrypto.recipe:
--------------------------------------------------------------------------------
1 | depends="mymonerocorecpp"
2 | inherit lib
3 |
4 | build() {
5 | cd $base_dir/..
6 | export WORK_DIR=$work_dir
7 |
8 | case $target in
9 | android-*) output=libnativecrypto.so ;;
10 | *) output=libnativecrypto.a ;;
11 | esac
12 |
13 | export CFLAGS="$CFLAGS -O2"
14 | export CXXFLAGS="$CXXFLAGS -O2"
15 |
16 | # Build:
17 | make $output V=1
18 |
19 | # Install:
20 | mkdir -p $install_dir/lib
21 | cp $work_dir/$output $install_dir/lib
22 | cp src/native-crypto.h $install_dir/include
23 | }
24 |
25 | clean() {
26 | cd $base_dir/..
27 | export WORK_DIR=$work_dir
28 | make clean
29 | }
30 |
31 | tar() {
32 | cd $base_dir/..
33 | export WORK_DIR=$work_dir/native
34 | make tar V=1
35 | }
36 | task tar build-native
37 |
38 | lib="lib/libnativecrypto.a"
39 | include="include/native-crypto.h"
40 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/ndk/langinfo.h:
--------------------------------------------------------------------------------
1 | /* Android is missing these symbols for some reason,
2 | * so pick a reasonable approximation: */
3 | #ifndef RADIXCHAR
4 | #define RADIXCHAR MON_DECIMAL_POINT
5 | #endif
6 |
7 | #ifndef THOUSEP
8 | #define THOUSEP MON_THOUSANDS_SEP
9 | #endif
10 |
--------------------------------------------------------------------------------
/native-libs/deps/recipes/ndk/ndk.recipe:
--------------------------------------------------------------------------------
1 | # This recipe contains the setup tasks for unpacking and installing the NDK
2 | inherit common
3 |
4 | version="r15c"
5 |
6 | # Select the correct NDK version for the host system:
7 | case $(uname -sm) in
8 | "Linux x86_64")
9 | system=linux-x86_64
10 | source="https://dl.google.com/android/repository/android-ndk-$version-$system.zip#0bf02d4e8b85fd770fd7b9b2cdec57f9441f27a2" ;;
11 | "Darwin x86_64")
12 | system=darwin-x86_64
13 | source="https://dl.google.com/android/repository/android-ndk-$version-$system.zip#ea4b5d76475db84745aa8828000d009625fc1f98" ;;
14 | *)
15 | echo "Unknown host platform!"
16 | exit 1;;
17 | esac
18 |
19 | # Unzip the NDK archive.
20 | unzip_ndk() {
21 | echo Unpacking NDK...
22 | archive="$download_dir/android-ndk-$version-$system.zip"
23 | unzip -o -d"$work_dir" $archive
24 | }
25 | task unzip-ndk download
26 |
27 | # Extracts a standalone toolchain from the NDK.
28 | # $1 arch name for installing the toolchain.
29 | setup() {
30 | echo Unpacking toolchain...
31 | cd android-ndk-$version
32 | python build/tools/make_standalone_toolchain.py --verbose --arch $1 --api 21 --stl libc++ --force --install-dir $work_dir/$1
33 |
34 | echo Patching headers...
35 | cat $recipe_dir/langinfo.h >> $work_dir/$1/sysroot/usr/local/include/langinfo.h
36 | }
37 | setup_arm() {
38 | setup arm
39 | }
40 | setup_arm64() {
41 | setup arm64
42 | }
43 | setup_x86() {
44 | setup x86
45 | }
46 | setup_x86_64() {
47 | setup x86_64
48 | }
49 | task setup-arm unzip-ndk
50 | task setup-arm64 unzip-ndk
51 | task setup-x86 unzip-ndk
52 | task setup-x86_64 unzip-ndk
53 | default=setup-arm
54 |
--------------------------------------------------------------------------------
/native-libs/deps/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | # Command-line options:
6 | if [ $# -ne 2 ]; then
7 | echo "Usage:"
8 | echo " $0 recipe task"
9 | fi
10 | recipe=$1
11 | task=$2
12 |
13 | # Essential directories:
14 | base_dir=$(pwd)
15 |
16 | build_dir=${BUILD_DIR:-build}
17 | mkdir -p $build_dir
18 | build_dir=$(cd $build_dir; pwd)
19 |
20 | work_dir=$build_dir/$recipe
21 | mkdir -p $work_dir
22 |
23 | ################################################################################
24 | # Utility functions:
25 |
26 | # Returns true if the string is found in a list.
27 | # $1 the string to search for
28 | # $@ the list to search
29 | contains() {
30 | local string=$1 s
31 | shift
32 | for s; do
33 | [ $s = $string ] && return 0
34 | done
35 | return 1
36 | }
37 |
38 | # Takes an absolute path, and makes it relative to the base directory.
39 | # For example, `$(relative $build_dir/foo)` might return `build/foo`.
40 | relative() {
41 | echo ${1#$base_dir/}
42 | }
43 |
44 | # Returns the name of a recipe source file.
45 | # $1 recipe name
46 | recipe_file() {
47 | echo $base_dir/recipes/$1/$1.recipe
48 | }
49 |
50 | # Returns the name of a class source file.
51 | # $1 class name
52 | class_file() {
53 | echo $base_dir/classes/$1
54 | }
55 |
56 | # Returns the name of the makefile fragment for the given recipe.
57 | # $1 recipe name
58 | task_file() {
59 | echo $build_dir/$1/tasks.mk
60 | }
61 |
62 | # Returns the name of the state file associated with the given task.
63 | # $1 recipe name
64 | # $2 task name
65 | done_file() {
66 | echo $build_dir/$1/$2.done
67 | }
68 |
69 | # Returns the name of the state file associated with the given task.
70 | # $1 recipe and task name, in dot format
71 | done_file_dot() {
72 | local task=$1
73 | local raw_task=${task#*.} raw_recipe
74 | if [ $raw_task = $task ]; then
75 | raw_recipe=$recipe
76 | else
77 | raw_recipe=${task%%.*}
78 | fi
79 | echo $(done_file $raw_recipe $raw_task)
80 | }
81 |
82 | ################################################################################
83 | # Recipe commands:
84 |
85 | # Pulls in a class file. Like "source", but with double-include guards.
86 | # $1 class name
87 | recipe_files=$(relative $(recipe_file $recipe))
88 | inherit() {
89 | local class_file=$(class_file $1)
90 | if ! contains $(relative $class_file) $recipe_files; then
91 | recipe_files="$recipe_files $(relative $class_file)"
92 | source $class_file
93 | fi
94 | }
95 |
96 | # Defines a task to be performed
97 | # $1 the name of the new task
98 | # $@ any prerequisites for the task. If a prerequisite comes from another
99 | # recipe, it should be prefixed with the recipe name and a dot.
100 | recipe_tasks=write-tasks
101 | task() {
102 | local task=$1
103 | if contains $task $recipe_tasks; then
104 | echo >&2 "error: Task '$task' defined more than once in recipe '$recipe'"
105 | exit 1
106 | fi
107 | recipe_tasks="$recipe_tasks $task"
108 | }
109 |
110 | # The one built-in task, which is needed to bootstrap the whole thing.
111 | write_tasks() {
112 | out=$(task_file $recipe)
113 | echo >$out "# Generated from $(relative $(recipe_file $recipe))"
114 |
115 | # The write-tasks rule itself:
116 | echo >>$out "$recipe.write-tasks: $(relative $(task_file $recipe))"
117 | echo >>$out "$(relative $(task_file $recipe)): $recipe_files run.sh"
118 | echo >>$out " @./run.sh $recipe write-tasks" # Caution - literal tab character!
119 |
120 | # Redefine the task function to actually write tasks to disk:
121 | recipe_files=$(relative $(recipe_file $recipe))
122 | task() {
123 | local task=$1
124 | shift 1
125 |
126 | local dep deps="\$(wildcard $(relative $recipe_dir)/*)"
127 | for dep; do
128 | deps="$deps $(relative $(done_file_dot $dep))"
129 | done
130 |
131 | echo >>$out
132 | echo >>$out "$recipe.$task: $(relative $(done_file $recipe $task))"
133 | echo >>$out "$(relative $(done_file $recipe $task)): $deps"
134 | echo >>$out " @./run.sh $recipe $task" # Caution - literal tab character!
135 | }
136 | source $(recipe_file $recipe)
137 |
138 | # The default rule, if any:
139 | if [ -n "$default" ]; then
140 | echo >>$out
141 | echo >>$out "$recipe: $recipe.$default"
142 | fi
143 | }
144 |
145 | ################################################################################
146 | # Task runner:
147 |
148 | recipe_dir=$(dirname $(recipe_file $recipe))
149 | log=$work_dir/$task.log
150 | echo "Running $recipe.$task"
151 |
152 | source $(recipe_file $recipe)
153 |
154 | if ! contains $task $recipe_tasks; then
155 | echo >&2 "error: Task '$task' is not defined in recipe '$recipe'"
156 | exit 1
157 | fi
158 |
159 | # Run the task:
160 | set +e
161 | (
162 | set -e
163 | cd $work_dir
164 | $(echo $task | sed s/-/_/g)
165 | ) > $log 2>&1
166 | status=$?
167 | set -e
168 |
169 | # Handle errors:
170 | if [ $status -ne 0 ]; then
171 | echo "Task failed (see $(relative $log) for full logs):"
172 | echo "================================"
173 | tail $log
174 | echo "================================"
175 | exit $status
176 | fi
177 |
178 | # The clean rule deletes the build directory, so only update the
179 | # task-done file if the directory still exists:
180 | if [ -d $work_dir ]; then
181 | touch $(done_file $recipe $task)
182 | fi
183 |
--------------------------------------------------------------------------------
/native-libs/jni-bridge/crypto_bridge.cpp:
--------------------------------------------------------------------------------
1 | //fastCrypto.cpp
2 | #include
3 | #include
4 | #include
5 |
6 | #define LOG_TAG "crypto_bridge-JNI"
7 |
8 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
9 |
10 | extern "C" {
11 |
12 | /*
13 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
14 | *
15 | * @APPLE_LICENSE_HEADER_START@
16 | *
17 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
18 | *
19 | * This file contains Original Code and/or Modifications of Original Code
20 | * as defined in and that are subject to the Apple Public Source License
21 | * Version 2.0 (the 'License'). You may not use this file except in
22 | * compliance with the License. Please obtain a copy of the License at
23 | * http://www.opensource.apple.com/apsl/ and read it before using this
24 | * file.
25 | *
26 | * The Original Code and all software distributed under the License are
27 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
28 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
29 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
30 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
31 | * Please see the License for the specific language governing rights and
32 | * limitations under the License.
33 | *
34 | * @APPLE_LICENSE_HEADER_END@
35 | */
36 |
37 | #include
38 |
39 | JNIEXPORT jint JNICALL
40 | Java_co_airbitz_fastcrypto_MoneroAsyncTask_moneroCoreCreateRequest(JNIEnv *env, jobject thiz, jobject buf, jint height) {
41 | char *data = (char *) env->GetDirectBufferAddress(buf);
42 | if (data == nullptr) {
43 | // Return error code for invalid buffer
44 | return -1;
45 | }
46 |
47 | jlong capacity = env->GetDirectBufferCapacity(buf);
48 | if (capacity < 0) {
49 | // If 'buf' is not a direct buffer, capacity could be -1;
50 | // Not expected here since data != nullptr, but just in case
51 | // Return error code for invalid capacity
52 | return -2;
53 | }
54 |
55 | // Safely clamp 'capacity' to SIZE_MAX to avoid overflow in case jlong > size_t
56 | size_t max_length = (capacity > (jlong) SIZE_MAX)
57 | ? SIZE_MAX
58 | : (size_t) capacity;
59 |
60 | size_t length = 0;
61 | const char *m_body = create_blocks_request(height, &length);
62 | if (m_body == nullptr) {
63 | // Return error code for request creation failure
64 | return -3;
65 | }
66 |
67 |
68 | if (length > max_length) {
69 | // Return error code for insufficient buffer capacity
70 | return -4;
71 | }
72 |
73 | memcpy(data, m_body, length);
74 |
75 | return length;
76 | }
77 |
78 | JNIEXPORT jstring JNICALL
79 | Java_co_airbitz_fastcrypto_MoneroAsyncTask_extractUtxosFromBlocksResponse(JNIEnv *env, jobject thiz, jobject buf, jstring jsJsonParams) {
80 | char *data = (char *) env->GetDirectBufferAddress(buf);
81 | size_t length = (size_t) env->GetDirectBufferCapacity(buf);
82 | char *szJsonParams = (char *) env->GetStringUTFChars(jsJsonParams, 0);
83 |
84 | char *szResultHex = NULL;
85 | extract_utxos_from_blocks_response(data, length, szJsonParams, &szResultHex);
86 |
87 | // Free dynamically allocated memory to avoid memory leaks.
88 | env->ReleaseStringUTFChars(jsJsonParams, szJsonParams);
89 |
90 | if (szResultHex == nullptr) {
91 | return nullptr;
92 | }
93 |
94 | jstring out = env->NewStringUTF(szResultHex);
95 | free(szResultHex);
96 |
97 | return out;
98 | }
99 |
100 | JNIEXPORT jstring JNICALL
101 | Java_co_airbitz_fastcrypto_MoneroAsyncTask_extractUtxosFromClarityBlocksResponse(JNIEnv *env, jobject thiz, jobject buf, jstring jsJsonParams) {
102 | char *data = (char *) env->GetDirectBufferAddress(buf);
103 | size_t length = (size_t) env->GetDirectBufferCapacity(buf);
104 | char *szJsonParams = (char *) env->GetStringUTFChars(jsJsonParams, 0);
105 |
106 | char *szResultHex = NULL;
107 | extract_utxos_from_clarity_blocks_response(data, length, szJsonParams, &szResultHex);
108 |
109 | // Free dynamically allocated memory to avoid memory leaks.
110 | env->ReleaseStringUTFChars(jsJsonParams, szJsonParams);
111 |
112 | if (szResultHex == nullptr) {
113 | return nullptr;
114 | }
115 |
116 | jstring out = env->NewStringUTF(szResultHex);
117 | free(szResultHex);
118 |
119 | return out;
120 | }
121 |
122 | JNIEXPORT jstring JNICALL
123 | Java_co_airbitz_fastcrypto_MoneroAsyncTask_getTransactionPoolHashes(JNIEnv *env, jobject thiz, jobject buf) {
124 |
125 | char *data = (char *) env->GetDirectBufferAddress(buf);
126 | size_t length = (size_t) env->GetDirectBufferCapacity(buf);
127 |
128 | char *szResultHex = NULL;
129 | get_transaction_pool_hashes(data, length, &szResultHex);
130 | jstring out = env->NewStringUTF(szResultHex);
131 | free(szResultHex);
132 |
133 | return out;
134 | }
135 |
136 | JNIEXPORT jstring JNICALL
137 | Java_co_airbitz_fastcrypto_MoneroAsyncTask_moneroCoreJNI(JNIEnv *env, jobject thiz,
138 | jstring jsMethod,
139 | jstring jsJsonParams) {
140 | char *szJsonParams = (char *) 0;
141 | char *szMethod = (char *) 0;
142 |
143 | if (jsMethod) {
144 | szMethod = (char *) env->GetStringUTFChars(jsMethod, 0);
145 | if (!szMethod) {
146 | return env->NewStringUTF("Invalid monero method!");
147 | }
148 | }
149 |
150 | if (jsJsonParams) {
151 | szJsonParams = (char *) env->GetStringUTFChars(jsJsonParams, 0);
152 | if (!szJsonParams) {
153 | env->ReleaseStringUTFChars(jsMethod, szMethod);
154 | return env->NewStringUTF("Invalid monero jsonParams!");
155 | }
156 | }
157 |
158 | char *szResultHex = NULL;
159 | fast_crypto_monero_core(szMethod, szJsonParams, &szResultHex);
160 | jstring out = env->NewStringUTF(szResultHex);
161 | free(szResultHex);
162 | env->ReleaseStringUTFChars(jsJsonParams, szJsonParams);
163 | env->ReleaseStringUTFChars(jsMethod, szMethod);
164 | return out;
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/native-libs/src/.gitignore:
--------------------------------------------------------------------------------
1 | Test
2 | xcuserdata
3 |
--------------------------------------------------------------------------------
/native-libs/src/native-crypto.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, Airbitz, Inc.
3 | * All rights reserved.
4 | *
5 | * See the LICENSE file for more information.
6 | */
7 |
8 | #include "native-crypto.h"
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | const char *create_blocks_request(int height, size_t *length) {
17 | return serial_bridge::create_blocks_request(height, length);
18 | }
19 |
20 | void extract_utxos_from_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult) {
21 | std::string strParams = szJsonParams;
22 | std::string result = serial_bridge::extract_data_from_blocks_response_str(buffer, length, strParams);
23 |
24 | int size = result.length() + 1;
25 | *pszResult = (char *) malloc(sizeof(char) * size);
26 | if (*pszResult == nullptr) {
27 | // Memory allocation failed
28 | return;
29 | }
30 |
31 | memcpy(*pszResult, result.c_str(), result.length() + 1);
32 | }
33 |
34 | void extract_utxos_from_clarity_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult) {
35 | std::string strParams = szJsonParams;
36 | std::string result = serial_bridge::extract_data_from_clarity_blocks_response_str(buffer, length, strParams);
37 |
38 | int size = result.length() + 1;
39 | *pszResult = (char *) malloc(sizeof(char) * size);
40 |
41 | if (*pszResult == nullptr) {
42 | // Memory allocation failed
43 | return;
44 | }
45 |
46 | memcpy(*pszResult, result.c_str(), result.length() + 1);
47 | }
48 |
49 | void get_transaction_pool_hashes(const char *buffer, size_t length, char **pszResult) {
50 | std::string result;
51 |
52 | try {
53 | result = serial_bridge::get_transaction_pool_hashes_str(buffer, length);
54 | } catch (...) {
55 | result = "{\"err_msg\":\"mymonero-core-cpp threw an exception\"}";
56 | }
57 |
58 | int size = result.length() + 1;
59 | *pszResult = (char *) malloc(sizeof(char) * size);
60 | if (*pszResult == nullptr) {
61 | // Memory allocation failed
62 | return;
63 | }
64 |
65 | memcpy(*pszResult, result.c_str(), result.length() + 1);
66 | }
67 |
68 | void fast_crypto_monero_core(const char *szMethod, const char *szJsonParams, char **pszResult) {
69 | std::string strParams = szJsonParams;
70 | std::string method = szMethod;
71 | std::string result;
72 |
73 | try {
74 | if (method.compare("send_step1__prepare_params_for_get_decoys") == 0) {
75 | result = serial_bridge::send_step1__prepare_params_for_get_decoys(strParams);
76 | } else if (method.compare("pre_step2_tie_unspent_outs_to_mix_outs_for_all_future_tx_attempts") == 0) {
77 | result = serial_bridge::pre_step2_tie_unspent_outs_to_mix_outs_for_all_future_tx_attempts(strParams);
78 | } else if (method.compare("send_step2__try_create_transaction") == 0) {
79 | result = serial_bridge::send_step2__try_create_transaction(strParams);
80 | } else if (method.compare("decode_address") == 0) {
81 | result = serial_bridge::decode_address(strParams);
82 | } else if (method.compare("is_subaddress") == 0) {
83 | result = serial_bridge::is_subaddress(strParams);
84 | } else if (method.compare("is_integrated_address") == 0) {
85 | result = serial_bridge::is_integrated_address(strParams);
86 | } else if (method.compare("estimated_tx_network_fee") == 0) {
87 | result = serial_bridge::estimated_tx_network_fee(strParams);
88 | } else if (method.compare("generate_key_image") == 0) {
89 | result = serial_bridge::generate_key_image(strParams);
90 | } else if (method.compare("generate_key_derivation") == 0) {
91 | result = serial_bridge::generate_key_derivation(strParams);
92 | } else if (method.compare("derive_public_key") == 0) {
93 | result = serial_bridge::derive_public_key(strParams);
94 | } else if (method.compare("derive_subaddress_public_key") == 0) {
95 | result = serial_bridge::derive_subaddress_public_key(strParams);
96 | } else if (method.compare("decodeRct") == 0) {
97 | result = serial_bridge::decodeRct(strParams);
98 | } else if (method.compare("decodeRctSimple") == 0) {
99 | result = serial_bridge::decodeRctSimple(strParams);
100 | } else if (method.compare("derivation_to_scalar") == 0) {
101 | result = serial_bridge::derivation_to_scalar(strParams);
102 | } else if (method.compare("encrypt_payment_id") == 0) {
103 | result = serial_bridge::encrypt_payment_id(strParams);
104 | } else if (method.compare("extract_utxos") == 0) {
105 | result = serial_bridge::extract_utxos(strParams);
106 | } else {
107 | *pszResult = NULL;
108 | return;
109 | }
110 | } catch (std::exception &e) {
111 | std::string error_message;
112 | error_message.append("{\"err_msg\":\"mymonero-core-cpp threw an std::exception ");
113 | error_message.append(e.what());
114 | error_message.append("\"}");
115 |
116 | result = error_message;
117 | } catch (...) {
118 | result = "{\"err_msg\":\"mymonero-core-cpp threw an unknown type\"}";
119 | }
120 | int size = result.length() + 1;
121 | *pszResult = (char *) malloc(sizeof(char) * size);
122 | if (*pszResult == nullptr) {
123 | // Memory allocation failed
124 | return;
125 | }
126 |
127 | memcpy(*pszResult, result.c_str(), result.length() + 1);
128 | }
129 |
130 |
--------------------------------------------------------------------------------
/native-libs/src/native-crypto.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, Airbitz
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms are permitted provided that
6 | * the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this
9 | * list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. Redistribution or use of modified source code requires the express written
14 | * permission of Airbitz Inc.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | *
27 | * The views and conclusions contained in the software and documentation are those
28 | * of the authors and should not be interpreted as representing official policies,
29 | * either expressed or implied, of the Airbitz Project.
30 | */
31 | /**
32 | * @file
33 | * AirBitz public API. The wallet only calls functions found in this file.
34 | */
35 |
36 | #ifndef native_crypto_h
37 | #define native_crypto_h
38 |
39 | #include
40 | #include
41 | #include
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | const char *create_blocks_request(int height, size_t *length);
48 | void extract_utxos_from_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult);
49 | void extract_utxos_from_clarity_blocks_response(const char *buffer, size_t length, const char *szJsonParams, char **pszResult);
50 | void get_transaction_pool_hashes(const char *buffer, size_t length, char **pszResult);
51 |
52 | void fast_crypto_monero_core(const char *szMethod, const char *szJsonParams, char **pszResult);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif // native_crypto_h
59 |
--------------------------------------------------------------------------------
/native-libs/test/README.md:
--------------------------------------------------------------------------------
1 | ### Input format
2 |
3 | ```json
4 | {
5 | "storage_path": "/tmp",
6 | "storage_percent": 10,
7 | "latest": 2077262,
8 | "oldest": 2075072,
9 | "size": 330,
10 | "params_by_wallet_account": {
11 | "exodus_0": {
12 | "send_txs": [
13 | "a3aa1e4e3565d9e0122013576f8197fe3e0d0552cc5e7ab0afd0abe5260fef36"
14 | ],
15 | "sec_viewKey_string": "0000000000000000000000000000000000000000000000000000000000000000",
16 | "pub_spendKey_string": "0000000000000000000000000000000000000000000000000000000000000000"
17 | },
18 | "exodus_1": {
19 | "key_images": [
20 | "599a3d0f3064ad088449bfbb71d2ef72ef4b84d786f9cb796cc65e8d26f65deb"
21 | ],
22 | "sec_viewKey_string": "0000000000000000000000000000000000000000000000000000000000000000",
23 | "pub_spendKey_string": "0000000000000000000000000000000000000000000000000000000000000000",
24 | "sec_spendKey_string": "0000000000000000000000000000000000000000000000000000000000000000"
25 | }
26 | }
27 | }
28 | ```
29 |
30 | ### Output format
31 |
32 | ```json
33 | {
34 | "current_height": "1971749",
35 | "end_height": "1971748",
36 | "latest": "2077262",
37 | "oldest": "1971010",
38 | "size": "331",
39 | "txs_by_wallet_account": {
40 | "exodus_0": [
41 | {
42 | "id": "a3aa1e4e3565d9e0122013576f8197fe3e0d0552cc5e7ab0afd0abe5260fef36",
43 | "timestamp": "1574262755",
44 | "height": "1971100",
45 | "pub": "815315f6b25c26fd309b8de73197269263f249003d751e539e94e2058823a025",
46 | "fee": "37370000",
47 | "epid": "7229840319f07c53",
48 | "inputs": [
49 | "4826deeff1b32151c2bfc612162bc1b800a3f82f09e1131a5ede7b2b88f69d83",
50 | "0ed2a535c0bcda7636224644c974ca7a369548723676ec7946950e3a40390f1b"
51 | ],
52 | "utxos": ""
53 | }
54 | ],
55 | "exodus_1": [
56 | {
57 | "id": "599a3d0f3064ad088449bfbb71d2ef72ef4b84d786f9cb796cc65e8d26f65deb",
58 | "timestamp": "1574275165",
59 | "height": "1971222",
60 | "pub": "94223f05cc7747d02658fff46b30191db67077c03693b7df78d6185c1ddf43f7",
61 | "fee": "37450000",
62 | "epid": "99dd0b7fe1df4f5d",
63 | "inputs": [
64 | "6e18d72efc34451d207fb679d18959f8f216b70e34eae84c460c5856b890fffc",
65 | "28df8dc7e44dbc08d27681dbbce6ae999bf9a5e61b44154a4b42e83584c92b4f"
66 | ],
67 | "utxos": ""
68 | }
69 | ]
70 | }
71 | }
72 | ```
73 |
--------------------------------------------------------------------------------
/native-libs/test/input/blocks.json.gzip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ExodusMovement/react-native-fast-crypto/4e3cf8723118b40f79fdb878a419654a794607d9/native-libs/test/input/blocks.json.gzip
--------------------------------------------------------------------------------
/native-libs/test/input/d.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ExodusMovement/react-native-fast-crypto/4e3cf8723118b40f79fdb878a419654a794607d9/native-libs/test/input/d.bin
--------------------------------------------------------------------------------
/native-libs/test/input/input.json:
--------------------------------------------------------------------------------
1 | {
2 | "storage_path": "/tmp",
3 | "storage_percent": 10,
4 | "latest": 2077262,
5 | "oldest": 2075072,
6 | "size": 330,
7 | "params_by_wallet_account": {
8 | "exodus_0": {
9 | "subaddresses": 200,
10 | "key_images": [],
11 | "sec_viewKey_string": "12de640c5e8e7e318ee701ca4801287f13c657b8290073338b57caa44b21c505",
12 | "pub_spendKey_string": "df9cee70033050334f5b1b94b180fa2c08c96149354df0c5337c251b78f01d3a",
13 | "sec_spendKey_string": "f3be56ce634c13d47f8170e4f44f9643d4072a28a73d9dc080a5b0dc2ee4a90b"
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/native-libs/test/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | void test_encode() {
16 | size_t length = 0;
17 | const char *body = serial_bridge::create_blocks_request(1573230, &length);
18 |
19 | std::ofstream out("test/output/req.bin", std::ios::binary);
20 | out.write(body, length);
21 |
22 | out.close();
23 |
24 | std::free((void *)body);
25 | }
26 |
27 | void test_decode() {
28 | std::ifstream in("test/input/d.bin", std::ios::binary | std::ios::ate);
29 | if (!in) {
30 | std::cout << "No file\n";
31 | return;
32 | }
33 |
34 | int size = in.tellg();
35 | in.seekg(0, std::ios::beg);
36 | char *input = new char[size];
37 | in.read(input, size);
38 | std::string m_body(input, size);
39 |
40 | std::ifstream paramsFile("test/input/input.json");
41 | std::stringstream paramsStream;
42 | paramsStream << paramsFile.rdbuf();
43 | std::string params = paramsStream.str();
44 |
45 | auto resp = serial_bridge::extract_data_from_blocks_response_str(input, size, params);
46 | std::cout << resp << '\n';
47 |
48 | delete[] input;
49 | }
50 |
51 | void test_decompress() {
52 | std::ifstream file("test/input/blocks.json.gzip", std::ios::binary | std::ios::ate);
53 | if (!file) {
54 | throw std::runtime_error("Failed to open file");
55 | }
56 |
57 | file.seekg(0, std::ios::end);
58 | size_t fileSize = file.tellg();
59 | file.seekg(0, std::ios::beg);
60 |
61 | // Read the file into a vector
62 | char *buffer = new char[fileSize];
63 | if (!file.read(buffer, fileSize)) {
64 | throw std::runtime_error("Failed to read file");
65 | }
66 |
67 | size_t length = 0;
68 | std::string decompressedData = serial_bridge::decompress(buffer, fileSize);
69 |
70 | delete[] buffer;
71 | }
72 |
73 | void test_decode_with_clarity() {
74 | std::ifstream file("test/input/blocks.json.gzip", std::ios::binary | std::ios::ate);
75 | if (!file) {
76 | throw std::runtime_error("Failed to open file");
77 | }
78 |
79 | file.seekg(0, std::ios::end);
80 | size_t fileSize = file.tellg();
81 | file.seekg(0, std::ios::beg);
82 |
83 | // Read the file into a vector
84 | char *buffer = new char[fileSize];
85 | if (!file.read(buffer, fileSize)) {
86 | throw std::runtime_error("Failed to read file");
87 | }
88 |
89 | std::ifstream paramsFile("test/input.json");
90 | std::stringstream paramsStream;
91 | paramsStream << paramsFile.rdbuf();
92 | std::string params = paramsStream.str();
93 |
94 | auto resp = serial_bridge::extract_data_from_clarity_blocks_response_str(buffer, fileSize, params);
95 | std::cout << resp << '\n';
96 |
97 | delete[] buffer;
98 | }
99 |
100 | static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
101 | std::vector* buffer = (std::vector*)userp;
102 | const char* data = (const char*)contents;
103 | buffer->insert(buffer->end(), data, data + size * nmemb); // Append data to vector
104 | return size * nmemb;
105 | }
106 |
107 | bool downloadFile(const std::string& url, std::vector& buffer) {
108 | CURL *curl;
109 | CURLcode res;
110 | curl = curl_easy_init();
111 | if (curl) {
112 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
113 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
114 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
115 | res = curl_easy_perform(curl);
116 | curl_easy_cleanup(curl);
117 | return (res == CURLE_OK);
118 | }
119 | curl_easy_cleanup(curl); // Clean up even if curl_easy_init fails
120 | return false;
121 | }
122 |
123 | void test_full_flow_with_clarity() {
124 | std::string url = "https://xmr-proxy-d.a.exodus.io/v1/monero/get_blocks_file/3148308.json.gzip";
125 | std::vector buffer;
126 |
127 | std::cout << "Start download blocks file" << '\n';
128 | downloadFile(url, buffer);
129 | if (!downloadFile(url, buffer)) {
130 | std::cerr << "Failed to download blocks file\n";
131 | return;
132 | }
133 | std::cout << "Done download file" << '\n';
134 |
135 | std::ifstream paramsFile("test/input/input.json");
136 | if (!paramsFile) {
137 | std::cerr << "Failed to open parameter file\n";
138 | return;
139 | }
140 |
141 | std::stringstream paramsStream;
142 | paramsStream << paramsFile.rdbuf();
143 | std::string params = paramsStream.str();
144 |
145 | auto resp = serial_bridge::extract_data_from_clarity_blocks_response_str(buffer.data(), buffer.size(), params);
146 | std::cout << resp << '\n';
147 | return;
148 | }
149 |
150 | int main() {
151 | test_encode();
152 | test_decode();
153 | test_decompress();
154 | // test_decode_with_clarity();
155 | test_full_flow_with_clarity();
156 |
157 | return 0;
158 | }
159 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@exodus/react-native-fast-crypto",
3 | "version": "18.3.5-rc.1",
4 | "description": "Native C/C++ implemented crypto libraries for React Native apps",
5 | "keywords": [
6 | "react-native",
7 | "scrypt",
8 | "fast",
9 | "native"
10 | ],
11 | "homepage": "https://github.com/EdgeApp/react-native-fast-crypto",
12 | "repository": {
13 | "type": "git",
14 | "url": "git@github.com:EdgeApp/react-native-fast-crypto.git"
15 | },
16 | "license": "MIT",
17 | "author": "Edge",
18 | "contributors": [
19 | "Paul Puey "
20 | ],
21 | "main": "index.js",
22 | "scripts": {
23 | "test": "NATIVE_TESTS=1 ./build-deps",
24 | "build": "yarn build:native",
25 | "prebuild:native": "rm -rf ios/Libraries android/jni/libs",
26 | "build:native": "./build-deps",
27 | "postbuild:native": "./generate-sums.sh"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/shasums.txt:
--------------------------------------------------------------------------------
1 | 88dfb22350eae3607637539f1d3871b6b58dc388f18bd6b81fcbb4d44212e421 ios/Frameworks/libboost_atomic.a.xcframework/ios-arm64_armv7_armv7s/libboost_atomic.a
2 | dff0a485e8499b7b5a8010d9b0d851fb2163b3553d04237af212174a529884d3 ios/Frameworks/libboost_atomic.a.xcframework/ios-arm64_i386_x86_64-simulator/libboost_atomic.a
3 | 192597687e456b690f47c595c0e8eabd6049de6eb98966e970f1b7d1d62b39c4 ios/Frameworks/libboost_regex.a.xcframework/ios-arm64_armv7_armv7s/libboost_regex.a
4 | 18ab88644fbe46ea707bfdac7a1d59ed508bc1c43a4fd2fadc7d97fd81d291e1 ios/Frameworks/libboost_regex.a.xcframework/ios-arm64_i386_x86_64-simulator/libboost_regex.a
5 | 0cb0ef5a558f63fe4c2c8750fcfb6b42965214b392c301ec0a994ddef51467fe ios/Frameworks/libboost_system.a.xcframework/ios-arm64_armv7_armv7s/libboost_system.a
6 | b6e45f0a4e7aadb215c1704ab3d1cb2b2fb2c3d315390b488a38fc48bf7bf0cc ios/Frameworks/libboost_system.a.xcframework/ios-arm64_i386_x86_64-simulator/libboost_system.a
7 | 575e148ea01773085573ccfdd651592179c041d7bd322785b59312b7e96ddba0 ios/Frameworks/libboost_thread.a.xcframework/ios-arm64_armv7_armv7s/libboost_thread.a
8 | 11caf18ecdd380f005bc80e6901c7fe0919b3d03b040cc5b20cb33543da3e416 ios/Frameworks/libboost_thread.a.xcframework/ios-arm64_i386_x86_64-simulator/libboost_thread.a
9 | c242c51c3230c1e3d6162708299b691ffc3c04d71aa28dc4fa360025a0344430 ios/Frameworks/libmymonerocorecpp.a.xcframework/ios-arm64_armv7_armv7s/libmymonerocorecpp.a
10 | c35aaaed386512c24b39e77dded75acd26804ad666662339ece35056d0aa22fc ios/Frameworks/libmymonerocorecpp.a.xcframework/ios-arm64_i386_x86_64-simulator/libmymonerocorecpp.a
11 | e05026534351be7ec8891c2e7ea5dbba34f4eaacaf7a8285095641864b67b37a ios/Frameworks/libnativecrypto.a.xcframework/ios-arm64_armv7_armv7s/libnativecrypto.a
12 | eea6c3414ec15395c0e499b70e331a4cf0dfdbaa4bb0170ce1c9a39836e02347 ios/Frameworks/libnativecrypto.a.xcframework/ios-arm64_i386_x86_64-simulator/libnativecrypto.a
13 | 46640a59840be914f759beb99382ad8d6ed94a255660b6c220bcd600632be6b3 android/jni/libs/arm64-v8a/libcrypto_bridge.so
14 | e3bf23fc8a6cd2dc9c15f5e6c1b18f8b72ca407bfac063b5d16b3079eb279e2e android/jni/libs/arm64-v8a/libnativecrypto.so
15 | 498b3d918352c573188054d5fd5b843f666bef003662efbeed802eb57400faac android/jni/libs/armeabi-v7a/libcrypto_bridge.so
16 | 15c706575f6fb14923d2075fa904b49e760845e3412aa25bd197c24d0d43a8ff android/jni/libs/armeabi-v7a/libnativecrypto.so
17 | 6ad211e4e5ef3dc24b0d26bd6d1ce364add0160f76c87322adee1d03dac2c0f4 android/jni/libs/x86/libcrypto_bridge.so
18 | 2cf23134a276eeea5fcd320bc3079f5c9a484a17567e16d8e37318992d8b00a6 android/jni/libs/x86/libnativecrypto.so
19 | 1152558c5ed6324a3a935dd9acab7e91fade049507a99ca88ccbff05319c475f android/jni/libs/x86_64/libcrypto_bridge.so
20 | 1987c9a6792d4277ae8c1fa3328fe1ca577cc347cef3d597bb5dc63cf5cdcdd1 android/jni/libs/x86_64/libnativecrypto.so
21 |
--------------------------------------------------------------------------------