Commit Graph

10024 Commits

Author SHA1 Message Date
Christian Decker 45607577b9 jsonrpc: Add parsing for parameter of extra parameters 2021-06-26 10:55:13 +09:30
Christian Decker 473be0f6e4 plugin: Add extra TLVs to the invoice_payment hook 2021-06-26 10:55:13 +09:30
Christian Decker 477f574569 htlc: Keep the parsed TLV payload around with the htlc_in
We want to show the fields in the invoice_payment hook.
2021-06-26 10:55:13 +09:30
Christian Decker edf4b416c2 htlc: Wire extra TLV types into the HTLC onion decoding 2021-06-26 10:55:13 +09:30
Christian Decker b4ead97517 tlv: Allow passing some extra types to accept when parsing the stream 2021-06-26 10:55:13 +09:30
Christian Decker b68acb8cf0 opts: Add option to register extra TLV types to accept
Incoming HTLCs are rejected by the HTLC logic if the payload contains
an even type that `lightningd` doesn't recognize. This is to prevent
us from accidentally accepting a payment that has extra semantics
attached (for example if we get a keysend payment and don't know what
to do with the TLV field containing the message we should reject it,
otherwise the overall semantics of the message delivery fail).
2021-06-26 10:55:13 +09:30
Rusty Russell 84190af72c pytest: Add test that we can redo closing negotiation even after onchain.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell ca0358f978 channeld: send shutdown_complete even if reestablish_only.
This lets us transition (with a few supporting changes) to closingd,
which will happily let them mutual close with us.

We already handle the case where this mutual close is redundant (for
packet loss), so this is easy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Protocol: We will now reestablish and negotiate mutual close on channels we've already closed (great if peer has lost their database).
2021-06-25 13:23:28 +09:30
Rusty Russell 44829d1361 openingd: tell lightningd if we get a reestablish.
It simply uses connectd to send an error if it doesn't know anything
about the channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell 9929d6383a channeld: add a message to read if we only want to reestablish.
This supports reestablish on a closed channel: we tell channeld to
respond to the reestablish message appropriately, then close the
channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell 6afb9f8fe7 lightningd: add channel_closed helper, expose find_channel_by_id().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell b223a6acbb common/read_peer_msg: don't try to handle reestablish/reopen.
Let the callers do that (only channeld needs to do this).

