Commit Graph

15009 Commits

Author SHA1 Message Date
Rusty Russell
1a4256842c fetchinvoice: handle blinded paths in offers.
We iterate through the blinded paths until we can use one, and because we use
the modern code, we properly join paths if we need to route more than one hop
to reach the start of the blinded path.

Changelog-EXPERIMENTAL: fixed: fetchinvoice tries all blinded paths until one is usable, and handles case where we have to route more than one hop to reach the entry point.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
ef641e81c6 fetchinvoice: don't stash path in sent object, hand directly.
Simplification.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
a6cfdea71b fetchinvoice: use common/onion_message routines.
This is significantly simpler, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
386f7ab64c plugins/offers: don't establish_onion_path at start of processing invoice_request
send_onion_reply() does that for us now, so we don't need to do it up-front.

Simplifies the code quite a bit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
a43705194d plugins/offers: make send_onion_reply() handle making transient connections.
And make it use inject_onionmessage.  This means we have to be more careful
in createinvoice_done where we had a payload field allocated off tmpctx.

The new code correctly handles the case where we find a path (not just
a peer!) to the start of a blinded path, and need to join the paths.

It worked before if we had to connect directly, just not in the case
where we actually found a usable route of more than 1 hop.

Changelog-EXPERIMENTAL: fixed: onionmessage replies now work even if we need to route to the start of the blinded reply path.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
fa9574da6e plugins/offers: use common/onion_message routines in invoice_request handling.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
8c81d6a0b9 plugin/offers: add inject_onionmessage helper.
This will obsolete the existing calls to RPC "sendonionmessage", but
we transition by introducing it separately.  It's designed to work with
the common/onion_message routines and "injectonionmessage".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
eee7344bf2 common/onion_message: new unified, documented routines for making onion messages.
This is complicated, and I needed to write it down.  All the current routines
are spread through the code, and I wanted it all in one place.

This implementation also support *joining* two paths together, which we
previously didn't.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
d664d52342 plugins/offers: neaten fetchinvoice integration.
We already parse some fields, so hand them directly rather than
having fetchinvoice behave as if it's a raw hook.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-17 10:57:11 +02:00
Rusty Russell
a782ea75b5 plugins: move fetchinvoice functionality into offers plugin.
This means only a single gossmap, and they already share the fetchinvoice-noconnect option
and autoconnect code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: the `fetchinvoice` plugin has been combined into the `offers` plugin.
2024-07-17 10:57:11 +02:00
ShahanaFarooqui
1e1d072b65 ci: Adding new step to run basic tests on minimum supported BTC version
As suggested by @rustyrussell, Adding another step for testing minimum supported Bitcoin version with clang test suite.

Changelog-None.
2024-07-16 16:10:51 -05:00
ShahanaFarooqui
57814766bc doc: Update README for BTC min version 2024-07-16 16:10:51 -05:00
Dusty Daemon
21bc89f189 splice: Add funding outnum
Fixes #7005

Changelog-Changed: Added outnum of new funding output to splice_signed RPC command
2024-07-15 13:31:01 -05:00
ShahanaFarooqui
d77301c338 git: Ignore .doc_version
With recent updates in PR #7444, the file is created but should not be uploaded to git.

Changelog-None.
2024-07-15 13:00:48 -05:00
Rusty Russell
e910418373 Makefile: check formatting of notification schemas too.
We had an extra space, which should have been caught!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-12 17:30:14 -07:00
Rusty Russell
418887b24a doc: fix up added versions for notification schemas.
The *schemas* were added in v24.05, but the actual fields are much older.  Unfortunately,
fixing this required a manual edit of the .msggen.json file, as msggen won't let the
added version change (for good reason).

Versions when these notifications were originally added:
connect: v0.6.3
channel_opened: v0.7.2.1:
channel_state_changed: v0.9.1
channel_open_failed: v0.9.3
block_added: v22.11
custommsg: v24.02

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-12 17:30:14 -07:00
Vincenzo Palazzo
05f5976a9c bolt12: partial support for minimal offer
Making sure that we are able to fetch the invoice
from an offer without description

