EttaWallet / EttaWallet

Simple open-source non-custodial bitcoin/lightning wallet with a strong bias towards usability, accessibility and good UX
72 stars 18 forks source link

Greetings from WalletScrutiny + minor bug #7

Open xrviv opened 9 months ago

xrviv commented 9 months ago

Hello,

I'm currently trying to reproducibly build your app following the instructions but adapting it for use in a Dockerfile.

It would be helpful if you could provide some assistance as to how to adapt the instructions so we could reproducibly build your app in a docker container. Right now, I tried:

# Use an Ubuntu base image with JDK and Node.js installed
FROM ubuntu:latest

# Install dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    openjdk-11-jdk \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# Install Node.js LTS version (>= 16)
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
    apt-get install -y nodejs

# Install yarn
RUN npm install --global yarn

# Set environment variable for JDK (required by the Android build process)
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH

# Download and unzip Android SDK command line tools
RUN mkdir -p /usr/lib/android-sdk/cmdline-tools && \
    curl -o cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip && \
    unzip cmdline-tools.zip -d /usr/lib/android-sdk/cmdline-tools && \
    rm cmdline-tools.zip && \
    mv /usr/lib/android-sdk/cmdline-tools/cmdline-tools /usr/lib/android-sdk/cmdline-tools/latest

# Set environment variable for Android SDK
ENV ANDROID_HOME /usr/lib/android-sdk
ENV PATH $ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH

# Accept the license agreements of the Android SDK
RUN yes | sdkmanager --licenses

# Install Android SDK platforms and tools
RUN sdkmanager "platform-tools" "platforms;android-29" "build-tools;29.0.3"

# Clone the EttaWallet repository
ARG ETTAWALLET_GITHUB_URL=https://github.com/EttaWallet/EttaWallet
RUN git clone $ETTAWALLET_GITHUB_URL /EttaWallet

# Set the working directory to the cloned repo
WORKDIR /EttaWallet

# Install app dependencies
RUN yarn install

# Add local.properties to specify the SDK location
RUN echo "sdk.dir=$ANDROID_HOME" > android/local.properties

# Expose the port used by the React Native packager
EXPOSE 8081

# Command to run when starting the container
CMD ["./gradlew", "assembleDebug", "-p", "android"]

I would love to receive some feedback on this.

Thank you.

Minor-bug:

When viewing the recovery phrases, after inputting the last digit of the 6-digit pin, nothing happens. I pressed "back" and that's when it showed the 12 words.

xrviv commented 6 months ago

Hello, I've tried this again with this error:

> Task :app:compressReleaseAssets
Execution optimizations have been disabled for task ':app:compressReleaseAssets' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/EttaWallet/android/android/app/build/intermediates/assets/release/mergeReleaseAssets'. Reason: Task ':app:compressReleaseAssets' uses this output of task ':app:copyReleaseBundledJs' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.5.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

> Task :app:validateSigningRelease FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file '/EttaWallet/android/android/app/'debug.keystore'' not found for signing config 'release'.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

Execution optimizations have been disabled for 2 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.

BUILD FAILED in 10m 43s
920 actionable tasks: 920 executed
+ result
+ fromPlayUnzipped=/tmp/fromPlay_com.ettaln_7
+ fromBuildUnzipped=/tmp/fromBuild_com.ettaln_7
+ rm -rf /tmp/fromBuild_com.ettaln_7 /tmp/fromPlay_com.ettaln_7
+ unzip -d /tmp/fromPlay_com.ettaln_7 -qq /home/danny/work/apk/com.ettaln.apk
+ unzip -d /tmp/fromBuild_com.ettaln_7 -qq /tmp/test_com.ettaln/android/app/build/outputs/apk/release/ettawallet.apk
unzip:  cannot find or open /tmp/test_com.ettaln/android/app/build/outputs/apk/release/ettawallet.apk, /tmp/test_com.ettaln/android/app/build/outputs/apk/release/ettawallet.apk.zip or /tmp/test_com.ettaln/android/app/build/outputs/apk/release/ettawallet.apk.ZIP.
+ exit 1

This is the script that I used to try and build it:

#!/bin/bash

repo=https://github.com/xrviv/EttaWallet
tag=next
builtApk="$workDir/android/app/build/outputs/apk/release/ettawallet.apk"

