mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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 <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
a3c51168db
commit
8375857116
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,7 +16,7 @@ libsodium.la
|
|||||||
libwallycore.a
|
libwallycore.a
|
||||||
libwallycore.la
|
libwallycore.la
|
||||||
gen_*
|
gen_*
|
||||||
daemon/lightning-cli
|
lightning-cli/lightning-cli
|
||||||
tools/check-bolt
|
tools/check-bolt
|
||||||
coverage
|
coverage
|
||||||
ccan/config.h
|
ccan/config.h
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -189,6 +189,7 @@ include bitcoin/Makefile
|
|||||||
include wire/Makefile
|
include wire/Makefile
|
||||||
include wallet/Makefile
|
include wallet/Makefile
|
||||||
include lightningd/Makefile
|
include lightningd/Makefile
|
||||||
|
include cli/Makefile
|
||||||
|
|
||||||
# Git doesn't maintain timestamps, so we only regen if git says we should.
|
# 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"" ]
|
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
|
check: test-protocol
|
||||||
$(MAKE) pytest
|
$(MAKE) pytest
|
||||||
|
|
||||||
pytest: daemon/lightning-cli lightningd-all
|
pytest: cli/lightning-cli lightningd-all
|
||||||
PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f
|
PYTHONPATH=contrib/pylightning python3 tests/test_lightningd.py -f
|
||||||
|
|
||||||
# Keep includes in alpha order.
|
# Keep includes in alpha order.
|
||||||
@@ -319,7 +320,7 @@ maintainer-clean: distclean
|
|||||||
@echo 'This command is intended for maintainers to use; it'
|
@echo 'This command is intended for maintainers to use; it'
|
||||||
@echo 'deletes files that may need special tools to rebuild.'
|
@echo 'deletes files that may need special tools to rebuild.'
|
||||||
|
|
||||||
clean: daemon-clean wire-clean
|
clean: wire-clean
|
||||||
$(MAKE) -C secp256k1/ clean || true
|
$(MAKE) -C secp256k1/ clean || true
|
||||||
$(RM) libsecp256k1.{a,la}
|
$(RM) libsecp256k1.{a,la}
|
||||||
$(RM) libsodium.{a,la}
|
$(RM) libsodium.{a,la}
|
||||||
@@ -331,8 +332,6 @@ clean: daemon-clean wire-clean
|
|||||||
find . -name '*gcda' -delete
|
find . -name '*gcda' -delete
|
||||||
find . -name '*gcno' -delete
|
find . -name '*gcno' -delete
|
||||||
|
|
||||||
include daemon/Makefile
|
|
||||||
|
|
||||||
update-mocks/%: %
|
update-mocks/%: %
|
||||||
@set -e; BASE=/tmp/mocktmp.$$$$.`echo $* | tr / _`; trap "rm -f $$BASE.*" EXIT; \
|
@set -e; BASE=/tmp/mocktmp.$$$$.`echo $* | tr / _`; trap "rm -f $$BASE.*" EXIT; \
|
||||||
START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $< | cut -d: -f1`;\
|
START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $< | cut -d: -f1`;\
|
||||||
|
|||||||
16
README.md
16
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 <address>
|
# Returns an address <address>
|
||||||
daemon/lightning-cli newaddr
|
cli/lightning-cli newaddr
|
||||||
|
|
||||||
# Returns a transaction id <txid>
|
# Returns a transaction id <txid>
|
||||||
bitcoin-cli -testnet sendtoaddress <address> <amount>
|
bitcoin-cli -testnet sendtoaddress <address> <amount>
|
||||||
@@ -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 `<ip>:<port>` and has the node ID `<node_id>`:
|
Let's assume the remote node is accepting connections at `<ip>:<port>` and has the node ID `<node_id>`:
|
||||||
|
|
||||||
```
|
```
|
||||||
daemon/lightning-cli connect <ip> <port> <node_id>
|
cli/lightning-cli connect <ip> <port> <node_id>
|
||||||
daemon/lightning-cli fundchannel <node_id> <amount>
|
cli/lightning-cli fundchannel <node_id> <amount>
|
||||||
```
|
```
|
||||||
|
|
||||||
This opens a connection and, on top of that connection, then opens a channel.
|
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_.
|
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
|
### Receiving and receiving payments
|
||||||
@@ -93,7 +93,7 @@ Payments in Lightning are invoice based.
|
|||||||
The recipient creates an invoice with the expected `<amount>` in millisatoshi and a `<label>`:
|
The recipient creates an invoice with the expected `<amount>` in millisatoshi and a `<label>`:
|
||||||
|
|
||||||
```
|
```
|
||||||
daemon/lightning-cli invoice <amount> <label>
|
cli/lightning-cli invoice <amount> <label>
|
||||||
```
|
```
|
||||||
|
|
||||||
This returns a random value called `rhash` that is part of the invoice.
|
This returns a random value called `rhash` that is part of the invoice.
|
||||||
@@ -103,8 +103,8 @@ The sender needs to compute a route to the recipient, and use that route to actu
|
|||||||
The route contains the path that the payment will take throught the Lightning Network and the respective funds that each node will forward.
|
The route contains the path that the payment will take throught the Lightning Network and the respective funds that each node will forward.
|
||||||
|
|
||||||
```
|
```
|
||||||
route=$(daemon/lightning-cli getroute <recipient_id> <amount> 1 | jq --raw-output .route -)
|
route=$(cli/lightning-cli getroute <recipient_id> <amount> 1 | jq --raw-output .route -)
|
||||||
daemon/lightning-cli sendpay $route <rhash>
|
cli/lightning-cli sendpay $route <rhash>
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that in the first step we stored the route in a variable and reused it in the second step.
|
Notice that in the first step we stored the route in a variable and reused it in the second step.
|
||||||
@@ -123,4 +123,4 @@ JSON-RPC interface is documented in the following manual pages:
|
|||||||
* [getroute](doc/lightning-getroute.7.txt)
|
* [getroute](doc/lightning-getroute.7.txt)
|
||||||
* [sendpay](doc/lightning-sendpay.7.txt)
|
* [sendpay](doc/lightning-sendpay.7.txt)
|
||||||
|
|
||||||
For simple access to the JSON-RPC interface you can use the `daemon/lightning-cli` tool, or the [python API client](contrib/pylightning).
|
For simple access to the JSON-RPC interface you can use the `cli/lightning-cli` tool, or the [python API client](contrib/pylightning).
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ bool short_channel_id_from_str(const char *str, size_t strlen,
|
|||||||
return matches == 3;
|
return matches == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *short_channel_id_to_str(tal_t *ctx, const struct short_channel_id *scid)
|
char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid)
|
||||||
{
|
{
|
||||||
return tal_fmt(ctx, "%d:%d:%d", scid->blocknum, scid->txnum, scid->outnum);
|
return tal_fmt(ctx, "%d:%d:%d", scid->blocknum, scid->txnum, scid->outnum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ bool short_channel_id_from_str(const char *str, size_t strlen,
|
|||||||
bool short_channel_id_eq(const struct short_channel_id *a,
|
bool short_channel_id_eq(const struct short_channel_id *a,
|
||||||
const struct short_channel_id *b);
|
const struct short_channel_id *b);
|
||||||
|
|
||||||
char *short_channel_id_to_str(tal_t *ctx, const struct short_channel_id *scid);
|
char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid);
|
||||||
|
|
||||||
#endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */
|
#endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */
|
||||||
|
|||||||
37
cli/Makefile
Normal file
37
cli/Makefile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
LIGHTNING_CLI_SRC := cli/lightning-cli.c
|
||||||
|
LIGHTNING_CLI_OBJS := $(LIGHTNING_CLI_SRC:.c=.o)
|
||||||
|
|
||||||
|
JSMN_OBJS := daemon/jsmn.o
|
||||||
|
JSMN_HEADERS := daemon/jsmn/jsmn.h
|
||||||
|
|
||||||
|
LIGHTNING_CLI_COMMON_OBJS := \
|
||||||
|
common/configdir.o \
|
||||||
|
common/json.o \
|
||||||
|
common/version.o
|
||||||
|
|
||||||
|
lightning-cli-all: cli/lightning-cli
|
||||||
|
|
||||||
|
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)
|
||||||
|
|
||||||
|
# Git submodules are seriously broken.
|
||||||
|
daemon/jsmn/jsmn.h:
|
||||||
|
git submodule update daemon/jsmn/
|
||||||
|
[ -f $@ ] || git submodule update --init daemon/jsmn/
|
||||||
|
|
||||||
|
# If we tell Make that the above builds both, it runs it twice in
|
||||||
|
# parallel. So we lie :(
|
||||||
|
daemon/jsmn/jsmn.c: daemon/jsmn/jsmn.h
|
||||||
|
[ -f $@ ]
|
||||||
|
|
||||||
|
daemon/jsmn.o: daemon/jsmn/jsmn.c
|
||||||
|
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
$(LIGHTNING_CLI_OBJS) $(JSMN_OBJS): $(JSMN_HEADERS) $(COMMON_HEADERS) $(CCAN_HEADERS)
|
||||||
|
|
||||||
|
cli/lightning-cli: $(LIGHTNING_CLI_OBJS) $(LIGHTNING_CLI_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS)
|
||||||
|
|
||||||
|
clean: lightning-cli-clean
|
||||||
|
|
||||||
|
lightning-cli-clean:
|
||||||
|
$(RM) $(LIGHTNING-CLI_LIB_OBJS) $(DAEMON_JSMN_OBJS)
|
||||||
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Helper to submit via JSON-RPC and get back response.
|
* Helper to submit via JSON-RPC and get back response.
|
||||||
*/
|
*/
|
||||||
#include "configdir.h"
|
|
||||||
#include "json.h"
|
|
||||||
#include "version.h"
|
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
#include <ccan/opt/opt.h>
|
#include <ccan/opt/opt.h>
|
||||||
#include <ccan/read_write_all/read_write_all.h>
|
#include <ccan/read_write_all/read_write_all.h>
|
||||||
#include <ccan/str/str.h>
|
#include <ccan/str/str.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/configdir.h>
|
||||||
|
#include <common/json.h>
|
||||||
|
#include <common/version.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -1,26 +1,37 @@
|
|||||||
COMMON_SRC := \
|
COMMON_SRC := \
|
||||||
common/close_tx.c \
|
common/close_tx.c \
|
||||||
|
common/configdir.c \
|
||||||
common/derive_basepoints.c \
|
common/derive_basepoints.c \
|
||||||
common/funding_tx.c \
|
common/funding_tx.c \
|
||||||
common/htlc_tx.c \
|
common/htlc_tx.c \
|
||||||
|
common/htlc_state.c \
|
||||||
common/initial_channel.c \
|
common/initial_channel.c \
|
||||||
common/initial_commit_tx.c \
|
common/initial_commit_tx.c \
|
||||||
|
common/json.c \
|
||||||
common/permute_tx.c \
|
common/permute_tx.c \
|
||||||
|
common/pseudorand.c \
|
||||||
|
common/timeout.c \
|
||||||
common/type_to_string.c \
|
common/type_to_string.c \
|
||||||
common/utils.c \
|
common/utils.c \
|
||||||
common/version.c \
|
common/version.c \
|
||||||
common/withdraw_tx.c
|
common/withdraw_tx.c
|
||||||
|
|
||||||
COMMON_HEADERS := $(COMMON_SRC:.c=.h) common/overflows.h
|
COMMON_HEADERS_NOGEN := $(COMMON_SRC:.c=.h) common/overflows.h common/htlc.h
|
||||||
|
COMMON_HEADERS_GEN := common/gen_htlc_state_names.h
|
||||||
|
|
||||||
|
COMMON_HEADERS := $(COMMON_HEADERS_GEN) $(COMMON_HEADERS_NOGEN)
|
||||||
COMMON_OBJS := $(COMMON_SRC:.c=.o)
|
COMMON_OBJS := $(COMMON_SRC:.c=.o)
|
||||||
|
|
||||||
|
common/gen_htlc_state_names.h: common/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
||||||
|
ccan/ccan/cdump/tools/cdump-enumstr common/htlc_state.h > $@
|
||||||
|
|
||||||
check-makefile: check-common-makefile
|
check-makefile: check-common-makefile
|
||||||
|
|
||||||
check-common-makefile:
|
check-common-makefile:
|
||||||
@if [ x"`LC_ALL=C ls common/*.h | grep -v ^gen_`" != x"`echo $(COMMON_HEADERS) | tr ' ' '\n' | LC_ALL=C sort`" ]; then echo COMMON_HEADERS incorrect; exit 1; fi
|
@if [ x"`LC_ALL=C ls common/*.h | grep -v ^common/gen_`" != x"`echo $(COMMON_HEADERS_NOGEN) | tr ' ' '\n' | LC_ALL=C sort`" ]; then echo COMMON_HEADERS_NOGEN incorrect; exit 1; fi
|
||||||
|
|
||||||
check-source-bolt: $(COMMON_SRC:%=bolt-check/%) $(COMMON_HEADERS:%=bolt-check/%)
|
check-source-bolt: $(COMMON_SRC:%=bolt-check/%) $(COMMON_HEADERS:%=bolt-check/%)
|
||||||
check-whitespace: $(COMMON_SRC:%=check-whitespace/%) $(COMMON_HEADERS:%=check-whitespace/%)
|
check-whitespace: $(COMMON_SRC:%=check-whitespace/%) $(COMMON_HEADERS:%=check-whitespace/%)
|
||||||
|
|
||||||
check-source: $(COMMON_SRC:%=check-src-include-order/%) \
|
check-source: $(COMMON_SRC:%=check-src-include-order/%) \
|
||||||
$(COMMON_HEADERS:%=check-hdr-include-order/%)
|
$(COMMON_HEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "configdir.h"
|
#include "configdir.h"
|
||||||
#include "log.h"
|
|
||||||
#include <ccan/opt/opt.h>
|
#include <ccan/opt/opt.h>
|
||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "bitcoin/locktime.h"
|
#include "bitcoin/locktime.h"
|
||||||
#include "htlc_state.h"
|
#include "htlc_state.h"
|
||||||
#include "pseudorand.h"
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ccan/crypto/sha256/sha256.h>
|
#include <ccan/crypto/sha256/sha256.h>
|
||||||
#include <ccan/crypto/siphash24/siphash24.h>
|
#include <ccan/crypto/siphash24/siphash24.h>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "htlc.h"
|
|
||||||
#include "gen_htlc_state_names.h"
|
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
|
#include <common/htlc.h>
|
||||||
|
#include "gen_htlc_state_names.h"
|
||||||
|
|
||||||
const char *htlc_state_name(enum htlc_state s)
|
const char *htlc_state_name(enum htlc_state s)
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef LIGHTNING_LIGHTNINGD_HTLC_TX_H
|
#ifndef LIGHTNING_LIGHTNINGD_HTLC_TX_H
|
||||||
#define LIGHTNING_LIGHTNINGD_HTLC_TX_H
|
#define LIGHTNING_LIGHTNINGD_HTLC_TX_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
|
|
||||||
struct keyset;
|
struct keyset;
|
||||||
struct preimage;
|
struct preimage;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
#include <lightningd/channel_config.h>
|
#include <lightningd/channel_config.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#define LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
|
#define LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
#include <lightningd/channel/channeld_htlc.h>
|
#include <lightningd/channel/channeld_htlc.h>
|
||||||
|
|
||||||
struct keyset;
|
struct keyset;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* JSON core and helpers */
|
/* JSON core and helpers */
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ccan/build_assert/build_assert.h>
|
#include <ccan/build_assert/build_assert.h>
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
@@ -436,43 +435,6 @@ void json_add_hex(struct json_result *result, const char *fieldname,
|
|||||||
json_add_string(result, fieldname, hex);
|
json_add_string(result, fieldname, hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void json_add_pubkey(struct json_result *response,
|
|
||||||
const char *fieldname,
|
|
||||||
const struct pubkey *key)
|
|
||||||
{
|
|
||||||
u8 der[PUBKEY_DER_LEN];
|
|
||||||
|
|
||||||
pubkey_to_der(der, key);
|
|
||||||
json_add_hex(response, fieldname, der, sizeof(der));
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_add_short_channel_id(struct json_result *response,
|
|
||||||
const char *fieldname,
|
|
||||||
const struct short_channel_id *id)
|
|
||||||
{
|
|
||||||
char *str = tal_fmt(response, "%d:%d:%d", id->blocknum, id->txnum, id->outnum);
|
|
||||||
json_add_string(response, fieldname, str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_add_address(struct json_result *response, const char *fieldname,
|
|
||||||
const struct ipaddr *addr)
|
|
||||||
{
|
|
||||||
json_object_start(response, fieldname);
|
|
||||||
char *addrstr = tal_arr(response, char, INET6_ADDRSTRLEN);
|
|
||||||
if (addr->type == ADDR_TYPE_IPV4) {
|
|
||||||
inet_ntop(AF_INET, addr->addr, addrstr, INET_ADDRSTRLEN);
|
|
||||||
json_add_string(response, "type", "ipv4");
|
|
||||||
json_add_string(response, "address", addrstr);
|
|
||||||
json_add_num(response, "port", addr->port);
|
|
||||||
} else if (addr->type == ADDR_TYPE_IPV6) {
|
|
||||||
inet_ntop(AF_INET6, addr->addr, addrstr, INET6_ADDRSTRLEN);
|
|
||||||
json_add_string(response, "type", "ipv6");
|
|
||||||
json_add_string(response, "address", addrstr);
|
|
||||||
json_add_num(response, "port", addr->port);
|
|
||||||
}
|
|
||||||
json_object_end(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
void json_add_object(struct json_result *result, ...)
|
void json_add_object(struct json_result *result, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -3,15 +3,16 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <daemon/routing.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define JSMN_STRICT 1
|
#define JSMN_STRICT 1
|
||||||
# include "jsmn/jsmn.h"
|
# include "daemon/jsmn/jsmn.h"
|
||||||
|
|
||||||
|
struct ipaddr;
|
||||||
struct json_result;
|
struct json_result;
|
||||||
|
struct short_channel_id;
|
||||||
|
|
||||||
/* Include " if it's a string. */
|
/* Include " if it's a string. */
|
||||||
const char *json_tok_contents(const char *buffer, const jsmntok_t *t);
|
const char *json_tok_contents(const char *buffer, const jsmntok_t *t);
|
||||||
@@ -102,20 +103,6 @@ void json_add_null(struct json_result *result, const char *fieldname);
|
|||||||
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
|
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
|
||||||
void json_add_hex(struct json_result *result, const char *fieldname,
|
void json_add_hex(struct json_result *result, const char *fieldname,
|
||||||
const void *data, size_t len);
|
const void *data, size_t len);
|
||||||
/* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */
|
|
||||||
void json_add_pubkey(struct json_result *response,
|
|
||||||
const char *fieldname,
|
|
||||||
const struct pubkey *key);
|
|
||||||
|
|
||||||
/* '"fieldname" : "1234/5/6"' */
|
|
||||||
void json_add_short_channel_id(struct json_result *response,
|
|
||||||
const char *fieldname,
|
|
||||||
const struct short_channel_id *id);
|
|
||||||
|
|
||||||
/* JSON serialize a network address for a node */
|
|
||||||
void json_add_address(struct json_result *response, const char *fieldname,
|
|
||||||
const struct ipaddr *addr);
|
|
||||||
|
|
||||||
void json_add_object(struct json_result *result, ...);
|
void json_add_object(struct json_result *result, ...);
|
||||||
|
|
||||||
const char *json_result_string(const struct json_result *result);
|
const char *json_result_string(const struct json_result *result);
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "lightningd.h"
|
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
#include "bitcoin/locktime.h"
|
|
||||||
#include "bitcoin/pubkey.h"
|
|
||||||
#include "bitcoin/tx.h"
|
|
||||||
#include "daemon/htlc.h"
|
|
||||||
#include "type_to_string.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/type_to_string.h>
|
||||||
|
#include <common/utils.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
/* We need at least one, and this is in CCAN so register it here. */
|
/* We need at least one, and this is in CCAN so register it here. */
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <ccan/autodata/autodata.h>
|
#include <ccan/autodata/autodata.h>
|
||||||
|
#include <ccan/crypto/sha256/sha256.h>
|
||||||
#include <secp256k1.h>
|
#include <secp256k1.h>
|
||||||
|
|
||||||
/* This must match the type_to_string_ cases. */
|
/* This must match the type_to_string_ cases. */
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ HOST="$1"
|
|||||||
PORT="$2"
|
PORT="$2"
|
||||||
AMOUNT="$3"
|
AMOUNT="$3"
|
||||||
|
|
||||||
NEWADDR=`daemon/lightning-cli newaddr | sed -n 's/{ "address" : "\(.*\)" }/\1/p'`
|
NEWADDR=`cli/lightning-cli newaddr | sed -n 's/{ "address" : "\(.*\)" }/\1/p'`
|
||||||
TXID=`bitcoin-cli -testnet sendtoaddress $NEWADDR $AMOUNT`
|
TXID=`bitcoin-cli -testnet sendtoaddress $NEWADDR $AMOUNT`
|
||||||
RAWTX=`bitcoin-cli -testnet getrawtransaction $TXID`
|
RAWTX=`bitcoin-cli -testnet getrawtransaction $TXID`
|
||||||
|
|
||||||
echo "Connecting to $HOST port $PORT with $AMOUNT (minus fee) in address $NEWADDR tx $TXID"
|
echo "Connecting to $HOST port $PORT with $AMOUNT (minus fee) in address $NEWADDR tx $TXID"
|
||||||
echo "(Note: this will block until we get sufficient confirmations!)"
|
echo "(Note: this will block until we get sufficient confirmations!)"
|
||||||
exec daemon/lightning-cli connect "$HOST" "$PORT" $RAWTX
|
exec cli/lightning-cli connect "$HOST" "$PORT" $RAWTX
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ DEST="$1"
|
|||||||
AMOUNT="$2"
|
AMOUNT="$2"
|
||||||
PHASH="$3"
|
PHASH="$3"
|
||||||
|
|
||||||
if ROUTE=`daemon/lightning-cli getroute $DEST $AMOUNT 1`; then
|
if ROUTE=`cli/lightning-cli getroute $DEST $AMOUNT 1`; then
|
||||||
# Strip down to raw array.
|
# Strip down to raw array.
|
||||||
ROUTE=`echo $ROUTE | sed 's/^{ "route" : \(.*\) }$/\1/'`
|
ROUTE=`echo $ROUTE | sed 's/^{ "route" : \(.*\) }$/\1/'`
|
||||||
# Get first amount.
|
# Get first amount.
|
||||||
@@ -18,7 +18,7 @@ if ROUTE=`daemon/lightning-cli getroute $DEST $AMOUNT 1`; then
|
|||||||
read REPLY
|
read REPLY
|
||||||
case $REPLY in
|
case $REPLY in
|
||||||
""|y*|Y)
|
""|y*|Y)
|
||||||
daemon/lightning-cli sendpay "$ROUTE" "$PHASH"
|
cli/lightning-cli sendpay "$ROUTE" "$PHASH"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -34,11 +34,8 @@ DAEMON_SRC := \
|
|||||||
|
|
||||||
DAEMON_OBJS := $(DAEMON_SRC:.c=.o)
|
DAEMON_OBJS := $(DAEMON_SRC:.c=.o)
|
||||||
|
|
||||||
DAEMON_CLI_SRC := daemon/lightning-cli.c
|
|
||||||
DAEMON_CLI_OBJS := $(DAEMON_CLI_SRC:.c=.o)
|
|
||||||
|
|
||||||
DAEMON_JSMN_OBJS := daemon/jsmn.o
|
DAEMON_JSMN_OBJS := daemon/jsmn.o
|
||||||
DAEMON_JSMN_HEADERS := daemon/jsmn/jsmn.h
|
DAEMON_JSMN_HEADERS := daemon/jsmn/jsmn.hb
|
||||||
|
|
||||||
DAEMON_GEN_HEADERS := \
|
DAEMON_GEN_HEADERS := \
|
||||||
daemon/gen_htlc_state_names.h
|
daemon/gen_htlc_state_names.h
|
||||||
@@ -64,9 +61,6 @@ DAEMON_HEADERS := \
|
|||||||
daemon/timeout.h \
|
daemon/timeout.h \
|
||||||
daemon/watch.h
|
daemon/watch.h
|
||||||
|
|
||||||
daemon/gen_htlc_state_names.h: daemon/htlc_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
|
||||||
ccan/ccan/cdump/tools/cdump-enumstr daemon/htlc_state.h > $@
|
|
||||||
|
|
||||||
daemon/gen_feechange_state_names.h: daemon/feechange_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
daemon/gen_feechange_state_names.h: daemon/feechange_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
||||||
ccan/ccan/cdump/tools/cdump-enumstr daemon/feechange_state.h > $@
|
ccan/ccan/cdump/tools/cdump-enumstr daemon/feechange_state.h > $@
|
||||||
|
|
||||||
@@ -91,19 +85,6 @@ check-source-bolt: $(DAEMON_SRC:%=bolt-check/%) $(DAEMON_HEADERS:%=bolt-check/%)
|
|||||||
|
|
||||||
check-whitespace: $(DAEMON_SRC:%=check-whitespace/%) $(DAEMON_HEADERS:%=check-whitespace/%) check-whitespace/daemon/Makefile
|
check-whitespace: $(DAEMON_SRC:%=check-whitespace/%) $(DAEMON_HEADERS:%=check-whitespace/%) check-whitespace/daemon/Makefile
|
||||||
|
|
||||||
# Git submodules are seriously broken.
|
|
||||||
daemon/jsmn/jsmn.h:
|
|
||||||
git submodule update daemon/jsmn/
|
|
||||||
[ -f $@ ] || git submodule update --init daemon/jsmn/
|
|
||||||
|
|
||||||
# If we tell Make that the above builds both, it runs it twice in
|
|
||||||
# parallel. So we lie :(
|
|
||||||
daemon/jsmn/jsmn.c: daemon/jsmn/jsmn.h
|
|
||||||
[ -f $@ ]
|
|
||||||
|
|
||||||
daemon/jsmn.o: daemon/jsmn/jsmn.c
|
|
||||||
$(COMPILE.c) -DJSMN_STRICT=1 $(OUTPUT_OPTION) $<
|
|
||||||
|
|
||||||
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/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:
|
daemon-clean:
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
#ifndef LIGHTNING_DAEMON_LIGHTNING_H
|
|
||||||
#define LIGHTNING_DAEMON_LIGHTNING_H
|
|
||||||
#include "config.h"
|
|
||||||
#include "bitcoin/pubkey.h"
|
|
||||||
#include "watch.h"
|
|
||||||
#include <ccan/list/list.h>
|
|
||||||
#include <ccan/short_types/short_types.h>
|
|
||||||
#include <ccan/timer/timer.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <wire/wire.h>
|
|
||||||
|
|
||||||
/* Various adjustable things. */
|
|
||||||
struct config {
|
|
||||||
/* How long do we want them to lock up their funds? (blocks) */
|
|
||||||
u32 locktime_blocks;
|
|
||||||
|
|
||||||
/* How long do we let them lock up our funds? (blocks) */
|
|
||||||
u32 locktime_max;
|
|
||||||
|
|
||||||
/* How many blocks before we expect to see anchor?. */
|
|
||||||
u32 anchor_onchain_wait;
|
|
||||||
|
|
||||||
/* How many confirms until we consider an anchor "settled". */
|
|
||||||
u32 anchor_confirms;
|
|
||||||
|
|
||||||
/* How long will we accept them waiting? */
|
|
||||||
u32 anchor_confirms_max;
|
|
||||||
|
|
||||||
/* How many blocks until we stop watching a close commit? */
|
|
||||||
u32 forever_confirms;
|
|
||||||
|
|
||||||
/* Maximum percent of fee rate we'll accept. */
|
|
||||||
u32 commitment_fee_max_percent;
|
|
||||||
|
|
||||||
/* Minimum percent of fee rate we'll accept. */
|
|
||||||
u32 commitment_fee_min_percent;
|
|
||||||
|
|
||||||
/* Percent of fee rate we'll use. */
|
|
||||||
u32 commitment_fee_percent;
|
|
||||||
|
|
||||||
/* Minimum/maximum time for an expiring HTLC (blocks). */
|
|
||||||
u32 min_htlc_expiry, max_htlc_expiry;
|
|
||||||
|
|
||||||
/* How many blocks before upstream HTLC expiry do we panic and dump? */
|
|
||||||
u32 deadline_blocks;
|
|
||||||
|
|
||||||
/* Fee rates. */
|
|
||||||
u32 fee_base;
|
|
||||||
s32 fee_per_satoshi;
|
|
||||||
|
|
||||||
/* How long between polling bitcoind. */
|
|
||||||
struct timerel poll_time;
|
|
||||||
|
|
||||||
/* How long between changing commit and sending COMMIT message. */
|
|
||||||
struct timerel commit_time;
|
|
||||||
|
|
||||||
/* Whether to enable IRC peer discovery. */
|
|
||||||
bool use_irc;
|
|
||||||
|
|
||||||
/* Whether to ignore database version. */
|
|
||||||
bool db_version_ignore;
|
|
||||||
|
|
||||||
/* IPv4 or IPv6 address to announce to the network */
|
|
||||||
struct ipaddr ipaddr;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Here's where the global variables hide! */
|
|
||||||
struct lightningd_state {
|
|
||||||
/* Where all our logging goes. */
|
|
||||||
struct log_book *log_book;
|
|
||||||
struct log *base_log;
|
|
||||||
FILE *logf;
|
|
||||||
|
|
||||||
/* Our config dir, and rpc file */
|
|
||||||
char *config_dir;
|
|
||||||
char *rpc_filename;
|
|
||||||
|
|
||||||
/* Port we're listening on */
|
|
||||||
u16 portnum;
|
|
||||||
|
|
||||||
/* We're on testnet. */
|
|
||||||
bool testnet;
|
|
||||||
|
|
||||||
/* Configuration settings. */
|
|
||||||
struct config config;
|
|
||||||
|
|
||||||
/* The database where we keep our stuff. */
|
|
||||||
struct db *db;
|
|
||||||
|
|
||||||
/* Any pending timers. */
|
|
||||||
struct timers timers;
|
|
||||||
|
|
||||||
/* Cached block topology. */
|
|
||||||
struct chain_topology *topology;
|
|
||||||
|
|
||||||
/* Our peers. */
|
|
||||||
struct list_head peers;
|
|
||||||
|
|
||||||
/* Addresses to contact peers. */
|
|
||||||
struct list_head addresses;
|
|
||||||
|
|
||||||
/* Any outstanding "pay" commands. */
|
|
||||||
struct list_head pay_commands;
|
|
||||||
|
|
||||||
/* Our private key */
|
|
||||||
struct privkey *privkey;
|
|
||||||
|
|
||||||
/* This is us. */
|
|
||||||
struct pubkey id;
|
|
||||||
|
|
||||||
/* Our tame bitcoind. */
|
|
||||||
struct bitcoind *bitcoind;
|
|
||||||
|
|
||||||
/* Wallet addresses we maintain. */
|
|
||||||
struct list_head wallet;
|
|
||||||
|
|
||||||
/* Maintained by invoices.c */
|
|
||||||
struct invoices *invoices;
|
|
||||||
|
|
||||||
/* Routing information */
|
|
||||||
struct routing_state *rstate;
|
|
||||||
|
|
||||||
/* For testing: don't fail if we can't route. */
|
|
||||||
bool dev_never_routefail;
|
|
||||||
|
|
||||||
/* Re-exec hack for testing. */
|
|
||||||
char **reexec;
|
|
||||||
|
|
||||||
/* IP/hostname to be announced for incoming connections */
|
|
||||||
char *external_ip;
|
|
||||||
|
|
||||||
/* Announce timer. */
|
|
||||||
struct oneshot *announce;
|
|
||||||
};
|
|
||||||
#endif /* LIGHTNING_DAEMON_LIGHTNING_H */
|
|
||||||
@@ -10,37 +10,16 @@ lightningd-all: $(LIGHTNINGD_BINS)
|
|||||||
|
|
||||||
default: lightningd-all
|
default: lightningd-all
|
||||||
|
|
||||||
LIGHTNINGD_OLD_SRC := \
|
|
||||||
daemon/bitcoind.c \
|
|
||||||
daemon/broadcast.c \
|
|
||||||
daemon/chaintopology.c \
|
|
||||||
daemon/configdir.c \
|
|
||||||
daemon/dns.c \
|
|
||||||
daemon/invoice.c \
|
|
||||||
daemon/json.c \
|
|
||||||
daemon/jsonrpc.c \
|
|
||||||
daemon/log.c \
|
|
||||||
daemon/netaddr.c \
|
|
||||||
daemon/options.c \
|
|
||||||
daemon/opt_time.c \
|
|
||||||
daemon/pseudorand.c \
|
|
||||||
daemon/routing.c \
|
|
||||||
daemon/watch.c
|
|
||||||
LIGHTNINGD_OLD_OBJS := $(LIGHTNINGD_OLD_SRC:.c=.o)
|
|
||||||
LIGHTNINGD_OLD_HEADERS := $(LIGHTNINGD_OLD_SRC:.c=.h)
|
|
||||||
|
|
||||||
LIGHTNINGD_OLD_LIB_SRC := \
|
|
||||||
daemon/htlc_state.c \
|
|
||||||
daemon/pseudorand.c \
|
|
||||||
daemon/timeout.c
|
|
||||||
LIGHTNINGD_OLD_LIB_OBJS := $(LIGHTNINGD_OLD_LIB_SRC:.c=.o)
|
|
||||||
LIGHTNINGD_OLD_LIB_HEADERS := $(LIGHTNINGD_OLD_LIB_SRC:.c=.h)
|
|
||||||
|
|
||||||
# Common source we use.
|
# Common source we use.
|
||||||
LIGHTNINGD_COMMON_OBJS := \
|
LIGHTNINGD_COMMON_OBJS := \
|
||||||
|
common/configdir.o \
|
||||||
common/derive_basepoints.o \
|
common/derive_basepoints.o \
|
||||||
common/funding_tx.o \
|
common/funding_tx.o \
|
||||||
|
common/htlc_state.o \
|
||||||
|
common/json.o \
|
||||||
common/permute_tx.o \
|
common/permute_tx.o \
|
||||||
|
common/pseudorand.o \
|
||||||
|
common/timeout.o \
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/version.o \
|
common/version.o \
|
||||||
@@ -70,47 +49,51 @@ LIGHTNINGD_LIB_OBJS := $(LIGHTNINGD_LIB_SRC:.c=.o)
|
|||||||
LIGHTNINGD_LIB_HEADERS := $(LIGHTNINGD_LIB_SRC:.c=.h)
|
LIGHTNINGD_LIB_HEADERS := $(LIGHTNINGD_LIB_SRC:.c=.h)
|
||||||
|
|
||||||
LIGHTNINGD_SRC := \
|
LIGHTNINGD_SRC := \
|
||||||
|
lightningd/bitcoind.c \
|
||||||
lightningd/build_utxos.c \
|
lightningd/build_utxos.c \
|
||||||
lightningd/dev_ping.c \
|
lightningd/chaintopology.c \
|
||||||
|
lightningd/dns.c \
|
||||||
lightningd/gossip_control.c \
|
lightningd/gossip_control.c \
|
||||||
lightningd/htlc_end.c \
|
|
||||||
lightningd/hsm_control.c \
|
lightningd/hsm_control.c \
|
||||||
|
lightningd/htlc_end.c \
|
||||||
|
lightningd/invoice.c \
|
||||||
|
lightningd/jsonrpc.c \
|
||||||
lightningd/lightningd.c \
|
lightningd/lightningd.c \
|
||||||
|
lightningd/log.c \
|
||||||
|
lightningd/netaddr.c \
|
||||||
lightningd/new_connection.c \
|
lightningd/new_connection.c \
|
||||||
|
lightningd/opt_time.c \
|
||||||
|
lightningd/options.c \
|
||||||
lightningd/pay.c \
|
lightningd/pay.c \
|
||||||
lightningd/peer_control.c \
|
lightningd/peer_control.c \
|
||||||
lightningd/peer_htlcs.c \
|
lightningd/peer_htlcs.c \
|
||||||
lightningd/subd.c
|
lightningd/subd.c \
|
||||||
|
lightningd/watch.c
|
||||||
|
|
||||||
LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o)
|
# Source files without corresponding headers
|
||||||
|
LIGHTNINGD_SRC_NOHDR := \
|
||||||
|
lightningd/dev_ping.c \
|
||||||
|
|
||||||
|
LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o)
|
||||||
|
|
||||||
LIGHTNINGD_JSMN_OBJS := daemon/jsmn.o
|
LIGHTNINGD_JSMN_OBJS := daemon/jsmn.o
|
||||||
LIGHTNINGD_JSMN_HEADERS := daemon/jsmn/jsmn.h
|
LIGHTNINGD_JSMN_HEADERS := daemon/jsmn/jsmn.h
|
||||||
|
|
||||||
# We accumulate all lightningd/ headers in these three:
|
# We accumulate all lightningd/ headers in these three:
|
||||||
LIGHTNINGD_HEADERS_NOGEN = \
|
LIGHTNINGD_HEADERS_NOGEN = \
|
||||||
lightningd/build_utxos.h \
|
$(LIGHTNINGD_SRC:.c=.h) \
|
||||||
lightningd/gossip_control.h \
|
|
||||||
lightningd/hsm_control.h \
|
|
||||||
lightningd/htlc_end.h \
|
|
||||||
lightningd/lightningd.h \
|
|
||||||
lightningd/new_connection.h \
|
|
||||||
lightningd/pay.h \
|
|
||||||
lightningd/peer_control.h \
|
|
||||||
lightningd/peer_htlcs.h \
|
|
||||||
lightningd/peer_state.h \
|
lightningd/peer_state.h \
|
||||||
lightningd/subd.h \
|
|
||||||
$(LIGHTNINGD_OLD_LIB_HEADERS) \
|
|
||||||
$(LIGHTNINGD_LIB_HEADERS) \
|
$(LIGHTNINGD_LIB_HEADERS) \
|
||||||
$(WIRE_HEADERS) \
|
$(WIRE_HEADERS) \
|
||||||
$(BITCOIN_HEADERS) \
|
$(BITCOIN_HEADERS) \
|
||||||
$(COMMON_HEADERS) \
|
$(COMMON_HEADERS_NOGEN) \
|
||||||
$(DAEMON_HEADERS) \
|
|
||||||
$(WALLET_LIB_HEADERS)
|
$(WALLET_LIB_HEADERS)
|
||||||
|
|
||||||
# Generated headers
|
# Generated headers
|
||||||
LIGHTNINGD_HEADERS_GEN = \
|
LIGHTNINGD_HEADERS_GEN = \
|
||||||
lightningd/gen_peer_state_names.h \
|
lightningd/gen_peer_state_names.h \
|
||||||
|
lightningd/gen_peer_state_names.h \
|
||||||
|
$(COMMON_HEADERS_GEN) \
|
||||||
$(WIRE_GEN_HEADERS) \
|
$(WIRE_GEN_HEADERS) \
|
||||||
$(GEN_HEADERS)
|
$(GEN_HEADERS)
|
||||||
|
|
||||||
@@ -139,7 +122,7 @@ $(LIGHTNINGD_OBJS) $(LIGHTNINGD_LIB_OBJS): $(LIGHTNINGD_HEADERS)
|
|||||||
lightningd/gen_peer_state_names.h: lightningd/peer_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
lightningd/gen_peer_state_names.h: lightningd/peer_state.h ccan/ccan/cdump/tools/cdump-enumstr
|
||||||
ccan/ccan/cdump/tools/cdump-enumstr lightningd/peer_state.h > $@
|
ccan/ccan/cdump/tools/cdump-enumstr lightningd/peer_state.h > $@
|
||||||
|
|
||||||
check-source: $(LIGHTNINGD_SRC:%=check-src-include-order/%)
|
check-source: $(LIGHTNINGD_SRC:%=check-src-include-order/%) $(LIGHTNINGD_SRC_NOHDR:%=check-src-include-order/%)
|
||||||
check-source: $(LIGHTNINGD_LIB_SRC:%=check-src-include-order/%)
|
check-source: $(LIGHTNINGD_LIB_SRC:%=check-src-include-order/%)
|
||||||
check-source: $(LIGHTNINGD_CLI_SRC:%=check-src-include-order/%)
|
check-source: $(LIGHTNINGD_CLI_SRC:%=check-src-include-order/%)
|
||||||
check-source: $(LIGHTNINGD_HEADERS_NOGEN:%=check-hdr-include-order/%)
|
check-source: $(LIGHTNINGD_HEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||||
@@ -151,7 +134,7 @@ check-makefile: check-lightningd-makefile
|
|||||||
check-lightningd-makefile:
|
check-lightningd-makefile:
|
||||||
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
|
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
|
||||||
|
|
||||||
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_OLD_OBJS) $(LIGHTNINGD_OLD_LIB_OBJS) $(LIGHTNINGD_LIB_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(LIGHTNINGD_JSMN_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(CCAN_OBJS) $(CCAN_SHACHAIN48_OBJ) $(LIGHTNINGD_HSM_CONTROL_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIBBASE58_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) libsecp256k1.a libsodium.a libwallycore.a
|
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_LIB_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(LIGHTNINGD_JSMN_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(CCAN_OBJS) $(CCAN_SHACHAIN48_OBJ) $(LIGHTNINGD_HSM_CONTROL_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIBBASE58_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) libsecp256k1.a libsodium.a libwallycore.a
|
||||||
|
|
||||||
clean: lightningd-clean
|
clean: lightningd-clean
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "bitcoin/shadouble.h"
|
#include "bitcoin/shadouble.h"
|
||||||
#include "bitcoin/tx.h"
|
#include "bitcoin/tx.h"
|
||||||
#include "bitcoind.h"
|
#include "bitcoind.h"
|
||||||
#include "json.h"
|
|
||||||
#include "lightningd.h"
|
#include "lightningd.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include <ccan/cast/cast.h>
|
#include <ccan/cast/cast.h>
|
||||||
@@ -16,6 +15,7 @@
|
|||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
|
#include <common/json.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <lightningd/build_utxos.h>
|
#include <lightningd/build_utxos.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
#include "jsonrpc.h"
|
#include "jsonrpc.h"
|
||||||
#include "lightningd.h"
|
#include "lightningd.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "timeout.h"
|
|
||||||
#include "watch.h"
|
#include "watch.h"
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/asort/asort.h>
|
#include <ccan/asort/asort.h>
|
||||||
#include <ccan/io/io.h>
|
#include <ccan/io/io.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/timeout.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/time/time.h>
|
#include <ccan/time/time.h>
|
||||||
#include <daemon/jsmn/jsmn.h>
|
#include <daemon/jsmn/jsmn.h>
|
||||||
#include <daemon/watch.h>
|
#include <lightningd/watch.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
struct bitcoin_tx;
|
struct bitcoin_tx;
|
||||||
@@ -28,10 +28,13 @@ LIGHTNINGD_CHANNEL_OBJS := $(LIGHTNINGD_CHANNEL_SRC:.c=.o)
|
|||||||
# Common source we use.
|
# Common source we use.
|
||||||
CHANNELD_COMMON_OBJS := \
|
CHANNELD_COMMON_OBJS := \
|
||||||
common/derive_basepoints.o \
|
common/derive_basepoints.o \
|
||||||
|
common/htlc_state.o \
|
||||||
common/htlc_tx.o \
|
common/htlc_tx.o \
|
||||||
common/initial_channel.o \
|
common/initial_channel.o \
|
||||||
common/initial_commit_tx.o \
|
common/initial_commit_tx.o \
|
||||||
common/permute_tx.o \
|
common/permute_tx.o \
|
||||||
|
common/pseudorand.o \
|
||||||
|
common/timeout.o \
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/version.o
|
common/version.o
|
||||||
|
|||||||
@@ -13,10 +13,9 @@
|
|||||||
#include <ccan/time/time.h>
|
#include <ccan/time/time.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
#include <common/htlc_tx.h>
|
#include <common/htlc_tx.h>
|
||||||
|
#include <common/timeout.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <daemon/routing.h>
|
|
||||||
#include <daemon/timeout.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel/commit_tx.h>
|
#include <lightningd/channel/commit_tx.h>
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
#include <lightningd/cryptomsg.h>
|
#include <lightningd/cryptomsg.h>
|
||||||
#include <lightningd/daemon_conn.h>
|
#include <lightningd/daemon_conn.h>
|
||||||
#include <lightningd/debug.h>
|
#include <lightningd/debug.h>
|
||||||
|
#include <lightningd/gossip/routing.h>
|
||||||
#include <lightningd/hsm/gen_hsm_client_wire.h>
|
#include <lightningd/hsm/gen_hsm_client_wire.h>
|
||||||
#include <lightningd/key_derive.h>
|
#include <lightningd/key_derive.h>
|
||||||
#include <lightningd/msg_queue.h>
|
#include <lightningd/msg_queue.h>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define LIGHTNINGD_CHANNELD_HTLC_H
|
#define LIGHTNINGD_CHANNELD_HTLC_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
|
#include <common/pseudorand.h>
|
||||||
#include <wire/gen_onion_wire.h>
|
#include <wire/gen_onion_wire.h>
|
||||||
|
|
||||||
struct htlc {
|
struct htlc {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#define LIGHTNING_LIGHTNINGD_COMMIT_TX_H
|
#define LIGHTNING_LIGHTNINGD_COMMIT_TX_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
|
#include <common/htlc.h>
|
||||||
#include <common/initial_commit_tx.h>
|
#include <common/initial_commit_tx.h>
|
||||||
#include <daemon/htlc.h>
|
|
||||||
#include <lightningd/channel/channeld_htlc.h>
|
#include <lightningd/channel/channeld_htlc.h>
|
||||||
|
|
||||||
struct keyset;
|
struct keyset;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/htlc.h>
|
||||||
#include <common/htlc_tx.h>
|
#include <common/htlc_tx.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <daemon/htlc.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel/commit_tx.h>
|
#include <lightningd/channel/commit_tx.h>
|
||||||
#include <lightningd/channel/full_channel.h>
|
#include <lightningd/channel/full_channel.h>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <common/close_tx.h>
|
#include <common/close_tx.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
|
#include <common/htlc.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <daemon/htlc.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/closing/gen_closing_wire.h>
|
#include <lightningd/closing/gen_closing_wire.h>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <lightningd/channel/gen_channel_wire.h>
|
#include <lightningd/channel/gen_channel_wire.h>
|
||||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/sphinx.h>
|
#include <lightningd/sphinx.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
|||||||
@@ -11,14 +11,10 @@ LIGHTNINGD_GOSSIP_CONTROL_HEADERS := lightningd/gossip/gen_gossip_wire.h
|
|||||||
LIGHTNINGD_GOSSIP_CONTROL_SRC := lightningd/gossip/gen_gossip_wire.c
|
LIGHTNINGD_GOSSIP_CONTROL_SRC := lightningd/gossip/gen_gossip_wire.c
|
||||||
LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o)
|
LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o)
|
||||||
|
|
||||||
# These should eventually be migrated to the lightningd directory, after
|
|
||||||
# deprecating the legacy daemons
|
|
||||||
LIGHTNINGD_GOSSIP_LEGACY_HEADERS := daemon/routing.h daemon/broadcast.h \
|
|
||||||
daemon/log.h
|
|
||||||
|
|
||||||
# lightningd/gossip needs these:
|
# lightningd/gossip needs these:
|
||||||
LIGHTNINGD_GOSSIP_HEADERS := lightningd/gossip/gen_gossip_wire.h \
|
LIGHTNINGD_GOSSIP_HEADERS := lightningd/gossip/gen_gossip_wire.h \
|
||||||
$(LIGHTNINGD_GOSSIP_LEGACY_HEADERS)
|
lightningd/gossip/routing.h \
|
||||||
|
lightningd/gossip/broadcast.h
|
||||||
LIGHTNINGD_GOSSIP_SRC := lightningd/gossip/gossip.c \
|
LIGHTNINGD_GOSSIP_SRC := lightningd/gossip/gossip.c \
|
||||||
$(LIGHTNINGD_GOSSIP_HEADERS:.h=.c)
|
$(LIGHTNINGD_GOSSIP_HEADERS:.h=.c)
|
||||||
LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o)
|
LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o)
|
||||||
@@ -32,6 +28,8 @@ LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_GOSSIP_HEADERS)
|
|||||||
|
|
||||||
# Common source we use.
|
# Common source we use.
|
||||||
GOSSIPD_COMMON_OBJS := \
|
GOSSIPD_COMMON_OBJS := \
|
||||||
|
common/pseudorand.o \
|
||||||
|
common/timeout.o \
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/version.o
|
common/version.o
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "daemon/broadcast.h"
|
#include <lightningd/gossip/broadcast.h>
|
||||||
|
|
||||||
struct broadcast_state *new_broadcast_state(tal_t *ctx)
|
struct broadcast_state *new_broadcast_state(tal_t *ctx)
|
||||||
{
|
{
|
||||||
@@ -9,19 +9,20 @@
|
|||||||
#include <ccan/read_write_all/read_write_all.h>
|
#include <ccan/read_write_all/read_write_all.h>
|
||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <ccan/timer/timer.h>
|
||||||
|
#include <common/timeout.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <daemon/broadcast.h>
|
|
||||||
#include <daemon/routing.h>
|
|
||||||
#include <daemon/timeout.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/cryptomsg.h>
|
#include <lightningd/cryptomsg.h>
|
||||||
#include <lightningd/daemon_conn.h>
|
#include <lightningd/daemon_conn.h>
|
||||||
#include <lightningd/debug.h>
|
#include <lightningd/debug.h>
|
||||||
|
#include <lightningd/gossip/broadcast.h>
|
||||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||||
|
#include <lightningd/gossip/routing.h>
|
||||||
#include <lightningd/gossip_msg.h>
|
#include <lightningd/gossip_msg.h>
|
||||||
#include <lightningd/ping.h>
|
#include <lightningd/ping.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
#include "lightningd.h"
|
|
||||||
#include "pseudorand.h"
|
|
||||||
#include "routing.h"
|
#include "routing.h"
|
||||||
#include "wire/gen_peer_wire.h"
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <bitcoin/block.h>
|
#include <bitcoin/block.h>
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
@@ -10,9 +7,12 @@
|
|||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/overflows.h>
|
#include <common/overflows.h>
|
||||||
|
#include <common/pseudorand.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
|
#include <wire/gen_peer_wire.h>
|
||||||
|
|
||||||
/* 365.25 * 24 * 60 / 10 */
|
/* 365.25 * 24 * 60 / 10 */
|
||||||
#define BLOCKS_PER_YEAR 52596
|
#define BLOCKS_PER_YEAR 52596
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef LIGHTNING_DAEMON_ROUTING_H
|
#ifndef LIGHTNING_DAEMON_ROUTING_H
|
||||||
#define LIGHTNING_DAEMON_ROUTING_H
|
#define LIGHTNING_DAEMON_ROUTING_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "bitcoin/pubkey.h"
|
#include <bitcoin/pubkey.h>
|
||||||
#include "daemon/broadcast.h"
|
|
||||||
#include "wire/wire.h"
|
|
||||||
#include <ccan/htable/htable_type.h>
|
#include <ccan/htable/htable_type.h>
|
||||||
|
#include <lightningd/gossip/broadcast.h>
|
||||||
|
#include <wire/wire.h>
|
||||||
|
|
||||||
#define ROUTING_MAX_HOPS 20
|
#define ROUTING_MAX_HOPS 20
|
||||||
#define ROUTING_FLAGS_DISABLED 2
|
#define ROUTING_FLAGS_DISABLED 2
|
||||||
@@ -7,12 +7,12 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/cryptomsg.h>
|
#include <lightningd/cryptomsg.h>
|
||||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||||
#include <lightningd/gossip_msg.h>
|
#include <lightningd/gossip_msg.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <wire/gen_peer_wire.h>
|
#include <wire/gen_peer_wire.h>
|
||||||
|
|
||||||
static void gossip_finished(struct subd *gossip, int status)
|
static void gossip_finished(struct subd *gossip, int status)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H
|
#define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/pubkey.h>
|
#include <bitcoin/pubkey.h>
|
||||||
#include <daemon/routing.h>
|
#include <lightningd/gossip/routing.h>
|
||||||
|
|
||||||
struct gossip_getnodes_entry {
|
struct gossip_getnodes_entry {
|
||||||
struct pubkey nodeid;
|
struct pubkey nodeid;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#include <ccan/io/io.h>
|
#include <ccan/io/io.h>
|
||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/hsm/gen_hsm_wire.h>
|
#include <lightningd/hsm/gen_hsm_wire.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#include <ccan/crypto/siphash24/siphash24.h>
|
#include <ccan/crypto/siphash24/siphash24.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
#include <daemon/log.h>
|
#include <common/pseudorand.h>
|
||||||
#include <daemon/pseudorand.h>
|
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
size_t hash_htlc_key(const struct htlc_key *k)
|
size_t hash_htlc_key(const struct htlc_key *k)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/htable/htable_type.h>
|
#include <ccan/htable/htable_type.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <daemon/htlc_state.h>
|
#include <common/htlc_state.h>
|
||||||
#include <lightningd/sphinx.h>
|
#include <lightningd/sphinx.h>
|
||||||
#include <wire/gen_onion_wire.h>
|
#include <wire/gen_onion_wire.h>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/preimage.h>
|
#include <bitcoin/preimage.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
#include <lightningd/sphinx.h>
|
#include <lightningd/sphinx.h>
|
||||||
#include <wire/gen_onion_wire.h>
|
#include <wire/gen_onion_wire.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "db.h"
|
|
||||||
#include "invoice.h"
|
#include "invoice.h"
|
||||||
#include "jsonrpc.h"
|
#include "jsonrpc.h"
|
||||||
#include "lightningd.h"
|
#include "lightningd.h"
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
/* Code for JSON_RPC API */
|
/* Code for JSON_RPC API */
|
||||||
/* eg: { "method" : "dev-echo", "params" : [ "hello", "Arabella!" ], "id" : "1" } */
|
/* eg: { "method" : "dev-echo", "params" : [ "hello", "Arabella!" ], "id" : "1" } */
|
||||||
#include "chaintopology.h"
|
#include <arpa/inet.h>
|
||||||
#include "json.h"
|
|
||||||
#include "jsonrpc.h"
|
|
||||||
#include "lightningd.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
#include <ccan/io/io.h>
|
#include <ccan/io/io.h>
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/json.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <lightningd/chaintopology.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -368,6 +369,43 @@ struct json_result *null_response(const tal_t *ctx)
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void json_add_pubkey(struct json_result *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct pubkey *key)
|
||||||
|
{
|
||||||
|
u8 der[PUBKEY_DER_LEN];
|
||||||
|
|
||||||
|
pubkey_to_der(der, key);
|
||||||
|
json_add_hex(response, fieldname, der, sizeof(der));
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_add_short_channel_id(struct json_result *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct short_channel_id *id)
|
||||||
|
{
|
||||||
|
json_add_string(response, fieldname,
|
||||||
|
type_to_string(response, struct short_channel_id, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_add_address(struct json_result *response, const char *fieldname,
|
||||||
|
const struct ipaddr *addr)
|
||||||
|
{
|
||||||
|
json_object_start(response, fieldname);
|
||||||
|
char *addrstr = tal_arr(response, char, INET6_ADDRSTRLEN);
|
||||||
|
if (addr->type == ADDR_TYPE_IPV4) {
|
||||||
|
inet_ntop(AF_INET, addr->addr, addrstr, INET_ADDRSTRLEN);
|
||||||
|
json_add_string(response, "type", "ipv4");
|
||||||
|
json_add_string(response, "address", addrstr);
|
||||||
|
json_add_num(response, "port", addr->port);
|
||||||
|
} else if (addr->type == ADDR_TYPE_IPV6) {
|
||||||
|
inet_ntop(AF_INET6, addr->addr, addrstr, INET6_ADDRSTRLEN);
|
||||||
|
json_add_string(response, "type", "ipv6");
|
||||||
|
json_add_string(response, "address", addrstr);
|
||||||
|
json_add_num(response, "port", addr->port);
|
||||||
|
}
|
||||||
|
json_object_end(response);
|
||||||
|
}
|
||||||
|
|
||||||
void command_success(struct command *cmd, struct json_result *result)
|
void command_success(struct command *cmd, struct json_result *result)
|
||||||
{
|
{
|
||||||
struct json_connection *jcon = cmd->jcon;
|
struct json_connection *jcon = cmd->jcon;
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef LIGHTNING_DAEMON_JSONRPC_H
|
#ifndef LIGHTNING_DAEMON_JSONRPC_H
|
||||||
#define LIGHTNING_DAEMON_JSONRPC_H
|
#define LIGHTNING_DAEMON_JSONRPC_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "json.h"
|
|
||||||
#include <ccan/autodata/autodata.h>
|
#include <ccan/autodata/autodata.h>
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
|
#include <common/json.h>
|
||||||
|
|
||||||
/* Context for a command (from JSON, but might outlive the connection!)
|
/* Context for a command (from JSON, but might outlive the connection!)
|
||||||
* You can allocate off this for temporary objects. */
|
* You can allocate off this for temporary objects. */
|
||||||
@@ -54,6 +54,21 @@ struct json_result *null_response(const tal_t *ctx);
|
|||||||
void command_success(struct command *cmd, struct json_result *response);
|
void command_success(struct command *cmd, struct json_result *response);
|
||||||
void PRINTF_FMT(2, 3) command_fail(struct command *cmd, const char *fmt, ...);
|
void PRINTF_FMT(2, 3) command_fail(struct command *cmd, const char *fmt, ...);
|
||||||
|
|
||||||
|
/* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */
|
||||||
|
void json_add_pubkey(struct json_result *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct pubkey *key);
|
||||||
|
|
||||||
|
/* '"fieldname" : "1234:5:6"' */
|
||||||
|
void json_add_short_channel_id(struct json_result *response,
|
||||||
|
const char *fieldname,
|
||||||
|
const struct short_channel_id *id);
|
||||||
|
|
||||||
|
/* JSON serialize a network address for a node */
|
||||||
|
void json_add_address(struct json_result *response, const char *fieldname,
|
||||||
|
const struct ipaddr *addr);
|
||||||
|
|
||||||
|
|
||||||
/* For initialization */
|
/* For initialization */
|
||||||
void setup_jsonrpc(struct lightningd_state *dstate, const char *rpc_filename);
|
void setup_jsonrpc(struct lightningd_state *dstate, const char *rpc_filename);
|
||||||
|
|
||||||
@@ -13,17 +13,16 @@
|
|||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <ccan/tal/grab_file/grab_file.h>
|
#include <ccan/tal/grab_file/grab_file.h>
|
||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
|
#include <common/timeout.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <daemon/bitcoind.h>
|
#include <lightningd/bitcoind.h>
|
||||||
#include <daemon/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <daemon/invoice.h>
|
#include <lightningd/invoice.h>
|
||||||
#include <daemon/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <daemon/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <daemon/options.h>
|
|
||||||
#include <daemon/routing.h>
|
|
||||||
#include <daemon/timeout.h>
|
|
||||||
#include <lightningd/onchain/onchain_wire.h>
|
#include <lightningd/onchain/onchain_wire.h>
|
||||||
|
#include <lightningd/options.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
#include <bitcoin/chainparams.h>
|
#include <bitcoin/chainparams.h>
|
||||||
#include <bitcoin/privkey.h>
|
#include <bitcoin/privkey.h>
|
||||||
#include <ccan/container_of/container_of.h>
|
#include <ccan/container_of/container_of.h>
|
||||||
#include <daemon/lightningd.h>
|
#include <ccan/time/time.h>
|
||||||
|
#include <ccan/timer/timer.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
/* BOLT #1:
|
/* BOLT #1:
|
||||||
@@ -15,6 +17,130 @@
|
|||||||
*/
|
*/
|
||||||
#define DEFAULT_PORT 0x2607
|
#define DEFAULT_PORT 0x2607
|
||||||
|
|
||||||
|
/* Various adjustable things. */
|
||||||
|
struct config {
|
||||||
|
/* How long do we want them to lock up their funds? (blocks) */
|
||||||
|
u32 locktime_blocks;
|
||||||
|
|
||||||
|
/* How long do we let them lock up our funds? (blocks) */
|
||||||
|
u32 locktime_max;
|
||||||
|
|
||||||
|
/* How many blocks before we expect to see anchor?. */
|
||||||
|
u32 anchor_onchain_wait;
|
||||||
|
|
||||||
|
/* How many confirms until we consider an anchor "settled". */
|
||||||
|
u32 anchor_confirms;
|
||||||
|
|
||||||
|
/* How long will we accept them waiting? */
|
||||||
|
u32 anchor_confirms_max;
|
||||||
|
|
||||||
|
/* How many blocks until we stop watching a close commit? */
|
||||||
|
u32 forever_confirms;
|
||||||
|
|
||||||
|
/* Maximum percent of fee rate we'll accept. */
|
||||||
|
u32 commitment_fee_max_percent;
|
||||||
|
|
||||||
|
/* Minimum percent of fee rate we'll accept. */
|
||||||
|
u32 commitment_fee_min_percent;
|
||||||
|
|
||||||
|
/* Percent of fee rate we'll use. */
|
||||||
|
u32 commitment_fee_percent;
|
||||||
|
|
||||||
|
/* Minimum/maximum time for an expiring HTLC (blocks). */
|
||||||
|
u32 min_htlc_expiry, max_htlc_expiry;
|
||||||
|
|
||||||
|
/* How many blocks before upstream HTLC expiry do we panic and dump? */
|
||||||
|
u32 deadline_blocks;
|
||||||
|
|
||||||
|
/* Fee rates. */
|
||||||
|
u32 fee_base;
|
||||||
|
s32 fee_per_satoshi;
|
||||||
|
|
||||||
|
/* How long between polling bitcoind. */
|
||||||
|
struct timerel poll_time;
|
||||||
|
|
||||||
|
/* How long between changing commit and sending COMMIT message. */
|
||||||
|
struct timerel commit_time;
|
||||||
|
|
||||||
|
/* Whether to enable IRC peer discovery. */
|
||||||
|
bool use_irc;
|
||||||
|
|
||||||
|
/* Whether to ignore database version. */
|
||||||
|
bool db_version_ignore;
|
||||||
|
|
||||||
|
/* IPv4 or IPv6 address to announce to the network */
|
||||||
|
struct ipaddr ipaddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Here's where the global variables hide! */
|
||||||
|
struct lightningd_state {
|
||||||
|
/* Where all our logging goes. */
|
||||||
|
struct log_book *log_book;
|
||||||
|
struct log *base_log;
|
||||||
|
FILE *logf;
|
||||||
|
|
||||||
|
/* Our config dir, and rpc file */
|
||||||
|
char *config_dir;
|
||||||
|
char *rpc_filename;
|
||||||
|
|
||||||
|
/* Port we're listening on */
|
||||||
|
u16 portnum;
|
||||||
|
|
||||||
|
/* We're on testnet. */
|
||||||
|
bool testnet;
|
||||||
|
|
||||||
|
/* Configuration settings. */
|
||||||
|
struct config config;
|
||||||
|
|
||||||
|
/* The database where we keep our stuff. */
|
||||||
|
struct db *db;
|
||||||
|
|
||||||
|
/* Any pending timers. */
|
||||||
|
struct timers timers;
|
||||||
|
|
||||||
|
/* Cached block topology. */
|
||||||
|
struct chain_topology *topology;
|
||||||
|
|
||||||
|
/* Our peers. */
|
||||||
|
struct list_head peers;
|
||||||
|
|
||||||
|
/* Addresses to contact peers. */
|
||||||
|
struct list_head addresses;
|
||||||
|
|
||||||
|
/* Any outstanding "pay" commands. */
|
||||||
|
struct list_head pay_commands;
|
||||||
|
|
||||||
|
/* Our private key */
|
||||||
|
struct privkey *privkey;
|
||||||
|
|
||||||
|
/* This is us. */
|
||||||
|
struct pubkey id;
|
||||||
|
|
||||||
|
/* Our tame bitcoind. */
|
||||||
|
struct bitcoind *bitcoind;
|
||||||
|
|
||||||
|
/* Wallet addresses we maintain. */
|
||||||
|
struct list_head wallet;
|
||||||
|
|
||||||
|
/* Maintained by invoices.c */
|
||||||
|
struct invoices *invoices;
|
||||||
|
|
||||||
|
/* Routing information */
|
||||||
|
struct routing_state *rstate;
|
||||||
|
|
||||||
|
/* For testing: don't fail if we can't route. */
|
||||||
|
bool dev_never_routefail;
|
||||||
|
|
||||||
|
/* Re-exec hack for testing. */
|
||||||
|
char **reexec;
|
||||||
|
|
||||||
|
/* IP/hostname to be announced for incoming connections */
|
||||||
|
char *external_ip;
|
||||||
|
|
||||||
|
/* Announce timer. */
|
||||||
|
struct oneshot *announce;
|
||||||
|
};
|
||||||
|
|
||||||
/* FIXME: This is two structures, during the migration from old setup to new */
|
/* FIXME: This is two structures, during the migration from old setup to new */
|
||||||
struct lightningd {
|
struct lightningd {
|
||||||
/* Must be first, since things assume we can tal() off it */
|
/* Must be first, since things assume we can tal() off it */
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "pseudorand.h"
|
|
||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
#include <ccan/opt/opt.h>
|
#include <ccan/opt/opt.h>
|
||||||
@@ -7,6 +6,7 @@
|
|||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/time/time.h>
|
#include <ccan/time/time.h>
|
||||||
|
#include <common/pseudorand.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
#include <ccan/array_size/array_size.h>
|
#include <ccan/array_size/array_size.h>
|
||||||
#include <ccan/fdpass/fdpass.h>
|
#include <ccan/fdpass/fdpass.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <lightningd/cryptomsg.h>
|
#include <lightningd/cryptomsg.h>
|
||||||
#include <lightningd/handshake/gen_handshake_wire.h>
|
#include <lightningd/handshake/gen_handshake_wire.h>
|
||||||
#include <lightningd/hsm/gen_hsm_wire.h>
|
#include <lightningd/hsm/gen_hsm_wire.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/new_connection.h>
|
#include <lightningd/new_connection.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
|
|
||||||
/* The minimal info about an htlc. */
|
/* The minimal info about an htlc. */
|
||||||
struct htlc_stub {
|
struct htlc_stub {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ OPENINGD_COMMON_OBJS := \
|
|||||||
common/initial_channel.o \
|
common/initial_channel.o \
|
||||||
common/initial_commit_tx.o \
|
common/initial_commit_tx.o \
|
||||||
common/permute_tx.o \
|
common/permute_tx.o \
|
||||||
|
common/pseudorand.o \
|
||||||
common/type_to_string.o \
|
common/type_to_string.o \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/version.o
|
common/version.o
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
#include <common/funding_tx.h>
|
#include <common/funding_tx.h>
|
||||||
#include <common/initial_channel.h>
|
#include <common/initial_channel.h>
|
||||||
|
#include <common/pseudorand.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
#include "bitcoin/chainparams.h"
|
|
||||||
#include "daemon/bitcoind.h"
|
|
||||||
#include "daemon/chaintopology.h"
|
|
||||||
#include "daemon/configdir.h"
|
|
||||||
#include "daemon/lightningd.h"
|
|
||||||
#include "daemon/log.h"
|
|
||||||
#include "daemon/opt_time.h"
|
|
||||||
#include "daemon/options.h"
|
|
||||||
#include "daemon/routing.h"
|
|
||||||
#include "lightningd/lightningd.h"
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <bitcoin/chainparams.h>
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
#include <ccan/opt/opt.h>
|
#include <ccan/opt/opt.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/grab_file/grab_file.h>
|
#include <ccan/tal/grab_file/grab_file.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <common/configdir.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <lightningd/bitcoind.h>
|
||||||
|
#include <lightningd/chaintopology.h>
|
||||||
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
|
#include <lightningd/opt_time.h>
|
||||||
|
#include <lightningd/options.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -228,10 +226,6 @@ static void config_register_opts(struct lightningd_state *dstate)
|
|||||||
opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32,
|
opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32,
|
||||||
&dstate->config.fee_per_satoshi,
|
&dstate->config.fee_per_satoshi,
|
||||||
"Microsatoshi fee for every satoshi in HTLC");
|
"Microsatoshi fee for every satoshi in HTLC");
|
||||||
opt_register_arg("--add-route", opt_add_route, NULL,
|
|
||||||
dstate,
|
|
||||||
"Add route of form srcid/dstid/base/var/delay/minblocks"
|
|
||||||
"(base in millisatoshi, var in millionths of satoshi per satoshi)");
|
|
||||||
opt_register_noarg("--disable-irc", opt_set_invbool,
|
opt_register_noarg("--disable-irc", opt_set_invbool,
|
||||||
&dstate->config.use_irc,
|
&dstate->config.use_irc,
|
||||||
"Disable IRC peer discovery for routing");
|
"Disable IRC peer discovery for routing");
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
#include <bitcoin/preimage.h>
|
#include <bitcoin/preimage.h>
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
#include <daemon/chaintopology.h>
|
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/channel/gen_channel_wire.h>
|
#include <lightningd/channel/gen_channel_wire.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
#include <lightningd/sphinx.h>
|
#include <lightningd/sphinx.h>
|
||||||
@@ -231,7 +231,7 @@ static void json_sendpay(struct command *cmd,
|
|||||||
if (!short_channel_id_from_str(buffer + chantok->start,
|
if (!short_channel_id_from_str(buffer + chantok->start,
|
||||||
chantok->end - chantok->start,
|
chantok->end - chantok->start,
|
||||||
&hop_data[n_hops].channel_id)) {
|
&hop_data[n_hops].channel_id)) {
|
||||||
command_fail(cmd, "route %zu invalid id", n_hops);
|
command_fail(cmd, "route %zu invalid channel_id", n_hops);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!pubkey_from_hexstr(buffer + idtok->start,
|
if (!pubkey_from_hexstr(buffer + idtok->start,
|
||||||
|
|||||||
@@ -11,23 +11,23 @@
|
|||||||
#include <common/close_tx.h>
|
#include <common/close_tx.h>
|
||||||
#include <common/funding_tx.h>
|
#include <common/funding_tx.h>
|
||||||
#include <common/initial_commit_tx.h>
|
#include <common/initial_commit_tx.h>
|
||||||
#include <daemon/chaintopology.h>
|
#include <common/timeout.h>
|
||||||
#include <daemon/dns.h>
|
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <daemon/timeout.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/build_utxos.h>
|
#include <lightningd/build_utxos.h>
|
||||||
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/channel/gen_channel_wire.h>
|
#include <lightningd/channel/gen_channel_wire.h>
|
||||||
#include <lightningd/closing/gen_closing_wire.h>
|
#include <lightningd/closing/gen_closing_wire.h>
|
||||||
#include <lightningd/dev_disconnect.h>
|
#include <lightningd/dev_disconnect.h>
|
||||||
|
#include <lightningd/dns.h>
|
||||||
#include <lightningd/gen_peer_state_names.h>
|
#include <lightningd/gen_peer_state_names.h>
|
||||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||||
#include <lightningd/hsm/gen_hsm_wire.h>
|
#include <lightningd/hsm/gen_hsm_wire.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/key_derive.h>
|
#include <lightningd/key_derive.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/new_connection.h>
|
#include <lightningd/new_connection.h>
|
||||||
#include <lightningd/onchain/gen_onchain_wire.h>
|
#include <lightningd/onchain/gen_onchain_wire.h>
|
||||||
#include <lightningd/onchain/onchain_wire.h>
|
#include <lightningd/onchain/onchain_wire.h>
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#include <ccan/compiler/compiler.h>
|
#include <ccan/compiler/compiler.h>
|
||||||
#include <ccan/crypto/shachain/shachain.h>
|
#include <ccan/crypto/shachain/shachain.h>
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
#include <daemon/htlc.h>
|
#include <common/htlc.h>
|
||||||
#include <daemon/json.h>
|
#include <common/json.h>
|
||||||
#include <daemon/netaddr.h>
|
|
||||||
#include <lightningd/channel_config.h>
|
#include <lightningd/channel_config.h>
|
||||||
|
#include <lightningd/netaddr.h>
|
||||||
#include <lightningd/peer_state.h>
|
#include <lightningd/peer_state.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/derive_basepoints.h>
|
#include <common/derive_basepoints.h>
|
||||||
#include <common/overflows.h>
|
#include <common/overflows.h>
|
||||||
#include <daemon/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <daemon/invoice.h>
|
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <lightningd/channel/gen_channel_wire.h>
|
#include <lightningd/channel/gen_channel_wire.h>
|
||||||
#include <lightningd/gossip/gen_gossip_wire.h>
|
#include <lightningd/gossip/gen_gossip_wire.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
#include <lightningd/htlc_wire.h>
|
#include <lightningd/htlc_wire.h>
|
||||||
|
#include <lightningd/invoice.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/onchain/onchain_wire.h>
|
#include <lightningd/onchain/onchain_wire.h>
|
||||||
#include <lightningd/pay.h>
|
#include <lightningd/pay.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <ccan/tal/path/path.h>
|
#include <ccan/tal/path/path.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <daemon/log.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|||||||
@@ -32,12 +32,12 @@
|
|||||||
#include "chaintopology.h"
|
#include "chaintopology.h"
|
||||||
#include "lightningd.h"
|
#include "lightningd.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "pseudorand.h"
|
|
||||||
#include "timeout.h"
|
|
||||||
#include "watch.h"
|
#include "watch.h"
|
||||||
#include <ccan/crypto/siphash24/siphash24.h>
|
#include <ccan/crypto/siphash24/siphash24.h>
|
||||||
#include <ccan/ptrint/ptrint.h>
|
#include <ccan/ptrint/ptrint.h>
|
||||||
#include <ccan/structeq/structeq.h>
|
#include <ccan/structeq/structeq.h>
|
||||||
|
#include <common/pseudorand.h>
|
||||||
|
#include <common/timeout.h>
|
||||||
|
|
||||||
const struct txwatch_output *txowatch_keyof(const struct txowatch *w)
|
const struct txwatch_output *txowatch_keyof(const struct txowatch *w)
|
||||||
{
|
{
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
#include "daemon/log.h"
|
|
||||||
#include "lightningd/lightningd.h"
|
|
||||||
|
|
||||||
#include <ccan/str/hex/hex.h>
|
#include <ccan/str/hex/hex.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
|
|
||||||
#define DB_FILE "lightningd.sqlite3"
|
#define DB_FILE "lightningd.sqlite3"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
#define WALLET_DB_H
|
#define WALLET_DB_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "daemon/log.h"
|
#include <ccan/short_types/short_types.h>
|
||||||
|
#include <ccan/tal/tal.h>
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/peer_htlcs.h>
|
#include <lightningd/peer_htlcs.h>
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
|
||||||
struct lightningd;
|
struct lightningd;
|
||||||
|
struct pubkey;
|
||||||
|
|
||||||
struct wallet {
|
struct wallet {
|
||||||
struct db *db;
|
struct db *db;
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/withdraw_tx.h>
|
#include <common/withdraw_tx.h>
|
||||||
#include <daemon/bitcoind.h>
|
|
||||||
#include <daemon/chaintopology.h>
|
|
||||||
#include <daemon/jsonrpc.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <lightningd/bitcoind.h>
|
||||||
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/hsm/gen_hsm_wire.h>
|
#include <lightningd/hsm/gen_hsm_wire.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/key_derive.h>
|
#include <lightningd/key_derive.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/status.h>
|
#include <lightningd/status.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <lightningd/utxo.h>
|
#include <lightningd/utxo.h>
|
||||||
|
|||||||
@@ -204,12 +204,7 @@ void fromwire_pad(const u8 **cursor, size_t *max, size_t num)
|
|||||||
fromwire(cursor, max, NULL, num);
|
fromwire(cursor, max, NULL, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *fmt_short_channel_id(const tal_t *ctx,
|
REGISTER_TYPE_TO_STRING(short_channel_id, short_channel_id_to_str);
|
||||||
const struct short_channel_id *id)
|
|
||||||
{
|
|
||||||
return tal_fmt(ctx, "%u/%u/%u", id->blocknum, id->txnum, id->outnum);
|
|
||||||
}
|
|
||||||
REGISTER_TYPE_TO_STRING(short_channel_id, fmt_short_channel_id);
|
|
||||||
REGISTER_TYPE_TO_HEXSTR(channel_id);
|
REGISTER_TYPE_TO_HEXSTR(channel_id);
|
||||||
|
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
|
|||||||
Reference in New Issue
Block a user