Commit Graph

1283 Commits

Author SHA1 Message Date
Rusty Russell 068cdc825f htlc_tx: fix fee for HTLC-timeout tx.
Reported-by: Fabrice Drouin <fabrice.drouin@acinq.fr>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell 726e7226c4 commit_tx: update HTLC-tx fees to match latest BOLT.
As per lightning-rfc BOLT #3 ec99f893f320e8c88f564c1c8566f3454f0f1f5f:
"fixed htlc weight calculation"

Reported-by: Fabrice Drouin <fabrice.drouin@acinq.fr>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell 35909ba94a cryptomsg: wording fix with update to latest BOLT.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell f7cc079221 test/run-commit_tx: Fix derivation of BOLT #3 test vectors.
We were using the remote per_commitment_point instead of the local
per_commitment_point to generate the remotekey for the local transaction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell 20a07d860a check-source: include tests, libdir.
And fix the resulting issues.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +10:30
Rusty Russell 7cee3b0f68 wire: sha256_double, privkey and u64/u32/bool array support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 15:15:28 +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 fd09345628 generate-wire: handle variable-size arrays of unknown types.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 14:59:14 +10:30
Christian Decker c15511cf39 routing: Actually return the port when parsing node_announcements
We parsed it, but did not pass it back out.
2017-02-18 13:09:08 +01:00
Christian Decker a6cf93782b gitignore: Ignoring some more test-binaries. 2017-02-09 11:08:32 +01:00
Christian Decker b5c2d7d47d pytest: Gossip subdaemon had a flaky test
Whenever we were checking for the status before the daemon was
initialized the test would fail. Now just waiting for the state
transition.
2017-02-08 16:59:57 +01:00
Christian Decker c7e6f197b0 pytest: Chaning startup sentinel for bitcoind.
By looking for 'Done loading' in the log output we should actually be
called after `SetRPCWarmupFinished` in bitcoind. Only then is it safe
to make RPC calls. This resulted in the test suite being a bit flaky.
2017-02-08 16:59:56 +01:00
Rusty Russell 66d122684d lightningd/test/run-commit_tx: Creation of BOLT 3 test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell 0fe53cc8e7 permute_tx: reintroduce permute map.
We used to have a permutation map; this reintroduces a variant which
uses the htlc pointers directly.