test() {
  # build
  BUILDER_IMAGE="reactnativecommunity/react-native-android@sha256:4ff9c9f80da57c72284900fcfdbd079183e735684c62d7fafd3df50fdb895453"

  # Check if the container exists, and if so, remove it
  container_exists=$(podman ps -a | grep etta_builder_container | wc -l)
  if [ "$container_exists" -eq "1" ]; then
      echo "Container 'etta_builder_container' exists. Removing..."
      podman rm -f etta_builder_container
  fi

  podman run --rm --name etta_builder_container -it -v `pwd`:/EttaWallet/android  $BUILDER_IMAGE bash -c \
    'echo -e "\n\n********************************\n*** Building Ettawallet...\n********************************\n" && \
      cd /EttaWallet ; yarn install --frozen-lockfile && \
      cd /EttaWallet/android/android ; yarn install ; yarn add @react-native-community/cli-platform-android ; ./gradlew assembleRelease && \

      echo -e "\n\n********************************\n**** APKs and SHA256 Hashes\n********************************\n" && \
      cd /EttaWallet && \
      for f in android/app/build/outputs/apk/release/*.apk;
      do
              RENAMED_FILENAME=$(echo $f | sed -e "s/app-/ettawallet-/" | sed -e "s/-release-unsigned//")
              mv $f $RENAMED_FILENAME
              sha256sum $RENAMED_FILENAME
      done && \
      echo -e "\n" '
}
crukundo commented 6 months ago

First, apologies I'm only just getting to this issue now. Thanks for pinging me. This is important and perhaps, with your permission, we can use modify your script and add it to the project directly for posterity.

I tried your script with podman but I had some memory issues getting the emulator to work on M1 arm64 which might be related to the docker image that's built for amd64 and there are no alternatives. I was able to get it to work with docker though.

The error you have with assembleRelease seems to be related to signing. Can you comment out line 241 in android/app/build.gradle and try again?

xrviv commented 6 months ago

Thank you! I will try again. I appreciate your assistance.

  1. Commented out line 241 in android/app/build.gradle
  2. Placed .env file in /home/danny/work/builds/com.ettaln/EttaWallet with contents:
DEV_RESTORE_NAV_STATE_ON_RELOAD=false
DEFAULT_NETWORK=bitcoinTestnet
  1. ran $ ./gradlew assembleRelease in android folder, this is the result:
danny@lw10:~/work/builds/com.ettaln/EttaWallet/android$ ./gradlew assembleRelease

> Configure project :app
Error: The 'kotlin-android-extensions' Gradle plugin is no longer supported. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
Reading env from: .env

> Configure project :react-native-flipper
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
Checking the license for package Android SDK Build-Tools 33 in /usr/local/android-sdk/licenses
License for package Android SDK Build-Tools 33 accepted.
Preparing "Install Android SDK Build-Tools 33 (revision: 33.0.0)".
Warning: Failed to read or create install properties file.
Checking the license for package Android SDK Platform 33 in /usr/local/android-sdk/licenses
License for package Android SDK Platform 33 accepted.
Preparing "Install Android SDK Platform 33 (revision: 3)".
Warning: Failed to read or create install properties file.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/danny/work/builds/com.ettaln/EttaWallet/node_modules/react-native-flipper/android/build.gradle' line: 120

* What went wrong:
A problem occurred configuring project ':react-native-flipper'.
> Failed to install the following SDK components:
      build-tools;33.0.0 Android SDK Build-Tools 33
      platforms;android-33 Android SDK Platform 33
  The SDK directory is not writable (/usr/local/android-sdk)

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 11s
5 actionable tasks: 5 up-to-date

Note: I am currently doing this on walletscrutiny's ssh'd build server.

xrviv commented 6 months ago

I think I finally built it! image

The pastebin

I will run a diff tomorrow. Hopefully we can also automate the process. This is still version 0.0.1

crukundo commented 6 months ago

Awesome!! Let me know if the diffs match.

xrviv commented 6 months ago

The built apk is unsigned. So there are expected diffs. From the build output:

danny@lw10:~/work/builds/com.ettaln/compare-apks/fromBuild$ unzip /home/danny/work/builds/com.ettaln/EttaWallet/android/app/build/outputs/apk/release/app-release-unsigned.apk -d ~/work/builds/com.ettaln/compare-apks/fromBuild

I then copy the apk I got from Google Play on my phone to the build server, and then:

danny@lw10:~/work/builds/com.ettaln/compare-apks$ unzip com.ettaln_v7.apk -d fromPlay/

Then run the diff:

danny@lw10:~/work/builds/com.ettaln/compare-apks$ diff -r fromPlay/ fromBuild/

Pastebin results