Rusty Russell
726e7226c4
commit_tx: update HTLC-tx fees to match latest BOLT.
As per lightning-rfc BOLT #3 ec99f893f320e8c88f564c1c8566f3454f0f1f5f:
"fixed htlc weight calculation"
Reported-by: Fabrice Drouin <fabrice.drouin@acinq.fr>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
35909ba94a
cryptomsg: wording fix with update to latest BOLT.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
f7cc079221
test/run-commit_tx: Fix derivation of BOLT #3 test vectors.
We were using the remote per_commitment_point instead of the local
per_commitment_point to generate the remotekey for the local transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
20a07d860a
check-source: include tests, libdir.
And fix the resulting issues.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
9fd40da38c
generate-wire: don't hand unknown structures specially.
It's awkward to handle them differently. But this change means we
need to expose them to the generated code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
66d122684d
lightningd/test/run-commit_tx: Creation of BOLT 3 test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
0fe53cc8e7
permute_tx: reintroduce permute map.
We used to have a permutation map; this reintroduces a variant which
uses the htlc pointers directly.
We need this because we have to send the htlc-tx signatures in output
order as part of the protocol: without two-stage HTLCs we only needed
to wire them up in the unilateral spend case so we simply brute-forced
the ordering.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
e11d9304ab
lightningd/hbtlc_tx: creation of BOLT 3 htlc transactions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
f9189254e4
lightningd/commit_tx: creation of BOLT 3 commitment transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
b290a96a4a
lightningd: use daemon/htlc_state.c
We're about to need HTLC handling.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
be46fdf254
lightningd/funding_tx.c: helper to create a funding transaction (with change).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
75c6dd1981
channel_config: convenient structure for handling open/accept config info.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
dc3b27e1d3
key_derive: key derivation from basepoints as specified in BOLT 3
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
4ed259c46c
gen_peer_wire_csv: update for latest spec.
We have a separate announcement_signatures message now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
fb814a7a9e
gossip: Adding announcement handling to the gossip subdaemon.
We now have all the pieces to wire in the handling functionality to
the new gossip subdaemon.
8 years ago
Christian Decker
76e2c980e1
gossip: Moving to intmap-based broadcast for the legacy daemon
Moved the broadcast functionality to broadcast.[ch]. So far this
includes only the enqueuing side of broadcasts, the dequeuing and
actual push to the peer is daemon dependent. This also adds the
broadcast_state to the routing_state and the last broadcast index to
the peer for the legacy daemon.
8 years ago
Christian Decker
3cb576d69d
refactor: Moving gossip/routing specific state into its own struct
This used to be part of `lightningd_state` which is being split up for
the various subdaemons. The main change is the addition of the `struct
routing_state` in `routing.h` and the addition of `rstate` in `struct
lightningd_state` for backwards compatibility.
8 years ago
Rusty Russell
a600b1a30f
handshake: hand in client fd on exec instead of gratuitous fd passing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
13a30ff79c
subdaemon: close unused fds when creating subdaemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
2f9b04b0d9
subdaemon: start fds at 3 not 4.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
f9eea9041e
handshake: update for BOLT 8 latest revision.
This now matches commit fc4846a27bf420c591ba0b024cc34972816913c7,
and fixes "make check-source".
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
a02f1e10c4
make check: run all the tests.
We can't run them in parallel, but we can at least have 'make check'
run them all.
Developers should be running "make check-source && make check".
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
6bf3c30a10
lightningd/Makefile: fix check-source
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
b41d71da30
Makefile: Making sure header vars are populated correctly
The problem with wire headers not being generated in time before stuff
depended on it turns out to be related with inclusion order of
sub-makefiles. The inclusions must preceed the use of
LIGHTNINGD_HEADERS since they append to that variable.
8 years ago
Rusty Russell
33748bf119
lightningd/Makefile: combine all headers (wire/gen was missing)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
73d07ce441
libsodium: use our local submodule.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
3af081aded
Makefile: make all lightningd objects depend on all lightningd headers.
Christian reported that we weren't generating some gen_ files.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
1e34e5344d
lightningd/lightningd: add getpeers command.
This has an optional log level if you want to see logs for the peers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
dc8b174e3a
lightningd/lightningd: maintain a per-peer log.
At the moment we just log each condition change.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
83b156517f
lightningd/lightningd: maintain "condition" for each peer.
This lets us return better messages to the connect json command on failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
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>
8 years ago
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>
8 years ago
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>
8 years ago
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>
8 years ago
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>
8 years ago
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>
8 years ago
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>
8 years ago
Rusty Russell
78841456e0
lightningd/handshake: test handshake, produce BOLT 8 test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
32e1b5bb06
lightningd/handshake: simple daemon to do BOLT 8 crypto handshake.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
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".
8 years ago
Rusty Russell
0444d68197
lightningd/lightningd: add rpc interface.
daemon/lightning-cli works with this.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
542e6844f7
lightningd/lightningd: start HSM at initialization time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
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>
8 years ago
Rusty Russell
6a089ce112
cryptomsg: add towire/fromwire for crypto state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
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>
8 years ago
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>
8 years ago
Rusty Russell
faebb87d01
lightningd/subdaemon: routines to create daemons and get request/response.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
8bf33c7839
lightningd/lightningd: daemon for controlling the other daemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago