mobile
[]
(https://travis-ci.org/gcash/bchwallet)
This package is intended to be used to run bchwallet on iOS and Android devices. It offers exported functions
which start and stop the wallet that can be called from the language binding.
The following is an example of how to compile for Android:
-
Make sure the android SDK is installed on your computer. If you use android studio you should already have it installed.
-
Install NDK. You can find this in the Android SDK Manager inside Android Studio under SDK Tools.
-
Set the ANDROID_HOME environmental variable and also put it in your path:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
-
Initalize gomobile
gomobile init -ndk=$HOME/Android/Sdk/ndk-bundle
-
Build the language bindings. This generates a .aar file
cd $GOPATH/src/github.com/gcash/bchwallet/mobile
gomobile bind -target=android -o=bchwallet.aar
-
Import the .aar file as a dependency in Android Studio. See this stack overflow answer for the steps
of how to import import into your project.
-
You can now start the wallet from the Java code.
String configPath = getFilesDir() + "/bchwallet.conf";
mobile.Mobile.StartWallet(configPath);
-
The wallet is now running and you can use the gRPC API to control it.
-
Use mobile.Mobile.StopWallet()
to stop it and perform a clean shutdown.
Note that StartWallet
takes in a path to a config file. You will need to programatically create and save the config file on the device. As you do this make sure
to set the appdata
and logdir
to a valid path on the device. You will also most likely want to use the noinitialload
config option and create the wallet using the API.
Finally you may run into this bug in gomobile which may require you to modify a python file in your Android SDK.
Package mobile is licensed under the copyfree ISC
License.