Commit Graph

1796 Commits

Author SHA1 Message Date
Rusty Russell 599ec5efbe gossipd: allow an array of excluded channels for getroute_request.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 8738940a8f listpeers: show channel direction for each outgoing channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell be64dd84ca waitsendpay: indicate which channel direction the error was.
You can figure this yourself by knowing the route, but it's better to report
it directly here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 2a8a8c64e9 invoice: add DEVELOPER-only optional dev-routes param.
This lets us test explicit routes which are more complex than the ones
we currently generate.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 1567238dd9 invoice: option to expose/not-expose private channels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell f321b1d35f getroute: remove seed arg, document fromid, make default fuzzpercent match docs.
seed isn't very useful at this level: I've left it in routing.c
because it might be useful for detailed testing.  Pretty sure it's unused,
so I simply removed it.

The fuzzpercent is documented to default at 5%, but actually was 75%.
Fix that too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell e65b680807 json: move bitcoin/lightning specific helpers into common/json_helpers.
We don't need them in common/json, since lightning-cli doesn't need these,
but plugins want them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell ea7e13b5a7 lightningd: fix leak when next peer is unknown.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 26dda57cc0 utils: make tal_arr_expand safer.
Christian and I both unwittingly used it in form:

	*tal_arr_expand(&x) = tal(x, ...)

Since '=' isn't a sequence point, the compiler can (and does!) cache
the value of x, handing it to tal *after* tal_arr_expand() moves it
due to tal_resize().

The new version is somewhat less convenient to use, but doesn't have
this problem, since the assignment is always evaluated after the
resize.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 12:01:38 +01:00
Rusty Russell 61420bf79b configure: (mostly) revert b7a56f0531
Plugins are a first-class citizen again.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-15 02:52:13 +00:00
Rusty Russell c3e96e058e bolt: Updated the BOLT specification to unify UNKNOWN_PAYMENT_HASH & INCORRECT_PAYMENT_AMOUNT
This is based on Christian's change, but removes all trace of the old codes.

I've proposed another spec change which removes this code altogether:
	https://github.com/lightningnetwork/lightning-rfc/pull/544

Signed-off-by: Christian Decker <decker.christian@gmail.com>
Reported-by: Rusty Russell <@rustyrussell>
2019-01-15 02:19:56 +00:00
Christian Decker 65054ae72e bolt: Updated the BOLT specification to a07dc3df3b4611989e3359f28f96c574f7822850
This is mainly just copying over the copy-editing from the
lightning-rfc repository.

[ Split to just perform changes prior to the UNKNOWN_PAYMENT_HASH change --RR ]

Signed-off-by: Christian Decker <decker.christian@gmail.com>
Reported-by: Rusty Russell <@rustyrussell>
2019-01-15 02:19:56 +00:00
Christian Decker b7a56f0531 plugin: Gate the plugin subsystem with the --enable-plugins configure flag
Since we are planning to release a bug fix release, and the plugin
subsystem is not yet complete, it is better to make plugin support
opt-in while we continue testing.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-10 17:15:10 -08:00
Rusty Russell 109c6eb3a3 channeld: include proper sha value in BADONION errors.
Fortunately, we can calculate the sha256 ourselves, so the
outgoing channeld doesn't need to tell us.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-08 19:20:28 +01:00
Rusty Russell 8f8783c0e3 pay: correctly blame the *next* node on BADONION error.
The node which sent the error is doing so because the following
one sent WIRE_UPDATE_FAIL_MALFORMED_HTLC.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-08 19:20:28 +01:00
Rusty Russell 554c3ec7e5 channeld: process onion packet ourselves.
This covers all the cases where an onion can be malformed; this means
we know in advance that it's bad.  That allows us to distinguish two
cases: where lightningd rejects the onion as bad, and where the next
peer rejects the next onion as bad.  Both of those (will) set failcode
to one of the BADONION values.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-08 19:20:28 +01:00
Rusty Russell 59febcb968 sphinx: explain why parse_onionpacket fails.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-08 19:20:28 +01:00
Rusty Russell 7e01efbd1f lightningd: clean up htlc_in->shared_secret to be optional.
We currently use 'all-zeroes' as 'unknown', but NULL is more natural
even if we have to send it as all-zeroes over the wire due to
expressiveness limitations in our generation code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-08 19:20:28 +01:00
lisa neigut efa38875b2 listpeers: include `private` field in `channels` output
Reveal channel's 'privacy' in `listpeers` output

Suggested-By: @shesek
2019-01-08 02:21:32 +00:00
Christian Decker 36e060aa60 init: Reap tested subdaemon processes to release OS resources
The processes that were used to test the subdaemon versions were not
reaped correctly keeping some resources bound.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-01-08 00:16:50 +00:00
Rusty Russell 3006844f92 lightningd: don't allow zero cltv HTLCs. (#2214)
Fixes: #2077
Fixes: #2213
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-04 01:08:35 +01:00
Rusty Russell e6c68b606d lightningd: add comment on why we have "useless" initialization.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-01-02 01:29:14 +00:00
William Casarin 0fa209c64d lightningd: fix compile error in peer_control
Error on gcc 7.3.0:

lightningd/peer_control.c: In function ‘json_close’:
lightningd/peer_control.c:955:3: error: ‘channel’ may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
   channel_set_state(channel,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~
       channel->state, CHANNELD_SHUTTING_DOWN);

