Commit Graph

1342 Commits

Author SHA1 Message Date
Rusty Russell 7aaffda779 lightningd/lightningd: finish connect command once gossip started.
This is after the INIT message is received, so we know there are no
incompatible features.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell c536616bee lightningd/lightningd: wire up lightningd_gossip.
Now we hand peers off to the gossip daemon, to do the INIT handshake and
re-transmit/receive gossip.  They may stay there forever if neither we nor
them wants to open a channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 1800e84db7 subdaemon: callback to handle subdaemon status updates.
It's a bit messy, since some status messages are accompanied by an FD:
in this case, the handler returns STATUS_NEED_FD and we read that then
re-call the handler.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 21a5c62ead lightningd_gossip: daemon to look after peers which don't a channel (yet)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 03758af4e1 lightningd/lightningd: create unique ID for each peer.
This distinguishes them before they have an ID, and also if the daemon
doesn't know the ID.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell bf118f1b86 lightningd/lightningd: add connect command.
Unlike the old daemon, this just connects; a separate command will be needed
to create a channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 211491f4d7 lightningd/lightningd: add lightning_handshake.
Now we do crypto handshake when peer comes in.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 78841456e0 lightningd/handshake: test handshake, produce BOLT 8 test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 32e1b5bb06 lightningd/handshake: simple daemon to do BOLT 8 crypto handshake.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 6f5fed17d8 lightningd/test: simple black-box tests.
These use the same infrastructure as the daemon/test blackbox tests,
so they're not currently wired into make check; use make
"lightningd-blackbox-tests".
2017-01-10 15:38:33 +10:30
Rusty Russell e39d09d5a5 daemon/test/scripts: maek slightly more general for lightningd/lightningd
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 0444d68197 lightningd/lightningd: add rpc interface.
daemon/lightning-cli works with this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 542e6844f7 lightningd/lightningd: start HSM at initialization time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 015eb072b8 Makefile: split CORE_SRC into CORE_SRC, CORE_TX_SRC and CORE_PROTOBUF_SRC
With the lightningd daemon split, we don't need them all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 10b8dc5950 lightningd/hsm: simple daemon to control the keys.
This provides APIs to access the keys.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 6a089ce112 cryptomsg: add towire/fromwire for crypto state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 89a06734c4 lightningd/cryptomsg: test routines.
This creates output similar to the BOLT #8 test vectors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell a7f682c66e lightningd/cryptomsg: routines to encrypt on the wire.
After the handshake, it's a simple matter of AEAD and key rotation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell faebb87d01 lightningd/subdaemon: routines to create daemons and get request/response.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30
Rusty Russell 8bf33c7839 lightningd/lightningd: daemon for controlling the other daemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:37:51 +10:30
Rusty Russell 4b9eb19c68 status: don't send overlarge messages.
We'll assert if we try: better to truncate, trace a warning, and let the
recipient complain about a truncated message,

