Skip to content

Commit

Permalink
daemon/lightningd: remove building, and main files
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Aug 29, 2017
1 parent 5db4e11 commit 88bb38f
Show file tree
Hide file tree
Showing 68 changed files with 75 additions and 14,951 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ dist: trusty
sudo: true

env:
- NOVALGRIND=1 NO_VALGRIND=0
- NOVALGRIND=0 NO_VALGRIND=1
- NOVALGRIND=1
- NOVALGRIND=0

# Trusty (aka 14.04) is way way too old, so run in docker...
script:
- docker pull cdecker/lightning-ci > /dev/null
- docker run --rm=true -v "${TRAVIS_BUILD_DIR}":/build -t cdecker/lightning-ci make -j3
- docker run --rm=true -e NOVALGRIND=${NOVALGRIND:-0} -e TEST_DEBUG=${TEST_DEBUG:-0} -e NO_VALGRIND=${NOVALGRIND:-0} -v "${TRAVIS_BUILD_DIR}":/build -t cdecker/lightning-ci make check
- docker run --rm=true -e NOVALGRIND=${NOVALGRIND:-0} -e TEST_DEBUG=${TEST_DEBUG:-0} -v "${TRAVIS_BUILD_DIR}":/build -t cdecker/lightning-ci make check
- docker run --rm=true -v "${TRAVIS_BUILD_DIR}":/build -t cdecker/lightning-ci make check-source
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ make
Running lightning:
```
bitcoind &
./daemon/lightningd &
./lightningd/lightningd &
./daemon/lightning-cli help
```
**Note**: You may need to include `testnet=1` in `bitcoin.conf`
Expand Down Expand Up @@ -85,6 +85,6 @@ Running lightning:
```
bitcoind
export LD_LIBRARY_PATH=/usr/local/lib
./daemon/lightningd
./lightningd/lightningd
./daemon/lightning-cli help
```
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ CFLAGS := $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) -I libwally-core/src/secp25
LDLIBS := -lprotobuf-c -lgmp -lsqlite3 $(COVFLAGS)
$(PROGRAMS): CFLAGS+=-I.

default: $(PROGRAMS) doc-all daemon-all
default: $(PROGRAMS) doc-all

include doc/Makefile
include bitcoin/Makefile
Expand All @@ -242,7 +242,7 @@ test-protocol: test/test_protocol
check: test-protocol
$(MAKE) pytest

pytest: daemon/lightningd daemon/lightning-cli lightningd-all
pytest: daemon/lightning-cli lightningd-all
PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f

# Keep includes in alpha order.
Expand All @@ -255,7 +255,7 @@ check-hdr-include-order/%: %
@if [ "$$(grep '^#include' < $< | tail -n +2)" != "$$(grep '^#include' < $< | tail -n +2 | LC_ALL=C sort)" ]; then echo "$<:1: includes out of order"; exit 1; fi

# Make sure Makefile includes all headers.
check-makefile: check-daemon-makefile
check-makefile:
@if [ "`echo bitcoin/*.h`" != "$(BITCOIN_HEADERS)" ]; then echo BITCOIN_HEADERS incorrect; exit 1; fi
@if [ x"`ls *.h | grep -v ^gen_ | fgrep -v lightning.pb-c.h`" != x"`echo $(CORE_HEADERS) $(CORE_TX_HEADERS) | tr ' ' '\n' | LC_ALL=C sort`" ]; then echo CORE_HEADERS incorrect; exit 1; fi
@if [ x"$(CCANDIR)/config.h `find $(CCANDIR)/ccan -name '*.h' | grep -v /test/ | LC_ALL=C sort | tr '\n' ' '`" != x"$(CCAN_HEADERS) " ]; then echo CCAN_HEADERS incorrect; exit 1; fi
Expand Down
2 changes: 1 addition & 1 deletion contrib/pylightning/lightning/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .lightning import LightningRpc, LegacyLightningRpc
from .lightning import LightningRpc
95 changes: 0 additions & 95 deletions contrib/pylightning/lightning/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,101 +105,6 @@ def dev_add_route(self, src, dst, base, var, delay, minblocks):
return self._call("dev-add-route", [src, dst, base, var, delay, minblocks])


class LegacyLightningRpc(UnixDomainSocketRpc):
def getchannels(self):
"""List all known channels.
"""
return self._call("getchannels", [])['channels']

def getnodes(self):
"""List all known nodes in the network.
"""
return self._call("getnodes", [])

def getlog(self, level=None):
"""Get logs, with optional level: [io|debug|info|unusual]
"""
return self._call("getlog", [level])

def getpeers(self):
"""Return a list of peers.
"""
return self._call("getpeers", [])

def getroute(self, destination, amount, riskfactor=1):
"""Return route to `destination` for `amount` milli satoshis, using `riskfactor`
"""
return self._call("getroute", [destination, amount, riskfactor])['route']

def getinfo(self):
"""Get general information about this node"""
return self._call("getinfo", [])

def invoice(self, amount, label, paymentKey=None):
"""Create a new invoice.
Create invoice for `amount` millisatoshi with
`label`. Optionally you can specify the `paymentKey`,
otherwise a random one will be generated. The `label` has to
be unique.
"""
args = [amount, label]
if paymentKey is not None:
args.append(paymentKey)
return self._call("invoice", args)

def waitinvoice(self, label=None, async=False):
"""Wait for the next invoice to be paid, after `label` (if supplied)
"""
args = []
if label is not None:
args.append(label)
def call():
return self._call("waitinvoice", args)
if async:
return self.executor.submit(call)
else:
return call()

def sendpay(self, route, paymenthash):
"""Send along `route` in return for preimage of `paymenthash`
"""
return self._call("sendpay", [route, paymenthash])

def pay(self, destination, amount, paymenthash):
"""Shorthand for `getroute` and `sendpay`
Sends `amount` millisatoshi to `destination` for invoice matching `paymenthash`
"""
route = self.getroute(destination, amount, 1)
return self.sendpay(route, paymenthash)

def dev_rhash(self, secret):
res = self._call("dev-rhash", [secret])
print(res)
return self._call("dev-rhash", [secret])['rhash']

def dev_newhtlc(self, peerid, amount, expiry, rhash):
return self._call("dev-newhtlc", [peerid, amount, expiry, rhash])

def dev_add_route(self, src, dst, base_fee, fee_rate, delay, minblocks):
return self._call("dev-add-route", [src, dst, base_fee, fee_rate, delay, minblocks])

def connect(self, hostname, port, fundingtxhex, async=False):
"""Connect to a `host` at `port` using `fundingtxhex` to fund
"""
def call_connect():
return self._call("connect", [hostname, port, fundingtxhex])

if not async:
return call_connect()
else:
return self.executor.submit(call_connect)

def newaddr(self):
"""Get a new address to fund a channel
"""
return self._call("newaddr", [])

if __name__ == "__main__":
l1 = LightningRpc("/tmp/lightning1/lightning-rpc")
Expand Down
62 changes: 4 additions & 58 deletions daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LC_CTYPE=C
daemon-wrongdir:
$(MAKE) -C .. daemon-all

daemon-all: daemon/lightningd daemon/lightning-cli
daemon-all: daemon/lightning-cli

DAEMON_LIB_SRC := \
daemon/configdir.c \
Expand All @@ -21,35 +21,16 @@ DAEMON_SRC := \
daemon/bitcoind.c \
daemon/broadcast.c \
daemon/chaintopology.c \
daemon/channel.c \
daemon/commit_tx.c \
daemon/cryptopkt.c \
daemon/db.c \
daemon/dns.c \
daemon/failure.c \
daemon/feechange.c \
daemon/htlc.c \
daemon/htlc_state.c \
daemon/invoice.c \
daemon/irc_announce.c \
daemon/jsonrpc.c \
daemon/lightningd.c \
daemon/netaddr.c \
daemon/options.c \
daemon/opt_time.c \
daemon/output_to_htlc.c \
daemon/p2p_announce.c \
daemon/packets.c \
daemon/pay.c \
daemon/peer.c \
daemon/routing.c \
daemon/routingrpc.c \
daemon/secrets.c \
daemon/sphinx.c \
daemon/timeout.c \
daemon/wallet.c \
daemon/watch.c \
daemon/names.c \
irc.c

DAEMON_OBJS := $(DAEMON_SRC:.c=.o)
Expand All @@ -61,50 +42,28 @@ DAEMON_JSMN_OBJS := daemon/jsmn.o
DAEMON_JSMN_HEADERS := daemon/jsmn/jsmn.h

DAEMON_GEN_HEADERS := \
daemon/gen_feechange_state_names.h \
daemon/gen_htlc_state_names.h \
daemon/gen_pkt_names.h \
daemon/gen_state_names.h
daemon/gen_htlc_state_names.h

DAEMON_HEADERS := \
daemon/bitcoind.h \
daemon/broadcast.h \
daemon/chaintopology.h \
daemon/channel.h \
daemon/commit_tx.h \
daemon/configdir.h \
daemon/cryptopkt.h \
daemon/db.h \
daemon/dns.h \
daemon/failure.h \
daemon/feechange.h \
daemon/feechange_state.h \
daemon/htlc.h \
daemon/htlc_state.h \
daemon/invoice.h \
daemon/irc_announce.h \
daemon/json.h \
daemon/jsonrpc.h \
daemon/lightningd.h \
daemon/log.h \
daemon/names.h \
daemon/netaddr.h \
daemon/opt_time.h \
daemon/options.h \
daemon/output_to_htlc.h \
daemon/p2p_announce.h \
daemon/packets.h \
daemon/pay.h \
daemon/peer.h \
daemon/peer_internal.h \
daemon/pseudorand.h \
daemon/routing.h \
daemon/secrets.h \
daemon/sphinx.h \
daemon/state.h \
daemon/state_types.h \
daemon/timeout.h \
daemon/wallet.h \
daemon/watch.h

