From 83758571165cd16c6c9a1acd21178dc7591f9d71 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 29 Aug 2017 01:34:01 +0930 Subject: [PATCH] common: absorb remaining files from daemon/ Also, we split the more sophisticated json_add helpers to avoid pulling in everything into lightning-cli, and unify the routines to print struct short_channel_id (it's ':', not '/' too). Signed-off-by: Rusty Russell --- .gitignore | 2 +- Makefile | 7 +- README.md | 16 +-- bitcoin/short_channel_id.c | 2 +- bitcoin/short_channel_id.h | 2 +- cli/Makefile | 37 ++++++ {daemon => cli}/lightning-cli.c | 6 +- common/Makefile | 17 ++- {daemon => common}/configdir.c | 1 - {daemon => common}/configdir.h | 0 {daemon => common}/htlc.h | 1 - {daemon => common}/htlc_state.c | 4 +- {daemon => common}/htlc_state.h | 0 common/htlc_tx.h | 2 +- common/initial_channel.h | 2 +- common/initial_commit_tx.h | 2 +- {daemon => common}/json.c | 38 ------ {daemon => common}/json.h | 19 +-- {daemon => common}/pseudorand.c | 0 {daemon => common}/pseudorand.h | 0 {daemon => common}/timeout.c | 1 - {daemon => common}/timeout.h | 0 common/type_to_string.c | 8 +- common/type_to_string.h | 1 + contrib/lightning-open-channel | 4 +- contrib/lightning-pay | 4 +- daemon/Makefile | 21 +--- daemon/lightningd.h | 135 ---------------------- lightningd/Makefile | 73 +++++------- {daemon => lightningd}/bitcoind.c | 2 +- {daemon => lightningd}/bitcoind.h | 0 lightningd/build_utxos.c | 2 +- {daemon => lightningd}/chaintopology.c | 2 +- {daemon => lightningd}/chaintopology.h | 2 +- lightningd/channel/Makefile | 3 + lightningd/channel/channel.c | 4 +- lightningd/channel/channeld_htlc.h | 1 + lightningd/channel/commit_tx.h | 2 +- lightningd/channel/full_channel.c | 2 +- lightningd/closing/closing.c | 2 +- lightningd/dev_ping.c | 4 +- {daemon => lightningd}/dns.c | 0 {daemon => lightningd}/dns.h | 0 lightningd/gossip/Makefile | 10 +- {daemon => lightningd/gossip}/broadcast.c | 2 +- {daemon => lightningd/gossip}/broadcast.h | 0 lightningd/gossip/gossip.c | 7 +- {daemon => lightningd/gossip}/routing.c | 6 +- {daemon => lightningd/gossip}/routing.h | 6 +- lightningd/gossip_control.c | 4 +- lightningd/gossip_msg.h | 2 +- lightningd/hsm_control.c | 2 +- lightningd/htlc_end.c | 6 +- lightningd/htlc_end.h | 2 +- lightningd/htlc_wire.h | 2 +- {daemon => lightningd}/invoice.c | 1 - {daemon => lightningd}/invoice.h | 0 {daemon => lightningd}/jsonrpc.c | 48 +++++++- {daemon => lightningd}/jsonrpc.h | 17 ++- lightningd/lightningd.c | 15 ++- lightningd/lightningd.h | 128 +++++++++++++++++++- {daemon => lightningd}/log.c | 2 +- {daemon => lightningd}/log.h | 0 {daemon => lightningd}/netaddr.c | 0 {daemon => lightningd}/netaddr.h | 0 lightningd/new_connection.c | 4 +- lightningd/onchain/onchain_wire.h | 2 +- lightningd/opening/Makefile | 1 + lightningd/opening/opening.c | 1 + {daemon => lightningd}/opt_time.c | 0 {daemon => lightningd}/opt_time.h | 0 {daemon => lightningd}/options.c | 22 ++-- {daemon => lightningd}/options.h | 0 lightningd/pay.c | 8 +- lightningd/peer_control.c | 10 +- lightningd/peer_control.h | 6 +- lightningd/peer_htlcs.c | 6 +- lightningd/subd.c | 2 +- {daemon => lightningd}/watch.c | 4 +- {daemon => lightningd}/watch.h | 0 wallet/db.c | 5 +- wallet/db.h | 3 +- wallet/wallet.c | 1 + wallet/wallet.h | 1 + wallet/walletrpc.c | 7 +- wire/fromwire.c | 7 +- 86 files changed, 387 insertions(+), 394 deletions(-) create mode 100644 cli/Makefile rename {daemon => cli}/lightning-cli.c (98%) rename {daemon => common}/configdir.c (97%) rename {daemon => common}/configdir.h (100%) rename {daemon => common}/htlc.h (99%) rename {daemon => common}/htlc_state.c (99%) rename {daemon => common}/htlc_state.h (100%) rename {daemon => common}/json.c (89%) rename {daemon => common}/json.h (87%) rename {daemon => common}/pseudorand.c (100%) rename {daemon => common}/pseudorand.h (100%) rename {daemon => common}/timeout.c (97%) rename {daemon => common}/timeout.h (100%) delete mode 100644 daemon/lightningd.h rename {daemon => lightningd}/bitcoind.c (99%) rename {daemon => lightningd}/bitcoind.h (100%) rename {daemon => lightningd}/chaintopology.c (99%) rename {daemon => lightningd}/chaintopology.h (99%) rename {daemon => lightningd}/dns.c (100%) rename {daemon => lightningd}/dns.h (100%) rename {daemon => lightningd/gossip}/broadcast.c (97%) rename {daemon => lightningd/gossip}/broadcast.h (100%) rename {daemon => lightningd/gossip}/routing.c (99%) rename {daemon => lightningd/gossip}/routing.h (98%) rename {daemon => lightningd}/invoice.c (99%) rename {daemon => lightningd}/invoice.h (100%) rename {daemon => lightningd}/jsonrpc.c (92%) rename {daemon => lightningd}/jsonrpc.h (73%) rename {daemon => lightningd}/log.c (99%) rename {daemon => lightningd}/log.h (100%) rename {daemon => lightningd}/netaddr.c (100%) rename {daemon => lightningd}/netaddr.h (100%) rename {daemon => lightningd}/opt_time.c (100%) rename {daemon => lightningd}/opt_time.h (100%) rename {daemon => lightningd}/options.c (97%) rename {daemon => lightningd}/options.h (100%) rename {daemon => lightningd}/watch.c (99%) rename {daemon => lightningd}/watch.h (100%) diff --git a/.gitignore b/.gitignore index 94e0baf48..7f272cdd6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ libsodium.la libwallycore.a libwallycore.la gen_* -daemon/lightning-cli +lightning-cli/lightning-cli tools/check-bolt coverage ccan/config.h diff --git a/Makefile b/Makefile index 9e71d9ac1..e36863bb0 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,7 @@ include bitcoin/Makefile include wire/Makefile include wallet/Makefile include lightningd/Makefile +include cli/Makefile # Git doesn't maintain timestamps, so we only regen if git says we should. CHANGED_FROM_GIT = [ x"`git log $@ | head -n1`" != x"`git log $< | head -n1`" -o x"`git diff $<`" != x"" ] @@ -205,7 +206,7 @@ test-protocol: test/test_protocol check: test-protocol $(MAKE) pytest -pytest: daemon/lightning-cli lightningd-all +pytest: cli/lightning-cli lightningd-all PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f # Keep includes in alpha order. @@ -319,7 +320,7 @@ maintainer-clean: distclean @echo 'This command is intended for maintainers to use; it' @echo 'deletes files that may need special tools to rebuild.' -clean: daemon-clean wire-clean +clean: wire-clean $(MAKE) -C secp256k1/ clean || true $(RM) libsecp256k1.{a,la} $(RM) libsodium.{a,la} @@ -331,8 +332,6 @@ clean: daemon-clean wire-clean find . -name '*gcda' -delete find . -name '*gcno' -delete -include daemon/Makefile - update-mocks/%: % @set -e; BASE=/tmp/mocktmp.$$$$.`echo $* | tr / _`; trap "rm -f $$BASE.*" EXIT; \ START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $< | cut -d: -f1`;\ diff --git a/README.md b/README.md index 627d470bf..07b0b4a22 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ First you need to transfer some funds to `lightningd` so that it can open a chan ``` # Returns an address
-daemon/lightning-cli newaddr +cli/lightning-cli newaddr # Returns a transaction id bitcoin-cli -testnet sendtoaddress
@@ -79,12 +79,12 @@ Once `lightningd` has funds, we can connect to a node and open a channel. Let's assume the remote node is accepting connections at `:` and has the node ID ``: ``` -daemon/lightning-cli connect -daemon/lightning-cli fundchannel +cli/lightning-cli connect +cli/lightning-cli fundchannel ``` This opens a connection and, on top of that connection, then opens a channel. -You can check the status of the channel using `daemon/lightning-cli getpeers`. +You can check the status of the channel using `cli/lightning-cli getpeers`. The funding transaction needs to confirm in order for the channel to be usable, so wait a few minutes, and once that is complete it `getpeers` should say that the status is in _Normal operation_. ### Receiving and receiving payments @@ -93,7 +93,7 @@ Payments in Lightning are invoice based. The recipient creates an invoice with the expected `` in millisatoshi and a `