Rusty Russell
bbed5e3411
Rename subdaemons, move them into top level.
We leave the *build* results in lightningd/ for ease of in-place testing though.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
739b163f8b
Makefiles: simplify dependencies.
Gather all binaries and objects and make the depend on external
requirements and common headers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
f42f34b82d
external: new subdirectory for all external libraries and submodules.
You will want to 'make distclean' after this.
I also removed libsecp; we use the one in in libwally anyway.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
c6976cd947
shachain: always build 48 bit version.
No more special Makefile hacks required.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
a37c165cb9
common: move some files out of lightningd/
Basically all files shared by different daemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
8375857116
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>
7 years ago
Rusty Russell
85ff95e829
common: new directory for any shared objects.
To avoid everything pulling in HTLCs stuff to the opening daemon, we
split the channel and commit_tx routines into initial_channel and
initial_commit_tx (no HTLC support) and move full HTLC supporting versions
into channeld.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
d7db0be5da
lightningd: start onchaind when we see funding spent.
We're very simple about it: if there's a reorganization, we restart. Otherwise
we tell it about everything.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
1b2fb18944
onchaind: basic daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
4bfaaef408
keyset: abstraction over what keys we need for a specific commitment.
onchaind will need to do similar logic to channeld, so this allows them
to share much more code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
f5f8ca5352
onchain/onchain_wire: routines to marshal/unmarshal htlc stubs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
f765e0e846
bip32: marshal/unmarshal routines.
Neater than using a u8 array as we do now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
a87d50acc9
Makefile: clean daemons on clean.
Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
a827d2b2bb
lightningd: add in support for closingd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
e5a8a7502c
lightningd/closing: subdaemon for closing negotiation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
479036604b
wallet: Implement withdrawal transaction generation
This will be used by both the master daemon and the HSM to
generate (hopefully) identical transactions for signature and
broadcast.
8 years ago
Rusty Russell
ae62509b58
lightningd: remove dev-newhtlc command.
It added another path to the local-htlc handling, and we have full
invoice support now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
ad3ab53fa4
lightningd/htlc_wire: wire types for sending HTLCs to/from channel daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
7c9b66e67f
lightningd: peer_htlcs.c
Move HTLC handling out of peer_control.c.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
9882a9fb29
wallet: Start the wallet interface and link it into lightningd
The database is hidden behind the wallet interface, which has all the
wallet specific functionality. First up is the tracking of outputs.
8 years ago
Rusty Russell
9b1d240c1f
lightningd: --dev-disconnect support.
We use a file descriptor, so when we consume an entry, we move past it
(and everyone shares a file offset, so this works).
The file contains packet names prefixed by - (treat fd as closed when
we try to write this packet), + (write the packet then ensure the file
descriptor fails), or @ ("lose" the packet then ensure the file
descriptor fails).
The sync and async peer-write functions hook this in automatically.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Header from folded patch 'test-run-cryptomsg__fix_compilation.patch':
test/run-cryptomsg: fix compilation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
f6495d3310
lightningd/peer_control: don't create peer struct until we've connected.
We currently create a peer struct, then complete handshake to find out
who it is. This means we have a half-formed peer, and worse: if it's
a reconnect we get two peers the same.
Add an explicit 'struct connection' for the handshake phase, and
construct a 'struct peer' once that's done.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
34e6e56471
lightningd: introduce peer_state enum.
The actual state names are place holders for now, really.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
09b31624f0
sphinx: Creating copy of sphinx for new daemon
Keeping both the legacy daemon and the new daemon happy with the
restructure is a lot of work, so we just don't do it :-)
8 years ago
Rusty Russell
8f358b7a91
lightningd: add dev_ping command for channeld.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
d5be8d26f2
lightningd/ping: ping support.
A spec update brings ping support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
b18eaf8e1c
pay: Makefile was missing a header file
8 years ago
Rusty Russell
e2dc10f98d
lightningd: pay support.
The previous code was very tied to the old daemon, so this copies a large
part of it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
f3dbc75eb3
lightningd: send message on HTLC failure, relay to peer.
We don't do the encryption wrapping we're supposed to do yet.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
826fb0c2dc
lightningd: track HTLC ends.
This lets us link HTLCs from one peer to another; but for the moment it
simply means we can adjust balance when an HTLC is fulfilled.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
be4af38d0c
channel: unwrap and send incoming HTLCs to master.
So far it just looks it up, marks it resolved, then does nothing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
eb61446ec8
daemon/invoice: wean off dstate (a little), link into new daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
27764b65f9
lightningd: fix shachain to be 48-bits, with hack for legacy.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
0197353bd9
lightningd/Makefile: put timeout into OLD_LIB_SRC for all daemons.
And remove the now-redundant mention in gossipd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
47da80fdca
lightningd: dev_newhtlc command.
For testing point-to-point HTLCs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
185a649572
lightningd: include daemon/sphinx.
We're going to need it to make routes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
cf6d25cad6
lightningd/connection: rename to lightningd/daemon_conn
To match the structure name.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
4bf398c4e7
status: move into lightningd/status.
It's really a lightningd-only thing, and we're about to do surgery on it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
74df755a29
gossip: Added nested message types for getnodes query
Added a struct that represents a single entry in a `getnodes` reply,
so that we can append one after the other and parse them again on the
other side.
8 years ago
Christian Decker
408d2f5170
Async connection abstraction
This is an attempt at unifying all the async connection handling into
a reusable module.
8 years ago
Rusty Russell
da5c7e0a08
daemon/subdaemon: remove in favor of daemon/subd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
95f41287f0
lightningd/subd: new code for subdaemons.
This uses a single fd for both status and control.
To make this work, we enforce the convention that replies are the same
as requests + 100, and that their name ends in "_REPLY".
This also means that various daemons can simply exit when done; there's
no race between reading request and closing status fds.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
cd62b74b1c
lightningd/msg_queue: helper for queues of messages/
Since they're short, we use a simple array. This can be replaced later.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
9035d281c6
lightningd/lightningd: hook in channel daemon.
Doesn't do much yet except wait for funding confirmation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
9014f2593e
lightningd/channel: normal operation daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
c64447a929
lightningd/derive_basepoints: hoist derivation logic.
All the daemons will use a common seed for point derivation, so drag
it out of lightningd/opening.
This also provide a nice struct wrapper to reduce argument count.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
6a14e24a82
lightningd: integrate bitcoind.
This allows us to broadcast transactions and watch for them.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
e6efcdf5bd
daemon/bitcoind: wean off struct lightningd_state.
We want to use this in the new daemon, so use 'struct bitcoind'
everywhere.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
9aebd5c797
lightningd: add opening to dependencies.
Without this, make check doesn't rebuild opening subdaemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
fd258fe495
lightningd: wire up opening daemon.
Now we can actually open a channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago