Commit Graph

4129 Commits

Author SHA1 Message Date
Rusty Russell 14d6fc4a31 onchaind: use HSM for signing htlc transactions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 522b9dc96b hsmd: add routing to sign a local htlc transaction for onchaind.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 4098f47cfc onchaind: use HSM to sign "to-us" transactions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 437b65eba1 onchaind: clean up types for penalty transactions.
We can use pubkey_from_secret() to avoid the ugly sha->secret->privkey
conversion.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell dfaf74d972 hsmd: add routines to sign onchain transactions, part 1.
This handles the "to-us" transactions which return funds to the wallet.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 93b8217eb0 lightningd: get HSM to sign the last commitment tx for us.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 5d815238cf common/derive_basepoints: complete the set of single-value derive functions.
This helps make it explicit what we're deriving; these two were missing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell dd2773dfc0 common/keyset: use struct basepoints rather than open-coding fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 76cc428923 onchaind: make commit number a global.
The HSM will to need it to create signatures: we currently use it to create
privkeys then don't hand it around.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell f456fdfab1 lightningd: keep local_basepoints and local_funding_pubkey.
For now we can always regenerate them, but eventually they'll be given
to us by the HSM.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 289e39a0a3 bitcoin/pubkey: add pubkey_from_secret.
Really, we should have a 'struct point' since we don't use all points
as pubkeys.  But this is the minimal fix to avoid type cast nastiness.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 9dd0415a15 channeld: don't free msg in init.
It's allocated off tmpctx, and it's already freed if we loop in
peer_reconnect().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Rusty Russell 26deec0c82 channeld: remove duplicate call to channel_announcement_negotiate().
It's called in peer_reconnect, but the caller init_channel() calls it too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-24 00:40:01 +02:00
Mark Beckwith 05d4e8519c improved testing section
I went to the Nakamoto dinner last week and told some guys they
could get involved by improving our test coverage. So I updated
the docs for newbs like me. (I only recently discovered `PYTEST_PAR`).

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-23 02:21:36 +00:00
wintercooled e0a5c8144e Change withdrawal documentation failure outcome - referred to channel not transaction. (#1726)
Text related to channel funding not withdrawal.
2018-07-20 22:55:11 +02:00
Hiroki Gondo 552b00e2c1 lightningd: fix crash on rpc.invoice with clang
There is a type mismatch of variable argument.
2018-07-20 16:51:40 +02:00
Rusty Russell d84d358562 lightningd: fix crash on listpeers.
Fixes: #1680
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-20 03:17:25 +00:00
Mark Beckwith f850849486 Modern param style for all remaining files
Removed `json_get_params`.

Also added json_tok_percent and json_tok_newaddr. Probably should
have been a separate PR but it was so easy.

[ Squashed comment update for gcc workaround --RR ]
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-20 01:14:02 +00:00
Mark Beckwith 61ad8684a6 Added recently created unit tests to .gitignore
run-param and run-derive_basepoints

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-19 05:49:43 +00:00
Rusty Russell 7986af1b1e pytest: only_one() helper to catch if RPC returns more elements than we expect
I saw an error in test_gossip_weirdalias in Travis, where listnodes(nodeid)
returned *BOTH* nodes; it happened to fail because [0] was the wrong one, but
it would have passed if the order had been different.

This helper asserts that we really do only have one element, and should
catch such bugs faster.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-18 15:11:05 +02:00
Mark Beckwith b876c601a6 Modern param style for chaintopology.c, ...
connect_control.c, dev_ping.c, gossip_control.c, invoice.c.

This converts about 50% of all calls of `json_get_params` to `param`.

After trying (and failing) to squash and rebase #1682 I just made a new branch
from a patch file and closed #1682.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-17 14:33:14 +02:00
Rusty Russell 232b330284 tools/generate-wire.py: simple scheme to autoindent.
I verified that the generated files don't change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell 6758062a56 tools/generate-wire.py: remove ugly blank lines after for loops
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell ab28972aee tools/generate-wire.py: style cleanups.
Suggested-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell 28c3706f87 hsmd: fix missing status messages.
I crashed the HSMD, and it gave no output at all.  That's because we
were only reading the status fd when we were waiting for a reply.

Fix this by using a separate request fd and status fd, which also means
that hsm_sync_read() is no longer required.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell d4300e0ce8 hsm: create both channel_announcement signatures.
We already know the id, so that's redundant.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell ff6a6f8deb lightningd: create hsm_get_client_fd() helper.
We're going to use this more when we hand hsm fds to openingd,
onchaind and closingd.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell f9e5dc7ee8 hsmd: take dbid for client.
We need this later, to generate its seed.  When we switch to lnd's key system,
we'll only need this, and not peerid.

Note also that the peerid is not just for messages any more, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell 64008e275a common/derive_basepoints: add routines to get a specific secret.
Often we only need a single secret, so it's clearer to have routines
to do just that.  When we change to the lnd key scheme, there will be
no benefit in calculating them all together.

This also adds a test!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell b2b85100d7 common/derive_basepoints: add routines for marshal/unmarshal.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell ad9dbaaa3f openingd: rename confusing 'our_commit' and 'their_commit'.
We use 'our_commit' for the commit we sign (ie. the remote commitment tx),
and vice versa.  Use local/remote nomenclature.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell e217bc1220 per-commit-secret is a struct secret, not a sha256.
Well, it's generated by shachain, so technically it is a sha256, but
that's an internal detail.  It's a secret.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell 6c98457ef2 per-peer seed is a 'struct secret' not a 'struct privkey'.
They're both 32 bytes, but it's not a privkey at all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell 019ba86b91 gossipd: use optional fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Rusty Russell ac4c6b1a82 tools/generate-wire.py: support for optional fields, with ? before typename.
We already work around this by using an array with a 0/1 length convention,
but better to be explicit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-17 12:32:00 +02:00
Hiroki Gondo 070aa08709 fix: compile error with clang 2018-07-17 05:08:29 +00:00
Rusty Russell edf043c89b pytest: make utils.py read config.vars.
I could not figure out why test_announce_address suddenly stopped working:
I had previously been using DEVELOPER=1 on the cmdline for historical
reasons when testing locally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-16 23:16:34 +02:00
Rusty Russell a37e692af6 pytest: mark test_reconnect_normal flaky for now.
The bad gossip order bug is going to take a while to fix.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-16 22:48:41 +02:00
Mark Beckwith 19a0b78fec param: renamed files
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-16 03:51:21 +00:00
Christian Decker 356dcbba97 pylightning: Don't attempt to deserialize after every read
We make use of the structure of the final read to decide when to deserialize.
2018-07-16 00:24:04 +00:00
Bertrand Marlier 760b053d7b pylightning: fix incorrect description for disconnect() method 2018-07-15 18:40:48 +02:00
SimonVrouwe f2ffb6d03e improves exponential smoothing of feerate estimates (#1699)
- fixes problem with polling interval > 150 * 0.9
- fixes log message 'feerate hit floor' at every feerate change
- smoothed fee now reaches 90% of (exp weighted) fee estimates polled in last
120s, independent of polling interval
- only apply smoothing when effect > 10 percent so it doesn't correct forever
- fix indentation
2018-07-15 18:30:43 +02:00
Rusty Russell e0c21debc2 pytest: fix sleep(1) in test_channel_persistence.
It's obviously not enough under load, as Travis demonstrates.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-15 17:37:29 +02:00
Rusty Russell b1182702ae pytest: increase timeout for test_payment_failed_persistence
This happened under travis.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-15 17:37:29 +02:00
arowser 97118c558e add --conf parameter 2018-07-15 09:45:55 +00:00
Mark Beckwith cf12130627 params: shortened names
This is a cosmetic change only. No functional changes.

I shortened the names of macros and changed param_parse() to param().

Also went through params.h with a fine-toothed comb and updated the comments
to reflect the current API.

I wanted to change the files:

	params.c -> param.c
	params.h -> param.h
	run-params.c -> run->param.c

but that confused `git diff` for params.h so its best left for another PR.

I'm keeping #1682 updated locally with all these changes.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-13 23:44:50 +00:00
Mark Beckwith 891dee739d params: Fix arg size
Fixes #1668

Reported-by: @jsarenik

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-13 11:30:52 +00:00
Mark Beckwith 7ce19b0bc8 Improved comment.
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-07-13 11:21:39 +00:00
Rusty Russell cf86c74870 params: add helper to provide default initialization.
@wythe points out that many cases want a default value, not NULL.
Nicer to do it in the param_parse() call.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-13 11:21:39 +00:00
gallizoltan 1220a4eb1d pylightning: add missing arguments to getroute 2018-07-13 13:12:49 +02:00