This is particularly an issue when we're sending encapsulated messages;
this avoids extra checks in the caller.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:25:20 +10:30
Rusty Russell a0ac5c276e status: API for status reporting.
The API formalizes how daemons should report their statuses back to
the main lightningd.  It's a simple write API, which includes tracing
support (currently it always sends traces, later it could send iff
there's a failure, for example).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:24:20 +10:30
Rusty Russell 1afb6c68ad wire/Makefile: don't erase source in clean, fix deps.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:23:20 +10:30
Rusty Russell a10ea23e0d wire: add ccan/io helpers to send (unencrypted) messages between damones.
Format is "le16 len; u8 message[len]" same as wire format specified in
BOLTs, even though the endian conversion is overkill for local messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:22:20 +10:30
Rusty Russell 9d316e39cd wire/wire_sync: helper routines for direct read/write of messages.
Some of the simple daemons want to use this, as do the status messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:21:20 +10:30
Rusty Russell 2b8c7cc840 tools/generate-wire.py: don't allocate on unknown names.
This introduces a potential leak; use a static buffer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:20:20 +10:30
Rusty Russell 1ba7f59d31 ccan: updates to get constant STR_MAX_CHARS and io_close_taken_fd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:19:33 +10:30
Rusty Russell 42f474af18 wire: make lengths of variable fields implied by tal_count()
This is a much nicer interface, and works better in practice too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:19:25 +10:30
Rusty Russell 7b1a4fc765 utils: add tal_hex() helper.
This is a shortcut when the data being dumped is a tal array.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:19:25 +10:30
Rusty Russell 4a233090ae log: rename struct log_record to struct log_book.
I think "log entry" when I see "log record", so this name is better.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:18:26 +10:30
Rusty Russell 350d8edb7e log: don't include dstate any more.
Before we had a global secp256k1_ctx we needed to hold this to print
out pubkeys, now it's completely orthogonal.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:17:51 +10:30
Christian Decker 07fbeee29d coverage: Added `coverage` makefile target
Added coverage files to `clean` and `coverage` target to generate HTML
report of coverage.
2017-01-10 09:27:55 +10:30
Christian Decker bd6b9c377e coverage: Enable compilation with `--coverage`
Setting the environment variable `COVERAGE=1` allows us to turn
coverage measurements on. This produces a number of auxiliary gcno and
gcda files which can then be converted into coverage reports.

I know line coverage and branch coverage is not a perfect metric, but
it might get us some more visibility into where more tests might be
needed.
2017-01-10 09:27:55 +10:30
Christian Decker af43cc5e2c makefile: Be more verbose in `check-daemon-headers`
So far it was failing silently, now it diffs the Makefile state
against the directory listing. This also fixes a bug when the locale
was not set the sort order would not match.
2017-01-10 09:26:06 +10:30
Rusty Russell 71ab218ed8 test/run-peer-wire.c: fix for variable-length reason field in update_fail_htlc
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:58:39 +10:30
Rusty Russell af2ad72c50 wire: update peer CSV file.
This is from my fix-peer-numbering branch (without that, the code
won't compile due to dup numbers) and temporarily removes the
alignment check (fails due to sha256 in update_fail_malformed_htlc,
which will be fixed in my onion-failmsg-cleanup branch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:40:35 +10:30
Rusty Russell d8feec2197 wire: split onion messages from peer wire messages.
The recent update to BOLT #4 includes failure message specifications,
which are completely orthogonal to the normal ones.  Don't include
them in the gen_peer_wire_csv.

This onion_defs.h file assumes we are using 2-byte failure codes as per
the onion-failmsg-cleanup branch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:40:35 +10:30
Rusty Russell b6a55a68ea tools/generate-wire.py: handle non-integer enum values.
BOLT 4 uses values like "PERM|1", so allow that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:40:06 +10:30
Rusty Russell 2057de6d4f tools/generate-wire.py: Apparently OptionParser is deprecated, use argparse.
It is a bit nicer though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:24:45 +10:30
Rusty Russell 8b72604d4d wire: allow #include directives in csv comments, and unknown structure types.
This lets us marshal and unmarshal undefined complex types; the fromwire
function will allocate it for us, so we don't even need to know the size.

This turns out to be really nice for marshalling 'struct crypto_state'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:24:45 +10:30
Rusty Russell b59fe5a2b6 daemon/Makefile: objects depend on wire headers too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-06 13:23:50 +10:30
Christian Decker 452656f5a1 base58: Making check-source happy again
Trailing whitespace and include ordering was broken.
2017-01-05 12:12:30 +10:30
Christian Decker 96af89139e base58: Unittests need in-tree libbase58 2017-01-05 12:12:30 +10:30
Rusty Russell a6f98ad02b Makefile: wire objects also depend on CCAN headers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-05 12:11:18 +10:30
Rusty Russell 9df0aa7538 libbase58: add autosubmodule rule, move depends to bitcoin/Makefile
The object file should not be built inside the submodule, as that can
confuse git.

Not everything depends on the libbase58 header (CCAN doesn't), so
move that to the everything-else depends line.

The BITCOIN_SRC etc should also move to bitcoin/Makefile, but that's
a bigger change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-05 12:11:18 +10:30
Lucas Betschart 5a41439eef Update INSTALL.md libbase58 2017-01-05 12:11:18 +10:30
Lucas Betschart 3e6bb958eb Add libbase58 as git submodule
Pointing to the latest release (0.1.4)
2017-01-05 12:11:18 +10:30
Rusty Russell bdc4972df6 wire/gen_peer_wire_csv: update to latest spec #2
828eda61df5a7be27051c605f7808e4f690739e4, in particular, it has the
new address format for node_announcement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:21 +10:30
Rusty Russell d3bdb073b5 wire/gen_peer_wire_csv: update to latest spec #1
In particular, add features bitfields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:21 +10:30
Rusty Russell f50af430e1 wire: add bool routines.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:09:21 +10:30