Commit Graph

7519 Commits

Author SHA1 Message Date
Michael Schmoock f2478e9160 doc: point out 8char visual tabs in STYLE.md
Changelog-None
2020-03-19 10:45:35 +01:00
Rusty Russell 24984ec680 common/sphinx: add realm flag so we can avoid legacy parsing.
For messages, we use the onion but payload lengths 0 and 1 aren't special.
Create a flag to disable that logic.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-17 18:47:52 +01:00
Rusty Russell b162a0e5e2 tests: note the private keys of our test nodes.
I needed them to debug the onion messages API, so might as well record them
somewhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-17 18:47:52 +01:00
Rusty Russell f541044e8f devtools/onion: change defile assocdata to empty.
This is in preparation for messages, which want this as their assocdata.

Plus, it's a bit cleaner rather than creating a tmp tal array.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-17 18:47:52 +01:00
Rusty Russell 43a46e252c devtools/onion: allow '-' input file so you can pipe from stdin.
This avoid the requirement to use a temporary file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-17 18:47:52 +01:00
Vasil Dimov 2b2ee87801 travis: do not cache ./external
Caching the `./external` directory means that any changes to
`external/Makefile` or any updates of the submodules in `./external/*`
would not be picked up and travis would run with old instances of those,
possibly "activating" such changes after weeks or months when the cache
is pruned eventually.

Changelog-None
2020-03-12 21:55:01 +01:00
Christian Decker 37105497f0 sphinx: Use fromwire_tal_arrn() to deserialize compressed onions
Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <@cdecker>
2020-03-12 10:25:01 +10:30
Christian Decker ef86ee0bae sphinx: Migrate sphinx compression to new interface
It also removes the duplicate compression code and serialization code.
2020-03-12 10:25:01 +10:30
Christian Decker 6dd14a2039 sphinx: Kill read_buffer with fire 🔥
Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <@cdecker>
2020-03-12 10:25:01 +10:30
Christian Decker e79cda8c9a sphinx: Treat compressed onions as a standalone struct
Expands the interface to play with onions a bit more. Potentially a bit
slower due to allocations, but that's a small price to pay. It also allows us
to avoid serializing a compressed onion to `u8*` if we process it right away.
2020-03-12 10:25:01 +10:30
Christian Decker fd37c5b672 sphinx: Expose the shared secret creation function 2020-03-12 10:25:01 +10:30
Christian Decker 49a3321d7e sphinx: Add functions to decompress
Also implements a way to decompress an onion using the devtools/onion tool

