270 Commits

Author SHA1 Message Date
Rusty Russell
d0c158a69d pytest: make test_no_delay more robust.
Unfortunately the effect of leaving Nagle enabled is subtle.  Here it
is in v25.12:

Normal: 
    tests/test_connection.py::test_no_delay PASSED
    ====================================================================== 1 passed in 13.87s

Nagle enabled:
    tests/test_connection.py::test_no_delay PASSED
    ====================================================================== 1 passed in 21.70s

So it's hard to both catch this issue and not have false positives.  Improve the
test by deliberately running with Nagle enabled, so we can do a direct comparison.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-20 10:47:10 +10:30
Rusty Russell
806dc89cad gossipd: remove --dev-gossip-time setting, we'll use CLN_DEV_SET_TIME.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-13 21:21:29 +10:30
Sangbida Chaudhuri
9754603dbe options: remove --use-bip86-derivation
We're removing --use-bip86-derivation. Since a mnemonic will now be the standard hsm_secret BIP86 base wallet addresses will also be the standard.
2025-10-26 12:37:58 +10:30
Sangbida Chaudhuri
1665665271 lightningd: store base and derive pubkeys locally
RIP to this commit there's a good chance a lot of this code doesn't even make this into the final PR. Pour one out for the fallen lines of code.

This commit is doing the rest of the derivation. There was a significant overlap between the bip32_pubkey derivation and the bip86_pubkey derivation so that has been refactored in one place.
2025-10-26 12:37:58 +10:30
Sangbida Chaudhuri
218dc2fe20 hsmd: use the new mnemonic-compatible hsm_secret routines.
Changelog-Changed: hsmd: New nodes will now be created with a BIP-39 12-word phrase as their root secret.
Changelog-Deprecated: config: `encrypted-hsm` to require a passphrase (use `hsm-passphrase`).
Changelog-Added: config: `hsm-passphrase` indicates we should use a manual passphrase with the hsm secret.
2025-10-26 12:37:58 +10:30
Sangbida Chaudhuri
e3fe739f64 hsmd: take the passphrase raw, not the derived secret.
In preparation for BIP-39, we need to hand the passphrase (if any) to HSMD.

So we extend the hsmd wire protocol to allow that.
2025-10-26 12:37:58 +10:30
Rusty Russell
52d69df10f lightningd: migrate events from bookkeeper at startup.
We take over the --bookkeeper-dir and --bookkeeper-db options, and
then if we can find the bookkeeper db we extract the records to
initialize our chain_moves and channel_moves tables.

Of course, bookkeeper now needs to not register those options.

When bookkeeper gets invoked the first time, it will reconstruct
everything from listchannelmoves and listcoinmoves.  It cannot
preserve manually-added descriptions, so we put those in the datastore
for it ready to go.

Note that the order of onchain_fee changes slightly from the original.
But this is fine.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-19 13:37:50 +09:30
Rusty Russell
233628ad48 lightningd: speed mapping from coinmoves table to channel for listcoinmoves.
Iterating through every peer and channel every time can be very slow
for large nodes, when calling wallet_coinmoves_extract for listcoinmoves.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-19 13:37:50 +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
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
167767d683 lightningd: don't hand redundant block_height to block notifications.
They can all call get_block_height(); the extra argument confused me and
I thought they were called before the block height was actually updated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-15 16:40:33 +09:30
Rusty Russell
53a67b6a86 lightningd: rename anchor_confirms to funding_confirms.
Calling the funding tx an anchor is pre-spec terminology, which is now
confusing; let's rename the variable.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-15 16:40:33 +09:30
Rusty Russell
c0d68c5c2c pytest: create warning if we grind signature shorter than 71 bytes, don't fail.
One in 256 times, we will grind a signature to 70 bytes (or shorter).  This breaks
our feerate tests.  Unfortunately the grinding is deterministic, so there doesn't
seem to be a way to avoid it.  So we add a log message, and then we skip the
feerate test if it happens.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Rusty Russell
1fe5644bf2 lightningd: keep closed channels in memory.
They're small, and this will allow us to efficiently respond to reestablish on them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-04-29 13:31:23 +09:30
Rusty Russell
c1c93a3212 lightningd: remove announce-addr-dns flag.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Config: `announce-addr-dns` (deprecated v23.08, disabled in v24.11).
2025-03-12 09:26:08 +10:30
Rusty Russell
f4872f96db common: return location of a ".setconfig" file when we load config.
This is where we will put all the dynamic settings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-24 19:38:37 +10:30
Rusty Russell
20257c3308 lightningd: --dev-low-prio-anchor-blocks and test for low-priority anchors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-26 14:49:36 +10:30
Rusty Russell
faf7ae6ad4 pytest: add test for connection ratelimiting.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-25 15:39:13 +10:30
Rusty Russell
15950bb7d4 connectd: reconnect for non-transient connections.
Rather than have lightningd call us repeatedly to try to connect, have
it tell us what peers are transient and aren't, and connectd will
automatically try to maintain that connection.

