Commit Graph

10103 Commits

Author SHA1 Message Date
Rusty Russell 30faf96efb lightningd: don't complain about unable to estimate fees if not mainnet.
'force-feerates' already bypasses this logic, but we should still suppres

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-09 07:26:09 +09:30
Rusty Russell adab9eb301 lightningd: add force-feerates option.
Useful for regtest and testnet.  Sure, you shouldn't use this on mainnet,
but I haven't restricted it because our users are usually pretty clever.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: #1806
Changelog-Added: config: `force_feerates` option to allow overriding feerate estimates (mainly for regtest).
2021-07-09 07:26:09 +09:30
Rusty Russell 131e79ab91 channeld: don't ever use 0 as a feerate.
This has been reported several times on regtest, most recently by Gijs
van Dam.  It turns out approx_max_feerate() was returning 0 in some
corner cases: we should *not* be using that value (as shown, it's
overly conservative) except as a ceiling on fee *increases*.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: don't ever send 0 fee_updates (regtest bug).
2021-07-09 07:26:09 +09:30
Rusty Russell 063366ed7e listinvoices: support listing by local offer_id.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 2cb16a65c4 invoices: display the payer note if it's for local offer, allow in fetchinvoice.
We don't do it for sendinvoice (yet?).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `fetchinvoice` can take a payer note, and `listinvoice` will show the payer_notes received.
2021-07-03 12:13:45 +09:30
Rusty Russell 12dd3a439b offers: include the payer_note field in the invoice if it's in the request.
And list it in bolt12-cli decode, and the `decode` command.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 18b6aa5e66 BOLT 12: update to include replace_invoice options.
We don't support it (yet), but update the spec to include it.

We include the previous field (recurrence_signature) as a shim for the
moment, for compat with existing nodes.  It's ugly, but next release
we'll stop *sending* it, then finally we'll stop accepting it!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell f9fe814ea3 offers: signatures are now optional.
As per latest spec revision.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: BOLT12 offers can now be unsigned, for really short QR codes.
2021-07-03 12:13:45 +09:30
Rusty Russell 6336d39a95 features: renumber from 102/103 to 38/39.
100+ is for experimentation, modern spec practice is to assign feature bits
sequentially as PRs get added, to avoid later renumbering.

Still respect the old bit for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 38fafc7d6d libplugin: create debug message for notifications
Makes it easier to post-mortem in the logs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 3657f26163 pytest: test for autoconnect in different circumstances.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell 8e3783a995 pytest: test that we try direct connection even for public nodes.
And even if we can't find *ourselves* because we have no channels
(we won't be able to pay, sure, but we can request an invoice!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-03 12:13:45 +09:30
Rusty Russell c974fbf0f1 fetchinvoice: try to connect to note if we can't find a path for messages.
This also adds a `fetchinvoice-noconnect` option to suppress it too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `fetchinvoice` and `sendinvoice` will connect directly if they can't find an onionmessage route.
Fixes: #4624
2021-07-03 12:13:45 +09:30
Rusty Russell 33a40ca73b listinvoice: populate local_offer_id when iterating whole db.
And add the local_offer_id to the schemas too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: JSONRPC: `listoffers` now shows `local_offer_id` when listing all offers.
2021-07-03 12:13:45 +09:30
Rusty Russell 68962083e7 listinvoice: don't crash if listinvoice given a non-bolt11 string.
Discovered by the next test, oops.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSONRPC: `listinvoice` no longer crashes if given an invalid (or bolt12) `invstring` argument.
2021-07-03 12:13:45 +09:30
Michael Schmoock 9a48221892 fix: remove spammy debug statements from getroute
Fixes #4617
https://github.com/ElementsProject/lightning/issues/4617

Changelog-None
2021-07-01 12:14:33 -05:00
Rusty Russell 85562db432 lightningd: print out what errno we got if unexpected in sigchild.
Looking at #4575, I'm not sure what happened.  This prints it out, at least.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-30 14:12:49 +09:30
Rusty Russell 8f33f46960 closingd: use a more accurate fee for closing fee negotiation.
We were actually using the last commit tx's size, since we were
setting it in lightningd.  Instead, hand the min and desired feerates
to closingd, and (as it knows the weight of the closing tx), and have
it start negotiation from there.

This can be significantly less when anchor outputs are enabled: for
example in test_closing.py, the commit tx weight is 1124 Sipa, the
close is 672 Sipa!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: Use a more accurate fee for mutual close negotiation.
2021-06-30 14:12:24 +09:30
Rusty Russell 1a74d8284c common: log at debug level when we update billboard.
Makes for easier postmortem.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-30 14:12:24 +09:30
Rusty Russell e27eaa9343 lightningd: fix typo in debug statements.
Show amount they were trying to pay with, not invoice amount.
Also, show min fee in closing, not fee they offered.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-30 14:12:24 +09:30
Rusty Russell c1ad7ac5cb pytest: fix weird case in test_closing_different_fees
We set amounts to a list, but then don't use the values except
as a boolean.

Make it a boolean, which should also speed the test up!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-06-30 14:12:24 +09:30
nathanael a8d2336ab9 doc: fix
lightning-config(5) -> lightningd-config(5)
< <email> > -> <<email>> in markdown files
2021-06-30 09:43:23 +09:30
nathanael 8167af553e sort alphabetically 2021-06-28 14:43:47 +09:30
nathanael bb64af1a33 add binaries to gitignore 2021-06-28 14:43:47 +09:30
Christian Decker 5f9e5d598e pytest: Add test for keysend extra-tlvs 2021-06-26 10:55:13 +09:30
Christian Decker a4e3773408 pyln: Add wrapper for the keysend command 2021-06-26 10:55:13 +09:30
Christian Decker b5291179e0 keysend: Accept a payment with unknown even TLV types
This is because we might allow the main daemon to transparently handle
these extra TLVs too.
2021-06-26 10:55:13 +09:30
Christian Decker 93b6c6f352 keysend: Add `extra-tlvs` option to keysend
Changelog-Added: keysend: You can now add extra TLVs to a payment sent via `keysend`
2021-06-26 10:55:13 +09:30
Christian Decker aba9af9e12 tlv: Add sorting of the tlvstream
So far we didn't need this since we were adding them in the correct
order. Now we have multiple possible origins so we better sort them.
2021-06-26 10:55:13 +09:30
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