Changelog-Added: devtools: The `onion` tool can now generate, compress and decompress onions for rendez-vous routing
2020-03-12 10:25:01 +10:30
Christian Decker 4724d55e80 pytest: Add test for compressed onion
This one generates a compressed onion, decompresses it, and then proceeds with
normal processing.
2020-03-12 10:25:01 +10:30
Christian Decker 45400cf12a onion: Allow devtool/onion to generate rendezvous onions
Adds the `--rendezvous-id` option allowing the caller to specify the node_id
of the rendez-vous node, and opting into the compressed onion generation.
2020-03-12 10:25:01 +10:30
Christian Decker 59b6159e56 sphinx: Functions to enable RV mode and serialize compressed onions
We will later use these to generate RV compressed onions and to opt into the
rendezvous style generation.
2020-03-12 10:25:01 +10:30
Christian Decker 96dc0238ba sphinx: Working onion wrapping with filler cancellation 2020-03-12 10:25:01 +10:30
Christian Decker bc74e49534 pytest: Add tests for the sphinx onion generation and processing
These just run the test vectors and add a test for the devtools/onion tool so
we don't accidentally break them.
2020-03-12 10:25:01 +10:30
darosior 06e9a9f31f bitcoind: check that Bitcoin plugin is alive before requesting 2020-03-11 16:01:36 -05:00
Arc 8539442de3
bitcoin-cli reference is confusing (#3583)
User will fund from whatever source they have. If they already have bitcoin-cli funded, then they will know how to fund from it?
2020-03-10 13:27:32 +10:30
lisa neigut 41b18050a0 plugin: add in deprecated_api behavior and test
we also check that the node isn't running now, for extra pedancity
2020-03-10 13:25:36 +10:30
lisa neigut b25a8ba29d plugins: test for option value checking and parsing 2020-03-10 13:25:36 +10:30
lisa neigut cac5a0cd1d plugins: use stricter parsing for option values
also: convert the stored int value from 'int' to 's64'

atoi fails silently, returning a zero. instead we use the more robust
strtoll which will allow us fail with an error.

we also make the parsing for bools stricter, only allowing plausibly
boolean values to parse.
2020-03-10 13:25:36 +10:30
lisa neigut d19cddf00f pyln: enforce types of options
we loosely enforce that the specified type must be one of the listed
options. you can still cause an error because we're not checking the
default value you're passing in ...

not sure if this is totally necessary, should we jsut let clightning
enforce the input?
2020-03-10 13:25:36 +10:30
lisa neigut 4e30a82f09 plugins: pass back opts as indicated type. fixes #3577
Changelog-Fixed: Plugins: if an option has a type int or bool, return the option as that type to the plugin's init
2020-03-10 13:25:36 +10:30
lisa neigut 34cef2cac3 pyln-testing: add flag 'expect_fail' to node factory get_node
if the node fails to start (and we're expecting it to) return to us the
node object anyway

we also signal to collect all of its stderr logs by setting stderr
on the tailableproc that backs the node
2020-03-10 13:25:36 +10:30
lisa neigut 0cf3e19e0b pyln-testing: save stderr logs for checking
just for convenience's sake
2020-03-10 13:25:36 +10:30
Christian Decker d2688bbaf5 plugin: Unwrap the rpc_command payload
We were nesting like the following:

```json
{"params": {
  "rpc_command": {
    "rpc_command": {
    }
  }
}
```

This is really excessive, so we unwrap once, and now have the following:

```json
{"params": {
  "rpc_command": {
  }
}
```

Still more wrapping than necessary (the method is repeated in the `params`
object), but it's getting closer.

Changelog-Deprecated: JSON-RPC: Removed double wrapping of `rpc_command` payload in `rpc_command` JSON field.

Suggested-by: @fiatjaf
Signed-off-by: Christian Decker <@cdecker>
2020-03-10 11:42:58 +10:30
Christian Decker 15ca3b615f make: Add compat flag for v0.8.1 2020-03-10 11:42:58 +10:30
Vasil Dimov 66eca2ff3f lightningd: always broadcast the latest close tx
Before this patch we would only update `channel->last_tx` with the newly
proposed closure tx from the peer if the fee of the new one was lower.

In negotiations where we are at the higher end and the peer starts
lower, all peer's subsequent proposals will be higher than his initial
proposal and in this case we would never update `channel->last_tx`
and would wrongly broadcast his initial proposal at the end of the
negotiation.

Fixes https://github.com/ElementsProject/lightning/issues/3549

Changelog-Fixed: Always broadcast the latest close transaction at the end of the close fee negotiation, instead of sometimes broadcasting the peer's initial closing proposal.
2020-03-10 11:40:19 +10:30
Rusty Russell c92e782e22 wire: add fromwire_tal_arrn() helper.
Does the allocation and copying; this is useful because we can
avoid being fooled into doing giant allocations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-09 16:04:56 +01:00
darosior 524d22e4cc doc: update listchannels manpage
After #3576 ..
2020-03-09 16:03:39 +01:00
Dave Scotese 53913c5119 Use of null
I added a hint how to specify source but not short channel id.
2020-03-07 15:48:22 +01:00
darosior 8e055a4506 bcli: remove a superfluous variable 2020-03-05 15:06:38 -06:00
darosior 1fd45a061b bitcoind: timeout if the Bitcoin plugin never completes the handshake
Reported-by: Vasil Dimov <@vasild>
2020-03-05 15:06:38 -06:00
Vasil Dimov 820f1b2f9d build: send cmp's stderr to /dev/null also
It was probably a typo to have 2>&2

Changelog-None
2020-03-05 14:58:57 -06:00
Vasil Dimov 53ecf098ab build: remove unrecognized option to libsodium
Silence a warning during libsodium's ./configure:

```
configure: WARNING: unrecognized options: --enable-tests
```

Changelog-None
2020-03-05 14:58:57 -06:00
Vasil Dimov 6e86022909 build: force libwally-core to compile in C99 mode
Without this gcc 4.8 defaults to an older standard and cannot compile
the code:

```
gcc-4.8 -DHAVE_CONFIG_H -I. -I../../libwally-core/src -I../../libwally-core -I../../libwally-core/src/ccan -DWALLY_CORE_BUILD=1 -Wall -Wextra -Wpedantic -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wformat -Wformat-security -Wformat-nonliteral -O0 -ggdb -DBUILD_ELEMENTS=1 -flax-vector-conversions -Wno-unused-function -Wno-long-long -Wno-overlength-strings -Wno-variadic-macros -fvisibility=hidden -g -O2 -MT libwallycore_la-elements.lo -MD -MP -MF .deps/libwallycore_la-elements.Tpo -c ../../libwally-core/src/elements.c -o libwallycore_la-elements.o
../../libwally-core/src/elements.c: In function ‘wally_asset_pak_whitelistproof’:
../../libwally-core/src/elements.c:629:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < num_keys; ++i) {
     ^
../../libwally-core/src/elements.c:629:5: note: use option -std=c99 or -std=gnu99 to compile your code
```

Changelog-None
2020-03-05 14:58:57 -06:00
Christian Decker ac5cba2243 htlc: Return an invalid payload error if payload is invalid
We somehow were always returning `badonion` when really it is an invalid
payload inside the onion.
2020-03-04 22:57:24 +01:00
Christian Decker 959687bf6d onion: Pass the position and type of the failing TLV type out
We'll need this when returning an error to the sender.
2020-03-04 22:57:24 +01:00
Christian Decker 0ba6aba7d1 onion: Do not leak parsed TLV if it is invalid
We were freeing the payload but not the TLV from which we extracted the
payload.
2020-03-04 22:57:24 +01:00
Christian Decker 9529529815 pytest: Repro wrong error being returned on invalid onion payloads
We are returning a `BADONION` error despite the cause being an invalid onion
payload containing an unknown even TLV type. It really should return
`INVALID_ONION_PAYLOAD` errors instead.
2020-03-04 22:57:24 +01:00
Rusty Russell 3572d598bf tests: fix flake in libplugin test.
My test machine is fast enough that we might not have seen the plugin
msg yet.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-04 16:42:34 +01:00
darosior 6f41d18a92 doc: add pyln-proto to PYTHONPATH for pytest in HACKING 2020-03-04 16:41:43 +01:00
Michael Schmoock 6c50185865 fix: cppcheck ignore two false positives on uninitvar 2020-03-04 14:04:51 +10:30
Michael Schmoock d3ece69a1b fix: adds bcli plugin to check-source targets
Changelog-None
2020-03-04 14:04:51 +10:30
Christian Decker 42d1d3b6d1 wally: Bump libwally to fix gcc 4.8 support 2020-03-04 13:29:39 +10:30
ZmnSCPxj jxPCSnmZ d9b2482415 lightningd/hsm_control.c: Implement `getsharedsecret`.
ChangeLog-Added: New `getsharedsecret` command, which lets you compute a shared secret with this node knowing only a public point. This implements the BOLT standard of hashing the ECDH point, and is incompatible with ECIES.
2020-02-28 14:45:50 +10:30
ZmnSCPxj jxPCSnmZ 1b0807444b hsmd/hsmd.c: Correct a comment.
ChangeLog-none
2020-02-28 14:45:50 +10:30
Rusty Russell f8a21f16c9 lightingd: do a local short_channel_id lookup for forwarding.
Even without optimization, it's faster to walk all the channels than
ping another daemon and wait for the response.

Changelog-Changed: Forwarding messages is now much faster (less inter-daemon traffic)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-28 09:44:47 +10:30
Rusty Russell 40e3566e9a lightningd: use the async mechanism for channel_update access.
Instead of saving a stripped_update, we use the new
local_fail_in_htlc_needs_update.

One minor change: we return the more correct
towire_temporary_channel_failure when the node is still syncing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-28 09:44:47 +10:30