Skip to content

Commit 30730b8

Browse files
committed
standalone mwebd for windows
1 parent 3bc921f commit 30730b8

File tree

14 files changed

+269
-103
lines changed

14 files changed

+269
-103
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,6 @@ lib/wl_gen/generated/
122122
/linux/flutter/generated_plugins.cmake
123123
/windows/flutter/generated_plugins.cmake
124124
/macos/Flutter/GeneratedPluginRegistrant.swift
125+
126+
/assets/windows/mwebd.exe
127+
/tool/build

docs/building.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Here you will find instructions on how to install the necessary tools for buildi
44

55
## Prerequisites
66

7-
- 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.
7+
- The only OS supported for building Android and Linux desktop is Ubuntu 24.04. Windows builds require using Ubuntu 24.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.
88
- Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies)
99
- 100 GB of storage
1010
- Install go: [https://go.dev/doc/install](https://go.dev/doc/install)
@@ -77,12 +77,12 @@ pip3 install --upgrade meson==0.64.1 markdown==3.4.1 markupsafe==2.1.1 jinja2==3
7777
```
7878

7979
### Flutter
80-
Install Flutter 3.29.2 by [following their guide](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.29.2` tag, and add its `flutter/bin` folder to your PATH as in
80+
Install Flutter 3.35.7 by [following their guide](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.35.7` tag, and add its `flutter/bin` folder to your PATH as in
8181
```sh
8282
FLUTTER_DIR="$HOME/development/flutter"
8383
git clone https://github.com/flutter/flutter.git "$FLUTTER_DIR"
8484
cd "$FLUTTER_DIR"
85-
git checkout 3.29.2
85+
git checkout 3.35.7
8686
echo 'export PATH="$PATH:'"$FLUTTER_DIR"'/bin"' >> "$HOME/.profile"
8787
source "$HOME/.profile"
8888
flutter precache
@@ -165,6 +165,7 @@ cd scripts/windows
165165
```
166166

167167
install go in WSL [https://go.dev/doc/install](https://go.dev/doc/install) (follow linux instructions) and ensure you have `x86_64-w64-mingw32-gcc`
168+
go version should be at least 1.24
168169

169170
and use `scripts/build_app.sh` to build plugins:
170171
```
@@ -292,13 +293,13 @@ If the DLLs were built on the WSL filesystem instead of on Windows, copy the res
292293
Frostdart will be built by the Windows host later.
293294

294295
### Install Flutter on Windows host
295-
Install Flutter 3.29.2 on your Windows host (not in WSL2) by [following their guide](https://docs.flutter.dev/get-started/install/windows/desktop?tab=download#install-the-flutter-sdk) or by cloning https://github.com/flutter/flutter, checking out the `3.29.2` tag, and adding its `flutter/bin` folder to your PATH as in
296+
Install Flutter 3.35.7 on your Windows host (not in WSL2) by [following their guide](https://docs.flutter.dev/get-started/install/windows/desktop?tab=download#install-the-flutter-sdk) or by cloning https://github.com/flutter/flutter, checking out the `3.35.7` tag, and adding its `flutter/bin` folder to your PATH as in
296297
```bat
297298
@echo off
298299
set "FLUTTER_DIR=%USERPROFILE%\development\flutter"
299300
git clone https://github.com/flutter/flutter.git "%FLUTTER_DIR%"
300301
cd /d "%FLUTTER_DIR%"
301-
git checkout 3.29.2
302+
git checkout 3.35.7
302303
setx PATH "%PATH%;%FLUTTER_DIR%\bin"
303304
echo Flutter setup completed. Please restart your command prompt.
304305
```

lib/app_config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ abstract class AppConfig {
1616

1717
static const emptyWalletsMessage = _emptyWalletsMessage;
1818

19+
static const windowsMwebdExeHash = _mwebdExeHash;
20+
1921
static String get appDefaultDataDirName => _appDataDirName;
2022
static String get shortDescriptionText => _shortDescriptionText;
2123
static String get commitHash => _commitHash;

lib/services/mwebd_service.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:math';
66
import 'package:mutex/mutex.dart';
77
import 'package:mweb_client/mweb_client.dart';
88

9+
import '../utilities/dynamic_object.dart';
910
import '../utilities/logger.dart';
1011
import '../utilities/prefs.dart';
1112
import '../utilities/stack_file_system.dart';
@@ -24,10 +25,7 @@ final class MwebdService {
2425
CryptoCurrencyNetwork.test4 => throw UnimplementedError(),
2526
};
2627

27-
final Map<
28-
CryptoCurrencyNetwork,
29-
({OpaqueMwebdServer server, MwebClient client})
30-
>
28+
final Map<CryptoCurrencyNetwork, ({DynamicObject server, MwebClient client})>
3129
_map = {};
3230

3331
late final StreamSubscription<TorConnectionStatusChangedEvent>
@@ -178,9 +176,9 @@ final class MwebdService {
178176
}
179177

180178
/// Get server status. Returns null if no server was initialized.
181-
Future<Status?> getServerStatus(CryptoCurrencyNetwork net) {
182-
return _updateLock.protect(() {
183-
return mwebdServerInterface.getServerStatus(_map[net]?.server);
179+
Future<StatusResponse?> getServerStatus(CryptoCurrencyNetwork net) {
180+
return _updateLock.protect(() async {
181+
return _map[net]?.client.status(StatusRequest());
184182
});
185183
}
186184

lib/utilities/dynamic_object.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class DynamicObjectTypeException implements Exception {
2+
final Type actual, expected;
3+
4+
DynamicObjectTypeException({required this.actual, required this.expected});
5+
6+
@override
7+
String toString() =>
8+
"DynamicObjectException: Found $actual, expected $expected";
9+
}
10+
11+
class DynamicObject {
12+
final Object _value;
13+
14+
DynamicObject(this._value);
15+
16+
T get<T>() {
17+
if (_value is T) return _value as T;
18+
throw DynamicObjectTypeException(actual: _value.runtimeType, expected: T);
19+
}
20+
21+
T? getIfMatch<T>() {
22+
if (_value is T) return _value as T;
23+
return null;
24+
}
25+
}
Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import '../../utilities/dynamic_object.dart';
12
import '../../wallets/crypto_currency/crypto_currency.dart';
23

34
export '../generated/mwebd_server_interface_impl.dart';
45

56
abstract class MwebdServerInterface {
67
const MwebdServerInterface();
78

8-
Future<({OpaqueMwebdServer server, int port})> createAndStartServer(
9+
Future<({DynamicObject server, int port})> createAndStartServer(
910
CryptoCurrencyNetwork net, {
1011
required String chain,
1112
required String dataDir,
@@ -15,58 +16,6 @@ abstract class MwebdServerInterface {
1516
});
1617

1718
Future<({String chain, String dataDir, String peer})> stopServer(
18-
OpaqueMwebdServer server,
19+
DynamicObject server,
1920
);
20-
21-
Future<Status?> getServerStatus(OpaqueMwebdServer? server);
22-
}
23-
24-
// local copy
25-
class Status {
26-
final int blockHeaderHeight;
27-
final int mwebHeaderHeight;
28-
final int mwebUtxosHeight;
29-
final int blockTime;
30-
31-
Status({
32-
required this.blockHeaderHeight,
33-
required this.mwebHeaderHeight,
34-
required this.mwebUtxosHeight,
35-
required this.blockTime,
36-
});
37-
38-
@override
39-
String toString() {
40-
return 'Status('
41-
'blockHeaderHeight: $blockHeaderHeight, '
42-
'mwebHeaderHeight: $mwebHeaderHeight, '
43-
'mwebUtxosHeight: $mwebUtxosHeight, '
44-
'blockTime: $blockTime'
45-
')';
46-
}
47-
48-
@override
49-
bool operator ==(Object other) =>
50-
identical(this, other) ||
51-
other is Status &&
52-
blockHeaderHeight == other.blockHeaderHeight &&
53-
mwebHeaderHeight == other.mwebHeaderHeight &&
54-
mwebUtxosHeight == other.mwebUtxosHeight &&
55-
blockTime == other.blockTime;
56-
57-
@override
58-
int get hashCode => Object.hash(
59-
blockHeaderHeight,
60-
mwebHeaderHeight,
61-
mwebUtxosHeight,
62-
blockTime,
63-
);
64-
}
65-
66-
final class OpaqueMwebdServer {
67-
final Object _value;
68-
69-
const OpaqueMwebdServer(this._value);
70-
71-
T get<T>() => _value as T;
7221
}

pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,10 @@ packages:
623623
dependency: "direct main"
624624
description:
625625
name: cs_wownero_flutter_libs
626-
sha256: "68b6c682c6cce0915418aa6b01b137ef77652932f8b3fb1bc868bfd20d15c562"
626+
sha256: ba1156d015a9f75c841f927ff2ce6565cd7cd37f15aaedd9aaf36703453a9884
627627
url: "https://pub.dev"
628628
source: hosted
629-
version: "2.0.0"
629+
version: "2.0.3"
630630
cs_wownero_flutter_libs_android:
631631
dependency: transitive
632632
description:
@@ -663,18 +663,18 @@ packages:
663663
dependency: transitive
664664
description:
665665
name: cs_wownero_flutter_libs_ios
666-
sha256: f80dd0164902565d4fd0058da5be446a3ea5eaee2ca8651289a35d7fc93f3ca4
666+
sha256: "9ffd158469a0a45668d89ce56b90e846dd823ffd44ee6997b50b76129e6f613c"
667667
url: "https://pub.dev"
668668
source: hosted
669-
version: "1.2.0"
669+
version: "1.3.0"
670670
cs_wownero_flutter_libs_linux:
671671
dependency: transitive
672672
description:
673673
name: cs_wownero_flutter_libs_linux
674-
sha256: b60a700f0ef676405bfa67793fb7431f7d2ffbaccc1f6ad69001da0c2e0a07b0
674+
sha256: "441c9a7b28e28434942709915e6a54ea2392b3261f90c116e03b27b02fce7492"
675675
url: "https://pub.dev"
676676
source: hosted
677-
version: "1.2.0"
677+
version: "1.4.0"
678678
cs_wownero_flutter_libs_macos:
679679
dependency: transitive
680680
description:

scripts/app_config/configure_campfire.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const _appDataDirName = "campfire";
6363
const _shortDescriptionText = "Your privacy. Your wallet. Your Firo.";
6464
const _commitHash = "$BUILT_COMMIT_HASH";
6565
66+
const _mwebdExeHash = "";
67+
6668
const Set<AppFeature> _features = {
6769
AppFeature.tor,
6870
AppFeature.swap

scripts/app_config/configure_stack_duo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const _appDataDirName = "stackduo";
5959
const _shortDescriptionText = "An open-source, multicoin wallet for everyone";
6060
const _commitHash = "$BUILT_COMMIT_HASH";
6161
62+
const _mwebdExeHash = "";
63+
6264
const Set<AppFeature> _features = {
6365
AppFeature.themeSelection,
6466
AppFeature.buy,

scripts/app_config/configure_stack_wallet.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ dart "${APP_PROJECT_ROOT_DIR}/tool/gen_interfaces.dart" \
5050
XEL \
5151
FROST
5252

53+
54+
MWEBD_EXE_SHA256=""
55+
if [[ "$1" == "windows" ]]; then
56+
dart "${APP_PROJECT_ROOT_DIR}/tool/build_standalone_mwebd_windows.dart"
57+
MWEBD_EXE_SHA256="$(sha256sum "${APP_PROJECT_ROOT_DIR}/assets/windows/mwebd.exe" | awk '{print $1}')"
58+
dart "${APP_PROJECT_ROOT_DIR}/tool/process_pubspec_deps.dart" \
59+
"${PUBSPEC_FILE}" MWEBDEXE
60+
fi
61+
62+
5363
export INCLUDE_EPIC_SO="ON"
5464
export INCLUDE_MWC_SO="ON"
5565

@@ -73,6 +83,8 @@ const _appDataDirName = "stackwallet";
7383
const _shortDescriptionText = "An open-source, multicoin wallet for everyone";
7484
const _commitHash = "$BUILT_COMMIT_HASH";
7585
86+
const _mwebdExeHash = "$MWEBD_EXE_SHA256";
87+
7688
const Set<AppFeature> _features = {
7789
AppFeature.themeSelection,
7890
AppFeature.buy,

0 commit comments

Comments
 (0)