Commit Graph

7525 Commits

Author SHA1 Message Date
Christian Decker a8fa55d275 wire: Add common messages that are independent of daemons
These messages may be exchanged between the master and any daemon. For now
these are just the daemons that a peer may be attached to at any time since
the first example of this is the custommsg infrastructure.
2020-01-28 23:50:52 +01:00
Christian Decker 28080b2e69 elementsd: Do not use `generate` for elementsd >= 0.17.0
The `generate` has been deprecated since 0.16 and has been removed in 0.18.0
so we better use `generatetoaddress` instead, which is already what we do with
`bitcoind`. So we remove the override here.
2020-01-28 20:03:55 +01:00
Christian Decker 234252016d cleanup: Remove block header fields we don't use 2020-01-28 20:03:55 +01:00
Christian Decker a61b044056 elements: Implement dynafed block format support
Changelog-Added: elements: Added support for the dynafed block header format and elementsd >=0.18.1
2020-01-28 20:03:55 +01:00
Christian Decker c99786e720 bitcoin: Use the block hash we computed while deserializing it
Since we now compute the hash while deserializing the block header we can now
just use it, no reason to serialize the header just to hash it again. This
also allows us to throw away all the added dynafed fields in the next commit
instead of having to carry them around.
2020-01-28 20:03:55 +01:00
Christian Decker fce05d74e1 elements: Construct the block header hash while we parse it 2020-01-28 20:03:55 +01:00
Christian Decker 8839be641a sha256: Add primitive to add a varint-encoded int to a hash
We're about to push a couple of varints as part of the dynafed blockparsing,
so we might as well make it easier for us.
2020-01-28 20:03:55 +01:00
Christian Decker 4de0d1ca22 bitcoin: Compute block hash while parsing
This avoids having to re-serialize the block header just to compute the
hash. It also frees us from having to carry around all the details in the
header and we can hand around a minimal version.
2020-01-28 20:03:55 +01:00
ZmnSCPxj jxPCSnmZ ccb895083f tests/test_invoices.py: Add test for `timeout` param of `waitanyinvoice`. 2020-01-28 14:07:52 +01:00
ZmnSCPxj jxPCSnmZ 67590fc6be lightningd/invoice.c: Add `timeout` parameter to `waitanyinvoice`.
Fixes: #3192

Changelog-Added: `waitanyinvoice` now supports a `timeout` parameter, which when set will cause the command to fail when the timeout is reached; can set this to 0 to fail immediately if no new invoice has been paid yet.
2020-01-28 14:07:52 +01:00
Rusty Russell e379528254 lightningd: fix memleak false positive.
json_listconfigs() returns in the middle; the name0 is not always freed.

It will be freed later with the response, but our memleak detection doesn't
know that, and Travis caught it:

           Global errors:
E            - Node /tmp/ltests-5mfrzh5v/test_hsmtool_secret_decryption_1/lightning-1/ has memory leaks: [
E               {
E                   "backtrace": [
E                       "ccan/ccan/tal/tal.c:437 (tal_alloc_)",
E                       "ccan/ccan/tal/tal.c:466 (tal_alloc_arr_)",
E                       "ccan/ccan/tal/tal.c:794 (tal_dup_)",
E                       "ccan/ccan/tal/str/str.c:32 (tal_strndup_)",
E                       "lightningd/options.c:1122 (add_config)",
E                       "lightningd/options.c:1282 (json_listconfigs)",
E                       "lightningd/jsonrpc.c:588 (command_exec)",
E                       "lightningd/jsonrpc.c:679 (rpc_command_hook_callback)",
E                       "lightningd/plugin_hook.c:123 (plugin_hook_call_)",
E                       "lightningd/jsonrpc.c:729 (plugin_hook_call_rpc_command)",
E                       "lightningd/jsonrpc.c:736 (call_rpc_command_hook)",
E                       "common/timeout.c:39 (timer_expired)",
E                       "lightningd/io_loop_with_timers.c:32 (io_loop_with_timers)",
E                       "lightningd/lightningd.c:871 (main)"
E                   ],
E                   "label": "lightningd/options.c:1122:char[]",
E                   "parents": [
E                       "lightningd/json_stream.c:49:struct json_stream",
E                       "ccan/ccan/io/io.c:91:struct io_conn",
E                       "lightningd/lightningd.c:104:struct lightningd"
E                   ],
E                   "value": "0x5569ada057a8"
E               }
E           ]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-28 13:13:12 +01:00
Rusty Russell 387cd400d4 lightningd: remove lightning-rpc file on migration.
Fixes: #3378
Closes: #3379
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-28 13:12:19 +01:00
nicolas.dorier 06c5663f75 Do not move the socket file on migration 2020-01-28 13:12:19 +01:00
ZmnSCPxj jxPCSnmZ 484370a6bc .github/CODEOWNERS: Remove nonexistent module.
This was factored out into a separate `plugins/pay`, though I
am still not prepared to take over that.

