Commit Graph

7837 Commits

Author SHA1 Message Date
Rusty Russell 8c984fbf1d common: make sphinx.c use hmac.c.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-25 14:26:28 +10:30
Rusty Russell b122e44a0b common: new file hmac for hmac calculation.
Blinded paths will want this too; it's mainly copied from sphinx.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-25 14:26:28 +10:30
Rusty Russell c66b3d4c04 common: make sphinx use struct secret internally.
We don't have a struct symkey, though perhaps we should?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-03-25 14:26:28 +10:30
Christian Decker e99ab03f79 pytest: Fix test_closing_fee regression in elements
Constants once again.
2020-03-24 09:52:33 +10:30
Christian Decker 453bfbc816 json-rpc: Fix test_txprepare if running with postgres
Postgres does not guarantee that the insertion order is the returned order,
which leads us to skip outputs that have already been stolen onto the selected
utxos set, but not added to it because it isn't confirmed. This may also
happen with sqlite3 though it's a lot rarer in that case.
2020-03-24 09:52:33 +10:30
Christian Decker 9736c7bfd0 pytest: Make test_pay_retry less flaky for liquid-regtest 2020-03-24 09:52:33 +10:30
Christian Decker 5532305d76 pytest: Unbreak the test_feerate_spam test for elementsd
Looking for specific feerates, but not adjusting the amounts involved doesn't
work.
2020-03-24 09:52:33 +10:30
Christian Decker 7201cb7315 pytest: Configure logging in a fixture to match stdout capturing
pytest captures the output by monkey patching out `sys.stdout`. This may
conflict with our use of `sys.stdout` when configuring logging, resulting in
the "Write to closed file" issue that is spamming the logs. By making the
logging configuration a fixture hopefully we always use the correct
stdout (after pytest has monkey-patched it).
2020-03-24 09:52:33 +10:30
Christian Decker cf8c972883 pyln-testing: Print a list of files if we can't remove the test dir
For some reason we fail to remove the test directory in some cases. My
hypothesis is that it is a daemon that is not completely shut down yet, and
still writes to the directory. This commit intercepts the error, prints any
files in the directory and re-raises the error. This should allow us to debug
the reappears.
2020-03-24 09:52:33 +10:30
Christian Decker 3e3b05e1b2 pyln: Migrate remaining uses of the deprecated pylightning module
`pylightning` is not much more than an alias for `pyln-client`, so this
removes the need to install that as well just to run the tests.
2020-03-24 09:52:33 +10:30
Christian Decker c236bf0fbd tx: Make elements_add_fee_output private 2020-03-24 09:52:33 +10:30
Christian Decker 42a63e4416 tx: Strengthen transaction construction checks
We roll the `elements_add_fee_output` function and the cropping of
overallocated arrays into the `bitcoin_tx_finalize` function. This is supposed
to be the final cleanup and compaction step before a tx can be sent to bitcoin
or passed off to other daemons.

This is the cleanup promised in #3491
2020-03-24 09:52:33 +10:30
Christian Decker 24aaf73982 pytest: Actually make sure that the direcory exists
Some tests may not spawn a node at all, so make sure that our assumption that
the directory exists in the fixture cleanup is correct by creating the
directory.
2020-03-24 09:52:33 +10:30
Vasil Dimov 751df868c7 gossipd: fix compilation warnings with clang 10
```
clang10 -DBINTOPKGLIBEXECDIR="\"../libexec/c-lightning\"" -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector  -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/libbacktrace/ -I external/libbacktrace-build -I . -I/usr/local/include   -DCCAN_TAKE_DEBUG=1 -DCCAN_TAL_DEBUG=1 -DCCAN_JSON_OUT_DEBUG=1 -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS   -DBUILD_ELEMENTS=1 -DBINTOPKGLIBEXECDIR="\"../libexec/c-lightning\""  -c -o gossipd/routing.o gossipd/routing.c
gossipd/routing.c:651:10: error: implicit conversion from 'unsigned long' to 'double' changes value
      from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
        if (r > UINT64_MAX)
              ~ ^~~~~~~~~~
```

It is ok to change the values because they are approximate anyway. Thus,
explicitly typecast to `double` to silence the warning without changing
behavior.

Changelog-None
2020-03-21 16:30:46 +10:30
lisa neigut 563b46814b plugins: remove 'blank' option parsing for bool
bools must be set!
2020-03-21 16:29:52 +10:30
lisa neigut 42cce55b45 plugins: add 'flag' type for plugin options
Updates the plugin docs to include more detailed info about how options
work.

Changelog-Added: Plugins: 'flag'-type option now available.
2020-03-21 16:29:52 +10:30
lisa neigut a08905c344 plugin tests: actually check log result + move over to '' -> true
a few things. one is that `is_in_log` returns a result rather than
enforcing a condition. so these lines all need asserts

two is that with the 'allow_deprecated_apis' option on, the python json
parser overwrites the now typed input with the later-added string
version, so the only option value present in the option key-value set is
the last, string one. the check for this has been updated to only verify
that the string version is included (i manually verified that both are
printed to the JSON message)
2020-03-21 16:29:52 +10:30
Michael Schmoock af7e879308 fix: rfc #740 requires 100% feespike margin
Changelog-Fixed: Use lightning-rfc #740 feespike margin factor of 2
2020-03-19 18:56:12 +01:00
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