mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
* chore: add ffi and ffigen dependencies to pubspec.yaml * refactor: replace method channel with FFI implementation for MWeb module * fix: correct `cd` command in build_mwebd.sh script * chore: add go.sum file with dependency checksums * fix: ensure ANDROID_NDK_VERSION is set before building and dynamically update NDK_BIN path * fix: update NDK_BIN path to dynamically detect platform in build_mwebd.sh script * refactor: remove unused mwebd dependencies and clean up CwMwebPlugin code * Update scripts/android/build_mwebd.sh Co-authored-by: cyan <cyjan@mrcyjanek.net> * refactor: replace iOS MoneroWallet framework with Mwebd.xcframework and clean up plugin implementation [skip-ci] * fix: mwebd ffi ios * refactor: update MWebFfi class to use non-nullable `lib` and improve address debug logging * chore: remove unused iOS/Android build scripts for mwebd * refactor: replace mweb.so with libmweb.so, use sync methods in MWebFfi, and update iOS/Android frameworks/scripts accordingly * chore: unify mwebd build process in workflows, remove unused gomobile init command --------- Co-authored-by: cyan <cyjan@mrcyjanek.net>
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"C"
|
|
"unsafe"
|
|
|
|
"github.com/ltcmweb/mwebd"
|
|
)
|
|
|
|
var server *mwebd.Server
|
|
|
|
//export StartServer
|
|
func StartServer(chain *C.char, dataDir *C.char, nodeUri *C.char) C.int {
|
|
if server != nil {
|
|
server.Stop()
|
|
}
|
|
goChain := C.GoString(chain)
|
|
goDataDir := C.GoString(dataDir)
|
|
goNodeUri := C.GoString(nodeUri)
|
|
|
|
var err error
|
|
server, err = mwebd.NewServer(goChain, goDataDir, goNodeUri)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
|
|
start, err := server.Start(0)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
|
|
return C.int(start)
|
|
}
|
|
|
|
//export StopServer
|
|
func StopServer() {
|
|
if server == nil {
|
|
return
|
|
}
|
|
server.Stop()
|
|
server = nil
|
|
}
|
|
|
|
//export Addresses
|
|
func Addresses(scanSecret *C.char, scanSecretLen C.int, spendPubKey *C.char, spendPubKeyLen C.int, i C.int, j C.int) *C.char {
|
|
// Convert C pointers to Go byte slices
|
|
goScanSecret := C.GoBytes(unsafe.Pointer(scanSecret), scanSecretLen)
|
|
goSpendPubKey := C.GoBytes(unsafe.Pointer(spendPubKey), spendPubKeyLen)
|
|
|
|
// Call the original Go function
|
|
addr := mwebd.Addresses(goScanSecret, goSpendPubKey, int32(i), int32(j))
|
|
|
|
// Convert the resulting Go string to a C string
|
|
// The C code must free this memory
|
|
return C.CString(addr)
|
|
}
|
|
|
|
func main() {}
|