Commit Graph

2960 Commits

Author SHA1 Message Date
Christian Decker 3fdb055606 wallet: Make first_blocknum a field of wallet_channel
We were sideloading it, which is awkward, now it's a field that we can
actually use in the code.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-07 00:47:13 +00:00
Rusty Russell d77972e827 test_lightningd.py: test io logging and toggling with SIGUSR1
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 99e246becd channeld: rely on io_logging, not our own boutique logging.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell c01f3267d5 common: only log io if they set --debug-subdaemon-io=<daemon> or with SIGUSR1.
Otherwise we just log the type of msg.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell de56dc0ffc common: add logging for peer packets, with status_io.
We log the plaintext, not the encrypted ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell e2eb694619 Use common loglevel JSON parser.
This now means we can ask for IO logs for peers, too (that case was missing!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell b7acd93578 log: separate levels for IO directions, allow msg + io data.
We currently don't handle LOG_IO properly, and we turn it into a string
before handing it to the ->print function, which makes it ugly for
the case where we're using copy_to_parent_log, and also means in
that case we lose *what peer* the IO is coming from.

Now, we handle the io as a separate arg, which is much neater.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 4856ca5db0 json_log: move command to log.c, share code with listpeers log.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell c076534220 logv: preserve errno.
Logging often gets called in error paths, so this is just good hygiene.
Also, log_io does this already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 4130a47f5b hsm: clean up status usage.
We log at a higher level when we have problems, and also just fail if
master behaves, rather than complaining and hanging.

Closes: #335
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell ad401f3a1c hsm: give it its own log, so it has unique prefix.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 84bf60f934 status: add multiple levels of logging.
status_trace maps to status_debug.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell f66c8306f4 wallet: don't use non-common objects as if they were common.
If needed, they should be directly #included; otherwise the following
patches really mess things up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 736a80db08 ccan: update so ccan/io doesn't exit when we get signals.
In particular, we're going to capture SIGUSR1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Rusty Russell 00a874d4a4 channeld: handle signals during select().
We're about to add SIGUSR1, don't get upset if it happens.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-07 00:46:49 +00:00
Jon Griffiths 4b38696613 pull_length: Take structure size into account when checking max
When a serialized length refers to an array of structures, the trivial
DOS prevention can be out by a factor of sizeof(serialized struct). Use
the size of the serialized structure as a multiplier to prevent this.

Transaction inputs are the motivating example, where the check is out by
a factor of ~40.
2018-02-07 00:45:26 +00:00
ZmnSCPxj 8e9bb39179 channel: Plug minor leaks. 2018-02-06 17:05:53 +01:00
ZmnSCPxj d4478458dd pay: Change origin_index to erring_index, start with local node = 0. 2018-02-06 17:05:12 +01:00
ZmnSCPxj 711d8822b0 test_lightning: Update to new error message format. 2018-02-06 17:05:12 +01:00
ZmnSCPxj b7c9029fe3 doc: Update for new error codes of sendpay. 2018-02-06 17:05:12 +01:00
ZmnSCPxj a6c6b8d9d3 pay: Provide detailed errors on `sendpay` or `pay` failure.
Fixes: #866
2018-02-06 17:05:12 +01:00
ZmnSCPxj 452925c05a pay: Tweak interface of remote_routing_failure.
In preparation for a common interface to reporting routing failures
  to JSON-RPC interface.
2018-02-06 17:05:12 +01:00
ZmnSCPxj a1b9fa7538 pay: Add origin_index to struct routing_failure. 2018-02-06 17:05:12 +01:00
ZmnSCPxj 6d789282c9 jsonrpc_errors.h: Header for JSON-RPC errors. 2018-02-06 17:05:12 +01:00
Rusty Russell b3534462e0 test_lightningd.py: fix race in test_fee_limits.
Sometimes the super-low-fee commitment tx succeeds, and we see
that 'sendrawtx exit 0' instead of the one we're expecting.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-06 02:50:30 +00:00
Rusty Russell 07c275e436 test_lightningd: fix race in test_closing_different_fees
fundrawtransaction returns before the actual sendrawtx, so we can
end up mining blocks before it's sent, thus not having enough confirms.

We handle this correctly in fund_channel, but this test open-codes it
for speed with multiple peers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-06 02:50:30 +00:00
ZmnSCPxj dcafce81ad test_lightningd: Increase times in expiration waiting test.
Fixes: #916

Makes it less flaky, as, the increased times reduce the
relative delay in processing by slower machines.
2018-02-06 02:50:30 +00:00
Rusty Russell 37670c04e0 test_lightning.py: disable test which needs bitcoind 0.16 (for now!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-06 01:37:58 +00:00
Christian Decker b2cec18a81 contrib: Add the addrtype argument to newaddr
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-06 01:37:58 +00:00
William Casarin 3d27bbb47d test: test_bech32_funding
1. Test wallet funding to a bech32 p2wpkh address
2. Test channel opening with this address

Signed-off-by: William Casarin <jb55@jb55.com>
2018-02-06 01:37:58 +00:00
William Casarin 0e59e091e7 test: switch invoice tests to use proper bip173 name
Signed-off-by: William Casarin <jb55@jb55.com>
2018-02-06 01:37:58 +00:00
William Casarin b30fb952e6 chainparams: fix regtest bip173_name
regtest bech32 hrp is bcrt, not tb

Signed-off-by: William Casarin <jb55@jb55.com>
2018-02-06 01:37:58 +00:00
William Casarin 37ea24e9c9 newaddr: support bech32 p2wpkh funding addresses
* Add optional addresstype param to newaddr, which can be one of:

    - bech32
    - p2sh-segwit
    - nothing (defaults to p2sh-segwit)

The naming here mirrors bitcoind

* txfilter already looks for p2wpkh outputs, so we're covered there

Signed-off-by: William Casarin <jb55@jb55.com>
2018-02-06 01:37:58 +00:00
Christian Decker 4fd7e26bf7 wallet: Re-introduce change assertion for withdrawals
This was removed because withdraw-to-self results in more than the
change being sent to us.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-06 01:36:54 +00:00
Wladimir J. van der Laan b2abe0d250 gossipd: Move include of time.h to routing.h
Commit a57a2dcb86 introduced a time_t
in routing.h. So also move the time.h include to the header. This
fixes the build on FreeBSD.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
2018-02-06 01:36:16 +00:00
Wladimir J. van der Laan 1ef79854c3 lightningd: Don't crash when libunwind backtrace not available
libunwind does not accept a NULL parameter for the error callback. It
will simply call into the NULL pointer. So add an error callback.

This makes the crash output somewhat more sensible on FreeBSD, where
there is no libunwind stack trace available:

    2018-02-05T20:24:50.598Z lightningd(75556): error getting backtrace: no stack trace because unwind library not available (0)

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
2018-02-06 01:35:31 +00:00
Christian Decker 7dd19d5b93 gossipd: Cleanup and less verbose on deferred node_announcements
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker f6c9c4fc3a gossipd: Use channels map to lookup pending cannouncements
Iterating over lists is so 1980s

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker b09666c51c gossip: Remember the channel_update broadcast index
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 81551b2e60 pytest: Increate timeout when waiting for gossip
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 0790d9b52f gossip: Add a map for pending node_announcements
We were dropping these on the floor while checking for txout. So now
we add a map that holds announcements while we are checking.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 35b44d5294 gossip: Remember which broadcast index the node_announcement had
Avoids searching for it in the uintmap.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 24d52ec23a gossip: Only replace with newer updates while txout check is pending
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 739e78a8c7 gossip: Reduce verbosity
Now we only report serious failures, or messages that actually changed
the local view.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker fa069d7d97 gossip: Use the channels map to look up by scid
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker a88076b1b0 gossip: Adding locally added channels to channels map
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 26b5588656 gossip: Use replace_broadcast when enqueuing a channel_announcement
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 01b7e2a7c0 broadcast: Added option to replace a specific index
We are wasting way too much time looking for announcements and updates
in the broadcast. We can just hint where to find the message to be
evicted and safe the traversal.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker 60ab947a2f gossip: Add new channels to channels map
Adding channels that we are currently verifying to the map, and
skipping if we already have a channel at that position.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00
Christian Decker d7224e2178 gossip: Added short_channel_id_to_uint for uintmap index
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-05 18:28:39 +00:00