Signed-off-by: William Casarin <jb55@jb55.com>
2019-01-02 01:29:14 +00:00
William Casarin 4d9190aa47 lightningd: fix compile error on unused variable
Switch to write_all instead

Error on gcc 7.3.0:

lightningd/lightningd.c: In function ‘on_sigterm’:
lightningd/lightningd.c:587:9: error: ignoring return value of ‘write’, declared
  with attribute warn_unused_result [-Werror=unused-result]
         write(STDERR_FILENO, msg, strlen(msg));
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: William Casarin <jb55@jb55.com>
2019-01-02 01:29:14 +00:00
Christian Decker 26f17e87a3 plugin: Add connect and disconnect notifications
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 5813567856 plugin: Dispatch notifications to subscribed plugins
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 37b2f907d4 plugin: Make plugin_send a more generic function
This used to be request-specific, but we now want to send
notifications and requests. As a drive-by we also clarify the
ownership of the json_stream instance that is being sent.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker dd2696a88b json: Add function to duplicate a json_stream
Will be used in the next commit to fan out notifications to multiple
subscribing plugins. We can't just use `tal_dup` from outside since
the definition is hidden outside the compilation unit.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 7355e62964 plugin: Add subscriptions when processing the plugin manifest
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
Christian Decker 9ad2f57e46 jsonrpc: Create a struct for notifications that we send
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-30 14:36:02 +01:00
lisa neigut b2ee53fd89 lightning-cli: add jsonrpc version to cmd json packet
Plugins expect jsonrpc commands to include the version, so let's include
it.
2018-12-22 16:30:06 +01:00
Mark Beckwith bcde9675e4 Handle SIGINT and SIGTERM for PID 1
Signed-off-by: Mark Beckwith <wythe@intrig.com>
2018-12-22 15:46:11 +01:00
Richard Bondi 9ca07728ad fix crash on check with plugin command 2018-12-22 14:20:15 +01:00
Rusty Russell add822a072 jsonrpc: don't be coy with details for command_its_complicated().
Obviously the Facebook relationship status joke was a bit subtle, but I've
continued it anyway because I'm especially susceptible to Dad jokes.

Suggested-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 26484b8aa5 memdump: rearrange order to avoid command_its_complicated().
memdump iterates through the various daemons asking them to check for
leaks.

We currently call openingds (there might be none), channelds (there
might be none), then hsmd synchronously (the other daemons).  If hsmd
reports a leak, we'll fail the dev-memleak command immediately.

Change the order to call connectd first; that's always async, so we
can happily mark the command still pending.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell e5c61fcb0c jsonrpc: plumb through dispatch result to avoid command_its_complicated().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 819078fe18 param: make command_fail/command_success WARN_UNUSED_RESULT.
This causes a compiler warning if we don't do something with the
result (hopefully return immediately!).

We use was_pending() to ignore the result in the case where we
complete a command in a callback (thus really do want to ignore
the result).

This actually fixes one bug: we didn't return after command_fail
in json_getroute with a bad seed value.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 68bb36b210 json-rpc: make commands return 'struct command_result *'.
Usually, this means they return 'command_param_failed()' if param()
fails, and changing 'command_success(); return;' to 'return
command_success()'.

Occasionally, it's more complex: there's a command_its_complicated()
for the case where we can't exactly determine what the status is,
but it should be considered a last resort.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 1ede7bc55b wallet_tx: make wtx_select_utxos return command_result.
It can fail the command, so it should return accordingly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell bc41ab2cb9 param: make json_tok_ handlers all return command_result, rename to param_
Handers of a specific form are both designed to be used as callbacks
for param(), and also dispose of the command if something goes wrong.

Make them return the 'struct command_result *' from command_failed(),
or NULL.  

Renaming them just makes sense: json_tok_XXX is used for non-command-freeing
parsers too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 93bf7c4839 param: make command sinks (fail/success) return a special type.
These routines free the 'struct command': a common coding error is not
to return immediately.

To catch this, we make them return a non-NULL 'struct command_result
*', and we're going to make the command handlers return the same (to
encourage 'return command_fail(...)'-style usage).

We also provide two sources for external use:
1. command_param_failed() when param() fails.
2. command_its_complicated() for some complex cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 12731c4a60 json_tok_len, json_tok_contents: rename to json_tok_full_len and json_tok_full
These are only supposed to be used when you want the token contents including
surrounding "".  We should use this when reporting errors, but usually
we just want to access the tok members directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 22ca896b54 json: add and use a json_strdup() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 3773251d4e jsonrpc: mark all JSONRPC connections as notleak.
Live connections can confuse us; this happens a lot more when we're
running complex plugins, since they make JSONRPC connections while we're
running our tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell db58d089e2 jsonrpc: use tal_arr_remove().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Rusty Russell 0a3b38fb20 jsonrpc: fix leak.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-20 03:22:32 +00:00
Christian Decker 4c9e07eca5 opts: Fix crossed wires in autocleaninvoice options
Reported-by: Nadav Ivgi <@shesek>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-19 15:04:33 +01:00
Rusty Russell c4ffec57b4 log: play back prior log entries when opening log.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-18 12:16:14 +01:00
Rusty Russell a3a5ba5f21 options: set log-level and log-prefix early.
Otherwise we potentially miss debug-level logs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-12-18 12:16:14 +01:00
Christian Decker 2c53572798 plugin: Add missing context to tal_fmt call on error message
Seems the context parameter got lost somewhere.

Reported-by: Ulmo <@ulmo>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-12-16 04:40:06 +00:00