Skip to content

Android cross-compilation of c-lightning & bitcoin & tor for Android >= 24 Api.

License

Notifications You must be signed in to change notification settings

clightning4j/lightning_ndk

Repository files navigation

lightning_ndk

Android cross-compilation of c-lightning & bitcoin & tor for Android >= 24 Api.

This project is based on bitcoin_ndk used in ABCore.

GitHub Workflow Status

Get binaries

Download the artifacts from the latest github tagged release.

The package archive .tar.xz contains: ligthningd (and ligthning deamons), ligthning plugins, esplora plugin, ligthning-cli, bitcoind, bitcoin-cli and tor.

Build from sources

To build c-lightning with bitcoin follow the instructions:

bash build_deps.sh #download & install android ndk toolchain
export TARGET_HOST=aarch64-linux-android
export BITS=64
./buildenv.sh # set the toolchain variables based on your system
./buildlibs.sh # download & build dependency libraries
./buildlightning.sh # download & build clightning
./buildbitcoin.sh # download & build bitcoin core
./buildtor.sh # download & build bitcoin core
./archive.sh #prepare a compressed archive with the binaries

Push to the device

Push all the binaries inside the archive to the android device, using /data/local/tmp/ as binary folder.

adb push * /data/local/tmp/

Run on the device

Run lightningd and connect to a bitcoin node, using /sdcard/tmp/ as datadir.

adb shell
cd /data/local/tmp
chmod -R +x *
./lightningd/lightningd --lightning-dir=/sdcard/tmp/ --testnet --disable-plugin esplora
 --bitcoin-rpcconnect=$BITCOIN_HOST --bitcoin-rpcuser=$BITCOIN_USER 
 --bitcoin-rpcpassword=$BITCOIN_PWD --bitcoin-rpcport=$BITCOIN_PORT 
 --bitcoin-cli=/data/local/tmp/bitcoin-cli --bitcoin-datadir=/sdcard/tmp/ 
 --plugin-dir=/data/local/tmp/plugins --log-level=debug

If you want to use the esplora plugin as bitcoin backend

./lightningd/lightningd --lightning-dir=/sdcard/tmp/ --testnet --disable-plugin bcli
--esplora-api-endpoint=https://blockstream.info/testnet/api --log-level=debug 

Local testing

Run cli command in an adb shell, as the following

./cli/lightning-cli --lightning-dir=/sdcard/tmp/ newaddr

Dependencies

References

  • INSTALL.md of clightning to cross-compile c-lightning for Android
  • bitcoin_ndk: ndk build of bitcoin core, knots and liquid
  • abcore: ABCore - Android Bitcoin Core

Acknowledgement

Thanks domegabri to test this project on Android devices, and dieeasy from inbitcoin to test channels and pay invoices with globular.