Commit Graph

5019 Commits

Author SHA1 Message Date
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
lisa neigut a39c97c960 channeld: support private channel creation, fixes #2125
Adds a new 'announce' field for `fundchannel`, which if false
won't broadcast a `channel_announcement`.
2018-12-08 15:15:55 -08:00
lisa neigut eab992cecd py-tests: rename 'announce' to 'wait_for_announce'
Better description of what the option actually does -- if true
waits for the announcement messages to be generated and exchanged.
2018-12-08 15:15:55 -08:00
Rene Pickhardt c420f04d66 added more hints what to consider when loading several plugins
now the documentation also explains via command line example how to load several plugins
2018-12-08 09:51:59 +01:00
Rene Pickhardt f8d630a30c emphasized that a plugin needs to be executable
cost me a couple of minutes.
2018-12-08 09:51:59 +01:00
Michael Hawkins 1c3b8c8ec5 Created listpeers asciidoc, generated manpage using a2x and updated Makefile 2018-12-08 00:28:56 +00:00
Christian Decker be7674ed6c plugin: Added .params.configuration to init call
This tells the plugin both the `lightning-dir` as well as the
`rpc-filename` to use to talk to `lightningd`. Prior to this they'd
had to guess.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 17:17:53 +01:00
Christian Decker 5b6bb7c571 pylightning: Bump version number to 0.0.6 to make Pypi work again
Fixes #2135

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Christian Decker bd6e3bfe6a pylightning: Add a compatibility mode for pre-\n\n versions
We inadvertently broke the compatibility between the python library
and the binary when switching to \n\n-delimiters. This reintroduces
the old inefficient parsing, and dynamically upgrades to the faster
version if it detects the \n\n-delimiter.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Christian Decker a50529bcb0 pylightning: Allow both kwargs as well as positional args
We don't allow a mix (just like JSON-RPC), but we can use either or
now.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-07 10:29:21 +01:00
Rusty Russell b7da41e674 bitcoin/signature: implement SIGHASH_SINGLE|SIGHASH_ANYONECANPAY for segwit.
option_simplified_commitment wants this for HTLC txs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell c5633ea2c5 hsmd: use the fixed sign_tx_input semantics to make our lives easier.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell dffe2f516a signature: wrap almost all signatures in struct bitcoin_signature.
This is prep work for when we sign htlc txs with
SIGHASH_SINGLE|SIGHASH_ANYONECANPAY.

We still deal with raw signatures for the htlc txs at the moment, since
we send them like that across the wire, and changing that was simply too
painful (for the moment?).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell bbc4a599dc bitcoin/script.h: assert the constants in the header are correct.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell 9257f652fd channeld: don't save commit_sigs in struct peer.
We only use them for re-transmitting the last commitment tx,
and the HSM signs them sync so it's straight-line code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell a83e45fec2 bitcoin/signature: create/check tx sigs without mangling the tx.
We currently make sure that all the bitcoin_tx input scripts are NULL
and set the input script of the input we're signing, so we can easily
reuse the tx hashing code for signature checks.  This means that we
sometimes jump through hoops to make sure input scripts are NULL, and
also means that the tx can't be const.

Put more logic inside bitcoin/tx so it can simply ignore things we
don't want to hash.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell d613b3fa9d connectd: simply use global features from common/features.
We currently hand the feature set from lightningd, but that's confusing
if they were ever different.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell be6322a2d3 features: add local_feature_negotiated / global_feature_negotiated helpers.
We currently generally assume the features we offer are fixed; this
makes the code clearer and handles where we offer features iff
EXPERIMENTAL_FEATURES=1

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell fab5027d64 configure: add --experimental-features flag (default: == DEVELOPER).
This will be used for option_simplified_commitment and other
still-being-specified options.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell 23540fe956 common: make funding_tx and withdraw_tx share UTXO code.
They both do the same thing: convert utxos into tx inputs.  Share code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell a046af4416 lightningd/test: move some tests to common/ and channeld/
These unit tests stayed under lightningd/ even though the units they test
are elsewhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Rusty Russell aee2197a66 jsonrpc: make sure even errors are valid json.
We often quote their msg in our reply; sanitize it!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-06 23:11:51 +01:00
Mark Beckwith 164c76454c test: add json_tok_remove unit tests
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-06 02:06:03 +00:00
Mark Beckwith 70707bf767 rpc: add check command
The check command allows us to check the parameters of a command
without running it. Example:

	lightning-cli check invoice 234 foo desc

We do this by removing the "command_to_check" parameter and then using the
remaining parameters as-is.

I chose the parameter name "command_to_check" instead of just "command" because
it must be unique to all other parameter names for all other commands. Why?
Because it may be ambiguous in the case of a json object, where the parameters are
not necessary ordered.  We don't know which one is the command to check and
which one is a parameter.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-06 02:06:03 +00:00
Mark Beckwith 542f529ed1 param: add support for unused parameters
We can now set a flag to have param() ignore unexpected parameters.
Normally unexpected parameters are considered errors.
Needed by the check command.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-06 02:06:03 +00:00
Mark Beckwith 7cd6d39276 json: add print, copy, and remove functions
Needed for check command.  I left the print function in since it was so
convenient for debugging purposes.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-06 02:06:03 +00:00
Christian Decker f5a3f1f0a2 plugin: Add a test for timeout and broken manifest
Both of these plugins will fail in interesting ways, and we should
still handle them correctly.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker bd6ce102e6 plugin: Better cleanup when a plugin fails
This used to be a use-after-free bug in which we'd free the plugin and
then still have two connections that expect to be able to operate on
the plugin. This now signals the connections to exit and cleans up
once they do.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker b23a33ec7a jsonrpc: Use tal_arr_remove instead of leaving NULL in the commands
Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker 230730eca4 plugin: Migrate request creation to json_stream
We can use the internal buffering of the json_stream instead of
manually building JSON-RPC calls. This makes it a lot easier to handle
these requests.

Notice that we do not flush concurrently and still buffer all the
things, but it avoids double-buffering things.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker dc4fb650dc plugin: Add a timeout to the `getmanifest` call
If the plugin fails to respond to we may end up hanging indefinitely,
so we limit the time we're willing to wait to 10 seconds.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker 9ce3e960ec common: Add tal_arr_remove helper
Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Christian Decker 906bfef4fd changelog: Add plugin JSON-RPC passthrough
Signed-off-by: Christian Decker <@cdecker>
2018-12-05 23:15:59 +00:00
Christian Decker 83ecb61890 plugin: Ignore directories in the plugin-directory
They pass the executable test, but aren't really executable.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-05 23:15:59 +00:00
Michael Hawkins 561a66354b Man page for lightning-disconnect created 2018-12-05 01:26:01 +00:00
Rusty Russell 111d6df442 plugins: make log prefix the basename.
It's not perfect if they have multiple with same name, but better than number.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00
Rusty Russell aa4284a35e docs: document plugin options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00
Rusty Russell eb03b33655 plugins: add and install built-in plugin dir, add clear and disable options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00
Rusty Russell ac5002a79e pytest: add hack to force options into a given order.
Needed for testing plugin options which are order-senditive.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00
Rusty Russell a4287f99fd lightningd: add --plugin-dir option to load directory full of plugins.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00
Rusty Russell 31830ea6bb doc: Use subsections for option types.
And drive-by fix "if it's seems" to "if it seems".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-05 01:22:55 +01:00