Commit Graph

16573 Commits

Author SHA1 Message Date
Rusty Russell
a25c1d45ad libplugin: make jsonrpc_set_datastore_binary() take an explicit length.
This means it doesn't have to be a tal ptr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 19:49:09 +09:30
Rusty Russell
ed77edf4c6 db: better diagnostics when a query fails.
Print the error!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 19:49:09 +09:30
Rusty Russell
9b4a7085c2 pytest: save pre-movement dbs, and accounting dbs.
We can use these to test migrations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 19:49:09 +09:30
Rusty Russell
6fbc5d02ca common/htlc_wire: add towire/fromwire helpers for wrapped tlv streams.
And make sure we check the length properly in fromwire!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 18:57:05 +09:30
Rusty Russell
63065aa99c common: handle taken() extra_tlvs in new_existing_htlc properly.
Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 18:57:05 +09:30
Peter Neuroth
5c1fd782ec tools: Remove lockfiles from spell-checking
The rare case happened where a lockfile sha-sum contained a "Ctlv" which
spell-check complained about. Stupid lockfiles that don't know it is
actually "cltv"!

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
5e620cabce tools: Filter "highlight" case insensitive
There was a problem with a ‘highlight’ that was misunderstood as a
spelling mistake in lib-wally. Since ‘hightlight’ is already filtered
out, we simply instruct grep to ignore upper/lower case when filtering.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
40c01ea21b docs: Add extra_tlvs to the htlc_accepted_hook doc
Changelog-Added: The `htlc_accepted_hook` now gets the TLV-stream
attached to the HTLC passed through as `extra_tlvs` and can replace it.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
dbbb113123 tests: Add tests for extra_tlvs in hook
Adds some testcases for custom tlvs, set by a htlc_accepted_hook. We
check that the custom tlvs replace the update_add_htlc_tlvs and get
forwarded to the peer. We also check that a malformed tlv will result in
a **BROKEN** behaviour.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
2264b93c6c lightningd: Add extra_tlvs to htlc_accepted_hook
Add serializing and deserializing of the extra tlvs to to the
htlc_accepted_hook to allow plugin users to replace the tlv stream that
is attached to the update_add_htlc message on forwards.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
ef52de88aa channeld: Add extra_tlvs to incomming wire msg
This appends the extra_tlvs to the internal channeld_offer_htlc wire
msg. We also recombine the extra_tlvs with the blinded path key for
forwarding htlcs.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
631a1d950f channeld: Add extra_tlvs to wire htlcs
This appends the extra_tlvs to the internal wire htlcs "added" and
"existing" for the extra tlvs to be handed to lightningd.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
Peter Neuroth
f4cc633c6f channeld: add extra_tlvs from update_add_htlc msg
We currently only consider known tlv types in the internal
representation of a htlc. This commit adds the remaining unknown tlv
fields to the htlc as well. This is in prepareation to forward these to
the htlc_accepted_hook.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-08-14 18:57:05 +09:30
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