Skip to content

Commit

Permalink
libwally-core: import version 3b02512
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 21, 2017
1 parent 4a7418e commit 1271ac8
Show file tree
Hide file tree
Showing 259 changed files with 75,238 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ libsecp256k1.a
libsecp256k1.la
libsodium.a
libsodium.la
libwally-core.a
libwally-core.la
gen_*
daemon/lightning-cli
check-bolt
Expand Down
28 changes: 17 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ GEN_HEADERS := gen_version.h \
lightning.pb-c.h

LIBSODIUM_HEADERS := libsodium/src/libsodium/include/sodium.h
LIBWALLY_HEADERS := libwally-core/include/wally_bip32.h \
libwally-core/include/wally_core.h \
libwally-core/include/wally_crypto.h
LIBSECP_HEADERS := libwally-core/src/secp256k1/include/secp256k1_ecdh.h \
libwally-core/src/secp256k1/include/secp256k1.h

CDUMP_OBJS := ccan-cdump.o ccan-strmap.o

Expand All @@ -206,7 +211,7 @@ PROGRAMS := $(TEST_PROGRAMS)

CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition
CDEBUGFLAGS := -g -fstack-protector
CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I secp256k1/include/ -I libsodium/src/libsodium/include/ -I . $(FEATURES) $(COVFLAGS)
CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I libwally-core/src/secp256k1/include/ -I libwally-core/include/ -I libsodium/src/libsodium/include/ -I . $(FEATURES) $(COVFLAGS)

LDLIBS := -lprotobuf-c -lgmp -lsqlite3 $(COVFLAGS)
$(PROGRAMS): CFLAGS+=-I.
Expand All @@ -225,7 +230,7 @@ CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o
$(CCAN_OBJS) $(CDUMP_OBJS) $(HELPER_OBJS) $(BITCOIN_OBJS) $(TEST_PROGRAMS:=.o) ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS)

# Except for CCAN, everything depends on bitcoin/ and core headers.
$(HELPER_OBJS) $(CORE_OBJS) $(CORE_TX_OBJS) $(CORE_PROTOBUF_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(TEST_PROGRAMS:=.o): $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CCAN_HEADERS) $(GEN_HEADERS) $(LIBBASE58_HEADERS) $(LIBSODIUM_HEADERS)
$(HELPER_OBJS) $(CORE_OBJS) $(CORE_TX_OBJS) $(CORE_PROTOBUF_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(TEST_PROGRAMS:=.o): $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CCAN_HEADERS) $(GEN_HEADERS) $(LIBBASE58_HEADERS) $(LIBSODIUM_HEADERS) $(LIBWALLY_HEADERS)

