Rusty Russell
8f358b7a91
lightningd: add dev_ping command for channeld.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-25 22:00:28 +02:00
Rusty Russell
d5be8d26f2
lightningd/ping: ping support.
...
A spec update brings ping support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-25 22:00:28 +02:00
Rusty Russell
15519e5ddf
lightningd/channel: set signatures to zero before sending to HSM.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-12 09:09:19 -07:00
Rusty Russell
d06303c8a2
lightningd/channel: derive local channel_id.
...
We weren't setting it, but the peer wasn't checking it either.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-12 09:09:19 -07:00
Christian Decker
f4cf485f00
channeld: Added tracing of incoming and outgoing messages
...
Makes it easier to search for messages being exchanged when testing.
2017-04-11 16:56:27 -07:00
Christian Decker
8e98e438e9
channeld: Collect signatures before sending announcements
...
We now have two partially overlapping state-machines: the channel
state and the announcement state. We need to request signatures from
the HSM to exchange them with the peer, and we need to have both sets
of signatures before we can proceed and send the actual announcements.
2017-04-11 16:56:27 -07:00
Rusty Russell
041accb114
channeld: Passing channel_update to HSM for signing, hand to gossipd.
...
Base-on-patch-by: Christian Decker <decker.christian@gmail.com >
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-11 16:56:27 -07:00
Christian Decker
9c07376dcf
channeld: Use local secret to generate bitcoin signature
...
This key will eventually migrate to the HSM, but for now it's in the
channeld so we generate the signature there.
2017-04-11 16:56:27 -07:00
Rusty Russell
20716ad29b
channeld: Ask HSM for channel announcement signature
...
This is fairly simple: we use synchronous I/O to the HSM.
Based-on: Christian Decker <decker.christian@gmail.com >
2017-04-11 16:56:27 -07:00
Rusty Russell
e75309873b
lightningd/derive_basepoints.h: one place for 2^48 shachain constant.
...
Suggested-by: Christian Decker <decker.christian@gmail.com >
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
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 >
2017-04-01 23:59:46 +10:30
Rusty Russell
1c0b43f04d
channel: tell master about the HTLC fulfillment.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
86da7c3a4d
lightningd/channel: send and receive htlc_fulfilled messages.
...
Includes a fix for the direction we fulfill.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
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 >
2017-04-01 23:59:46 +10:30
Rusty Russell
d3cbde4b46
lightningd/channel: send and receive revoke_and_ack packets.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
2ddc0b696c
lightningd/channel: keep old commit points.
...
We need this, to validate that the secret they give us matches it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
8f2c4348a9
lightningd/channel.c: tell if we're still awaiting revoke_and_ack.
...
And make sure we don't send another commit if we are.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
3041cd5915
lightningd/channel.c: clearer functions names, better return values.
...
We call channel_sent_commit *before* sending (so we know if we need
to), so the name is wrong. Similarly channel_sent_revoke_and_ack.
We can usefully have them tell is if there is outstanding work to do,
too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
f83c04fdbe
lightningd/channel.c: make callbacks clearly generic
...
Passing through 'struct peer *' was a layering violation.
Reported-by: Christian Decker <decker.christian@gmail.com >
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
ada1eb5106
lightningd/channel.c: add callbacks for when HTLCs fully committed/removed.
...
The three cases we care about only happen on specific transitions:
1. They can no longer spend our failed HTLC: we can fail the source now.
2. They are fully committed to their new HTLC htlc: we can forward now.
3. They can no longer timeout their fulfilled HTLC: the funds are ours.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
82a467f131
lightningd/channel: send and receive update_commit
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
64b50e5cb6
lightningd/channel: handle adding HTLC, generalize handler.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
7919279367
lightningd/channel: inter-daemon messages for HTLC handling.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Rusty Russell
075092411e
lightningd/channel: generate htlc txs and wscripts as well.
...
In practice, this is what we want, either to generate or check signatures.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-04-01 23:59:46 +10:30
Christian Decker
7793bd1b9d
gossip: Consolidated direction bit computation
...
The direction bit was computed in several spots and was inconsistent
in some cases. Now we compute it just in routing, and once when
starting up `channeld`, this avoids recomputing it all over the place.
2017-03-28 14:06:48 +10:30
Christian Decker
60a2227f0d
channel: Disable channels that are lost via a channel_update
...
Before exiting, `channeld` constructs and sends a `channel_update`
marking the channel as disabled. This is the pro-active signalling
that the channel may no longer be used.
2017-03-23 13:34:03 +10:30
Christian Decker
d2c626820f
channel: Wait for 6 confirmations before sending announcement sigs
...
The protocol specifies that in order for an announcement to be valid,
the channel has to have at least 6 confirmations.
2017-03-20 17:09:12 +01:00
Rusty Russell
cf6d25cad6
lightningd/connection: rename to lightningd/daemon_conn
...
To match the structure name.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-20 07:50:53 +10:30
Rusty Russell
bdc41f00f3
lightningd/channel: use msg_queue properly for peer.
...
Use msg_enqueue's wake and msg_queue_wait, and don't clone packets since
msg_enqueue() respects take.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-20 07:50:53 +10:30
Rusty Russell
5637564cd4
lightningd/status: support daemon_conn for status_trace and status_failed.
...
We remove the unused status_send_fd, and rename status_send_sync (it
should only be used for that case now).
We add a status_setup_async(), and wire things internally to use that
if it's set up: status_setup() is renamed status_setup_sync().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-20 07:50:53 +10:30
Rusty Russell
7442cf7c3e
lightningd/channel: use daemon_conn.
...
This is a little more awkward, as we used to do some work
synchronously (the init message), but it's still pretty clear.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-20 07:50:53 +10:30
Rusty Russell
c213ea482d
channel: receive gossip fd on exec.
...
This simplifies things a little: hand the fd on exec rather than over the
request socket.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-20 07:50:53 +10:30
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 >
2017-03-20 07:50:53 +10:30
Christian Decker
8d5591f110
channel: Create gossip announcement upon channel establishment
2017-03-15 12:45:11 +10:30
Christian Decker
5a1fbb7aaf
channel: Passing through the endpoint node_ids
...
This is used to generate the announcements.
2017-03-15 12:45:11 +10:30
Christian Decker
8ae698d1dc
Migrating daemon_conn to msg_queue and msg_queue takes over messages
...
We have some duplication in handling queues, so this is an attempt at
deduplicating some of that work. `daemon_conn` now uses the
`msg_queue` and `channeld` was also migrated to `msg_queue`. At the
same time I made `msg_queue` create a copy of the messages or takes
over messages marked with `take()`. This should make cleaning up
messages easier.
2017-03-13 17:32:03 +01:00
Christian Decker
ea1a891d3f
channel: Forwarding incoming gossip messages to gossipd
2017-03-13 11:26:48 +01:00
Christian Decker
04f6070cb6
channel: Forwarding gossip messages to peer
2017-03-13 11:26:48 +01:00
Christian Decker
34c96399b0
channel: Passing gossipd client fd to channeld
2017-03-13 11:26:48 +01:00
Rusty Russell
14505594b5
lightningd/channel: convert to subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-11 07:19:41 +10:30
Rusty Russell
9014f2593e
lightningd/channel: normal operation daemon.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2017-03-07 11:56:12 +10:30