daemon/gen_htlc_state_names.h: daemon/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr
Expand All @@ -120,7 +79,7 @@ daemon/gen_state_names.h: daemon/state_types.h ccan/ccan/cdump/tools/cdump-enums
daemon/gen_pkt_names.h: lightning.pb-c.h ccan/ccan/cdump/tools/cdump-enumstr
(echo 'enum PktCase {'; grep '^ PKT__' lightning.pb-c.h; echo '};') | ccan/ccan/cdump/tools/cdump-enumstr - | sed 's/enum PktCase/Pkt__PktCase/' > $@

$(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): $(DAEMON_HEADERS) $(DAEMON_JSMN_HEADERS) $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CORE_TX_HEADERS) $(GEN_HEADERS) $(DAEMON_GEN_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(WIRE_GEN_HEADERS) $(LIBSODIUM_HEADERS) $(LIBBASE58_HEADERS)
$(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): $(DAEMON_JSMN_HEADERS) $(BITCOIN_HEADERS) $(CORE_HEADERS) $(CORE_TX_HEADERS) $(GEN_HEADERS) $(DAEMON_GEN_HEADERS) $(CCAN_HEADERS) $(WIRE_HEADERS) $(WIRE_GEN_HEADERS) $(LIBSODIUM_HEADERS) $(LIBBASE58_HEADERS)
$(DAEMON_JSMN_OBJS): $(DAEMON_JSMN_HEADERS)

$(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS): CFLAGS += -USHACHAIN_BITS
Expand All @@ -129,11 +88,6 @@ check-source: $(DAEMON_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_LIB_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_CLI_SRC:%=check-src-include-order/%)
check-source: $(DAEMON_HEADERS:%=check-hdr-include-order/%)
check-daemon-makefile:
@echo $(DAEMON_HEADERS) | tr ' ' '\012' > /tmp/daemon-headers-makefile
@ls daemon/*.h | grep -v daemon/gen > /tmp/daemon-headers-file
@if [ "`diff -w /tmp/daemon-headers-makefile /tmp/daemon-headers-file`" != "" ]; then echo DAEMON_HEADERS incorrect; diff -w --context=2 /tmp/daemon-headers-makefile /tmp/daemon-headers-file; exit 1; fi
@rm /tmp/daemon-headers-makefile /tmp/daemon-headers-file

check-source-bolt: $(DAEMON_SRC:%=bolt-check/%) $(DAEMON_HEADERS:%=bolt-check/%)

Expand All @@ -152,17 +106,9 @@ daemon/jsmn/jsmn.c: daemon/jsmn/jsmn.h
daemon/jsmn.o: daemon/jsmn/jsmn.c
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<

# We need a 64-bit shachain (default)
daemon/shachain-64.o: $(CCANDIR)/ccan/crypto/shachain/shachain.c $(CCAN_HEADERS)
$(CC) $(CFLAGS) -USHACHAIN_BITS -c -o $@ $<

daemon/lightningd: $(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_JSMN_OBJS) $(CORE_OBJS) $(CORE_TX_OBJS) $(CORE_PROTOBUF_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) daemon/shachain-64.o libsecp256k1.a libsodium.a

daemon/lightning-cli: $(DAEMON_CLI_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_JSMN_OBJS) $(CORE_OBJS) $(BITCOIN_OBJS) $(LIBBASE58_OBJS) $(WIRE_OBJS) $(CCAN_OBJS) libsecp256k1.a libsodium.a

daemon-clean:
$(RM) $(DAEMON_OBJS) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS) $(DAEMON_JSMN_OBJS) $(DAEMON_GEN_HEADERS)
$(RM) $(DAEMON_LIB_OBJS) $(DAEMON_CLI_OBJS) $(DAEMON_JSMN_OBJS) $(DAEMON_GEN_HEADERS)

daemon-maintainer-clean:

include daemon/test/Makefile
1 change: 0 additions & 1 deletion daemon/chaintopology.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "jsonrpc.h"
#include "lightningd.h"
#include "log.h"
#include "peer.h"
#include "timeout.h"
#include "utils.h"
#include "watch.h"
Expand Down
Loading

0 comments on commit 88bb38f

Please sign in to comment.