Commit Graph

16560 Commits

Author SHA1 Message Date
daywalker90
e3e41163e2 cln-bip353: add plugin that fetches payment instructions from human readable addresses
Changelog-Add: new plugin cln-bip353 that can fetch BIP-353 payment instructions from human readable addresses
2025-08-14 18:41:23 +09:30
Matt Whitlock
9112c1d518 common/json_parse_simple: make convenience functions inline
json_tok_streq(…) and json_get_member(…) are convenience wrappers for
json_tok_strneq(…) and json_get_membern(…) respectively. Unfortunately, using
them incurs a performance penalty in the common case where they are called with
a string literal argument because the compiler is unable to substitute a
compile-time constant in place of the buried call to strlen(…).

For example,

	json_get_member(buf, tok, "example");

…will have worse performance than…

	json_get_membern(buf, tok, "example", strlen("example"));

…because the former is forced to scan over "example" at run-time to count its
length whereas the latter is able to elide the strlen(…) call at compile time.

Hoist these convenience functions up into common/json_parse_simple.h and mark
them as inline so that the compiler can elide the strlen(…) call in the common
case of calling these functions with a string literal argument.

Changelog-None
2025-08-14 17:53:39 +09:30
Rusty Russell
5f5440383d lightningd: fix race with crossover pings.
We cannot use subd_req() here: replies will come out of order, and the
we should not simply assign the reponses in FIFO order.

Changelog-Fixed: lightningd: don't get confused with parallel ping commands.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 17:35:39 +09:30
Rusty Russell
a0fd72eb5e connectd: warn if we ignore peer incoming for longer than 5 seconds.
One reason why ping processing could be slow is that, once we receive
a message from the peer to send to a subdaemon, we don't listen for
others until we've drained that subdaemon queue entirely.

This can happens for reestablish: slow machines can take a while to
set that subdaemon up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 17:35:39 +09:30
Rusty Russell
0938d544ed gossipwith: add flag to insist that we receive all messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 17:35:39 +09:30
Rusty Russell
c88ec27de3 pytest: test xpay notifications.
The custom_notifications handler produces really ugly results, and I
was lazy, but it works!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 16:52:44 +09:30
Rusty Russell
e24bd9685a xpay: add pay_part_start and pay_part_end notifications.
Requested-by: Michael at Boltz
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Plugins: `xpay` now publishes `pay_part_start` and `pay_part_end` notifications on every payment send attempt.
2025-08-14 16:52:44 +09:30
Rusty Russell
4c23cf296c libplugin: correctly mark that plugin_notification_end STEALS the stream.
And also slightly generalize: plugin_notification_start() can take any
tal ptr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 16:52:44 +09:30
Rusty Russell
80309dfbe6 common: add json_add_timerel helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 16:52:44 +09:30
Dusty Daemon
052f36cf2e connectd: Implement sending of start_batch
Implement the sending of `start_batch` and `protocol_batch_element` from `channeld` to `connectd`.

Each real peer wire message is prefixed with `protocol_batch_element` so connectd can know the size of the message that were batched together.

`connectd` intercepts `protocol_batch_element` messages and eats them (doesn’t forward them to peer) to get individual messages out of the batch.

It needs this to be able to encrypt them individiaully. Afterwards it recombines the now encrypted messages into a single message to send over the wire to the peer.

`channeld` remains responsible for making `start_batch` the first message of the message bundle.
2025-08-14 16:40:04 +09:30
Dusty Daemon
3841737d5c channeld: Cleaner error messages
Since handling commit sig batches is coming for multiple locations now, add more explicity error handling so log messages are more useful.
2025-08-14 16:40:04 +09:30
Dusty Daemon
7eb2add23c channeld: Implement receiving of start_batch
Since `batch_size` has moved into this new message, we can’t ignore it anymore and have to process it
2025-08-14 16:40:04 +09:30
Dusty Daemon
e755be0c4c splice: Remove batch_size from commitment_signed
The new spec sends `batch_size` in `start_batch` and removes it from `commitment_signed` so we need to stop processing it in `commitment_signed`.

Since the tlv is now reduced to one element and that automagically turns it into a direct use TLV so we have to update the code everywhere it is referenced.
2025-08-14 16:40:04 +09:30
Dusty Daemon
07f4bc39b1 splice: Add start_batch and an internal wire type
We add `start_batch` to match t-bast’s splicing spec and we add a new internal wire type `WIRE_PROTOCOL_BATCH_ELEMENT` using the type number 0

