Commit Graph

84 Commits

Author SHA1 Message Date
Rusty Russell 95340aa03f bitcoind: use fundrawtransaction rather than sendtoaddress and -nowalletbroadcast
Luke-Jr points out this is the Right Way to do these things.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-11 16:40:53 +09:30
Rusty Russell 8104886503 Remove Alpha support.
I had already disabled it, and this clears the decks for Segregated Witness
which gives us everything we want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-04-11 16:32:43 +09:30
Rusty Russell 6410b0ac9c test: don't reply on specific bitcoin.conf settings.
I changed mine off regtest, and "make check" broke.  Fix that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-15 17:08:42 +10:30
Rusty Russell 09358498cd Remove test-cli
We're about to change the protocol again, and I don't want to do the
grunt work to update these.  They were useful for pre-build protocol
testing, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:37:15 +10:30
Rusty Russell e1eef5db65 close_tx: don't use protobufs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell 9aa0eac814 bitcoin: hand in a secp256k1_context to all routines.
We don't want to re-create them internally, ever.

The test-cli tools are patched to generate them all the time, but
they're not performance critical.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell 6d6abd57e7 funding: remove protobufs.
Use our own structure with the information we need about HTLCs,
and remove protobufs from the API.

The is_funder() helper goes inside gather_updates.h.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell d95d8a99c2 create_commit_tx: don't use protobufs in the API.
Hand anchor details and pubkeys directly; this is what we want
for the actual daemon which doesn't keep raw packets around.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell 3374ddd2a6 bitcoin: use a length arg to bitcoin_tx_from_hex
Our json parser doesn't use nul-terminated strings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell cf547d491b bitcoin: add len arg to pubkey conversion function.
Our json parser doesn't give nul-terminated strings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +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 2516a187bc test-cli: use OpenChannel__AnchorOffer instead of book for open_channel_pkt()
Clearer by being more explicit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell 93b5db89a8 signature: expose check_signed_hash()
This is wanted for crypto communications to check signature.

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 e272d759a5 Force -walletbroadcast=1 for tests.
Since lightningd wants walletbroadcast=0, override it on cmdline.

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 f710ba7c37 scripts/test.sh: boost CSV time to 512 seconds.
As per BIP68, that's the minimum.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 0ef2b9a32e test-cli: fix htlc balance on fulfill, and add assert that total is invariant.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:38:08 +10:30
Rusty Russell 57f0c3b38c test-cli/scripts: use setmocktime.
TIL about setmocktime.

Suggested-by: Gavin <gavinandresen@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-16 11:59:45 +10:30
Rusty Russell 0b50a7c9eb Fix test scripts for alpha.
Doesn't support getblockheader, also some occasional weirdness
with sequence enforcement for mempool?  Occasionally I could get
my spend tx into the mempool (doesn't happen with bitcoin).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-02 10:40:07 +09:30
Rusty Russell 242fa1b2dd pubkey: pubkey_eq helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-30 16:38:58 +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 31459d6cd2 protocol: rename update_complete_htlc to update_fulfill_htlc.
Complete was an overloaded word.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:51:18 +09:30
Rusty Russell f0cab4e74b gather_updates: fix rebase error.
Didn't update amount field in d00eeded9f.
Didn't compile test either :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-25 11:50:24 +09:30
Rusty Russell d00eeded9f protocol: split message update_remove_htlc into update_timedout_htlc and update_routefail_htlc, remove update_remove_htlc_delay.
For the moment, there's no way to remove an in-progress HTLC before
it's timed out.  The other side can remove it with a routefail, but
you can't push for it to be removed.

We may add that later, but by definition it's only a polited request, and
normally we should rely on timeouts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:02:49 +09:30
Rusty Russell 5bc22f0368 protocol: increase HTLC precision to 1/1000 satoshi.
This gets truncated for on-chain transactions (thus, rounding may
contribute to fees).

This also means we currently have an upper bound of 0.04 BTC per HTLC;
this can be increased later if required.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 15:00:47 +09:30
Rusty Russell 58a62e782d bitcoin/script: don't pass value for HTLC script.
We don't need it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 14:56:01 +09:30
Rusty Russell 186736050f test-cli: fix alpha case.
The output of grep confuses the scripts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-09-24 14:41:55 +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 3311580c62 scripts/test.sh: fix bitcoin case.
Now we use locktime, bitcoin needs delay too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:02:50 +09:30
Rusty Russell 0b33da08c1 scripts: auto-detect alpha vs bitcoin
A bit hacky, but saves editing two places.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:02:43 +09:30
Rusty Russell 6cea21750d HOWTO-USE.md: Just refer to test scripts.
This has fallen behind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-08 15:01:34 +09:30
Rusty Russell 3b214479ae test-cli/scripts/test.sh: basic HTLC spending test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 16:20:52 +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 bafc93886f test-cli/scripts/test.sh: basic HTLC creation test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:15:05 +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 106c447d17 gather_updates: handle HTLC updates.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:35 +09:30
Rusty Russell 769f9f1cc5 gather_updates: extract some update logic into update_rhash.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 14:13:29 +09:30
Rusty Russell a09c0a9fa7 funding: take into account HTLC add/remove.
Enhance funding_delta() to have an HTLC delta as well as an A->B delta.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 9a0163ec85 proto_to_locktime: abs and relative locktime handlers.
Our current proto_to_locktime actually handles relative locktimes,
and HTLCs use absolute.  Fix that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 7f21695a63 protocol: rename locktime fields to "delay" and "expiry"
For open transactions, locktime is a delay we require on the other
side's to-self commit transaction outputs to ensure we can cut them
off if necessary.

For HTLCs, it's an absolute expiry time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell a4dfe3ad72 channel_state: encapsulate funding of channel in one place.
This shows where funds are going at any time (fees vs to each side).
funding.c is mainly rewritten, and should be clearer now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 81bced330a protocol: move locktime into its own message type.
We're going to want this for HTLC times, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-07 12:45:30 +09:30
Rusty Russell 142e822342 test-cli/update-channel-signature: remove debugging message.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-05 16:54:53 +09:30
Rusty Russell a0fc4f8a79 Update .gitignore.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-03 16:29:35 +09:30
Rusty Russell b72ab56312 test-cli/open-anchor.c: add missing file.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-03 16:24:23 +09:30
Rusty Russell de051f0df9 protocol: add close fee logic.
The closer proposes the fee.  This is simple, at least.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-29 16:17:08 +09:30