cake_wallet
cake_wallet copied to clipboard
Wownero integration
Wownero integration
Due to previous cw_haven
integration efforts, creating this Wownero pull request was not too complicated.
Wownero is derived from Monero, as such the plugin cw_wownero
provided in this pull-request is similar to the cw_monero
plugin.
14 word seeds
The desktop wallet for Wownero (wowlet) uses 14 word mnemonic seeds. This seed scheme has a number of advantages over Monero core's seed scheme:
- The wallet creation date is embedded in the mnemonic seed. This way someone does not have to worry about restoring from the correct restore height.
- It uses BIP-39 wordlists. These wordlists container shorter and more common words than Monero's lists.
- 14 word seeds are quicker to write down and memorize.
Most importantly it avoids people bothering Cake's support department when funds are seemingly missing due to bad restore heights.
The library that achieves this can be found here: git.wownero.com/wowlet/wownero-seed.
-
scripts/*/build_wownero_seed.sh
will build it as a static library and move it into the appropriate dirs:- e.g:
cw_shared_external/ios/External/android/x86/lib/libwownero-seed.a
- e.g:
cw_shared_external/ios/External/android/x86/include/wownero_seed/
- e.g:
-
cw_wownero
links againstmonero-seed
, seecw_wownero/android/CMakeList.txt
This also means, for example, the 'restore from seed' screen only has 2 fields: name
, seed
:
The UI (stuff inside lib/src/screens/
) was flexible enough to deal with 14 word seeds without requiring a drastic change.
Some other things to note
1. Restoring from keys is disabled
Restoring from keys is an advanced feature. Wownero likes to keep it simple. As such, the only way to restore a wallet is via the mnemonic seed.
2. USD calculations are not working
I made an issue here https://github.com/cake-tech/cake_wallet/issues/361
3. Date -> restore height
calculations are 'built-in'
The function to calculate the restore height (dateToRestoreHeight()) from an arbitrary timestamp is provided by wownero-seed.
This means there is no need for Cake to provide its own implementation (as opposed to cw_monero
, cw_haven
).
4. iOS
I was able to build this PR on my Mac (M1) but was stuck getting the emulator to run.
This means I could not test inside an iOS emulator. Seems like I need a developer account (?). It was confusing.
I made sure to update scripts/ios/*
accordingly and as far as I can tell, everything builds fine under Mac OS.
Someone ought to test this PR inside an iOS emulator though.
5. Git repositories are pinned to hashes
This pull-request introduces 2 new repositories, both are pinned to commit hashes, ensuring that during the build process it enforces downloading a specific version.
-
https://git.wownero.com/wownero/wownero.git
-
https://git.wownero.com/wowlet/wownero-seed.git
6. Our Wownero repository needed a patch
The armv7a
Android build of Wownero was failing to compile. I had to:
- update
src/crypto/slow-hash.c
to the latest version that Monero currently has - modify
variant4_random_math.h
to facilitate the changes inslow-hash.c
This patch was done in branch origin/fix-armv7a-compile
So, scripts/*/build_wownero.sh
is currently on the fix-armv7a-compile
branch
In short; src/crypto/slow-hash.c
is now up to date with upstream Monero (I just copied the contents).
We can get rid of this patch in the future when Wownero forks (Sept. 2022 probably). Ill do that PR by then.
7. Synchronization is done in an asynchronous manner
I made sure the fetching/refreshing of blocks is async as to not block the UI.
8. Wownero does not offer accounts
The desktop wallet for Wownero (wowlet) does not use accounts, as we find them confusing. Our view is that someone ought to create a new wallet if they want a fresh account.
Keeping it simple here.
I might unironically use this.
Ready for review.
Good, i hope we will find time to start review of the PR on this week, but don't promise anything for now. I will check how it's working on iOS too.
YES Please! After this is launched, then the next feature would be atomic swaps XMR<>WOW within CAKE wallet. Now that would be a killer feature. Keep up the good work @sanderfoobar
Hi everyone, First, thank you @sanderfoobar for taking the time and effort to integrate this with Cake, I know this has been sitting here for a while, but are you still interested in continuing the work on this and integrating it into Cake Wallet?
Like last time I will not be able to debug/test on iOS, as I only have a Android device. Ill look at this PR next week.
sure no worries, we can verify it on iOS when it's ready
@OmarHatem28 Having some trouble preparing for a compile. Maybe you know how to fix.
I try: flutter build apk --target-platform android-arm
in hopes of only compiling the armeabi-v7a
version.
This is because scripts/android/build_all.sh
tries to compile for 4 different architectures, but I have trouble with build_zmq.sh
for aarch64
, so was hoping to only generate apk for aarch
for now.
When I do flutter build apk --target-platform android-arm
I get:
The plugins `cw_monero, cw_wownero` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove
these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cw_monero:buildCMakeRelWithDebInfo[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/opt/android/cake_wallet/cw_monero/android/.cxx/RelWithDebInfo/60675o18/arm64-v8a'
C++ build system [build] failed while executing:
/home/dsc/Android/Sdk/cmake/3.18.1/bin/ninja \
-C \
/opt/android/cake_wallet/cw_monero/android/.cxx/RelWithDebInfo/60675o18/arm64-v8a \
cw_monero
from /opt/android/cake_wallet/cw_monero/android
ninja: error: '../../../../../../cw_shared_external/ios/External/android/arm64-v8a/lib/monero/libwallet_api.a', needed by '/opt/android/cake_wallet/build/cw_monero/intermediates/cxx/RelWithDebInfo/60675o18/obj/arm64-v8a/libcw_monero.so', missing and no known rule to make it
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Running Gradle task 'assembleRelease'... 4.8s
Gradle task assembleRelease failed with exit code 1
So flutter is trying for ABI arm64-v8a
even though I specified --target-platform android-arm
.
e.g: I have /opt/android/cake_wallet/cw_shared_external/ios/External/android/armeabi-v7a/lib/wownero/libwallet.a
Alternatively, I see Docker stuff in scripts/docker/
for requirement generation, perhaps you can give some insight on how to use that instead if that's easier (please share the exact commands if so).
it's trying to build the other architectures for cw_monero
since it's an internal package, not sure why it's ignoring the --target-platform
tho.
for building Monero dependencies using docker you can follow these steps
- Firstly head over to the scripts/docker folder
cd scripts/docker
2. Then build the Docker-Image
docker build --tag=build_monero_deps .
2. Run the Container using docker compose
docker compose up -d
Hi @sanderfoobar still having trouble building the dependencies? let me know if I can help with this
@OmarHatem28 currently solving some issues, as the provided Dockerfile+compose does not work at all. I will ask for your help eventually when I get stuck but for now I will try to not use up any of your time.
I think the Wownero integration is completed, but having some troubles with the flutter toolchain.
$ flutter --version
Flutter 3.16.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2e9cb0aa71 (3 weeks ago) • 2023-12-11 14:35:13 -0700
Engine • revision 54a7145303
Tools • Dart 3.2.3 • DevTools 2.28.4
$ flutter build apk --release
The plugins `cw_monero, cw_wownero` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated
APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /home/dsc/.pub-cache/hosted/pub.dev/flutter_mailer-2.1.2/android/src/main/java/com/dataxad/flutter_mailer/FlutterMailerPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/dsc/.pub-cache/hosted/pub.dev/uni_links-0.5.1/android/src/main/java/name/avioli/unilinks/UniLinksPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/dsc/.pub-cache/hosted/pub.dev/in_app_review-2.0.8/android/src/main/java/dev/britannio/in_app_review/InAppReviewPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 1132 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 3128 bytes (99.8% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
e: /home/dsc/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.10/6d5560a229477df9406943d5feda5618e98eb64c/kotlin-stdlib-1.8.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /home/dsc/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.10/6d5560a229477df9406943d5feda5618e98eb64c/kotlin-stdlib-1.8.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /home/dsc/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.10/6d5560a229477df9406943d5feda5618e98eb64c/kotlin-stdlib-1.8.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /home/dsc/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.10/a61b182458550492c12aee66157d7b524a63a5ec/kotlin-stdlib-common-1.8.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.jvm.optionals.OptionalsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 12s
Running Gradle task 'assembleRelease'... 73.4s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update /opt/android/cake_wallet/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@OmarHatem28 maybe you know how to debug/solve this one?
@sanderfoobar please downgrade the flutter version to 3.10.x
as they added some Android breaking changes in the last couple of versions, I believe this should fix your build issue
for reference, here are the current versions that I have
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (6 months ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1
@OmarHatem28 Thanks, that worked. I also downgraded Java to 18.
I can compile and run the app now with Wownero included. Currently facing a runtime error when trying to create a new Wownero wallet. I am trying to locate the exact line number that emits this error, but adb logcat
does not seem to show it. Do you know how to setup Android Studio such that debugging (breakpoints) is possible (either remotely or via the emulator).
you should have a flutter config there
I believe you don't have Flutter plugin installed on Android studio, so please go to Plugins marketplace and install Flutter and then restart your android studio and run the app
I think it all works now, I will start a new branch and a new PR and submit it today or tomorrow.
continuing in #1260