Commit Graph

5059 Commits

Author SHA1 Message Date
Rusty Russell a8e0e1709a channeld: fix fee calculation.
Funder can't spend the fee it needs to pay for the commitment transaction:
we were not converting to millisatoshis, however!

This breaks our routeboost test, which no longer has sufficient funds
to make payment.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-15 13:50:15 +01:00
Christian Decker c5d77c391a mocks: Drop invalid __sentinel__ value in generated mocks
This was introduced in ed268d6c, which broke the mocks
generation. This just filters out the invalid sentinel value.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-15 01:13:02 +00:00
Rusty Russell 31a375af53 lightningd: add runtime checking for all system-provided libs.
And I tested this by rolling my own libz; make indeed detects
the change and fixes it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-14 05:36:34 +00:00
Rusty Russell 2a90325e80 Makefile: add dependency on external header versions.
There were a few reports that upgrading Ubuntu recently caused issues
because we assert that the sqlite3 library version matches the one we
were built with. 'make' doesn't fix this, because it doesn't know the
external libraries have changed.

Fix this harder, with a helper which updates a file every binary depends
on, which gets relinked every time so we detect link changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-14 05:36:34 +00:00
Christian Decker a304db9be2 plugin: Handle log notifications from plugins
Logs are parsed and injected into the main daemon's logs.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-13 02:36:43 +00:00
Christian Decker dc25c43945 plugin: Split the parsing from the request handling in the plugin
This is a preparatory step for the next commit which adds notification
parsing as well.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-13 02:36:43 +00:00
Rusty Russell 9b9f9e4837 openingd: I can't believe we have even more typo fixes.
Reported-by: @wythe
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 2c3a53b88e openingd: even more typo fixes.
Reported-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 6a04d2ced3 openingd: comment typo fixes
Reported-by: Conor Scott @connscott
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 9d95eba6f2 openingd: document this in semi-literate style.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 338e4bab45 openingd: don't create trivial single-use is_all_channel_error function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 1259e10761 openingd: plug UTXO leak on failed opening.
This existed previously, but code perturbations seem to have revealed it
now: test_bad_opening reports a leak.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell b50c670f08 openingd: plug a funding msg leak.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell fc92ae515b openingd: don't send opening_funder_failed twice funder gets a general error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell bc4a62d349 openingd: subtract *both* reserves for our "effective capacity" calculation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Rusty Russell 6d717d73a4 openingd: call it first_per_commitment_point not next_per_commit, as per BOLT 2.
And group struct state fields together into some kind of logical order.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-12 11:42:24 -08:00
Mark Beckwith 1ae4cb1e20 param: add NULL sentinel attr
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-11 13:22:43 +01:00
Mark Beckwith a6ca57c79a doc: speling typo
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-11 13:22:43 +01:00
Mark Beckwith e5469c051f add wythe to codeowners
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-11 13:22:43 +01:00
Mark Beckwith 33359e4a82 doc: discourage use of json_tok_tok
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-11 13:22:43 +01:00
Rusty Russell 6aa511fa7a channeld: only enable option_data_loss_protect if EXPERIMENTAL_FEATURES.
We have an incompatibility with lnd it seems: I've lost channels on
reconnect with 'sync error'.  Since I never got this code to be reliable,
disable it for next release since I suspect it's our fault :(

And reenable the check which didn't work, for others to untangle.

I couldn't get option_data_loss_protect to be reliable, and I disabled
the check.  This was a mistake, I should have either spent even more
time trying to get to the bottom of this (especially, writing test
vectors for the spec and testing against other implementations).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
Rusty Russell 54623a9ff5 channeld: don't assume we offered option_data_loss_protect.
Check it was negotiated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
Rusty Russell 881c3893e6 channeld: get local peer features from lightningd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
Rusty Russell 981b000949 pytest: add trivial test to make sure reconnect works with no channel activity.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
Rusty Russell 19ecf8c6fb disconnect: add force option to disconnect even with a live channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
Rusty Russell 4b77d803ef configure: don't turn on EXPERIMENTAL_FEATURES just because DEVELOPER.
It's about to become even more bleeding-edge.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 22:25:32 +00:00
William Casarin db9e250df8 python: fix check-python errors in plugins
Fixes some lint errors with unused variables:

contrib/plugins/fail/failtimeout.py:48:5:
  F841 local variable 'e' is assigned to but never used

contrib/plugins/helloworld.py:86:5:
  F841 local variable 'e' is assigned to but never used

