Merge pull request #847 from cypherstack/conflict_resolution

update testing
This commit is contained in:
julian-CStack 2024-05-03 14:33:50 -06:00 committed by GitHub
commit dea2585ad3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 179 additions and 37 deletions

View file

@ -4,12 +4,12 @@ Here you will find instructions on how to install the necessary tools for buildi
## Prerequisites
- The only OS supported for building Android and Linux desktop is Ubuntu 20.04. Windows build are completed using Ubuntu 20.04 on WSL2. Advanced users may also be able to build on other Debian-based distributions like Linux Mint.
- The only OS supported for building Android and Linux desktop is Ubuntu 20.04. Windows builds require using Ubuntu 20.04 on WSL2. macOS builds for itself and iOS. Advanced users may also be able to build on other Debian-based distributions like Linux Mint.
- Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies)
- 100 GB of storage
## Linux host
The following instructions are for building and running on a Linux host. Alternatively, see the [Windows](#Windows host) section.
The following instructions are for building and running on a Linux host. Alternatively, see the [Mac](#mac-host) and/or [Windows](#windows-host) section. This entire section (except for the Android Studio section) needs to be completed in WSL if building on a Windows host.
### Flutter
Install Flutter 3.19 beta (3.19.0-0.1.pre) by following these instructions: https://docs.flutter.dev/get-started/install/linux/desktop?tab=download#install-the-flutter-sdk. You can also clone https://github.com/flutter/flutter, check out the `3.19.0-0.1.pre` tag, and add its `flutter/bin` folder to your PATH. Run `flutter doctor` in a terminal to confirm its installation.
@ -23,42 +23,59 @@ sudo snap install android-studio --classic
```
Use `Tools > SDK Manager` to install:
- `SDK Tools > Android SDK (API 30)`
- `SDK Tools > NDK`
- `SDK Tools > Android SDK command line tools`
- `SDK Tools > CMake`
and for Android builds,
- `SDK Tools > Android SDK (API 30)`
- `SDK Tools > NDK`
Then in `File > Settings > Plugins`, install the **Flutter** and **Dart** plugins and restart the IDE. In `File > Settings > Languages & Frameworks > Flutter > Editor`, enable auto format on save to match the project's code style. If you have problems with the Dart SDK, make sure to run `flutter` in a terminal to download it (use `source ~/.bashrc` to update your environment variables if you're still using the same terminal from which you ran `setup.sh`). Run `flutter doctor` to install any missing dependencies and review and agree to any license agreements.
Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation
Install basic dependencies
```
sudo apt-get install libssl-dev curl unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm python3-distutils
```
Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation.
The following *may* be needed for Android studio:
```
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
```
### Flutter
Flutter and the Dart SDK should have been set up by Android studio, but if running `flutter` doesn't work (try `flutter doctor`, too), follow the [guide to install Flutter on any of their supported platforms](https://docs.flutter.dev/get-started/install) or:
- `git clone https://github.com/flutter/flutter` somewhere it can live (`/var`, `/opt`, `~`)
- `git checkout 3.16.0` after navigating into the `flutter` directory, and
- add `flutter/bin` to your PATH (on Ubuntu, add `PATH=$PATH:path/to/flutter/bin` to `~/.profile`).
Run `flutter doctor` to install any missing dependencies and review and agree to any license agreements.
### Build dependencies
Install basic dependencies
```
sudo apt-get install libssl-dev curl unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm python3-distutils
```
Install [Rust](https://www.rust-lang.org/tools/install) with command:
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.bashrc
rustup install 1.67.1
rustup install 1.73.0 # For cargo-ndk.
rustup install 1.72.0 # For frostdart & tor.
rustup install 1.73.0 # For cargo-ndk.
rustup install 1.67.1 # For flutter_libepiccash.
rustup default 1.67.1
```
Install the additional components for Rust:
```
cargo install cargo-ndk --version 2.12.7
cargo install cargo-ndk --version 2.12.7 --locked
```
Android specific dependencies:
```
sudo apt-get install libc6-dev-i386
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
```
Linux desktop specific dependencies:
```
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev meson python3-pip libgirepository1.0-dev valac xsltproc docbook-xsl
@ -70,18 +87,27 @@ After installing the prerequisites listed above, download the code and init the
git clone https://github.com/cypherstack/stack_wallet.git
cd stack_wallet
git submodule update --init --recursive
```
Remove pre-installed system libraries for the following packages built by cryptography plugins in the crypto_plugins folder: `boost iconv libjson-dev libsecret openssl sodium unbound zmq`. You can use
Build the secure storage dependencies in order to target Linux (not needed for Windows or other platforms):
```
sudo apt list --installed | grep boost
cd scripts/linux
./build_secure_storage_deps.sh
// when finished go back to the root directory
cd ../..
```
for example to find which pre-installed packages you may need to remove with `sudo apt remove`. Be careful, as some packages (especially boost) are linked to GNOME (GUI) packages: when in doubt, remove `-dev` packages first like with
```
sudo apt-get remove '^libboost.*-dev.*'
```
<!-- TODO: configure compiler to prefer built over system libraries. Should already use them? -->
### Build coinlib
Coinlib's native secp256k1 library must be built prior to running Stack Wallet. It can be built from within the root `stack_wallet` folder on a...
- Linux host for Linux targets: `dart run coinlib:build_linux`, or
- Linux host for Windows targets: `dart run coinlib:build_windows_crosscompile`
- Windows host: `dart run coinlib:build_windows`
- WSL2 host: `dart run coinlib:build_wsl`
<!-- - macOS host: `dart run coinlib:build_macos` -->
To build coinlib on Linux, you will need `docker` (see [installation instructions](https://docs.docker.com/engine/install/ubuntu/)) or [`podman`](https://podman.io/docs/installation) (`sudo apt-get -y install podman`)
For Windows targets, you can use a `secp256k1.dll` produced by any of the three bottom<!--^H^H^H^H^H^Hmiddle--> options if the first attempt doesn't succeed!
### Run prebuild script
@ -108,6 +134,19 @@ cd scripts/linux
./build_all.sh
```
##### Remove system packages (may be needed for building flutter_libmonero)
[`flutter_libmonero`](https://github.com/cypherstack/flutter_libmonero) may have issues building due to conflicts with system packages: if so, follow this section.
Remove pre-installed system libraries for the following packages built by cryptography plugins in the crypto_plugins folder: `boost iconv libjson-dev libsecret openssl sodium unbound zmq`. You can use
```
sudo apt list --installed | grep boost
```
for example to find which pre-installed packages you may need to remove with `sudo apt remove`. Be careful, as some packages (especially boost) are linked to GNOME (GUI) packages: when in doubt, remove `-dev` packages first like with
```
sudo apt-get remove '^libboost.*-dev.*'
```
<!-- TODO: configure compiler to prefer built over system libraries. Should already use them? -->
#### Building plugins for Windows
```
cd scripts/windows
@ -123,7 +162,7 @@ flutter pub get
flutter run android
```
Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work
Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work. You should [configure KVM](https://help.ubuntu.com/community/KVM/Installation) for much better performance.
#### Linux
Run the following commands or launch via Android Studio:
@ -132,20 +171,100 @@ flutter pub get
flutter run linux
```
## Mac host
### Dependencies
XCode, Homebrew and several homebrew packages, Rust, and Flutter are required for Mac development with the Flutter SDK. Multiple IDEs may work, but Android Studio is recommended.
Download and install Xcode at https://developer.apple.com/xcode/, register your device (Mac or iPhone), and enable developer mode for your device as applicable. After installing XCode, make sure commandline tools are installed with `xcode-select --install`.
Download and install [Homebrew](https://brew.sh/). The following command can install it via script:
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
After installing Homebrew, install the following packages:
```
brew install autoconf automake boost berkeley-db ca-certificates cbindgen cmake cmake cocoapods curl git libssh2 make openssl@1.1 openssl@3 perl pkg-config rustup-init sodium unbound unzip xz zmq
```
The following brew formula *may* be needed:
```
brew install brotli cairo coreutils gdbm gettext glib gmp libevent libidn2 libnghttp2 libtool libunistring libx11 libxau libxcb libxdmcp libxext libxrender lzo m4 openldap pcre2 pixman procs rtmpdump tcl-tk xorgproto zstd
```
<!-- TODO: determine which of the above list are not needed at all. -->
Download and install [Rust](https://www.rust-lang.org/tools/install). [Rustup](https://rustup.rs/) is recommended for Rust setup. Use `rustc` to confirm successful installation. Install toolchains 1.67.1 and 1.72.0 and `cbindgen` and `cargo-lipo` too. You will also have to add the platform target(s) `aarch64-apple-ios` and/or `aarch64-apple-darwin`. You can use the command(s):
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.bashrc
rustup install 1.67.1
rustup install 1.72.0
rustup default 1.67.1
cargo install cbindgen cargo-lipo
rustup target add aarch64-apple-ios aarch64-apple-darwin
```
Optionally download [Android Studio](https://developer.android.com/studio) as an IDE and activate its Dart and Flutter plugins. VS Code may work as an alternative, but this is not recommended.
### Flutter
Install [Flutter](https://docs.flutter.dev/get-started/install) 3.16.8 on your Mac host by following [these instructions](https://docs.flutter.dev/get-started/install/macos). Run `flutter doctor` in a terminal to confirm its installation.
### Build plugins
#### Building plugins for iOS
```
cd scripts/ios
./build_all.sh
```
#### Building plugins for macOS
```
cd scripts/macos
./build_all.sh
```
### Run prebuild script
Certain test wallet parameter and API key template files must be created in order to run Stack Wallet. These can be created by script as in
```
cd scripts
./prebuild.sh
// when finished go back to the root directory
cd ..
```
or manually by creating the files referenced in that script with the specified content.
### Running
#### iOS
Plug in your iOS device or use an emulato and then run the following commands:
```
flutter pub get
flutter run ios
```
#### macOS
Run the following commands or launch via Android Studio:
```
flutter pub get
flutter run macos
```
## Windows host
### Visual Studio
Visual Studio is required for Windows development with the Flutter SDK. Download it at https://visualstudio.microsoft.com/downloads/ and install the "Desktop development with C++" workload, including all of its default components.
Visual Studio is required for Windows development with the Flutter SDK. Download it at https://visualstudio.microsoft.com/downloads/ and install the "Desktop development with C++", "Linux development with C++", and "Visual C++ build tools" workloads. You may also need the Windows 10, 11, and/or Universal SDK workloads depending on your Windows version.
### Building libraries in WSL2
Set up Ubuntu 20.04 in WSL2. Follow the entire Linux host section in the WSL2 Ubuntu 20.04 host to get set up to build. You will also need to install Rust and MXE dependencies on the WSL2 Ubuntu 20.04 host:
- [Install Rust](https://rustup.rs/)
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
- Install MXE by running `stack_wallet/scripts/windows/deps.sh`
```sh
./stack_wallet/scripts/windows/deps.sh
```
### Build plugins in WSL2
Set up Ubuntu 20.04 in WSL2. Follow the entire Linux host section in the WSL2 Ubuntu 20.04 host to get set up to build. The Android Studio section may be skipped in WSL (it's only needed on the Windows host).
Install the following libraries:
```
sudo apt-get install libgtk2.0-dev
```
You will also need to install MXE on the WSL2 Ubuntu 20.04 host and can do so by running `stack_wallet/scripts/windows/deps.sh`:
```
./stack_wallet/scripts/windows/deps.sh
```
The WSL2 host may optionally be navigated to the `stack_wallet` repository on the Windows host in order to build the plugins in-place and skip the next section in which you copy the `dll`s from WSL2 to Windows. Then build windows `dll` libraries by running the following script on the WSL2 Ubuntu 20.04 host:
@ -162,9 +281,24 @@ Copy the resulting `dll`s to their respective positions on the Windows host:
<!-- TODO: script the copying or installation of libraries from WSL2 to the parent Windows host -->
### Install Flutter on Windows host
Install Flutter 3.19 beta (3.19.0-0.1.pre) on your Windows host (not in WSL2) by following these instructions: https://docs.flutter.dev/get-started/install/windows/desktop?tab=download#install-the-flutter-sdk. You can also clone https://github.com/flutter/flutter, check out the `3.19.0-0.1.pre` tag, and add its `flutter/bin` folder to your PATH. Run `flutter doctor` in PowerShell to confirm its installation.
Install Flutter 3.19.5 on your Windows host (not in WSL2) by following these instructions: https://docs.flutter.dev/get-started/install/windows/desktop?tab=download#install-the-flutter-sdk. You can also clone https://github.com/flutter/flutter, check out the `3.19.5` tag, and add its `flutter/bin` folder to your PATH. Run `flutter doctor` in PowerShell to confirm its installation.
### Dependencies
### Rust
Install [Rust](https://www.rust-lang.org/tools/install) on the Windows host (not in WSL2). Download the installer from [rustup.rs](https://rustup.rs), make sure it works on the commandline (you may need to open a new terminal), and install the following versions:
```
rustup install 1.72.0 # For frostdart and tor.
rustup install 1.67.1 # For flutter_libepiccash.
rustup default 1.67.1
```
<!--
You may also need to install `cargo-ndk`:
```
rustup install 1.73.0 # For cargo-ndk.
cargo install cargo-ndk --version 2.12.7 --locked
```
-->
### Windows SDK and Developer Mode
Install the Windows SDK: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ You may need to install the [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/), which can be installed [by Visual Studio](https://stackoverflow.com/a/73923899) (`Tools > Get Tools and Features... > Modify > Individual Components > Windows 10 SDK`).
Enable Developer Mode for symlink support,
@ -182,14 +316,14 @@ or [download the package](https://www.nuget.org/packages/Microsoft.Windows.CppWi
### Run prebuild script
Certain test wallet parameter and API key template files must be created in order to run Stack Wallet. These can be created by script as in
Certain test wallet parameter and API key template files must be created in order to run Stack Wallet on Windows. These can be created by script as in
```
cd scripts
./prebuild.ps1
// when finished go back to the root directory
cd ..
```
or manually by creating the files referenced in that script with the specified content.
or manually by creating the files referenced in that script with the specified content.
### Running

View file

@ -303,6 +303,7 @@ class EpiccashWallet extends Bip39Wallet {
Future<Address> _generateAndStoreReceivingAddressForIndex(
int index,
) async {
Address? address = await getCurrentReceivingAddress();
EpicBoxConfigModel epicboxConfig = await getEpicBoxConfig();
@ -311,6 +312,7 @@ class EpiccashWallet extends Bip39Wallet {
//Check if the address is the same as the current epicbox domain
//Since we're only using one epicbpox now this doesn't apply but will be
// useful in the future
final encodedConfig = jsonEncode(epicboxConfig);
if (splitted[1] != epicboxConfig.host) {
//Update the address
address = await thisWalletAddress(index, epicboxConfig);
@ -318,6 +320,13 @@ class EpiccashWallet extends Bip39Wallet {
} else {
address = await thisWalletAddress(index, epicboxConfig);
}
if (info.cachedReceivingAddress != address.value) {
await info.updateReceivingAddress(
newAddress: address.value,
isar: mainDB.isar,
);
}
return address;
}
@ -346,7 +355,6 @@ class EpiccashWallet extends Bip39Wallet {
subType: AddressSubType.receiving,
publicKey: [], // ??
);
await mainDB.updateOrPutAddresses([address]);
return address;
}