E           pyln.client.lightning.RpcError: RPC call failed: method:
offer, payload: {'amount': '2msat'}, error: {'code': -32602, 'message':
'bolt12: Offer does not contain a description: invalid token
\'"lno1qgsqvgnwgcg35z6ee2h3yczraddm72xrfua9uve2rlrm9deu7xyfzrcgqyppvggz953rvg9rtxj8lalh43z8epwydjfrmffn3y3p5qz5cywpu09rr4vs"\''}

Link: https://github.com/ElementsProject/lightning/issues/7405
Link: https://github.com/ElementsProject/lightning/issues/7404
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-07-11 14:51:56 +09:30
Rusty Russell
029034a71b config: onion messages are now always enabled.
Changelog-Added: Protocol: onion messages are now supported by default.
Changelog-Deprecated: Config: the --experimental-onion-messages option is ignored (on by default).
2024-07-10 13:34:00 +02:00
Rusty Russell
5d42600076 connectd: ratelimit onion messages
However fast we can handle them, it's antisocial to allow others to
make us spam the rest of the network.

Changelog-Protocol: onion messages: we limit incoming to 4 per second, allowing a little burst.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Rusty Russell
621bfe370e connectd: forward onion messages by scid as well as node_id.
This is now permitted in the offers PR, so we should support it.  But
we can't just look up in the gossmap, since the "short_channel_id"
could be an alias.  So we get lightningd to tell us all scid->peer
mappings, and look up in that.

Changelog-Added: Protocol: onion messages can now be forwarded by short_channel_id.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Rusty Russell
19af516dcb lightningd: tell connectd about all scids.
When we set them (i.e. at lockin), when we fire up channeld (for
aliases, which we create at channel init, but aren't really useful
until we have finished channel opening), and at startup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Rusty Russell
f122c0beb4 connectd: include map of scid->peer node id.
This will let us fwd onion messages via scid, even if they're aliases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Rusty Russell
b5f921ce0a lightningd: add routine to directly inject an onion message.
Unlike "sendonionmessage" which instructs us to send to a peer, this
process it locally (presumably, it contains the next hop).  This is
useful because it allows us to process an onion message which starts
with us (a legal case for a blinded path supplied by someone else!).
It also opens the door to bolt12 self-pay.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Rusty Russell
ba82592196 common/onion_message_parse: return string, not bool.
Allows for caller to log, but more importantly, when we add a command to
inject onion messages, allows for us to capture the error.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 13:34:00 +02:00
Tommy Volk
a3c15e8a4a chore: add ShortChannelId::to_u64 2024-07-10 11:49:19 +02:00
Rusty Russell
242ecbc906 Makefile: only run cppcheck on non-generated files.
For some reason CI now hits a race where it tries to analyze a still-being-generated file:

```
tools/headerversions.c:52:30: error: syntax error [syntaxError]
 new = tal_fmt(NULL, template,
                             ^
make: *** [Makefile:552: check-cppcheck] Error 123
```

Restrict it to real source files instead.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
47584bd504 connectd: tie gossip query responses into ratelimiting code.
A bit tricky, since we get more than one message at a time.  However,
this just means we go over quota for a bit, and will get caught when
those are sent (we do this for a single message already, so it's not
that much worse).

Note: this not only limits sending, but it limits the actuall query
processing, which is nice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
4a78d17748 connectd: do response to gossip queries, don't hand them to gossipd.
This basically means moving the code from gossipd to connectd to handle
these queries.

This will get connectd have finer control over ratelimiting them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
531845971c gossipd: drop zlib support.
This was removed from the spec on Apr 25, 2022.  We stopped ever sending them
in 0.12.0 (2022-08-23).  Now we remove receive support.

Changelog-Protocol: Removed support for zlib-compressed short-channel-ids in query responses.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
d60977f37f connectd: use gossmap streaming interface.
This is more efficient in a few ways:
1. It's trivial to get to the end of the gossip_store, we don't have
   to iterate.
2. It tends to be mmaped so we don't have to call pread().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
ba2bb5531d gossmap: add linear streaming interface.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
ae5ad486ea gossipd: delete empty gossipd_peerd_wire.csv
gossipd no longer connects directly to per-peer daemons, so remove old file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
401533667d connectd: throttle streaming gossip for peers.
We currently stream gossip as fast as we can, even if they start at
timestamp 0.  Instead, use a simple token bucket filter and only let
them have 1MB per second (500 bytes per second for testing).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Protocol: connectd: we now throttle outgoing gossip at 1MB/second per peer.
2024-07-10 12:21:19 +09:30
Rusty Russell
7f71e6353a doc: fix schema for listconfigs.
We never call `listconfigs` in our tests with `experimental-offers` enabled,
so we didn't notice that the schema is wrong: it does not expect the
"plugin" field in 'fetchinvoice-noconnect'.

