Skip to content

Instantly share code, notes, and snippets.

@wintercooled
Last active August 20, 2019 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wintercooled/0296f17b0ca8e4eac425bf6c289075a6 to your computer and use it in GitHub Desktop.
Save wintercooled/0296f17b0ca8e4eac425bf6c289075a6 to your computer and use it in GitHub Desktop.
Libwally Java and Python setup

Libwally - Java set up

Prerequitistes

Swig

Swig is needed to wrap the comipiled Libwally C++ code to provide an interface for Java. You can install Swig following the instructions here: http://swig.org/

Compiling Libwally with Java wrapper

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

If you need to later delete the generate files you can run:

./tools/cleanup.sh

... before then running autogen, configure, make etc.

Java tests and examples

To run the existing tests

The Java tests and examples are located in libwally-core/src/swig_java/src/com/blockstream/test

You can run each test individually by moving to the src folder:

cd libwally-core/src

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 test/examples within the test folder, you can compile them:

javac swig_java/src/com/blockstream/test/your_test.java

And then run them:

LD_LIBRARY_PATH=.libs java -Djava.library.path=.libs -classpath swig_java/src com.blockstream.test.your_test

The src/swig_java/src/com/blockstream/libwally/Wally.java fle contains the Java interface definitions.

Existing examples:

  • test_assets.java
  • test_bip32.java
  • test_mnemonic.java
  • test_tx.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment