Rusty Russell
2346f6bf14
daemon: routefail command.
...
This should be renamed: it's actually any kind of after-the-fact failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:28 +10:30
Rusty Russell
1e82799852
daemon: fulfillhtlc command
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:28 +10:30
Rusty Russell
17359279b2
daemon: getpeers: list HTLCs.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:28 +10:30
Rusty Russell
e1f772a443
peer: implement committed_to_htlcs().
...
Simply count how many HTLCs are in our current funding state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:28 +10:30
Rusty Russell
9efdbbb21b
peer: use funding.h's struct channel_htlc.
...
Instead of our own fields for the current htlc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:27 +10:30
Rusty Russell
fc4c94cb06
daemon: simple close support for the case of one side closing transaction.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:27 +10:30
Rusty Russell
6bdaa5d1ca
daemon: newhtlc command.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:27 +10:30
Rusty Russell
645958920e
peer: make_commit_txs() helper.
...
We need to call it in several places, so unify it into a single function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:27 +10:30
Rusty Russell
f5538bd1d2
daemon: test scripts.
...
We comment out the peer_create_close_tx() abort for now, so we
can test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:27 +10:30
Rusty Russell
3c9fd4fbe6
daemon: code to open channel and watch anchor.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:45:05 +10:30
Rusty Russell
ecbe671688
peer: keep current commit txs, anchor state, channel funding and their sig.
...
This lets us implement accept_pkt_anchor().
Also had to predeclare sha256 in commit_tx.h, revealed by the new
includes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:44:27 +10:30
Rusty Russell
ae04116883
daemon: send open_pkt on initialization.
...
This gets us to the creation of the anchor transaction, where we stop.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:44:25 +10:30
Rusty Russell
abc002ff15
daemon: add state.c.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:44:13 +10:30
Rusty Russell
c51a8d804f
bitcoind: routine to send to a specific address.
...
We use this to create our anchor payment.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:49 +10:30
Rusty Russell
fc49e3fd74
daemon: rename 'state' to 'dstate' everywhere.
...
This is the daemon state, not the state machine state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:49 +10:30
Rusty Russell
b04392609a
daemon: encapsulate each side's state in a struct.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:49 +10:30
Rusty Russell
0376e08fea
daemon: peer needs to know who offered the anchor.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:49 +10:30
Rusty Russell
e9237f94b1
daemon/watch: API to watch various bitcoin transactions.
...
This uses the functions in bitcoind to provide callbacks when various
things happen.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:49 +10:30
Rusty Russell
bf3080ca09
secrets: handle per-peer secrets as well.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
08ccb4b6f0
getpeers: new command.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
d8959b3117
peer: make connect command an async command.
...
So it can return failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
366f8a5f3f
dns: add failure callback.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
d68ae0b612
jsonrpc: adapt it to be async.
...
This allows for JSON commands which aren't instantaneous.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
74f294e36c
daemon: encrypted communication (version 3)
...
After useful feedback from Anthony Towns and Mats Jerratsch (of
thunder.network fame), this is the third version of inter-node crypto.
1) First, each side sends a 33-byte session pubkey. This is a
bitcoin-style compressed EC key, unique for each session.
2) ECDH is used to derive a shared secret. From this we generate
the following transmission encoding parameters for each side:
Session AES-128 key: SHA256(shared-secret || my-sessionpubkey || 0)
Session HMAC key: SHA256(shared-secret || my-sessionpubkey || 1)
IV for AES: SHA256(shared-secret || my-sessionpubkey || 2)
3) All packets from then on are encrypted of form:
/* HMAC, covering totlen and data */
struct sha256 hmac;
/* Total data transmitted (including this). */
le64 totlen;
/* Encrypted contents, rounded up to 16 byte boundary. */
u8 data[];
4) The first packet is an Authenticate protobuf, containing this node's
pubkey, and a bitcoin-style EC signature of the other side's session
pubkey.
5) Unknown protobuf fields are handled in the protocol as follows
(including in the initial Authenticate packet):
1) Odd numbered fields are optional, and backwards compatible.
2) Even numbered fields are required; abort if you get one.
Currently both sides just send an error packet "hello" after the
handshake, and make sure they receive the same.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
2df28021ac
daemon: command to connect
...
Now we can connect two daemons to each other. Who both say Hello! and
close.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
e4224f72d4
daemon: netaddr
...
Structure for a net address. We can expand it later to cover exotic
address types (Tor?).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30
Rusty Russell
469401610f
daemon: socket code.
...
At the moment, if you connect it just says Hello! and closes the socket.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au >
2016-01-22 06:41:48 +10:30