Commit Graph

1661 Commits

Author SHA1 Message Date
Rusty Russell 3c5a70910a lightningd/hsm: shutdown when master conn is freed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-12 09:09:19 -07:00
Rusty Russell 3509f10e30 lightningd/gossip: shut down daemon when status fd closed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-12 09:09:19 -07: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 b6fea5b429 pytest: Check that channels are announced and activated correctly 2017-04-11 16:56:27 -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
Christian Decker a215cb47f1 gossip: Verify channel_update signatures 2017-04-11 16:56:27 -07:00
Christian Decker 58196b5a32 gossipd: Verify signatures for incoming channel_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
Rusty Russell 21449650b0 lightningd/hsm: update_signature support.
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
Christian Decker 30934eb2fb hsm: Creating signatures for incoming channel announcement sig reqs 2017-04-11 16:56:27 -07:00
Christian Decker b41c8e240a hsm: Added channel announcement sig request and reply
Note this only does the node signature; the channeld itself currently
holds the bitcoin privkey for the funding tx.
2017-04-11 16:56:27 -07:00
Rusty Russell fc98d797d2 hsm: new fd type for channeld.
Instead of reusing HSMFD_ECDH, we have an explicit channeld hsm fd,
which can do ECDH and will soon do channel announce signatures as well.

Based-on: 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 218a59d64b Merge pull request #145 from inbitcoin/master
INSTALL.md: Add 'install' to apt command examples.
2017-04-10 15:16:58 -07:00
Marco Amadori 3d90176503 INSTALL.md: Add 'install' to apt command examples.
Signed-off-by: Marco Amadori <marco.amadori@gmail.com>
2017-04-10 11:43:16 +02:00
Christian Decker d934e730c3 Merge pull request #143 from rustyrussell/travis
Travis
2017-04-04 12:49:41 +02:00
Rusty Russell c2d093a6dc INSTALL: add python requirements for tests, move asciidoc to devel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-04 15:32:57 +09:30
Rusty Russell 6f9a7f7aa1 Travis support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-04 15:27:34 +09:30
Christian Decker b18eaf8e1c pay: Makefile was missing a header file 2017-04-04 12:27:07 +09:30
Rusty Russell 018c1d932d lightning/pay: fix missing include.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-03 06:07:56 +09:30
Rusty Russell 798c4b73c4 lightningd/htlc_end: fix key for stricter compiler.
We *should* split the struct into key and data, rather than only comparing
the key parts in the htlc_end_eq function.  But meanwhile, this fixes
the code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-02 09:36:29 +09:30
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 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>
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 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>
2017-04-01 23:59:46 +10:30
Rusty Russell 49d97a2fd6 Update wire from spec ed107e4ef019f33a88aa5567adca7fbb944e93af
This version correctly extracts fields with _ in them, meaning we get
more fields.

Also adds Makefile dependency which I noticed broke the build.

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 2d635a381b lightningd/channel: pass owner, not sender to channel_fulfill_htlc / channel_fail_htlc
I got this wrong when using them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell 85fd8218e2 lightningd: track channel balance.
This is an approximate result (it's only our confirmed balance, not showing
outstanding HTLCs), but it gives an easy way to check HTLCs have been
resolved.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell dc562f0533 Makefiles: fix from-scratch parallel build.
1) Need config.h before wire/gen_ are compiled.
2) The rule to checkout the libbase58 submodule doesn't work, so use the older
   one-depends-on-the-other approach.

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 8a84e961ed daemon/sphinx: support modern v0 hop payload.
This just means we put the outgoing_cltv_value where we used to put zeroes.
The old daemon simply ignores this, but the new one should check it as per
BOLT 4.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell fed25cc540 lightningd/subd: add a context to requests.
If a peer dies, and then we get a reply, that can cause access after free.
The usual way to handle this is to make the request a child of the peer,
but in fact we still want to catch (and disard) it, so it's a little
more complex internally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell a815500653 lightningd: hand HSM fd to channeld.
For the moment, it's just to do ECDH to read the onion.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell 8146b838e8 daemon/sphinx: split handling.
We want to use HSM to do the ECDH part, so split that out.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell e36a65a189 lightningd/subd: msgcb return -1 to close channel.
They can't free it while we're using it, but they can return a value
to close it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell eb61446ec8 daemon/invoice: wean off dstate (a little), link into new daemon.
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 27764b65f9 lightningd: fix shachain to be 48-bits, with hack for legacy.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-01 23:59:46 +10:30
Rusty Russell dd15361935 lightningd/derive_basepoints: helper to increment our per_commit_point.
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