Commit Graph

85 Commits

Author SHA1 Message Date
Rusty Russell 378dadc371 daemon: configuration directory (default ~/.lightning).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:48 +10:30
Rusty Russell 117cf6b02d daemon: add logging options.
Particularly logging to file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell 3e77c55a3b Makefile: add daemon source sanity checks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell dd35260ce8 daemon: first code.
Logging code based heavily on pettycoin's.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell caa27f1d93 names.h/names.c: wrappers to get name for states/inputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell e6dfff3ba8 licensing: Make license explicit.
Note that we're BSD-MIT but some of the ccan modules are different
licenses.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell 3a803eefbb bitcoin/tx: move bitcoin_tx_from_file() to test-cli, expose bitcoin_tx_from_hex()
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell 888389e625 ccan: update and add more.
We need the following additional modules for the daemon:
	io, time, timer, pipecmd

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell 906a5e4a32 Move pkt.c into test-cli.
We use cryptopkt for normal cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell a38d0c985e Makefile: more fascist warnings.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:37 +10:30
Rusty Russell 4163935bbb ccan: import time module.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell e97e8988f8 ccan: import isaac and dependencies.
We could probably just use Openssl's RAND_pseudo_bytes, but this gives
a nice interface to get a number between 1 and N.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell 4795a4d46f Makefile: sanity check source and makefile
This enforces the include order implemented by the previous patch, and
also make sure we haven't missed any headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:09 +10:30
Rusty Russell 4dafeba857 Makefile: depend on headers.
A halfway house between the horror of dynamic generation and the fail of
making everything depend on every header.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell ffe20fb2ae bitcoin: add OP_CHECKLOCKTIMEVERIFY support (BIP65)
No need to use noops now that BIP65 is active.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell aeedafc20f Switch to bitcoind by default.
I haven't implemented getting transactions from alphad (it needs the values
for the inputs, too), so switch to bitcoind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 4b02c6f558 locktime: nice abstractions for absolute and relative locktimes.
I got confused navigating these, especially since Alpha and Bitcoin
have diverged (BIP68 was proposed after Elements Alpha).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 45e0ab11ff Merge branch 'onion' 2016-01-22 06:35:11 +10:30
Rusty Russell 6b2d844f2a bitcoin: use ccan/mem instead of rolling own check_mem function.
Reported-by: John Newbery
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-26 21:06:23 +10:30
Anthony Towns b66852f1ab Makefile: add python onion tests 2015-10-06 23:49:52 +10:00
Anthony Towns 2042e1cdb7 onion_key: generate multiple keys at once 2015-10-06 23:49:52 +10:00
Rusty Russell ed46dd355d test_onion: split encode and decode, drive from cmdline.
This lets us test interaction with python code, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:53 +10:30
Rusty Russell 32a08ce6c5 test/onion_key: helper to generate deterministic key pairs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-06 12:03:09 +10:30
Rusty Russell f36ba8f8e1 Makefile: only erase protobuf and PDF files with maintainer-clean.
Reported-by: Anthony Towns
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell 81d35294f4 test/test_onion: demo program to show onion routing crypto.
We can make this more efficient, but this works for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:39:02 +09:30
Rusty Russell e7856e6e69 Update libsecp to git@github.com:bitcoin/secp256k1.git 52fd03f
We want the ecdh stuff for onion routing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:37:21 +09:30
Rusty Russell 17f457568a Makefile: generate libsecpk1 properly.
And clean it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:54 +09:30
Rusty Russell 454a3867e5 BIP68 support (nSequence enforcement)
The latest version of the BIP doesn't use inversion, but does use
bitshifts.

It also uncovered a bug in the test scripts: the block timestamps
creep forward when we generate large numbers of blocks (UpdateTime
insists it be > GetMedianTimePast() so it's valid).  We need to take
this into account when waiting for the median to move (reduced it from
60 to 30 seconds, since that adds about 14 seconds).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 10:54:11 +09:30
Rusty Russell 845d09ce68 check: simple Makefile target.
This makes it much easier to run all the test scripts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-29 17:02:02 +09:30
Rusty Russell 786bef9002 test/test_state_coverage: output dot format.
Good for documentation, plus impressive with all the error states...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 1556315f2e test_state_coverage: simple exhaustive coverage test for state machine.
Makes sure that we visit every state.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 5730b118f1 Some more ccan objs.
These are LGPL, but only used for tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 669479b671 gen_state_names.h: printable names for state_types enums.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell 8af4619406 Makefile: neaten
Reduces gratuitous patch conflicts in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:03:20 +09:30
Rusty Russell 1cb147c5b8 Version number, name, and build details.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 20:45:49 +09:30
Rusty Russell fcbba0280d test-cli/create-htlc-spend-tx: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 16:20:45 +09:30
Rusty Russell b5ff69e236 test-cli/update-channel-htlc-remove: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:15:01 +09:30
Rusty Russell 9b0ed51f2b test-cli/update-channel-htlc-complete: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:14:46 +09:30
Rusty Russell 5778b004dd test-cli/update-channel-htlc: new util.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:35 +09:30
Rusty Russell cf3433a0ad script: add OP_CHECKLOCKTIMEVERIFY.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell eac3af06f1 protocol: switch to single-funder anchor model.
Most complex change was gather_updates(), which handles all the "what
is the current state of the channel" logic for our dumb test utils.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-29 16:14:28 +09:30
Rusty Russell ee3af28980 test-cli/txid-of: simple helper to get txid.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-24 16:00:10 +09:30
Rusty Russell bde07aa6a7 Makefile: fix make clean, depend on bitcoin/ headers.
Didn't remove program object files, nor depend on all headers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-24 16:00:10 +09:30
Rusty Russell e4921b9bc6 Add documentation.
First up, a draft of a paper showing the differences between the LN draft
and this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-18 10:46:53 +09:30
Rusty Russell 8f64eb90af Switch over to CCAN's ripemd160.
Avoids handing naked u8 arrays around, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09 15:43:36 +09:30
Rusty Russell ec399e13a4 Makefile: update-ccan: new target.
Hacky, but syncs up ccan repository.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09 15:25:09 +09:30
Rusty Russell a663dc322c Remove signature leaking.
Alpha has segregated witnesses, so txid doesn't include the inputs.
That means we can create the first commit transaction before we sign
the anchor tx.

Bitcoin will need to do this differently: presumbly via new sipops
(a OP_CHECKSIG2VERIFY I imagine).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-03 14:00:54 +09:30
Rusty Russell f510e29e22 alpha: switch over to Elements Alpha by default.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-03 13:36:25 +09:30
Rusty Russell 62a002c860 script: make DER for signature encoding optional.
Alpha does the sane thing, places signatures raw.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30
Rusty Russell faae91f3fc Schnorr signature support.
This variation is used by alpha.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-01 16:27:52 +09:30