Commit Graph

796 Commits

Author SHA1 Message Date
Dusty Daemon
c02f89baa8 splice: Decrement next_commitment_number for Eclair
Eclair requires `next_commitment_number` to be decremented to resend the individual splice commitment_signed message.
2025-05-13 14:52:15 +09:30
Dusty Daemon
e928817fa7 splice: Update to Eclair style of reestablish
Update to use Eclair’s spec’d version of reestablish.

Changelog-None
2025-05-13 14:52:15 +09:30
Dusty Daemon
dd962225ef splice: Allow commit_sig batch in any order
Other implementations are sending commit_sig batches in different orders. We add support for them being in any order by ordering the batch of messages after receiving them.

Changelog-Changed: Increase interop compatability by loosening requirement that commitment signed messages be received in a particular order and sorting them internally.
2025-05-13 14:52:15 +09:30
Dusty Daemon
c9c56e340d PSBT: Clean up PSBT chunk allocations
Cleaning up the memory hierarchy of PSBT usage in splicing and `psbt_finalize_input`
2025-05-13 14:52:15 +09:30
Dusty Daemon
1621b67d34 splice: Prevent user from signing an unfinal splice
An extra check to ensure the user doesn’t try to sign a splice that wasn’t finalized.
2025-05-13 14:52:15 +09:30
Dusty Daemon
5e5ed774fc PSBT: Add audi_psbt routine
A routine that audit’s and asserts PSBT memory to confirm it has a sane memory allocation hierarchy.

Changelog-None
2025-05-13 14:52:15 +09:30
Dusty Daemon
58252a53a6 splice: Use clone instead of steal for PSBT
Update splice flows to use the new `clone_psbt` method instead of stealing back and forth.
2025-05-13 14:52:15 +09:30
Dusty Daemon
721f36831e splice: Add check for correct txid in splice_locked
Check that the peer sent the correct txid in their `splice_locked` message.

We have to check this later on in `check_mutal_splice_locked` so we store the value in `splice_state`
2025-05-13 14:52:15 +09:30
Richard Myers
940b6a3af2 splice: Add splice_txid to splice_locked message 2025-05-13 14:52:15 +09:30
Richard Myers
168c3b0d55 Add debug outputs and fix prevtx issue 2025-05-13 14:52:15 +09:30
Dusty Daemon
a953a12573 splice: Resume splice_locked on reestablish
A new case where `splice_locked` must be sent again on reestablish.

This handles the case where `splice_locked` did not complete locally or remotely and must be resumed.
2025-05-13 14:52:15 +09:30
Dusty Daemon
2bd39f270e splice: Add locked field to inflight db
This is needed to remember if a splice was locked and reconnect occurs mid `splice_locked` attempted so it can be resumed in reestablish.
2025-05-13 14:52:15 +09:30
Dusty Daemon
bed2796032 Splice: Rotating funding pubkey fix
Interop testing with Eclair revealed an issue with remote funding key rotation.

This searches for the funding output using the rotated remote funding pubkey instead of the furrent funding pubkey.

Also update the variable name to be more clear which this represents.

Changelog-Changed: Interop fixes for compatability with Eclair
2025-05-13 14:52:15 +09:30
Rusty Russell
70f05132d9 channeld: be more accurate with the weight of commitment txs.
We didn't add the weight of the two sigs!  The BOLT defines that to be a worst-case 73 byte sig,
but that turns out to be an overestimate (and this is not required for consensus) so we assume
everyone grinds.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Rusty Russell
2154289911 hsmd: rename simple_htlc to hsm_htlc, don't gratuitously dynamically allocate.
The renaming makes it clear that it's HSM specific.

And it has no pointers, so we can have an array instead of an array of pointers.

I tested this hadn't accidentally changed the wire format by disabling
version checks and using an old hsmd with the altered daemons and
running the test suite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Rusty Russell
29c8693b26 hsmd: roll the definition of simple_htlc into the csv.
This is such a simple struct that we can actually define it in csv.
This prevents us from accidentally breaking the ABI in future.

