Rusty Russell
35ab923163
peer: fix dangling peer->current_htlc->htlc pointer.
It currently points into freed memory once we've make_commit_txs; we
don't currently dereference it after that, but I did in some test code
and got a surprise. Make a copy in all cases where we set it, so
there can't be lifetime problems.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
3fbee72f3a
daemon/test: make --verbose flag less verbose.
Just print out the commands we do, not -x which gives TMI.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
ae82c0a12c
daemon/test: Make --gdb1/--gdb2 actually work, clean up params.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
16a7e3dc97
daemon/test: always test with valgrind, don't print errors unless a problem.
Unfortunately this seems to require longer sleeps.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
b280cab6b0
Makefile: clean daemon files with make clean.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
c1d1b360bf
daemon: add memcheck() in various places where we expect things to be initialized.
This just causes valgrind to warn sooner.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
ab1176d218
jsonrpc: rename "id" to "peerid" everywhere.
To be distinct from HTLC ids.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
48a4ec88dd
daemon/test/test.sh: remove -x flag, add --verbose option.
--verbose also turns on grep outputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
9544306f5b
Merge pull request #19 from braydonf/doc/install
doc: add install notes
9 years ago
Braydon Fuller
e0c4d40899
doc: add install notes
9 years ago
Rusty Russell
6750794667
Use #if instead of #ifdef (we already use -Wundef).
This avoids embarassing typos in future.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
1e93da5513
Really enable checklocktimeverify support.
Next patch will make sure this never happens again.
Fixes : #18
Reported-by: Fabrice
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
329f4f7dc2
Correct the formatting of HACKING.md; add top-level files reference.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Denis Gorbachev
8f18ca977b
Minor fixes
9 years ago
Rusty Russell
d3455e7c22
Add brief HACKING.md, and update name.
Each release gets names by a new contributor: this one thanks to
Anthony Towns!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
862509637b
daemon: implement unilateral commit.
This is only for the simple case where there are no HTLCs.
We group the current commit information together in the struct;
this involves a trivial transform from peer->cur_commit_theirsig to
peer->cur_commit.theirsig.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
27eedc9f51
patch bitcoind_get_mediantime.patch
9 years ago
Rusty Russell
6afe3f718d
daemon: bitcoind callback gives the blockhash the tx was included in.
This is required for transactions which use OP_CSV to lock outputs for
a given amount of time: we need to know the mediantime of the block
they were included into.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
b70c18a40e
daemon: implement anchor watch timeout.
We abort when this happens, but still worth testing.
This involves a refactor so we can allocate watches off a specific context,
for easy freeing when they're no longer wanted.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
4e5ced4de2
daemon: don't crash on pkt_err
We're about to test it, for anchor timeout.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
168ed96b12
daemon: close command.
This performs a mutual close.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
45c5c83d6f
daemon: exit main loop to free dead peers.
When a peer is finally to be freed (ie. STATE_CLOSED), doing this
inside the state logic is a bit fraught. We're better off exiting the
io loop and freeing it there.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
f690be1e83
daemon: dev-crash command.
Causes us to dump in crash.log.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
212f8ee022
daemon: fail if we enter an error state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
b76858c1a1
daemon: implement HTLC expiry.
We do the simplest thing: a timer goes off, and we check all HTLCs for
one which has expired more than 30 seconds ago.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
1018823f97
daemon: HTLC expiry limits.
Don't accept an HTLC which is about to expire, nor one which will take
too long to expire.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
a3e3f83d9f
daemon: dev-mocktime command
Useful for precise timing control for testing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
f3c5aa7634
daemon: don't close conn until we've sent all the output packets.
Otherwise we won't finish the conversation. In fact, only the writer
side should ever close: we wake it if we want to close and it tests
peer->cond.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
8b666ea449
daemon: queue commands rather than executing them immediately.
When the only commands are via JSON, you might argue that we should
simply insist the user not operate on the same peer in parallel. That
would suck, and also we need to handle the case of a command from
a timer (eg. HTLC expiry!) or a bitcoin event.
So, we need a queue for commands, but also we need to do some of the
command checking just before the command runs: the HTLC we're dealing
with might have vanished for example.
The current command is wrapped in an anonymous "curr_cmd" struct
for extra clarity.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
Rusty Russell
86f4bd772c
daemon/test/test.sh: check_status() helper for HTLC status checks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
1e82799852
daemon: fulfillhtlc command
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
17359279b2
daemon: getpeers: list HTLCs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
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>
9 years ago
Rusty Russell
fc4c94cb06
daemon: simple close support for the case of one side closing transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
6ba5c3cc3b
timeout: oneshot timer support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
9f560a9494
daemon: --closing-fee
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
6bdaa5d1ca
daemon: newhtlc command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
Rusty Russell
5acb3c9848
daemon: dev-rhash command.
Useful for creating SHA256(r) from scripts.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
8f0e10309a
daemon: --bitcoind-poll=<seconds>
Speeds up testing significantly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
6443629f6a
daemon/test/test.sh: add --valgrind and --gdb options.
We add a second to the sleep, as valgrind can be a little slow.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
Rusty Russell
3c9fd4fbe6
daemon: code to open channel and watch anchor.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
Rusty Russell
871e4d5172
secrets: peer_sign_theircommit() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
Rusty Russell
90e381f750
bitcoind: try gettransaction as well as getrawtransaction.
Because with walletbroadcast=0, getrawtransaction doesn't see them.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago
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>
9 years ago
Rusty Russell
12b9d39b76
daemon: store revocation hashes in the peer_visible_state structure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
9 years ago