Commit Graph

16440 Commits

Author SHA1 Message Date
Chandra Pratap
e721b0a89a fuzz-tests: Enhance b64_encode() validation with roundtrip decoding
Changelog-None: Currently, fuzz testing for b64_encode() merely
encodes input and frees the result, providing no real verification
of its behavior.

Introduce a new b64_decode() function (modeled after b32_decode())
and update the fuzz test to perform a roundtrip—encoding followed
by decoding—to ensure that b64_encode() correctly preserves the
original data.
2025-07-08 12:54:56 +09:30
Dusty Daemon
b4d0da5ff4 logs: A basic javascript log viewer
A basic javascript tool for filtering through large CLN log files.

Changelog-Added: A new tool for rendering CLN log files in the browser.
2025-07-08 12:24:24 +09:30
Matt Whitlock
cc0f66f07b hsmtool: implement new "derivetoremote" method
This method has a similar purpose as "guesstoremote" but is for use when
the channel's database ID is known. It produces the private key that can
spend the to_remote output of the peer's commitment transaction. It
assumes the channel was negotiated with option_static_remotekey unless
the optional per-commitment point argument is provided.

Changelog-Added: hsmtool has a new `derivetoremote` method.
2025-07-08 12:21:24 +09:30
Erick Cestari
6724db65de BOLT11: Make payment secret field ('s') mandatory
Make the payment secret field ('s') mandatory for BOLT11 payment requests,
implementing the requirement specified in BOLT11 spec PR #1242
(https://github.com/lightning/bolts/pull/1242).

This security enhancement prevents payment probing attacks by requiring
all invoices to include payment secrets. Changes include:

1. Adding validation in bolt11_decode_nosig() to reject invoices without
   the 's' field
2. Adding payment secrets to all test vectors
3. Updating expected encoded values in test cases to include payment secrets
4. Adding a specific test case that verifies proper rejection of invoices
   missing the payment secret field

Changelog-Changed: Made payment secret ('s' field) mandatory in BOLT11 payment requests for improved security.
2025-07-07 11:18:37 +09:30
Rusty Russell
66b6c111c2 pytest: fix up bolt11 tests to include s field.
It's about to be made compulsory.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
2b023be022 bolt11: don't accept wrong-length p, h, s or n fields.
Spec got stricter.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
17b3fb5196 common/bolt11: meet the new tighter parsing requirements.
These checks are a SHOULD, but implementing them helps avoid anyone
making such weird things in future.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
c0ff1b5768 lightningd: update comments about known preimages for missing HTLC outputs.
Doesn't change anything for us, since we will already fulfull the incoming
HTLCs if we can, but good to note.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
9298e5c212 wire: use real peer_storage messages now their format is fixed.
They weren't formatted correctly for bolts/tools/extract-formats.py
until this commit, so we had to patch them in manually.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
0cd6efe585 wire: update splice patch to produce expected peer_wire.csv.
Dusty patched peer_wire.csv directly, breaking regeneration `make extract-peer-csv`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-07-07 11:18:37 +09:30
Rusty Russell
d86b88d409 channeld: remove experimental-upgrade-protocol.
It was already disabled by Dusty due to a number conflict with splicing, and
the proposal probably needs updating to use quiescence now that is merged.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: The non-functional `experimental-upgrade-protocol` config option.
2025-07-07 11:18:37 +09:30
Rusty Russell
c50bd381ec doc: recommend injectpaymentonion in place of sendonion.
Among other things, injectpaymentonion insists on knowing the destination
amount_msat.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-30 13:23:26 +09:30
Rusty Russell
89f411ca79 doc: be explicit (with tests!) on when we don't know amount_msat for listsendpays.
Sangbida and I traced back through ancient history: when the pay plugin was introduced
in 0.9.0 (2019!) it already used the amount_msat parameter (then called `msatoshi`),
so this case effectively "never happens".

But we added a test for it just in case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-30 13:23:26 +09:30
ShahanaFarooqui
bd743d741e doc: Change commando plugin title
Changelog-None.
2025-06-27 11:08:16 +09:30
ShahanaFarooqui
d52e3c394b doc: Update image on App Development page 2025-06-27 11:08:16 +09:30
ShahanaFarooqui
94bdad19f0 doc: Update json-rpc-api categories due to updated RPC links 2025-06-27 11:08:16 +09:30
ShahanaFarooqui
e5ec688bf4 doc: Fix links to avoid 404 error 2025-06-26 14:21:56 +09:30
ShahanaFarooqui
adbe634453 doc: Update Commando plugin details and link 2025-06-26 14:21:56 +09:30
ShahanaFarooqui
2d73186a1e doc: Move deprecated features page from API reference list to Developer's guide 2025-06-26 14:21:56 +09:30
ShahanaFarooqui
5cc28a84eb docs: Fix script used to update versions in point release instructions
Changelog-None.
2025-06-26 13:58:51 +09:30
Rusty Russell
29230325bd doc: flesh out PR section of coding style guidelines.
Sangbida asked some excellent questions, and rather than answer them once,
I decided to update this document appropriately.  Could probably become
an entire video, TBH.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-25 11:21:11 +09:30
Rusty Russell
46fb007ea0 lightningd: remove experimental-anchors / experimental-onion-messages.
Changelog-Removed: Config: `experimental-anchors` and `experimental-onion-messages` (deprecated 24.02 / 24.08, disabled v25.05).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-25 09:06:31 +09:30
Rusty Russell
50e4aabe18 commando: remove old commando rune commands.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: JSON-RPC: `commando-rune`, `commando-listrunes`, `commando-blacklist` (deprecated v23.08, disabled v25.05).
2025-06-25 09:06:31 +09:30
Rusty Russell
4fc9856cf2 lightningd: remove clnrest override options.
Changelog-Removed: Config: autodetection for rest-port/rest-protocol/rest-host/rest-certs options to clnrest-* (deprecated v23.11, disabled v25.02).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-25 09:06:31 +09:30
Rusty Russell
b3c1728abc lightningd: remove --max-locktime-blocks.
Changelog-Removed: Config: `max-locktime-blocks` (deprecated v24.05, disabled v25.02).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-25 09:06:31 +09:30
Rusty Russell
710d632383 Makefile: update CLN_NEXT_VERSION to v25.09.
Hopefully Antoine Poinset won't have to go on a podcast to argue the
merits for this change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-24 09:57:24 +09:30
Rusty Russell
884778635c deprecations: update v26.05 to v26.06.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Future release schedule moved one month: v25.05 is now v25.06, and all deprecations incremented accordingly.
2025-06-24 09:57:24 +09:30
Rusty Russell
094ac3518f deprecations: update v26.02 to v26.03.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-24 09:57:24 +09:30
Rusty Russell
09e03e98ef deprecations: update v25.11 to v25.12.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-24 09:57:24 +09:30
Rusty Russell
f69fdd2664 deprecations: update v25.08 to v25.09.
There's only one (but in multiple places!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-24 09:57:24 +09:30
Alex Myers
2b8b709bfd meta: update changelog for v25.05
Changelog-None
2025-06-16 13:10:33 -05:00
Alex Myers
acf935e1c8 github: Update release dates for 25.09
Changelog-None
2025-06-16 13:10:33 -05:00
Rusty Russell
f2f7b6e225 pytest: fix flake in test_anchorspend_using_to_remote
With recent changes, particularly using postgres, we can finish the HTLC before
we force close, so the test fails.  Insert an explicit hangup here so we reliably
get the result we expect:

```
    @pytest.mark.parametrize("anchors", [False, True])
    @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd anchors not supportd')
    def test_anchorspend_using_to_remote(node_factory, bitcoind, anchors):
        """Make sure we can use `to_remote` output of previous close to spend anchor"""
        # Try with old output from both anchor and non-anchor channel.
        l4_opts = {}
        if anchors is False:
            l4_opts['dev-force-features'] = "-23"
    
        l1, l2, l3, l4 = node_factory.get_nodes(4, opts=[{},
                                                         {},
                                                         {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']},
                                                         l4_opts])
    
        # Give l2 some funds, from a to-remote output.  It will have to spend
        # this to use anchor.
        node_factory.join_nodes([l4, l2])
    
        # l4 unilaterally closes, l2 gets to-remote with its output.
        l4.rpc.pay(l2.rpc.invoice(100000000, 'test', 'test')['bolt11'])
>       wait_for(lambda: only_one(l4.rpc.listpeerchannels()['channels'])['htlcs'] != [])

tests/test_closing.py:4183: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

success = <function test_anchorspend_using_to_remote.<locals>.<lambda> at 0x7f8293e7fe20>
timeout = 180

    def wait_for(success, timeout=TIMEOUT):
        start_time = time.time()
        interval = 0.25
        while not success():
            time_left = start_time + timeout - time.time()
            if time_left <= 0:
>               raise ValueError("Timeout while waiting for {}".format(success))
E               ValueError: Timeout while waiting for <function test_anchorspend_using_to_remote.<locals>.<lambda> at 0x7f8293e7fe20>

```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-13 13:55:31 -05:00
Rusty Russell
6468d439e0 ccan: update for FreeBSD compile fixes.
Also gets some new timemono helpers, but we don't use them (yet).

Changelog-Fixed: Compilation on FreeBSD.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Closes: https://github.com/ElementsProject/lightning/issues/7758
2025-06-13 12:21:53 -05:00
Alex Myers
9d160eb8fb wallet: load closed channels at init
This seems to have been inadvertently omitted in the recent
closed channel refactor.

Fixes: #8346

Changelog-None: Changed this release.
2025-06-13 11:40:06 +09:30
daywalker90
40d319b7be python: raise minimum supported python version to 3.9
Changelog-None
2025-06-12 13:51:18 +02:00
Rusty Russell
03b4f4778e lightningd: fix log crash on weird escape lines from plugin.
Apparently clboss gives us \u UTF codes.  We don't support that (use UTF-8 directly)

```
126	../sysdeps/x86_64/multiarch/strlen-vec.S: No such file or directory.
(gdb) bt
    label=label@entry=0x63e2f9604db9 "char *[]") at ccan/ccan/tal/str/str.c:137
    complete=complete@entry=0x7ffe9090b0f6, destroyed=destroyed@entry=0x7ffe9090b0f7) at lightningd/plugin.c:773
```

Reported-by: Ken Sedgwick
Fixes: #8338
Changelog-None: broken in this release
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-06-11 08:50:34 -05:00
Rusty Russell
eddb0e3bbd CHANGELOG.md: warn that spec compliance mean we broke splicing.
The TLV numbers for splicing were used by the upgrade protocol, and we always
demarshal TLVs:

```
rusty@rusty-Framework:~/devel/cvs/lightning ((v25.02.1))$ ./devtools/decodemsg 00883d448f5a4d2d82c861a1e60ba317f5c848989d8c92f65833ff85cc82cb96adf500000000000000c600000000000000c559ebae46ed6f64c3e7c0005494bc684a630223d4b942a7e09b76742727b863cc02aac24eb41bbcfd77cb2e75f51bc5d298a6862cd7c2478268aa67572d8a08311801203d448f5a4d2d82c861a1e60ba317f5c848989d8c92f65833ff85cc82cb96adf503203d448f5a4d2d82c861a1e60ba317f5c848989d8c92f65833ff85cc82cb96adf5
WIRE_CHANNEL_REESTABLISH:
channel_id=3d448f5a4d2d82c861a1e60ba317f5c848989d8c92f65833ff85cc82cb96adf5
next_commitment_number=198
next_revocation_number=197
your_last_per_commitment_secret=59ebae46ed6f64c3e7c0005494bc684a630223d4b942a7e09b76742727b863cc
my_current_per_commitment_point=02aac24eb41bbcfd77cb2e75f51bc5d298a6862cd7c2478268aa67572d8a083118
channel_reestablish={
type=1
len=32
(msg_name=next_to_send)
commitment_number=**TRUNCATED tu64 channel_reestablish.channel_reestablish.commitment_number**
**TRUNCATED TLV channel_reestablish.channel_reestablish**
Segmentation fault (core dumped)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Closes: #8337
2025-06-11 08:15:56 -05:00
Matt Whitlock
3f6cd59dc9 gossipd: check for existing channel announcement before sigcheck
Checking a signature is a CPU-intensive operation that should be performed only
if gossmap doesn't already have the channel announcement in question and we're
not already checking for the announcement's UTxO.

Changelog-Fixed: `gossipd` doesn't waste CPU cycles checking signatures on channel announcements that are already known
Issue: https://github.com/ElementsProject/lightning/issues/7972
2025-06-10 16:40:33 -05:00
ShahanaFarooqui
ae320cd8d2 CI: Update Ubuntu version from 20 to 22 for Github Actions
Ubuntu 20.04 reached its end-of-life (EOL) on April 15, 2025, and GitHub Actions subsequently removed the Ubuntu 20.04 LTS runner. As a result, we must upgrade all workflow runners to at least Ubuntu 22.04. Currently, this update has only been applied to pypi.yml for core-lightning.

Changelog-None.
2025-06-09 14:24:53 -05:00
ShahanaFarooqui
ad2dc972de ci: Fix noble repro build by updating sqlite3 version and shasums
The reproducible build is currently failing on Ubuntu Noble, causing the daily `Repro Build Nightly` GitHub action to fail and triggering email notifications.

This update resolves the issue by adjusting the default sqlite3 version and checksums to match the packages now available in Noble, allowing the image to build successfully.

Changelog-None.
2025-06-05 17:38:55 -05:00
daywalker90
b97278fb9a python: upgrade grpcio-tools to 1.69.0 and protobuf to 5.29.4 for python3.13 compatibility
Changelog-None
2025-05-21 10:58:15 -05:00
Alex Myers
2c2fbe36e1 meta: update changelog for 25.05rc1 2025-05-19 14:12:55 -05:00
Alex Myers
8d6ae149ff release: update version for 25.05rc1
Changelog-None
2025-05-19 14:12:55 -05:00
Rusty Russell
f68feaeb37 pytest: fix races now connecting is slightly slower.
We asserted that a node would be connected, but now we always call the
chanbackup peer_connected hook, it might not be that fast:

```
2025-05-17T08:37:58.7193306Z     def test_funding_fail(node_factory, bitcoind):
...
2025-05-17T08:37:58.7204037Z         # Restart l2 without ridiculous locktime.
2025-05-17T08:37:58.7204546Z         del l2.daemon.opts['watchtime-blocks']
2025-05-17T08:37:58.7204990Z         l2.restart()
2025-05-17T08:37:58.7206578Z         l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2025-05-17T08:37:58.7207072Z     
2025-05-17T08:37:58.7207522Z         # We don't have enough left to cover fees if we try to spend it all.
2025-05-17T08:37:58.7208203Z         with pytest.raises(RpcError, match=r'not afford'):
2025-05-17T08:37:58.7208761Z             l1.rpc.fundchannel(l2.info['id'], funds)
2025-05-17T08:37:58.7209203Z     
2025-05-17T08:37:58.7209598Z         # Should still be connected (we didn't contact the peer)
2025-05-17T08:37:58.7210243Z         assert only_one(l1.rpc.listpeers()['peers'])['connected']
2025-05-17T08:37:58.7210875Z         l2.daemon.wait_for_log('Handed peer, entering loop')
2025-05-17T08:37:58.7211439Z >       assert only_one(l2.rpc.listpeers()['peers'])['connected']
2025-05-17T08:37:58.7211912Z E       assert False
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-17 13:05:04 -05:00
Rusty Russell
b15100d03a lightningd: don't complain when gossipd gives us channel_update for dying channel.
It can definitely happen (it's not dead yet):

```
2025-05-17T08:44:48.9829150Z lightningd-2 2025-05-17T08:36:43.597Z **BROKEN** 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#3: gossipd gave channel_update in CGOSSIP_CHANNEL_ANNOUNCED_DYING? update=01027cf5d46590c45eb608a7e07a7b123c998ac12a655ce11004c9d9bb59f83698e8760d7b992df0dcf925f6732503de55d596aadaa35f0a8837cee58e0769172d2a06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006f00000100006828493f010200060000000000000000000000010000000a000000003b023380
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-17 13:05:04 -05:00
Rusty Russell
04ba55d88b wallet: fix incorrect channel_htlcs id migration.
We were supposed to initialize `last_htlcs_created_index` but a typo
made us initialize `last_forwards_created_index` instead.  Fix up the
overwritten one, and actually initialize the one we were supposed to.

Fixes: https://github.com/ElementsProject/lightning/issues/8269
Fixes: https://github.com/ElementsProject/lightning/issues/8270
Changelog-None: recently introduced bug
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-17 13:05:04 -05:00
Rusty Russell
1cc64dd67c pytest: test to crash on migration from old db.
```
Error executing statement: wallet/wallet.c:3247: INSERT INTO channel_htlcs ( id, channel_id, channel_htlc_id, direction, origin_htlc, msatoshi, cltv_expiry, payment_hash, payment_key, hstate, routing_onion, malformed_onion, partid, groupid, fees_msat, min_commit_num) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?);: UNIQUE constraint failed: channel_htlcs.id
lightningd: FATAL SIGNAL 6 (version v25.02-321-g3999879)
0x642e42dc974f send_backtrace
	common/daemon.c:33
0x642e42dc97eb crashdump
	common/daemon.c:78
0x7d90f2e4532f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7d90f2e9eb2c __pthread_kill_implementation
	./nptl/pthread_kill.c:44
0x7d90f2e9eb2c __pthread_kill_internal
	./nptl/pthread_kill.c:78
0x7d90f2e9eb2c __GI___pthread_kill
	./nptl/pthread_kill.c:89
0x7d90f2e4527d __GI_raise
	../sysdeps/posix/raise.c:26
0x7d90f2e288fe __GI_abort
	./stdlib/abort.c:79
0x642e42d71f79 fatal_vfmt
	lightningd/log.c:1055
0x642e42da61e8 db_error
	wallet/db.c:1117
0x642e42e1eafc db_fatal
	db/utils.c:323
0x642e42e1eee6 db_exec_prepared_v2
	db/utils.c:197
0x642e42db1fd9 wallet_htlc_save_out
	wallet/wallet.c:3310
0x642e42d8f07f update_out_htlc
	lightningd/peer_htlcs.c:1978
0x642e42d8f435 changed_htlc
	lightningd/peer_htlcs.c:2011
0x642e42d929aa peer_sending_commitsig
	lightningd/peer_htlcs.c:2108
0x642e42d5002f channel_msg
	lightningd/channel_control.c:1533
0x642e42d9ec3a sd_msg_read
	lightningd/subd.c:560
0x642e42e88435 next_plan
	ccan/ccan/io/io.c:60
0x642e42e88906 do_plan
	ccan/ccan/io/io.c:422
0x642e42e889c3 io_ready
	ccan/ccan/io/io.c:439
0x642e42e8a332 io_loop
	ccan/ccan/io/poll.c:455
0x642e42d69b01 io_loop_with_timers
	lightningd/io_loop_with_timers.c:22
0x642e42d6f525 main
	lightningd/lightningd.c:1486
0x7d90f2e2a1c9 __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7d90f2e2a28a __libc_start_main_impl
	../csu/libc-start.c:360
0x642e42d41b64 ???
	???:0
0xffffffffffffffff ???
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-17 13:05:04 -05:00
Rusty Russell
44972b2e15 chanbackup: unbias our random peer selection.
We picked one node and iterated.  This means we would only sent to 1,
not 2 nodes if we picked the last (common if there were only a few
peers).  But it also means we would generally send to the same pair of
nodes, which isn't great for redundancy.

Rework to be more random.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-16 23:39:35 +09:30
Rusty Russell
b7e20b327c lightningd: enable peer storage by default,
Now we've make it only on existing channels, and not have to call
listdatastore every time, that means we can safely turn it on by
default.

Changelog-Added: Protocol: we now offer peer storage to any peers who create a channel.
Changelog-Deprecated: Config: `--experimental-peer-storage` (it's now the default).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-16 23:39:35 +09:30