Changelog-Added: support for `start_batch`
2025-08-14 16:40:04 +09:30
Rusty Russell
f265a956c7 pytest: test persistence of old scids, even if we spliced multiple times.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
d1f56eb668 lightningd: use the hash table to lookup scids.
This replaces the old "iterate through each peer, then each peer's channel" suboptimality.

A bit of care required that we don't expose scids if we're forwarding,
but that was already carefully handled.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
5e263bac78 lightningd: require local_alias in new_channel().
We allowed NULL for stub channels, but just don't put the stub scid
into the hash tables.  This cleans up all the callers to make it
clear this is a non-optional parameter.

We opencode channel_set_random_local_alias, since there's only one caller now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
bb4dda6f5a wallet: we can assume local_alias field is non-null.
We have a migration which ensures this, but then I discovered that did
*not* address channels without an SCID yet.  So fixed the migration, and
simpligied the code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
639452ac77 bitcoin: have random_scid() function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
ab80345754 lightningd: maintain a hash table of short_channel_id, for faster lookup.
This contains real scids, as well as aliases, and old scids.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
d70fc13b54 lightningd: consider old scids when looking up channels (for routing).
Changelog-Fixed: Protocol: we now allow routing through old short-channel-ids once a splice is done (previously we would refuse, leading to a 6 block gap in service).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
4abd0af3ec lightningd: save previous short_channel_ids during splice, and keep in db.
There can be any number of these, and it will be useful to allow
routing by older scids (when other nodes haven't seen our gossip, or
even before we *can* announce the new post-splice channel).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
51d6afec40 wallet: remove now-gratuitous counters from update statements.
When we had to use the number to the db_bind call, these annotations made
sense, but since 0bcff1e76d (for v23.08) we
removed that.

So remove all the counters, which are simple overhead if we want to
change something.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Rusty Russell
931924a108 pytest: test if we correctly route using old scids after splice
Spoiler: we don't!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Dusty Daemon
c602a8a54c channeld: Move counting code to its own function
Counting remote inputs needing sigs can be in its own method
2025-08-14 04:12:17 +09:30
Dusty Daemon
a5a71f3b22 psbt: don’t accumlate 0 lenth widtness data 2025-08-14 04:12:17 +09:30
Dusty Daemon
a17b364c6b splice: Test for two channel splice
A python test that splices into two channels at the same time with on transaction.

Changelog-Added: Adding support for cross-channel splicing.
2025-08-14 04:12:17 +09:30
Dusty Daemon
122dae1076 splice: Even if the psbt’s “match” the sig data may vary
Since the signature data may vary, we must copy the new psbt into splicing->current_psbt.

This never occured during normal operation, but when doing a cross splice there may be vital signature(s) in the psbt that came from another splice that get dropped without this step.
2025-08-14 04:12:17 +09:30
Dusty Daemon
2e660d9f06 splice: Fix cross-channel splices
When doing a cross channel splice, inputs move from having no SIGHASH to having SIGHASH_ALL assigned.

This causes psbt_get_changeset to flag the input as having changed, as the sighash value is compared.

This causes the second channel splice to `tx_remove_input` the input as it doesn’t match anymore, breaking the splice.

We fix this by removing the sighash value from input comparisions.
2025-08-14 04:12:17 +09:30
Dusty Daemon
286124e3d9 interactive_tx: Add verbose logging
Adding verbose logging option to introspect into what interactive tx is doing with inputs.
2025-08-14 04:12:17 +09:30
Dusty Daemon
8783f3c035 splice: Add details to log message
Add more information to funding issue failure messages when splicing
2025-08-14 04:12:17 +09:30
Dusty Daemon
e3e0813552 splice: Sign shared output early
When doing a multi channel splice, we need to break the deadlock by signing the shared output early (even though it is not sent to the peer until later).
2025-08-14 04:12:17 +09:30
Dusty Daemon
dd1e183b8a splice: Change abort rules to sent sigs
Previous behavior was to fail on abort when we have signatures in the inflight — change this behavior to fail on abort if we have sent our peer our signatures.
2025-08-14 04:12:17 +09:30
Dusty Daemon
d84d0f70d5 splice: Track if splice sigs are sent
Use the new i_sent_sigs field to track if we’ve sent our peer our user sigs.
2025-08-14 04:12:17 +09:30
Dusty Daemon
a8ff8ce717 splice: Add field to DB to track if we’ve sent sigs
We used to use a check on the active psbt to see if our splice signature was in it — but now we need to generate the signature early.