There's a new "downgrade_peer" message to tell it a peer is now
transient: to make it non-transient we simply tell connectd to
connect as a non-transient.

The first time, I missed that dual_open_control does its own state
transitions :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: `connectd` now handles maintaining/reconnecting to important peers, and we remember the last successful address we connected to.
2024-11-25 15:39:13 +10:30
Alex Myers
dc878dc937 lightningd: add option for minimum seeker autoconnect peers
Changelog-added: Added option --autoconnect-seeker-peers, allowing seeker to reach out to new nodes for additional gossip.
2024-11-22 15:21:45 +10:30
Rusty Russell
ca41414da4 offers: make it the default.
Changelog-Changed: offers: bolt12 now enabled by default (finally!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-18 10:42:54 +01:00
Lagrang3
bc419b41a8 lightningd: add option dev-strict-forwarding
Changelog-Add: add option dev-strict-forwarding
2024-11-12 10:44:10 +01:00
Rusty Russell
b525207e5c lightningd: track whether we're supposed to be throttling gossip.
We're going to need this for the next commit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-12 16:30:29 +09:30
Rusty Russell
a1fdeee76b Makefile: clean up install path handling.
We had some weird code to try to do relative paths.  Instead, use absolute
ones and keep life simple.  Also rename "daemon_dir" to the clearer
"subdaemon_dir" as that's what it's used for.

We now need special magic to do "installcheck", which is a bit awkward,
but at least it's contained.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-07 18:32:56 +02:00
Rusty Russell
74ef03d361 lightningd: use tweak on node_id of different key, for createinvoicerequest.
It's an internal difference, so doesn't actually break compatibility
(it would if we tried to prove we owned an old invoicerequest, but we
don't have infrastructure for that anyway).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-01 12:31:48 +09:30
Rusty Russell
09401e34b6 common/bolt12_id: generate alias tweak.
For now we only use a fake id for requesting invoices (as a payer_key), but we
will eventually use this generically, and we want plugins to be able to map them
too, so use the same scheme as path_id: a generated secret using the makesecret
API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-01 12:31:48 +09:30
Rusty Russell
c68204a32a lightningd: store our id as a struct pubkey as well as struct node_id.
We convert it in various places, so do that only once.  Also, the name
"id" is a little curt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-23 09:54:47 +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
155311b053 connectd: --dev-handshake-no-reply so we can test pending connections.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-14 18:16:26 -05:00
Rusty Russell
cca784c9d0 BOLT: update to include 2016 for max_htlc_cltv.
And deprecate the --max-locktime-blocks which allows them to set it.

Hilariously, the spec misspells CLTV as CTLV at one point, so we work around it for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 16:14:23 -05:00
Rusty Russell
80f1063dee lightningd: increase fd limit if we can, to double number of starting channels.
1024 is a common limit, and people are starting to hit that many channels, so we should increase it: twice the number of channels seems reasonable, though we only do this at restart time.

Changelog-Changed: lightningd: we now try to increase the number of file descriptors, if it's less than twice the number of channels at startup (and log if we cannot!).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 01:23:46 -05:00
Rusty Russell
c7339ea310 pytest: test various preapprove scenarios.
We wire through --dev options into the hsmd, and test preapprove accept and deby
with both old and new protocols.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
ba922f9160 lightningd/connectd: remove --experimental-websocket-port
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Config `experimental-websocket-port` (deprecated 23.08, EOL 24.02)
2024-03-25 15:02:35 +10:30
Rusty Russell
4c5c53cac7 lightningd: add --dev-allow-shutdown-destination-change to unstick existing nodes.
This will solve the problem for users who already hit the bug fixed by
the previous patch!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Yaacov Akiba Slama
a81c1c51f6 Add no-reconnect-private option to disable automatic reconnect-attempts
to peers connected to our node with private channels only
2024-02-13 17:50:00 +01:00
Rusty Russell
06d59839ec connectd: channel_gossip when we've tried to connect to all peers.
It then waits 10 more seconds (for plugins to call setlease, especially)
before it will update a node_announcement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
e4b21b467a lightningd: refine heuristics for remote address selection.
Rather than take the first two from peers with committed channels, use
the most common address given by at least 2 peers, and accept the majority
from non-committed peers if there are no committed peers.

This works well with the node_announcement rework, which waits until
everyone has a chance to connect before creating the node_announcement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
dd86e817b4 gossipd: tell lightningd its node_announcement on startup, if any.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
48b9b6a05c lightningd: add routines to generate node_announcement.
This is currently still done in gossipd, but we should generate it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
e531ff83b3 lightningd: add dev-any-channel-type to allow obsolete channel types.
We're about to make static_remotekey compulsory, but we still want to
do tests for pre-existing channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell
50e7c71dc7 lightningd: mark all internal deprecations by version.
I did some CHANGELOG and git digging to see when these were deprecated, and
some were very old (v0.8.2!).  But since they didn't warn users loudly, I
chose to do so this release only.

I renamed ld's `deprecated_apis` to `deprecated_ok` to make sure I
caught them all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-26 10:30:22 +10:30
Rusty Russell
d051a1ee67 lightningd: i-promise-to-fix-broken-api-user option.
This allows the user to specify the feature *by name*, and hopefully
complain to the developer to fix their code, knowing it will be removed entirely
in the next release!

Changelog-Added: config: `i-promise-to-fix-broken-api-user` allows for a one-release re-enablement of long-deprecated features.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-26 10:30:22 +10:30
Alex Myers
4265699fcd lightningd: add a feerate offset when updating feerates as opener
Adding a fee offset as the channel opener reduces the likelihood of a
disconnect by the peer do to slight variation in feerate calculation
between nodes.

Changelog-Fixed: Some peer disconnects due to update_fee disagreements are avoided.
2023-11-02 09:49:59 +10:30
Rusty Russell
52b1ba2992 wallet: remove premature optimization when making payment.
We didn't write to db immediately, but waited until it the actual HTLC got
added (or failed).  That way we didn't have a separate transaction to
write the payment into the db, but the complexity is not worth it: it
makes the next refactors harder, since we can't use the normal
iterator patterns like we do with the rest of the db (as we have to add
the unstored ones).

We might as well also make sendpay return immediately: we used to return
once the HTLC had been confirmed sent, since we entered it in the db
at that point, but we can keep it simple now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-28 15:48:26 +10:30
Chris Guida
fc4b2f864e add invoices-onchain-fallback config option and warnings
Changelog-Added: Config: `invoices-onchain-fallback` to automatically add an onchain p2tr address to invoices, and allow that for payment.
2023-10-26 19:11:17 +10:30
Rusty Russell
a50b795bc2 lightningd: implement recover command.
Changelog-Added: JSON-RPC: `recover` command to force (unused) lightningd node to restart with `--recover` flag.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-26 12:59:55 +10:30
Rusty Russell
3e124d9ec1 lightningd: remove #if DEVELOPER.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
64ab7c0c1d lightningd: add --developer runtime option.
Currently it just defaults to the DEVELOPER compile option, but we'll
move over to this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Config: `--developer` enables developer options and changes default to be "disable deprecated APIs".
2023-09-21 20:08:24 +09:30
Dusty Daemon
4628e3ace8 channeld: Code to implement splicing
Update the lightningd <-> channeld interface with lots of new commands to needed to facilitate spicing.

Implement the channeld splicing protocol leveraging the interactivetx protocol.

Implement lightningd’s channel_control to support channeld in its splicing efforts.

Changelog-Added: Added the features to enable splicing & resizing of active channels.
2023-07-31 21:00:22 +09:30
adi2011
51f72c1d1d lightningd: Added plugin hook to notify whenever started in rocover mode. 2023-07-31 11:29:59 +09:30