We temporarily send an error on unknown reestablish in openingd, as
this mimic previous behavior and avoids breaking tests (it does leave
a BROKEN message in the logs though, so
test_funding_external_wallet_corners needs to ignore that for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell ef138575e1 pytest: add test (failing) which allows talking about closed channels.
In particular, if one side sees the final CLOSING_SIGNED and the other
doesn't, we won't talk when it reconnects.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell 9f8a6e2314 lightningd: always pass closing connections through channeld.
It handles all the cases of retransmission, and in the normal case
retransmits shutdown and immediately returns for us to run closingd.

This is actually far simpler and reduces code duplication.

[ Includes fixup to stop warn_unused_result from Christian ]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: We could get stuck on signature exchange if we needed to retransmit the final revoke_and_ack.
2021-06-25 13:23:28 +09:30
Rusty Russell a997e798ee pytest: test for closing needing retranmission bug.
This was turned by at random by CI:

1. Alice has sent shutdown, but it still waiting for revoke_and_ack.
2. Bob has sent and received shutdown, and sent revoke_and_ack,
   so it considers it time for signature exchange.
3. Disconnect before Alice received revoke_and_ack.
4. Reconnect, Bob is in closingd, which doesn't rexmit revoke_and_ack.
5. Timeout.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Rusty Russell 62e1e2467c dev_disconnect: new option to stop using connection, but don't close.
This allows us to ensure a packet is read by the other end, but we
don't read anything else from them or write anything to them.

Using '+' is similar, but because it closes the connection, the peer
might notice before receiving the packet (such as if it does a write).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 13:23:28 +09:30
Nalin Bhardwaj 0fccfc0a9a tools/check-spelling: Fix grep error on macOS
Changelog-Fixed: Fixes `make full-check` errors on macOS
2021-06-25 10:16:41 +09:30
Nalin Bhardwaj bbaca4bb5c tools/mockup: Fix macOS bash 3 syntax error
Changelog-Fixed: Fixes `make` with `--enable-developer` option on macOS.
2021-06-25 10:16:41 +09:30
Vincenzo Palazzo 8d146ea36f Update at latest version of lnprototest with the support of channel_type
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2021-06-25 09:51:29 +09:30
Vincenzo Palazzo 33b8a55bec Update lnprototest submodule
This is a fix propose of the ticket https://github.com/ElementsProject/lightning/issues/4516

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2021-06-25 09:51:29 +09:30
Rusty Russell 408342dc23 doc: schema for listconfigs, compare with documentation.
This made me document what are options are now in plugins, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell d7e8e220e6 lightningd: clean up listconfigs output.
1. Hide the now-deprecated enable-autotor-v2-mode option.
2. Really don't print dev- options.
3. Don't print true and false as strings in some cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `listconfigs` would list some boolean options as strings `"true"` or `"false"` instead of using JSON booleans.
2021-06-25 09:49:33 +09:30
Rusty Russell 2ddecdc95a doc: schemas for everything else.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: doc: Epic documentation rewrite: each now lists complete and accurate JSON output, tested against testsuite.
2021-06-25 09:49:33 +09:30
Rusty Russell 977cb62e12 doc: listpeers schema.
This is the most complex one.  It gets its own commit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell 6e636a835f tools/fromschema.py: handle deprecated null field, don't create empty lists.
1. listpeers has a deprecated `"closer": null`, which we need
   to handle in the schema, while trying not to damage our
   documentation too much.

2. Don't print a condition if there are no fields to print.

3. Allow a special "untyped" marker for multifundchannel which returns
   arbitrary JSON in a field.

4. Allow a single field return (for 'stop').

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell 1a181a3240 doc/schemas: listfunds, listinvoices, listnodes, listoffers
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell 2296d4452f doc/schemas: listfunds
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell 74eeaa8213 doc/schemas: getsharedsecret, help, invoice, listchannels, listforwards
And a new "u8" type.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell a9f49b5326 doc: document how to try to write JSON schemas.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell fe161ff962 doc/schemas: tighten requirements.
If we have conditional fields, we often set `additionalProperties` `true`
at the top-level, but then we have to make sure to cover all the possible
combinations in conditionals, so unintended additions don't appear.

This revealed missing fields in delinvoice, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell bf74be3348 plugins: add `command` field to subcommand output.
Makes it possible to write a decent JSON schema, but means we need to carry
additional data, so we create a `struct plugin_command`.

We remove the unused struct dynamic_plugin, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-25 09:49:33 +09:30
Rusty Russell 0a99b8c64c listtransactions: don't create a msat field called "satoshis".
That's a terrible, terrible idea.  (Documentation comes in later patch
which has the schema).

Also, blockheight is a u32, so simplify.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `listtransactions` `outputs` `satoshis` field (use `msat` instead).
2021-06-25 09:49:33 +09:30
Rusty Russell d8136d856b listpeers: clean up JSON output.
In general, it's better to omit a field than put in a 'null', and
putting variable-named fields in an object is also a bad idea.

This is reflected in how hard this is to express in JSON schema, too.

Others:
1. Remove the obsolete "funding": "LOCAL" from unopened channels, but add
   "opener": "local" as used in normal channels.
2. htlc cltv_expiry is a u16.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `funding_allocation_msat` and `funding_msat`: use `funding`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `last_tx_fee`: use `last_tx_fee_msat`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `closer` is now omitted if it does not apply, not JSON `null`.
2021-06-25 09:49:33 +09:30
Rusty Russell edee0793d3 pyln.proto: fix receiving unknown fields in TLVs.
We can still convert these (e.g. k=1) to Python, by just using hex strings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-24 19:46:38 +09:30
Rusty Russell ca3680246e pyln.proto: fix handling of subtypes in TLVs.
This was revealed by using lnprototest on channel_types.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-24 19:46:38 +09:30
Rusty Russell eaa2ff23f1 EXPERIMENTAL_FEATURES: don't offer to downgrade anchor outputs!
We don't support this, even if other side allowed it (which we certainly
don't).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-24 19:46:38 +09:30
Rusty Russell 35c8247b5f cleanup: remove unused pyln-spec symlinks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-24 19:46:38 +09:30
nathanael 262f90d115 replace freenode with libera
Changelog-None
2021-06-21 12:42:09 +09:30
Christian Decker 2510bcad07 pay: Fix another instance of a crash when we can't find ourselves 2021-06-20 14:26:00 +09:30
Rusty Russell 50ebdfb5e8 invoice: allow creation of giant invoices.
https://github.com/lightningnetwork/lightning-rfc/pull/877 talks about
removing this restriction (only Electrum actually enforced it on
receive), so start by allowing creation of giant invoices, though
we mark them as requiring mpp.