I tested this hadn't accidentally changed the wire format by disabling
version checks and using an old hsmd with the altered daemons and
running the test suite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Rusty Russell
6e4fb1eb56 channeld: remove never-used "reestablish_only" option.
This was always false.  peer_start_channeld was called in various places
with the argument "NULL" instead of "false", which unfortunately compilers
didn't complain about :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-04-29 13:31:23 +09:30
Rusty Russell
733efcf7dd BOLTs: import spec additions for option_simple_close.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-03-18 14:30:58 +10:30
Rusty Russell
67c91a7e5c BOLTs: Update to version with peer storage merged.
Unfortunately a spec typo means the data fields are missing (PR pending),
so we still patch those in.

The message "your_peer_storage" got renamed to "peer_storage_retrieval",
and the option "want_peer_backup_storage" was removed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `experimental-peer-storage` now only advertizes feature 43, not 41.
2025-03-18 14:30:58 +10:30
Dusty Daemon
5818b522f5 splice: Don’t let users do unsigned splices
If a user tries to do a splice without signing their inputs we now provide them with a nice error message and cancel the RPC since that wouldn’t be productive for the user anyway.

We also add a helpful message if they do the opposite — try to sign a PSBT where they did not add any inputs.

Changelog-Changed: Update prevents users from trying to splice unsigned PSBTs — protecting against potential issues.
2025-02-07 12:49:20 -06:00
Rusty Russell
b6c1ffa359 ccan/htable: update to explicit DUPS/NODUPS types.
The updated API requires typed htables to explicitly state whether they
allow duplicates: for most cases we don't, but we've had issues in the
past.

This is a big patch, but mainly mechanical.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-01-21 09:18:25 +10:30
Rusty Russell
b5d1acee45 wire: call unknown types "UNKNOWN X" not "INVALID X".
It's freaking people out when they see things like:

```
 2024-11-11T05:26:41.281Z DEBUG ...53c-connectd: peer_out INVALID 22859
```

Fixes: https://github.com/ElementsProject/lightning/issues/7802
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: connectd: log unknown messages as "UNKNOWN" not "INVALID" to avoid freaking people out.
2024-12-02 15:09:45 +10:30
Dusty Daemon
d04e64670d splice: tx_abort no longer reestablishes
As per eclair implementation we skip `channel_reestablish` and go straight into the channel for `tx_abort` events.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
6d63e68e99 splice: Update messages to spec
Changelog-Changed: Splicing moved from test numbers to spec numbers.
2024-11-21 14:15:36 +10:30
Dusty Daemon
dcdf7db65f splice: Enable remote funding key rotation
Allows our peer to change their funding pub key during a splice.

Changelog-Changed: Support added for peers that wish to rotate their funding pubkey during a splice.
2024-11-21 14:15:36 +10:30
Dusty Daemon
03d7d8f45a splice: Update funding pubkey on splice lock
Set the remote funding pubkey on both lightningd and channeld when mutual splice lock is achieved.

This will be needed once rotating funding keys is enabled during splicing

Changelog-None.
2024-11-21 14:15:36 +10:30
Dusty Daemon
d04478f99e splice: Enable shared tx on interactivetx
By placing the funding tx into `interactivetx`, the message will be compressed by only sending the txid via tlvs.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
90c786f61b channeld: Move tx lookup function up
This function needs to be used earlier in the file so it is moved vertically up.

Chanelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
9b06a85f54 splice: Update find_channel_output for rotating funding key
We need to differentiate the funding pubkey since we allow the peer to rotate it now.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
2bb5d8ac67 splice: Update commit sigs to use dynamic remote funding pubkey.
Update the sending and receiving of commit sigs to use dyniamic funding pubkeys incase our remote peer rotates theirs during a splice.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
7a8e377b81 splice: Update commitment_signed_tlvs
As per eclair spec proposal.
1) A renaming to `funding_txid`
2) Adding of `batch_size` to indicate how many commitment_signed msgs are expected.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
2b41ada941 splice: Add new funding output balance
The prior spec left this value at 0 to be calculted later but the current spec requires we fill it in in advance.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
2b3cb8b8a8 splice: Update splice signature msg type
Update to use spec signature type.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
d077fd59c9 splice: Remove blockhash from peer msg
This is no longer used.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
aea35536c0 channeld: Update commitsigs to support remote_funding
Since funding keys can be rotated during splice, commit sig routines must be able to handle a dynamic value for the funding keys.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
a21ae33b2d channeld: Add dynamic funding_pubkeys to channel_txs
In anticipation of adding support for rotating funding pubkeys during a splice, `channel_txs` is updated to support specifying these manually instead of using the channel’s funding pubkeys.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
42440e3bee splice: Pass remote_funding between ld and channeld
Update lightningd and channeld interface to pass the remote funding pubkey back and forth to both daemons.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
17d2b24ebb channeld: Add remote_funding to inflight
Channeld stores its own cache of `inflight` and that needs to have a copy of `remote_funding` as well.

Since copying a secp256k1 pubkey isn’t documented and `copy_inflight` isn’t used anyway — we’re dropping `copy_inflight`.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
ba3bd750fa channeld: Store remote_funding for splice
Instead of assuming the remote funding pubkey does not change during splice, we store the new pubkey in the splice object.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
7d1a43d5d5 channeld: Fix tx_abort encoding
Switch to using same message format for `tx_abort` that wire_error and wire_warning use.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
4b3643d209 splice: Clean up error messages for RPC
Added and updated error messages when splicing to make it more clear to the user why a splice is failing.

Changelog-Changed: Improved error messaging for splice commands.
2024-11-21 14:15:36 +10:30
Dusty Daemon
dd956e2210 splice: reestablish should only assume stfu in one case 2024-11-12 06:42:52 +10:30
Dusty Daemon
fe7ba77234 splice: Add more verbose reestablish debug logging 2024-11-12 06:42:52 +10:30
Dusty Daemon
475d5f8bf9 splice: Abort on insufficent funds
If the user does not supply enough funds treat it as an abort instead of a channel warning.

Also clean up some indentation while we’re there.
2024-11-12 06:42:52 +10:30
Dusty Daemon
e4978a4037 splice: Update splice fee maximums
The fee maximum is used to issue a warning to the user their feerate is high in case they accidentally make a large donation to miners.

During python testing the feerates are high on purpose so we raise the warning level to at least the penality feerate.
2024-11-12 06:42:52 +10:30
Dusty Daemon
879d1191e8 splice: Bulk channel stfu and abort RPC
The ability to stfu channels in bulk is required to do complex multi channel operations. When stfu’ing in this manner, the available funds at the moment of stfu is returned to the user.

In order to cancel the stfu we also add a bulk tx_abort command.

Changelog-Added: `stfu_channels` and `abort_channels` are added for bulk multi-channel splice commands. These allow the user to pause (and resume) multiple channels in place.
2024-11-12 06:42:52 +10:30
Dusty Daemon
d60e9f342b splice: Extract remote sig from psbt if needed
On certain well timed restarts we lose their siganture from memory and don’t receive it from them. In these cases we can extract it from the PSBT directly.
2024-11-12 06:42:52 +10:30
Dusty Daemon
73ad8eaa31 splice: Allow splice_update to return signatures
This is needed to all multi-channel splices. When channeld can return the signatures to the user (based on signing order precedent), it now does from splice_update.

Additionally, we move sending of the initial psbt from splice_init down to splice_update. This is also necessary for correct psbt diff detection during multi-channel splices.

Changelog-Changed: splice_update can in some cases now return the remotely partiall signed psbt to the user, if so `signtures_secured` will be true.
2024-11-12 06:42:52 +10:30
Rusty Russell
498111ed8c channeld: routine to feed in a shachain.
This will be used by channeld_fakenet to create replies from the peer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-06 21:17:36 +10:30
Rusty Russell
1e4adbff17 common/msg_queue: send backtrace on oversize queues.
Scary looking, but great for debugging!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-01 16:54:49 +10:30