So we have to add a field tracking if we’ve sent it and add it to the database, wire protocols, and inflight objects.
2025-08-14 04:12:17 +09:30
Dusty Daemon
87ae35597d splice: Add details to log message
Make the failure reason more clear by adding more information to the signature failure message.
2025-08-14 04:12:17 +09:30
ShahanaFarooqui
2e58ed6f23 docs: Added json_object and json_group_array to permitted_sqlite3_functions list 2025-08-13 15:52:53 +09:30
ShahanaFarooqui
bab6429da0 tests: add sql json function tests 2025-08-13 15:52:53 +09:30
ShahanaFarooqui
d5c73185aa plugin: Allow json_object and json_group_array functions in sql plugin
Changelog-Added: Plugins: `sql` also supports functions `json_object(key1, value1, ...)` to construct JSON objects and `json_group_array(value)` to aggregate rows into JSON array.

Security Considerations
- No new SQL injection risks: Functions only process explicitly provided column values (no arbitrary string parsing).
- Explicit column requirements: Wildcards (*) are not supported, all fields must be named (e.g., json_object('peer_id', id)).
- Permission-bound data access: Functions adhere to the same table/row permissions as the underlying query.

Performance Impact
- Optimized native execution: Leverages SQLite’s built-in JSON1 extension (when available) for efficiency.
- Moderate CPU overhead: Complex nesting may impact performance on large datasets but still faster than application-layer JSON conversion.
2025-08-13 15:52:53 +09:30
Rusty Russell
b3774d4d6f openingd: remove compat hacks to "intuit" opt_scid_alias.
This was needed for v23.05 which would set opt_scid_alias even if we didn't.

Now everyone handles it properly, we can simply set it unconditionally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Protocol: backwards compatibility allowances for CLN before 23.08 which didn't handle option_scid_alias properly.
2025-08-13 14:20:28 +09:30
Rusty Russell
506fa914e0 lightningd: always tell openingd/dualopend what channel type we want.
Prior to it being compulsory, these daemons would need a default value.  Now it's
always required, it's clearer if it's always told.

There's no "default_channel_type" now everyone has to specify channel_type either,
so rename it to "desired_channel_type" and put it in lightningd specifically.

Note that the channel_type can have options added: either option_scid_alias or option_zeroconf.

This results in a slight behavior change: we will get type zeroconf even if we didn't ask for it, if they gave it to us.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: fundchannel / fundchannel_start returned `channel_type` will include option_zeroconf if it was implied by a 0 minimum_depth, even if we didn't explicitly ask for a zero conf channel.
2025-08-13 14:20:28 +09:30
Rusty Russell
a7316fef83 pytest: actually test channel_type when negotiating prviate channel.
Makes sure we don't break it!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-13 14:20:28 +09:30
Rusty Russell
193ac6fc77 pytest: test what happens if we *explicitly* ask for a zeroconf channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-13 14:20:28 +09:30
Rusty Russell
7893c878b1 pytest: use _ not - in plugin options to zeroconf-selective.py.
This allows us to specify:

	l2.rpc.plugin_start(plugin_path, zeroconf_allow=l1.info['id'])

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-13 14:20:28 +09:30
Rusty Russell
cd90576f88 openingd/dualopend: don't allow peer not to send channel_type.
Simplifies our logic somewhat.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-13 14:20:28 +09:30
Rusty Russell
4e94a6cb2b lightningd: make option_channel_type compulsory.
As per BOLT recommendation https://github.com/lightning/bolts/pull/1232, this means
we will insist on this being available.

For CLN, we added this in 0.12.0 (2022-08-23), though there were fixes as late as 24.02. Either way that's well outside our support window.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Closes: https://github.com/ElementsProject/lightning/issues/8152
Changelog-Changed: Protocol: We now insist that peers support `option_channel_type` (in CLN since 0.12.0 in late 2022, similar for other implementations).
2025-08-13 14:20:28 +09:30
Dusty Daemon
5a98d1bdf4 docs: Update the developer getting started guide
Push the beginer to the more useful `fund_nodes` instead of `connect`

Changelog-None
2025-08-12 21:03:03 -07:00
Alex Myers
ebbe5a274d reckless: add uv installer support for legacy projects
Those that only have a requirements.txt can be installed
with uv even if it's not managing the project requirements.
2025-08-12 09:28:21 +09:30
Alex Myers
d427a6644e pytest: test python plugin installation via uv 2025-08-12 09:28:21 +09:30
Alex Myers
542b54c649 pytest: refactor reckless check_stderr 2025-08-12 09:28:21 +09:30