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
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
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
47da80fdca
lightningd: dev_newhtlc command.
...
For testing point-to-point HTLCs.
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
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
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
f511012e29
lightningd/gossip: don't hand client fd until release.
...
The gossip subdaemon previously passed the fd after init: this is
unnecessary for peers which simply want to gossip (and not establish
channels).
Now we hand the gossip fd back with the peer fd. This adds another
error message for when we fail to create the gossip fds.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-20 07:50:53 +10:30
Rusty Russell
7a9df37ef3
lightningd/subd: support multiple fds sent at once in normal messages.
...
Rather than returning SUBD_NEED_FD, callback returns how many fds it needs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-20 07:50:53 +10:30
Rusty Russell
38bffc0f0c
lightningd/subd: support multiple fds sent at once in request reply.
...
Instead of indicating where to place the fd, you say how many: the
fd array gets passed into the callback.
This is also clearer for the users.
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
34c96399b0
channel: Passing gossipd client fd to channeld
2017-03-13 11:26:48 +01:00
Rusty Russell
da5c7e0a08
daemon/subdaemon: remove in favor of daemon/subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-11 07:19:41 +10:30
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
1781983be1
lightningd/opening: convert to subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-11 07:19:41 +10:30
Rusty Russell
e467afce06
lightningd/handshake: convert to subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-11 07:19:41 +10:30
Rusty Russell
5dc8cb12be
lightningd/gossip: convert to subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-11 07:19:40 +10:30
Rusty Russell
7f406ea80d
lightningd/hsm: convert to subd.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-11 07:19:32 +10:30
Rusty Russell
f0c838d250
lightningd: more updates to match latest BOLT2/3.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 16:22:34 +10:30
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>
2017-03-07 12:01:43 +10:30
Rusty Russell
c0b4bb1387
daemon/lightningd: store more state in peer.
...
We need to keep more information about the peer for handing off to the
channel daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:39:53 +10:30
Rusty Russell
5a73380e64
lightningd/subdaemon: keep peer pointer for one-per-peer daemons.
...
This is really useful to map daemon back to peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:39:03 +10:30
Rusty Russell
5f07e8405a
lightningd/opening: fix theoretical race.
...
We should start watching for the transaction before we send the
signature; we might miss it otherwise. In practice, we only see
transactions as they enter a block, so it won't happen, but be
thorough.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:35:03 +10:30
Rusty Russell
9eeb76e185
lightningd: broadcast transaction once we're told to.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:33:55 +10:30
Rusty Russell
b937793555
lightningd/funding_tx: output number is 16 bit.
...
It's actually always 0 or 1, but the spec wants 16 bits, so use that here.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:33:24 +10:30
Rusty Russell
ccff3ac437
lightningd/funding_tx: fill in scriptsigs for p2sh UTXOs.
...
This is a bit tricky: for our signing code, we don't want scriptsigs,
but to calculate the txid, we need them. For most transactions in lightning,
they're pure segwit so it doesn't matter, but funding transactions can
have P2SH-wrapped P2WPKH inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:31:55 +10:30
Rusty Russell
afc31cd68f
lightningd: export bitcoin_pubkey as bip32_pubkey.
...
We're going to need it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:29:16 +10:30
Rusty Russell
d77e7963f9
funding_tx: permute inputs, don't re-calculate fees
...
built_utxos needs to calculate fees for figuring out how many utxos to
use, so fix that logic and rely on it.
We make build_utxos return a pointer array, so funding_tx can simply hand
that to permute_inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-07 11:28:09 +10:30
Rusty Russell
5dc0402a44
Update to lightning-rfc to dc0b529161561c6be3ff53c5f8574b23c3305a04
...
Only minor changes, but I add some more spec text to
lightningd/test/run-commit_tx.c to be sure to catch if it changes
again.
One reference isn't upstream yet, so had to be commented out.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-03-02 22:51:49 +10:30
Rusty Russell
fd258fe495
lightningd: wire up opening daemon.
...
Now we can actually open a channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-24 16:22:56 +10:30
Rusty Russell
c8df820e58
lightning/peer_control: set logging level for peers to match global.
...
That way it's controlled by --log-level=
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-24 16:22:56 +10:30
Rusty Russell
90737371d0
lightningd/cryptomsg: split raw crypto_state vs peer_crypto_state
...
Raw crypto_state is what we send across the wire: the peer one is for
use in async crypto io routines (peer_read_message/peer_write_message).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-24 16:22:56 +10:30
Rusty Russell
ac1890136c
hsm: rename the hsmctl_hsmfd_ecdh_response to hsmctl_hsmfd_fd_response
...
We want to use it for other HSM fd requests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:29 +10:30
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>
2017-02-21 15:15:19 +10:30
Rusty Russell
a600b1a30f
handshake: hand in client fd on exec instead of gratuitous fd passing.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
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>
2017-01-10 15:38:34 +10:30
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>
2017-01-10 15:38:33 +10:30
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>
2017-01-10 15:38:33 +10:30
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
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