Signed-off-by: William Casarin <jb55@jb55.com>
2018-12-10 20:03:05 +01:00
Christian Decker 2834053457 plugin: Fix an issue with string IDs ending up quoted twice
The transparent passthrough that was recently introduced would end up
causing phantom quotes to appear around IDs when one of them was a
string. This happened for example when using `lightning-cli`, the code
would copy the quotes from the original request, insert our u64 ID,
and then re-add them on the way back as well.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-10 18:56:49 +00:00
Conor Scott 6470630db9 [doc] Add lightning-pay script as example for using pylightning library 2018-12-10 17:07:34 +01:00
Mark Beckwith d18d950a0a doc: check manpage
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-10 09:27:49 +01:00
Mark Beckwith 816840e9c4 rpc: check error now consistent with lightning-cli
We now return JSONRPC2_METHOD_NOT_FOUND if the command is not found,
just like lightning-cli does.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-10 09:27:49 +01:00
Rusty Russell 001e215064 check: rename returned result to match incoming, remove redundant 'parameters': 'OK'.
check will actually do an RPC error, so if it doesn't, you know it's OK.

This would, of course, be in our man page if we had one :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 09:27:49 +01:00
Rusty Russell 692d8e9685 json: simplify json_tok_copy.
Also fixes NULL case (we called tok_next() before NULL check).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 09:27:49 +01:00
Rusty Russell 0c5f8a3a15 pytest: add test for check command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-10 09:27:49 +01:00
Rusty Russell 1368ac7f3c lightningd: only initialize plugins once we're ready for them to connect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 09:15:48 +01:00
Rusty Russell d7e233e47d Move json and param core functionality into common, for plugins.
json_escaped.[ch], param.[ch] and jsonrpc_errors.h move from lightningd/
to common/.  Tests moved too.

We add a new 'common/json_tok.[ch]' for the common parameter parsing
routines which a plugin might want, taking them out of
lightningd/json.c (which now only contains the lightningd-specific
ones).

The rest is mainly fixing up includes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell c28cbf4a61 jsonrpc: remove ok pointer.
We can use the 'destructor-canary' trick instead.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 3f16c9a665 param: abstract 'struct command' so param doesn't need to access it.
I want to use param functions in plugins, and they don't have struct
command.

I had to use a special arg to param() for check to flag it as allowing
extra parameters, rather than adding a one-use accessor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 061938068f json: rename json_tok_bitcoin_amount.
json_tok* is used with 'struct command', so rename this to match the other
low-level json tok helpers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 86c517ac9b common/json: add context arg to json_parse_input.
All callers currently just hand the same arg twice, but plugins might
want this different.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell b3d30095cb lightningd/plugin: simply patch requests through and don't interpret them (much).
We simply look for the id token, and substitute it on the way in/out.
We also need to make sure output is '\n\n' terminated.

I started this because we weren't forwarding complex errors properly
(we treated them as a string), but it's also a huge simplification.

`struct plugin_rpc_request` is eliminated entirely: the information we need
is actually inside `struct command` already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 10260e2f24 lightningd: expose lower-level APIs.
We need these for literal copying of requests between plugin and client.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 8015e7dcfb jsonrpc: add the obj token to the callback.
This (will) avoid the plugin having to walk back from the params object
as it currently does.

No code changes; I removed UNUSED and UNNEEDED labels from the other
parameters though (as *every* json_rpc callback needs to call param()
these days, they're *always* used).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell f653723a85 plugin: log response given by plugin if it's invalid JSON.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell fbeef504f5 plugin: preserve stderr for plugins.
Now we've updated ccan/pipecmd, we can use pipecmd_preserve to
preserve stderr for plugins so we see their error spew.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 6da213be31 ccan: update to get updated pipecmd.
Note that this changes the order of arguments to pipecmd to match the
documentation, so we fix all the callers!

Also make configure re-run when configurator changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell 6323cc1898 plugins: allow --dev-debugger=<pluginname>.
This currently just invokes GDB, but we could generalize it (though
pdb doesn't allow attaching to a running process, other python
debuggers seem to).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Rusty Russell b484933b40 plugin: simplify plugin dir test a little.
Check if it's a normal file first, then check permissions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-10 00:00:50 +00:00
Franck Royer dc7b76e5e6 Update testing requirements and instructions 2018-12-09 16:26:30 +01:00
lisa neigut c497bad2e9 changelog + docs: Add entries for `announce` option on `fundchannel` 2018-12-08 15:15:55 -08:00