The next patch folds the fetchinvoice plugin into the offers plugin,
which is enabled even if `experimental-offers` isn't (for `decode`),
so we notice it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
991f6dcb0f config: actually deprecate --experimental-anchors.
Document and enforce the --experimental-anchors deprecation, which was somehow missed in v24.02

Changelog-Deprecated: Config: the --experimental-anchors option is ignored (on by default since v24.02).
2024-07-09 15:09:29 +02:00
Rusty Russell
0c7ce27a39 plugins/offers: establish_onion_path can have a simple boolean arg for connect_disable.
It's always the same string, so simplify the interface.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
34052f9960 bitcoin: hoist scid hash into common code.
A second user is coming.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
fa0926148d common: make struct sphinx_hop more generic.
Only sphinx internally uses the hmac field: it's actually a general descriptor
of onion contents, which we can use elsewhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
5e585d061f connectd: log incoming onion message IO properly.
I noticed we were missing this.  Move logging up a level so it's easier to
spot the omission.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
d7fa88b686 lightningd: clarify bolt12 "payment secret" logic.
We don't use the payment_secret in bolt12, but in onion_decode() we
do put the path_secret (if of correct length) into payment_secret.  Not
realizing this confused me, so document that, and make sure we insist
on it being present for bolt12.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
4647f3c2a3 common: don't pass (unused) has_realm parameter to process_onionpacket.
This was when we handled pre-TLV onions where the first byte was 0.  We haven't
done that for a while: you can tell, because process_onionpacket doesn't use
the parameter at all!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
f64d48e716 plugins/pay: fix crash if we try to self-pay a bolt12 invoice.
It doesn't work but at least now it doesn't crash!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
ec2b626630 plugins/pay: don't crash if getroute is empty.
This can't happen because we go the self-pay path in this case, but
once we fix that for bolt12, this can be reached.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
162ebe2a72 global: we always offer OPT_ROUTE_BLINDING, don't need to test.
We did since v23.05.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
01cd605cb1 connectd: fix missing peer close.
We were getting the following message in test_feerate_stress:

```
2024-07-08T02:15:45.5663941Z lightningd-2 2024-07-08T02:13:45.696Z **BROKEN** 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Peer did not close, forcing close
```

I can reproduce it locally if I run the test enough, and finally found
the issue by printing the status of the fd when we time it out (using
routines from connectd.c).

The peer fd alternates between reading and writing.  When we go to
discard it, we wake the write queue, so write_to_peer() get called.
It won't shutdown the socket if there are still subds attached, and
will wait again for a read.

The last subd exit has to also wake the write queue if we're draining,
so it can do the io_sock_shutdown.  Otherwise, we hit the timeout,
causing the message above.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 18:03:44 +09:30
Rusty Russell
578b297d46 ccan: update to get fdpass fix.
Theoretical only, but we could leak an fd if we closed a conn before
the fd was sent.  This doesn't happen in our current codebase because
we only hand fds to connectd, which only closes at shutdown.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 18:03:44 +09:30
Rusty Russell
6f8754a72b common/msg_queue: make sure to close any pending fds on destruction.
We only hand fds to connectd for now, so this doesn't happen (we don't
destroy that queue except on shutdown).  But it's still a potential issue.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 18:03:44 +09:30
Rusty Russell
5a5fee92b3 connectd: don't report socket fds twice.
The initial commit had this code twice, for some reason!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 18:03:44 +09:30
jackstar12
feaac0eb4f msggen: add missing-grpc command 2024-07-06 09:05:08 +09:30
ShahanaFarooqui
4b69c57d75 plugins: Remove requirements.txt for python plugins
Removing requirements.txt from clnrest and wss-proxy plugins due to their ever changing dependencies. We will only be dependent on pyproject.toml for more stable results.

Reference: https://github.com/ElementsProject/lightning/pull/7416#issuecomment-2181492069

Changelog-None.
2024-07-03 12:20:05 -07:00