We need this because we have to send the htlc-tx signatures in output
order as part of the protocol: without two-stage HTLCs we only needed
to wire them up in the unilateral spend case so we simply brute-forced
the ordering.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell e11d9304ab lightningd/hbtlc_tx: creation of BOLT 3 htlc transactions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell 3e1ae177fb bitcoin/script: BOLT 3 htlc transaction support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell f9189254e4 lightningd/commit_tx: creation of BOLT 3 commitment transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell b290a96a4a lightningd: use daemon/htlc_state.c
We're about to need HTLC handling.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:22 +10:30
Rusty Russell 6f3803aae7 bitcoin/script: BOLT 3 commitment transaction support.
This is a step away from the previous more generic script types into
specific helpers for each transaction type we need.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell be46fdf254 lightningd/funding_tx.c: helper to create a funding transaction (with change).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell 1bb66cde2a bitcoin/scrpt: add vanilla p2pkh support.
We are about to use it for our funding tx change output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell 75c6dd1981 channel_config: convenient structure for handling open/accept config info.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell dc3b27e1d3 key_derive: key derivation from basepoints as specified in BOLT 3
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell e899c47260 bitcoin/base58: don't segv if key_to_base58 / key_from_base58 called first.
We need to initialize b58_sha256_impl here too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:21 +10:30
Rusty Russell 4ed259c46c gen_peer_wire_csv: update for latest spec.
We have a separate announcement_signatures message now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-07 12:14:14 +10:30
Christian Decker eb75ae55e4 cleanup: Removed broadcast_queue from dstate
This is a left-over from the gossip refactoring.
2017-02-03 13:50:39 +01:00
Christian Decker c2764c10c5 broadcast: Implement replacing messages in the broadcast queue
If type and tag match, then we replace any existing message in the
queue. This allows us to drop old announcements. Special care needs to
be taken so that dependent messages are not reordered, but for gossip
this is the case, since the `channel_announcement` cannot be updated.
2017-02-03 05:52:11 +10:30
Christian Decker 6e63429fab gossip: Cleanup queued_message
The list and timestamp are no longer used since we are using the
intmap based broadcast queue.
2017-02-03 05:52:11 +10:30
Christian Decker fb814a7a9e gossip: Adding announcement handling to the gossip subdaemon.
We now have all the pieces to wire in the handling functionality to
the new gossip subdaemon.
2017-02-03 05:52:11 +10:30
Christian Decker 9de880dce7 refactor: Move the gossip handlers to routing
Moving the common functionality out of p2p_announce, sharing it
between legacy and subdaemon architecture.
2017-02-03 05:52:11 +10:30
Christian Decker d966961fbe gossip: Refactoring the gossip handlers to use the routing_state 2017-02-03 05:52:11 +10:30
Christian Decker d200a16988 irc: Rename irc handlers to avoid name clash 2017-02-03 05:52:11 +10:30
Christian Decker 92bc0abdc3 refactor: Move JSONRPC methods to separate compilation unit
This allows us to not care too much about bringing JSON into the new
subdaemons.
2017-02-03 05:52:11 +10:30
Christian Decker 76e2c980e1 gossip: Moving to intmap-based broadcast for the legacy daemon
Moved the broadcast functionality to broadcast.[ch]. So far this
includes only the enqueuing side of broadcasts, the dequeuing and
actual push to the peer is daemon dependent. This also adds the
broadcast_state to the routing_state and the last broadcast index to
the peer for the legacy daemon.
2017-02-03 05:52:11 +10:30
Christian Decker 3aa45a6d0b refactor: Moving write_ip and read_ip into routing.h
Further reduction in things in p2p_message so we can deprecate it
later.
2017-02-03 05:52:11 +10:30
Christian Decker 2a7e757053 refactor: Moving functionality out of p2p_announce
Further decoupling the old daemons from the new daemons.
2017-02-03 05:52:11 +10:30
Christian Decker 2c06524165 refactor: Moving legacy sync method out of routing
This was the only time we actually reference non-routing structs in
routing, so moving this out should allow us to get it working in the
new subdaemons.
2017-02-03 05:52:11 +10:30
Christian Decker 5d10093da3 refactor: Moving the node_map definition into routing.h
This allows us to move some legacy functions closer to where they are
actually used, and not worry about them when including routing.h into
the new subdaemons. `struct peer` is the main culprit here.
2017-02-03 05:52:11 +10:30
Christian Decker 3cb576d69d refactor: Moving gossip/routing specific state into its own struct
This used to be part of `lightningd_state` which is being split up for
the various subdaemons. The main change is the addition of the `struct
routing_state` in `routing.h` and the addition of `rstate` in `struct
lightningd_state` for backwards compatibility.
2017-02-03 05:52:11 +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 13a30ff79c subdaemon: close unused fds when creating subdaemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell 2f9b04b0d9 subdaemon: start fds at 3 not 4.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell 940053d000 htlc: move enum side crom daemon/channel.h to daemon/htlc.h
lightningd wants htlcs, but not the old struct channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell 7d68554787 type_to_string: add secp256k1_ecdsa_signature.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell 25a37fafae type_to_string: add privkey.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell d97e3489a0 daemon/htlc_state: split off from daemon/htlc.
We want to use struct htlc inside lightningd, and we need the state
bits.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell c6997f15c7 bitcoin/preimage: struct preimage.
We had a hack for 'struct rval' in protobuf_convert.h; make an
explicit header and put it in bitcoin/preimage.h.  It's not really
bitcoin-specific, but it's better than having bitcoin/script depend on
an external header.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell 279f216208 gen_peer_wire_csv: update to latest spec.
In particular, 860990fa0afb55f839e882a5e9abe8abe6ccb981 reordered
channel_announcement and c93bf5cf8c48eab1b028e85214cb35feeeffcbb3
reordered the update_fail_malformed_htlc message.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell f9eea9041e handshake: update for BOLT 8 latest revision.
This now matches commit fc4846a27bf420c591ba0b024cc34972816913c7,
and fixes "make check-source".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30
Rusty Russell a02f1e10c4 make check: run all the tests.
We can't run them in parallel, but we can at least have 'make check'
run them all.

Developers should be running "make check-source && make check".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-02 14:48:00 +10:30