Changelog-Changed: JSON-RPC: `invoice` now allows creation of giant invoices (>= 2^32 msat)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-20 14:25:40 +09:30
Antoine Poinsot 1643a61499 pyln-testing: check if process died after having read all logs
We would fail even if a process exited cleanly after having the line we
were looking for, because we checked if it died before reading the logs.

Co-Authored-by: Daniela Brozzoni <daniela@revault.dev>
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-06-18 10:40:07 +09:30
Antoine Poinsot d6f441bdf4 hsm_encryption: merge getline() logic between stdin and non-stdin
Avoid duplicating it, to minimize the potential for divergence.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-06-18 10:40:07 +09:30
Antoine Poinsot e19b67f6da qa: test hsm encryption password provided from stdin
Test that it roundtrips with the non-stdin way, in order to make sure we
don't introduce a discrepancy between the two.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-06-18 10:40:07 +09:30
Antoine Poinsot 526e6026f5 hsmtool: this is 'success', not 'succes'
I tried to wait_for_log() on "successfully" without success :/

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-06-18 10:40:07 +09:30
Michael Schmoock a53aa1aaef pyln: adds a help text to start plugins manually
Changelog-None
2021-06-18 09:59:54 +09:30
Rusty Russell 40544b74f9 plugins/bcli: fix uninitialized variable.
We didn't set this to false on non-regtest!

```
==198363== Conditional jump or move depends on uninitialised value(s)
==198363==    at 0x10EF88: estimatefees_parse_feerate (bcli.c:443)
==198363==    by 0x10F3BF: estimatefees_second_step (bcli.c:550)
==198363==    by 0x10E720: bcli_finished (bcli.c:258)
==198363==    by 0x1438A7: destroy_conn (poll.c:244)
==198363==    by 0x1438CB: destroy_conn_close_fd (poll.c:250)
==198363==    by 0x151A7A: notify (tal.c:240)
==198363==    by 0x151F91: del_tree (tal.c:402)
==198363==    by 0x15232D: tal_free (tal.c:486)
==198363==    by 0x141EB8: io_close (io.c:450)
==198363==    by 0x14400B: io_loop (poll.c:449)
==198363==    by 0x114BB0: plugin_main (libplugin.c:1414)
==198363==    by 0x1105C4: main (bcli.c:973)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-17 11:47:02 +09:30
Rusty Russell 976a79094b connectd: fix advertizing for Tor ports.
We were accidentally using the port that the tor service was
connecting to, not the /torport the user said to use.

Fixes: #4597
Reported-by: @openoms
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Config: `addr` autotor and statictor /torport arguments now advertized correctly.
2021-06-17 11:46:48 +09:30
Rusty Russell 41767560d6 common/test: test wireaddr parsing.
In case this was the issue (it wasn't)!.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-17 11:46:48 +09:30
Rusty Russell 75720ad0e1 lightningd: wait for gossipd to finish initalizing before starting plugins.
This mainly helps our CI under valgrind, which starts a fresh instance
and immediately calls the invoice command.  This can cause the topology
plugin to try to access the gossmap file before it's created.

We can also move the gossmap reading in topology to init time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-16 10:29:17 +09:30
Rusty Russell 7e7ab4cb3b gossipd: remove routing, listchannels and listnodes infrastructure.
This involves removing some fields from the now-misnamed routing.h
datastructures, and various internal messages.

One non-obvious change is to our "keepalive" logic which refreshes
channels every 13 days: instead of using the 'enabled' flag on the
last channel broadcast to decide whether to refresh it, we use the
local connected status directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-16 10:29:17 +09:30