test-protocol: test/test_protocol
set -e; TMP=`mktemp`; for f in test/commits/*.script; do if ! $(VALGRIND) test/test_protocol < $$f > $$TMP; then echo "test/test_protocol < $$f FAILED" >&2; exit 1; fi; diff -u $$TMP $$f.expected; done; rm $$TMP
Expand Down Expand Up @@ -297,14 +302,6 @@ FORCE::

ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDUMP_OBJS) $(CCAN_OBJS)

# We build a static libsecpk1, since we need ecdh
# (and it's not API stable yet!).
libsecp256k1.a: secp256k1/libsecp256k1.la

secp256k1/libsecp256k1.la:
cd secp256k1 && ./autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --enable-tests=no --enable-experimental=yes --enable-module-ecdh=yes --libdir=`pwd`/..
$(MAKE) -C secp256k1 install-exec

# We build libsodium, since Ubuntu xenial has one too old.
libsodium.a: libsodium/src/libsodium/libsodium.la

Expand All @@ -316,10 +313,18 @@ libsodium/src/libsodium/libsodium.la: libsodium/src/libsodium/include/sodium.h
cd libsodium && ./autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --enable-tests=no --libdir=`pwd`/..
$(MAKE) -C libsodium install-exec

# libsecp included in libwally.
# Wildcards here are magic. See http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file
libsecp256k1.% libwallycore.%: libwally-core/src/secp256k1/libsecp256k1.la libwally-core/src/libwallycore.la
$(MAKE) -C libwally-core install-exec

libwally-core/src/libwallycore.% libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
cd libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --libdir=`pwd`/.. && $(MAKE)

lightning.pb-c.c lightning.pb-c.h: lightning.proto
@if $(CHANGED_FROM_GIT); then echo $(PROTOCC) lightning.proto --c_out=.; $(PROTOCC) lightning.proto --c_out=.; else touch $@; fi

$(TEST_PROGRAMS): % : %.o $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) utils.o version.o libsecp256k1.a libsodium.a
$(TEST_PROGRAMS): % : %.o $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) utils.o version.o libwallycore.a libsecp256k1.a libsodium.a

ccan/config.h: ccan/tools/configurator/configurator
if $< > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi
Expand Down Expand Up @@ -352,6 +357,7 @@ distclean: clean
$(MAKE) -C secp256k1/ distclean || true
$(RM) libsecp256k1.a secp256k1/libsecp256k1.la
$(RM) libsodium.a libsodium/libsodium.la
cd libwally-core && tools/cleanup.sh

maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
Expand Down
59 changes: 59 additions & 0 deletions libwally-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
bld
src/*.pyc
src/test/*.pyc
src/test/__pycache__/
*~
*.class
*.gcno
*.gcda
*.o
*.lo
*.la
*.deps
*.dirstamp
*.libs
*.venv
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
build
compile
config.guess
config.log
config.status
config.sub
configure
depcomp
dist
install-sh
libtool
ltmain.sh
missing
src/*~
src/lcov*
src/Makefile
src/Makefile.in
src/config.h
src/config.h.in
src/stamp-h1
src/test/Makefile
src/test/Makefile.in
src/test_clear*
src/test-suite.log
src/swig_java/swig_java_wrap.c
src/swig_java/*.java
src/swig_java/*.jar
src/swig_java/src/com/blockstream/libwally
src/swig_python/swig_python_wrap.c
src/swig_python/wallycore/__init__.py
src/swig_python/wallycore/wallycore.egg-info
tools/build-aux/m4/l*.m4
tools/build-aux/test-driver
src/secp256k1/test-suite.log
src/secp256k1/tests.log
src/secp256k1/tests.trs
wallycore.egg-info/
wally*.gz
wally*.sha256
wally*.asc
43 changes: 43 additions & 0 deletions libwally-core/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
git:
depth: 5
branches:
only:
- master
language: c
sudo: required
os:
- linux
- osx
dist: trusty
compiler:
- clang
- gcc
addons:
apt:
packages:
- python
- python-dev
- python3
- python3-dev
- swig
- gcc-multilib
matrix:
include:
- os: linux
compiler: clang
env: HOST=i686-linux-gnu
- os: linux
compiler: gcc
env: HOST=i686-linux-gnu
- compiler: gcc
os: linux
env: PYTHON_VERSION=3.4

before_script:
- ./tools/cleanup.sh && ./tools/autogen.sh
before_install:
- ./tools/travis_install.sh
script:
- ./tools/travis_build.sh
notifications:
email: false
13 changes: 13 additions & 0 deletions libwally-core/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Use the following commands to build and install the library:

$ ./tools/autogen.sh
$ ./configure [options]
$ make
$ make install

Note that ./configure --help can be used to determine configuration options.

To fully clean the library, run:

$ ./tools/cleanup.sh
23 changes: 23 additions & 0 deletions libwally-core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Note: the modules in the src/ccan/ directory have their own licenses, but
except where noted in an individual source file, the rest of the code is
covered by the following (BSD-MIT) license:

Copyright Jon Griffiths (Blockstream) 2016.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions libwally-core/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ACLOCAL_AMFLAGS = -I tools/build-aux/m4
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
111 changes: 111 additions & 0 deletions libwally-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# libwally-core

Wally is a collection of useful primitives for cryptocurrency wallets.

Note that the library is currently pre-release and so the API may change
without notice.

Please report bugs and submit patches to https://github.com/jgriffiths/libwally-core.

[![Build Status](https://travis-ci.org/jgriffiths/libwally-core.svg?branch=master)](https://travis-ci.org/jgriffiths/libwally-core)

## Platforms

Wally currently builds on all linux and OSX platforms as well as all supported
Android NDK targets. Bindings for Python and Java are included.

Windows support and further language bindings such as JavaScript are planned.

## Building

```
$ ./tools/autogen.sh
$ ./configure <options - see below>
$ make
$ make check
```

### configure options

- `--enable-debug`. Enables debugging information and disables compiler
optimisations (default: no).
- `--enable-export-all`. Export all functions from the wally shared library.
Ordinarily only API functions are exported. (default: no). Enable this
if you want to test the internal functions of the library or are planning
to submit patches.
- `--enable-swig-python`. Enable the [SWIG](http://www.swig.org/) Python
interface. The resulting shared library can be imported from Python using
the generated interface file `src/swig_python/wallycore/wallycore.py`. (default: no).
- `--enable-swig-java`. Enable the [SWIG](http://www.swig.org/) Java (JNI)
interface. After building, see `src/swig_java/src/com/blockstream/libwally/Wally.java`
for the Java interface definition (default: no).
- `--enable-coverage`. Enables code coverage (default: no) Note that you will
need [lcov](http://ltp.sourceforge.net/coverage/lcov.php) installed to
build with this option enabled and generate coverage reports.

NOTE: If you wish to run the Python tests you currently need to pass
the `--enable-swig-python` option. This requirement will be removed
in a future version.

### Recommended development configure options

```
$ ./configure --enable-debug --enable-export-all --enable-swig-python --enable-coverage
```

### Python

For python development, you can build and install wally using:

```
$ python setup.py install
```

It is suggested you only install this way into a virtualenv while the library
is under heavy development.

## Cleaning

```
$ ./tools/cleanup.sh
```

## Submitting patches

Please use pull requests on github to submit. Before producing your patch you
should format your changes using [uncrustify](https://github.com/uncrustify/uncrustify.git)
version 0.60 or later. The script `./tools/uncrustify` will reformat all C
sources in the library as needed, with the currently chosen uncrustify options.

The version of uncrustify in Debian is unfortunately out of date and buggy. If
you are using Debian this means you will need to download and build uncrustify
from source using something like:

```
$ git clone --depth 1 https://github.com/uncrustify/uncrustify.git
$ cd uncrustify
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
```

You should also make sure the existing tests pass and if possible write tests
covering any new functionality, following the existing style.

## Generating a coverage report

To generate an HTML coverage report, use:

```
$ ./tools/cleanup.sh
$ ./tools/autogen.sh
$ ./configure --enable-debug --enable-export-all --enable-swig-python --enable-swig-java --enable-coverage
$ make
$ ./tools/coverage.sh clean
$ make check
$ ./tools/coverage.sh
```

The coverage report can then be viewed at `src/lcov/index.html`. Patches to
increase the test coverage are welcome.
Loading

0 comments on commit 1271ac8

Please sign in to comment.