Commit Graph

1369 Commits

Author SHA1 Message Date
Christian Decker bf81f7af15 Merge pull request #93 from ElementsProject/fix-87-open-too-small-for-fee
json_connect: don't try to double-fail if amount insufficient.
2016-11-16 13:04:26 +01:00
Christian Decker 1126499a10 Merge pull request #95 from ElementsProject/fix-91-32-bit
Fix #91 32 bit build
2016-11-16 13:03:56 +01:00
Rusty Russell 41299b679c sphinx: process_onionpacket doesn't modify the packet.
Make it const.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 14:22:14 +10:30
Rusty Russell 423572190b sphinx: use assignment instead of memcpy where possible.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 14:22:08 +10:30
Rusty Russell 6f9dedbe7f sphinx: remove redundant initialization
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 14:04:50 +10:30
Rusty Russell 8599d63256 sphinx: add brackets around constant definition
Always do this, otherwise "MACRO * foo" can have unexpected results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 14:02:56 +10:30
Rusty Russell 88837c20ca Makefile: pass CC through to libsecp256k1 build.
For CC="gcc -m32" in particular.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 13:59:20 +10:30
Rusty Russell 5465b61784 json: fix 32-bit build.
Assume we have strtoull everywhere (it's C99 and was common before).

Fixes: #91
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-16 13:34:56 +10:30
Christian Decker 686ff6edef irc: Switched to LFNet.org IRC server
This is a temporary fix until we finish #88.
2016-11-14 23:19:32 +01:00
Rusty Russell 94adbd241d json_connect: don't try to double-fail if amount insufficient.
Closes: #87
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-14 11:46:09 +10:30
Christian Decker 34b4134cb0 bugfix: Removed spurious printf in peer.c
I must've left that on in. Fixes #89
2016-11-14 00:29:01 +01:00
Christian Decker e5b44ff232 Merge pull request #85 from ElementsProject/whitespace
Whitespace
2016-11-11 16:40:23 +01:00
Christian Decker 2d6a98ee1f Merge pull request #45 from cdecker/travis-ci
Adding Travis-CI configuration
2016-11-11 16:38:08 +01:00
Christian Decker 9848b4ac3e travis-ci: Added travis-ci config
Added .travis.yml to get travis-ci to build and run tests for us.

In addition this fixes a flaky test due to the fact that when lightning2
connects to lightning3 and we tell lightning3 to restart, then
lightning2 will back-off its reconnection attempts, potentially causing
a timeout to trigger during tests. This was triggered by travis-ci
relatively consistently since the restart would take quite some
time. Now simply restarting them in reverse order and a small timeout
seems to fix this consistently.
2016-11-11 14:25:41 +01:00
Rusty Russell 0d7f6ce25b check-whitespace: add to check-source.
We don't check submodules (daemon/jsmn), or imported files (ccan/ secp256k1/)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:36:10 +10:30
Rusty Russell f5c00deec7 Remove trailing whitespace from source.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:32:04 +10:30
Rusty Russell 98910c03f2 check-source: add version to BOLTDIR.
This allows us to have different rfcs in different branches, which we're
going to need soon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:12:39 +10:30
Rusty Russell 716da21f85 chaintopology: reduce how far back we start on testnet.
When initially reading the blockchain, we start 100 back from the
current block, or at the first block with a funding transaction,
whichever is earlier.

This slows testing slightly, so use whatever the "forever" value is
(10 on testnet, still 100 on mainnet).

make check -j12 times:
	Before:	7m52.005s
	After:  6m31.896s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:53:48 +10:30
Rusty Russell ce96812ef0 test.sh: split into multiple scripts.
This significantly reduces re-testing of the same paths, and simplifies
the addition of new tests.

make check -j12 times:
	Before: 9m24.973s
	After:	7m52.005s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:44:49 +10:30
Rusty Russell fae7f68731 helpers.sh: make check_tx_spend able to check for a specific transaction.
It currently takes an unused "who to blame" argument, which doesn't
always make sense.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:34:35 +10:30
Rusty Russell c6a187a5d7 helpers.sh: set up funding in start_lightningd()
Every test wants this anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:33:35 +10:30
Rusty Russell 9e777ae922 test.sh: move core routines to scripts/helpers.sh
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:32:35 +10:30
Rusty Russell 973ef3c932 test.sh: move valgrind PREFIX setting to vars.sh
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:31:35 +10:30
Rusty Russell 700c536a27 Makefile: remove all the old Elements Alpha support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:30:35 +10:30
Rusty Russell bff81c0ecf lightningd: ignore SIGPIPE.
It can happen when a peer hangs up, but also a JSON connection.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:29:35 +10:30
Rusty Russell e7e7345596 peer: fix steal (penalty tx) generation code.
In particular, we got a segv because we were measuring the wrong
wscript, then we miswired the inputs.  It only worked because our
current steal tests don't have a to_us_idx output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:28:35 +10:30
Christian Decker b26afcb3df Merge pull request #83 from ElementsProject/fix-67-crash-on-forget
peer_disconnect: simply free if in STATE_INIT.
2016-11-10 13:57:35 +01:00
Rusty Russell 3372645d8e peer_disconnect: simply free if in STATE_INIT.
db_forget_peer() was harmless, but we haven't been entered into the
database yet anyway, and it asserted that we should have been STATE_CLOSED.

Closes: #67
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 11:21:16 +10:30
Rusty Russell c2d71497ff opt, utils: new arg for wrappers due to low-level tal change.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:56:38 +10:30
Rusty Russell 9708c7a019 timers: use time_mono, as that's what ccan/timers now wants.
Fixes: #58
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:56:15 +10:30
Rusty Russell 74d471d4e4 ccan: update.
This gives us a slew of -Wextra fixes (not all of them though!) but
we're actually doing it for the monotonic version of timers.

This breaks some stuff, so we fix that up next.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:55:15 +10:30
Rusty Russell 4bed6c8c67 controlled_time: remove
We don't need it for testing at the moment, and if we do it'll have
to change to relative anyway now we're going to use time_mono().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:54:15 +10:30
Rusty Russell c5de5d4c39 timeout: remove absolute timers.
We don't actually use them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:53:15 +10:30
Rusty Russell 3aca5c87e3 init: rebroadcast anchors on restart if we haven't seen them.
It's possible that we won't have sent the anchor, but state is
committed in db.  And our current philosophy is that we retransmit all
the txs dumbly, all the time.

Our --restart --timeout-anchor test trigger this case, too, so
re-enable that now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:52:15 +10:30
Rusty Russell 0f09605e17 test: restore anchor timeout tests.
Importantly, they're now entirely block driven.  We don't use
dev-setmocktime at all any more.

This also fixes a bug if we run the test twice against the same
bitcoind; we need to extract the time from the block header rather
than assuming bitcoind is on the current time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 17:50:54 +10:30
Rusty Russell 6f360422d4 chaintopology: restore anchor timeout.
Instead of using wall-clock time, we use blocks.  This is simpler and
better for database restores.  And both sides will time out.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 17:14:22 +10:30
Rusty Russell 1fe83f47a9 dev-broadcast: control whether we send out transactions.
Good for testing; we also flush broadcast when it's re-enabled.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 17:14:21 +10:30
Rusty Russell f715752e71 chaintopology: keep txs to send in a struct.
This allows us to add a new field for a callback at the end, but
more subtle, ensures broadcast in order (which simplifies testing).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 17:14:10 +10:30
Rusty Russell 56b0f03c5a peer: fix retransmission before open packet.
Re-enabling the next test revealed bugs: if we need to retransmit the
initial open_commit_sig packet, we currently tried to send it as an
UPDATE_COMMIT, which isn't allowed.  Fixing that revealed that if
we have to retransmit the initial open, we didn't do that either.

Thus the initial open should count towards the ack count, and we should
special case transmissions of 0 (pkt_open) and 1
(pkt_open_commit_sig).

We also save those early state changes to the database.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:28 +10:30
Rusty Russell 41f3f8e067 db: store anchor input.
If we die before we've established connection, we should remember how
we were going to fund it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:28 +10:30
Rusty Russell adae62e261 peer: determine fees earlier.
Sure, information might be out of date, but at least we can report an
error earlier.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:28 +10:30
Rusty Russell 9463e1b630 wallet: use pubkey as API, not pointer.
Much easier to save/restore to/from database in coming patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:28 +10:30
Rusty Russell 7f0a56f674 queue_pkt_open: take bool for API.
No need to leak protobuf enum outside.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:28 +10:30
Rusty Russell 536a48940e protocol: don't ever reply to PKT_ERR with PKT_ERR.
The simplest way is to always use peer_received_unexpected_pkt() which
sends the error packet, and ensure it doesn't do so in response to
pkt_err.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell d77d5edc07 Makefile: clean gen_ files and ccan/config in make clean.
Not on maintainer-clean; they don't need special tools.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell 49809785ca state.h state_types.h: move into daemon/
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell fd6c3ce5a3 names: move into daemon/
It was already only referred from that Makefile.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell ec072b5d68 gen_pkt_names, gen_state_names: move into daemon/
That's where they're used.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:27 +10:30
Rusty Russell c1e04eb43b state_input: remove unused enum.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:26 +10:30
Rusty Russell cf91409ff2 start_closing: always switch states inside transaction.
This means checks in multiple places, but ensures atomicity.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:26 +10:30