ChangeLog-none
2020-01-28 13:11:37 +01:00
Vasil Dimov dc26e3ed94 Add .editorconfig to make it easier to obey style
Changelog-None
2020-01-28 14:44:09 +10:30
ZmnSCPxj jxPCSnmZ 1e3fb8e750 doc/TOR.md: Mention about `statictor`.
Changelog-None
2020-01-28 13:46:33 +10:30
Christian Decker d3f6ebf911 pyln-proto: Added a couple of utilities to manage onions and zbase32 2020-01-28 13:43:44 +10:30
lisa neigut d36af2c340 txprepare: make output finding map for withdraw_tx variable len
The number of outputs got updated, but the map used to calculate the
change output's location did not (still assumes only one output). This
patch fixes this to make the output map a variable size.

Changelog-Fixed: JSON API: `txprepare` no longer crashes when more than two outputs are specified
2020-01-27 22:59:41 +01:00
lisa neigut f15d34465d txprepare: add test for multiple withdraw-to outputs
adds (currently failing test) for a txprepare with more than two outputs
2020-01-27 22:59:41 +01:00
lisa neigut 1763960c4a txprepare: don't crash on empty args
add test for empty args check
2020-01-27 22:59:41 +01:00
Christian Decker c2434ad4fb bitcoin: Compute block hash while parsing
This avoids having to re-serialize the block header just to compute the
hash. It also frees us from having to carry around all the details in the
header and we can hand around a minimal version.
2020-01-27 22:48:42 +01:00
Christian Decker 62e9ad1139 sphinx: Fix the broken legacy payload loading from test-vectors
We were for some reason encoding all payloads as raw payloads instead of
loading legacy payloads into a padded array.
2020-01-27 22:48:42 +01:00
Christian Decker 9038364c63 sphinx: Actually use the pad stream to generate the packet
We flipped two buffers and were not actually using the chacha20 stream.
2020-01-27 22:48:42 +01:00
ZmnSCPxj jxPCSnmZ 7f4ed54b46 lightningd/jsonrpc.c: Set JSON-RPC socket permissions by command line.
Changelog-Added: Can now set the permissions on the JSON-RPC socket by `--rpc-file-mode`.
2020-01-27 21:11:57 +01:00
darosior f619124cb9 doc: update readthedocs index 2020-01-27 16:24:12 +00:00
darosior b7699cff9f pyln: actually specify jsonrpc in requests
As per the spec (https://www.jsonrpc.org/specification#request_object)

```
A rpc call is represented by sending a Request object to a Server. The Request object has the following members:

jsonrpc
    A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".
```

Changelog-fixed: pyln now includes the "jsonrpc" field to jsonrpc2 requests
2020-01-27 12:38:40 +01:00
darosior 6489e63991 doc/INSTALL: correct some typos
A double `git` and a `mode`.
2020-01-24 18:25:59 +01:00
Rusty Russell 262e4c840f sphinx: use struct secret for shared secret.
Generally I prefer structures over u8, since the size is enforced at
runtime; and in several places we were doing conversions as the code
using Sphinx does treat struct secret as type of the secret.

Note that passing an array is the same as passing the address, so
changing from 'u8 secret[32]' to 'struct secret secret' means various
'secret' parameters change to '&secret'.  Technically, '&secret' also
would have worked before, since '&' is a noop on array, but that's
always seemed a bit weird.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-24 10:01:44 +10:30
Rusty Russell 1099f6a5e1 common: use struct onionreply.
This makes it clear we're dealing with a message which is a wrapped error
reply (needing unwrap_onionreply), not an already-wrapped one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell aa6aad0131 common: add struct onionreply
I really want a type which means "I am a wrapped onion reply" as separate
from "I am a normal wire msg".  Currently both user u8 *, and I got very
confused trying to figure out where each one was an unwrapped error msg,
or where it still needed (un)wrapping.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell aae5148206 common: remove onionreply type from sphinx.c
It's only mildly used, and I really to use onionreply in a more
generic sense in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell ddce5573c7 channeld: use wirestring for failure strings.
I think this code predated wirestring.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell a0a2c257be Makefile: add a COMPAT_V080 flag.
We're going to need this in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell fe84d69022 channeld: fix cut & paste bug.
It's failed[i] we're dealing with, not fulfilled[i].

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
Rusty Russell 9a72016640 lightningd: remove unused allocation.
Not a leak, since it's off tmpctx, but send_htlc_out allocates this itself.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-23 16:17:42 +10:30
darosior dd3d8d9504 plugin: fix a comment when setting up io conns 2020-01-21 22:38:14 +01:00
darosior 87f0733965 lightningd/plugin: fix the "plugins" entry in 'listconfigs'
The value 'as_int' should not be added as a bool.
2020-01-21 22:38:14 +01:00
darosior dc3aa33927 pytest: use pyln.client for functional tests 2020-01-21 22:38:14 +01:00
ZmnSCPxj a9f0f05eea pay: Implement retry in case of final CLTV being too soon for receiver.
Changelog-Fixed: Detect a previously non-permanent error (`final_cltv_too_soon`) that has been merged into a permanent error (`incorrect_or_unknown_payment_details`), and retry that failure case in `pay`.
2020-01-21 22:23:21 +01:00
ZmnSCPxj 72a24a2bdd test_pay.py: Add test for blockheight disagreement. 2020-01-21 22:23:21 +01:00
ZmnSCPxj 6c0d7ca737 pay: Implement tracking of blockheight for starting payment attempts. 2020-01-21 22:23:21 +01:00
ZmnSCPxj e9aa690d44 pay: Factor out execution of `getroute` from starting of payment attempt. 2020-01-21 22:23:21 +01:00
ZmnSCPxj 54cc735201 lightningd/peer_control.c: Implement waitblockheight.
This is needed to fully implement handling of blockheight disagreements
between us and payee.
If payee believes the blockheight is higher than ours, then `pay`
should wait for our node to achieve that blockheight.

Changelog-Add: Implement `waitblockheight` to wait for a specific blockheight.
2020-01-21 22:23:21 +01:00
ZmnSCPxj jxPCSnmZ 44e8256338 common/json.c: Implement `json_to_u32`. 2020-01-21 22:23:21 +01:00
Vasil Dimov fb7c006187 wire: add towire_int() and use it in connectd
Add towire_int() and fromwire_int() functions to "(de)serialize"
"int". This will only work as long as both the caller of towire_int()
and the caller of fromwire_int() use the same in-memory representation
of signed integers and have the same sizeof(int).

Changelog-None
2020-01-21 16:59:18 +01:00
Vasil Dimov fc75d8a9e6 connectd: add own err codes instead of generic -1
Make it possible for connectd to send an error code to lightningd in
addition to the error message. Introduce two new error codes, replacing
the catch-all -1.

This change, together with
https://github.com/ElementsProject/lightning/pull/3395
will implement https://github.com/ElementsProject/lightning/issues/3366

Changelog-Changed: The `connect` command now returns its own error codes instead of a generic -1.
2020-01-21 16:59:18 +01:00
Vasil Dimov 3cf91b23b9 doc: unify man pages error sections
Change all man pages to follow the style of doc/lightning-pay.7.md for
the section on returning errors.

Changelog-None
2020-01-21 12:49:33 +08:00
Vasil Dimov 89466f0e55 doc: list the error codes of funding_* commands
Changelog-None
2020-01-21 12:49:33 +08:00
Vasil Dimov 11da88a281 common: add 2 specific error codes wrt funding
Add "peer not connected" and "unknown peer" as error codes, so that
users can check against numeric error codes instead of textual error
messages.

Will ease https://github.com/ElementsProject/lightning/issues/3366

Changelog-None
2020-01-21 12:49:33 +08:00
lisa neigut e1ef902db4 wire-make: remove --silent flag from patch command
not supported on all architectures
2020-01-18 19:37:46 +08:00