Build Details of how to build Libwally are provided on the Libwally GitHub repository, along with steps of how to build the Swig wrappers needed to enable languages like Python and Java to use the library.
For Python use you can also install wally with pip, use the binary release or build the wrappers using the configure options.
npm package manager. An example of how to use the npm wallycore WASM package is shown here.
To build the WASM file yourself from source you can follow the instructions here which are targeted at a clean Ubuntu 22.04.1 minimal install.
Below we provide a detailed step process of how to build and use Libwally with Java.
You also need to initialize the
libsecp sources before trying to build Libwally. Note that you only need to run this step once.
git submodule init git submodule sync --recursive git submodule update --init --recursive
From the command line, run the following steps to configure and compile Libwally with Java wrappers and with Elements (and therefore Liquid) support:
git clone https://github.com/ElementsProject/libwally-core cd libwally-core ./tools/autogen.sh ./configure --enable-elements --enable-swig-java --enable-debug make make check
make check step will run the test that have been created in
libwally-core/src/swig_java/src/com/blockstream/test. The tests run are listed below and can be used as templates for any tests you want to add to check your own code additions. The
.class files are compiled and run as
test_assets.class test_bip32.class test_mnemonic.class test_pegs.class test_scripts.class test_tx.class
If you need to later delete the generate files you can run the following before then running
make etc again:
The Java examples are located in
libwally-core/src/swig_java/src/com/blockstream/test and presented as tests that are run during the
make check step covered above.
You can run each test individually by moving to the
And then calling the test while setting the path to the Wally jar file:
LD_LIBRARY_PATH=.libs java -Djava.library.path=.libs -classpath swig_java/src com.blockstream.test.test_tx
If you make you own tests and examples within the test folder, you can compile them and run them by following the steps below, which assumes your test file is called
cd swig_java/src javac com/blockstream/test/your_test.java cd .. cd .. LD_LIBRARY_PATH=.libs java -Djava.library.path=.libs -classpath swig_java/src com.blockstream.test.your_test
src/swig_java/src/com/blockstream/libwally/Wally.java file contains the Java interface definitions that are available to you.
Updated 10 months ago