From 6d22ba76ec1593be3e9f7249325745cbebdec9f0 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Thu, 14 May 2026 18:19:53 -0400 Subject: [PATCH] Add cw_mweb generated_bindings.g.dart stub for desktop builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cake's mwebd Go daemon is only built for iOS and Android — no Linux/macOS/ Windows toolchain in their build scripts. ffigen consequently never runs on those platforms, leaving cw_mweb/lib/mweb_ffi.dart dangling on a non-existent generated_bindings.g.dart import. This stub provides type-compatible signatures so the Dart build compiles on every platform. At runtime, DynamicLibrary.open will fail on desktop (no libmweb.so/.dll/.dylib shipped) and MWeb features will no-op — standard non-MWEB Litecoin sends/receives still work fine through cw_bitcoin. For Android the real bindings are still produced via ffigen against the libmweb.h Go-generated header, overwriting this stub at build time. Force-added past the *.g.dart gitignore — this one's a hand-maintained desktop fallback, not a build artifact. --- cw_mweb/lib/generated_bindings.g.dart | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cw_mweb/lib/generated_bindings.g.dart diff --git a/cw_mweb/lib/generated_bindings.g.dart b/cw_mweb/lib/generated_bindings.g.dart new file mode 100644 index 000000000..4d975415b --- /dev/null +++ b/cw_mweb/lib/generated_bindings.g.dart @@ -0,0 +1,44 @@ +// Hash Wallet: stub for the FFI bindings normally generated by ffigen from +// cw_mweb/android/src/main/jniLibs/arm64-v8a/libmweb.h. +// +// Upstream Cake only ships MWeb on iOS + Android — no Linux/macOS/Windows +// build of the Go-based mwebd daemon exists. Without this stub the Dart +// build fails on those platforms because cw_mweb/lib/mweb_ffi.dart imports +// MWebFlutter from this file at compile time. +// +// At runtime, attempting to use MWeb features will throw because +// DynamicLibrary.open(libPath) won't find a libmweb.so on desktop. That's +// fine — Litecoin's MWEB extension is a niche feature most users won't hit, +// and standard LTC sends/receives still work without it. +// +// To get real bindings (e.g. for an Android build): run ffigen against the +// libmweb.h header generated by `go build -buildmode=c-shared` in cw_mweb/go. +// See scripts/android/build_mwebd.sh for the canonical Android build. + +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +class MWebFlutter { + MWebFlutter(DynamicLibrary _); + + int StartServer( + Pointer chain, + Pointer dataDir, + Pointer nodeUri, + Pointer> errMsg, + ) => + 0; + + void StopServer() {} + + Pointer Addresses( + Pointer scanSecret, + int scanSecretLen, + Pointer spendPub, + int spendPubLen, + int fromIndex, + int toIndex, + ) => + ''.toNativeUtf8().cast(); +}