Commit graph

777 commits

Author SHA1 Message Date
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
Rusty Russell
fe344ee75b BOLT: update to latest BOLT 3 test vectors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-16 07:14:32 +10:30
Rusty Russell
45533584e2 global: rename blinding to path_key everywhere.
Get with the modern nomenclature: the pubkey inside a blinded path is called
the `path_key` now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-16 07:14:32 +10:30
Rusty Russell
dc18f3cd7b BOLTs: update which renames blinding terminology.
No code changes, just catching up with the BOLT changes which rework our
blinded path terminology (for the better!).

Another patch will sweep the rest of our internal names, this tries only to
make things compile and fix up the BOLT quotes.

1. Inside payload: current_blinding_point -> current_path_key
2. Inside update_add_htlc TLV: blinding_point -> blinded_path
3. Inside blinded_path: blinding -> first_path_key
4. Inside onion_message: blinding -> path_key.
5. Inside encrypted_data_tlv: next_blinding_override -> next_path_key_override

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-16 07:14:32 +10:30
Rusty Russell
3a9536fd37 BOLT catchup: quiescence is included.
This means we should support it by default.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Protocol: `option_quiesce` enabled by default.
Changelog-Deprecated: Config: --experimental-quiesce: it's now the default.
2024-10-16 07:14:32 +10:30
Rusty Russell
679f46f733 common/amount: rename amount_sat_zero/amount_msat_zerp -> amount_sat_is_zero/amount_msat_is_zero.
I used `amount_msat_eq(x, AMOUNT_MSAT(0))` because I forgot this
function existed.  I probably missed it because the name is surprising,
so add "is" in there to make it clear it's a boolean function.

You'll note almost all the places which did use it are Eduardo's and
Lisa's code, so maybe it's just me.

Fix up a few places which I could use it, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-19 12:16:53 +09:30
Rusty Russell
f05f871c92 common/amount: add amount_msat_accumulate()
Saves some typing, and is clearer than checking if both args really
are the same!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-19 12:16:53 +09:30
Rusty Russell
78b9ccf432 channeld: fix crash with pre-TLV peers.
send_tlvs is NULL if no special features are supported, and peer
sets `next_to_send` anyway:

```
0x5ed1c6719538 peer_reconnect
channeld/channeld.c:5205
0x5ed1c6719dab init_channel
channeld/channeld.c:5959
0x5ed1c6719f04 main
channeld/channeld.c:6005
```

Backport: v24.08
Fixes: https://github.com/ElementsProject/lightning/issues/7486
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-07 13:55:45 +02:00
Rusty Russell
ae5ad486ea gossipd: delete empty gossipd_peerd_wire.csv
gossipd no longer connects directly to per-peer daemons, so remove old file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-10 12:21:19 +09:30
Rusty Russell
162ebe2a72 global: we always offer OPT_ROUTE_BLINDING, don't need to test.
We did since v23.05.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
7d3d763b96 channeld: BOLT update, no longer allow creation of old (experimental-only!) non-zero-fee anchor channels.
These were removed from the spec.

We still support existing ones, though we were the only implementation
which ever did, and only in experimental mode, so we should be able to
upgrade them and avoid a forced close, with a bit of engineering...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-19 15:54:24 +09:30
Rusty Russell
b6d7ee1f11 common: No longer support new channels without option_static_remotekey.
We still support *existing* channels.  Just not new ones (before they could,
in theory, explicitly ask for one).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-19 15:54:24 +09:30
Ken Sedgwick
eda0b28cbb hsmd: HSM_VERSION 6: get_per_commitment_point never returns secret
Changelog-Changed: hsmd: HSM_VERSION 6: get_per_commitment_point does
not imply index - 2 is revoked, makes it safe to call on any index.
2024-05-14 10:39:12 -05:00
Ken Sedgwick
a02cc6441a channeld: split get_per_commitment_point uses into separate functions
Changelog-None: channeld internal

This factoring makes it much clearer which callers only need the pubkey and
which only need the old_secret.

VLS has merged a workaround which prevents crashing when fetching a
per-commitment-point beyond the allowed range (the secret is just not
returned in this case.
https://gitlab.com/lightning-signer/validating-lightning-signer/-/merge_requests/643

In HSM_VERSION 6 the semantic is cleaned up; get_per_commitment_point
never returns a secret and safely be called on any commitment number.
2024-05-14 10:39:12 -05:00
Ken Sedgwick
25312630aa channeld: factor out unneeded make_revocation_msg_from_secret
Changelog-None: internal to channeld

Since we don't need a special path for early old_secrets from validate
we can factor out duplicate code.
2024-05-14 10:39:12 -05:00
Ken Sedgwick
1c65fc2633 hsmd: prune unreachable pre HSM_VERSION 5 code
Changelog-None: shouldn't affect others

HSM_MIN_VERSION is 5 which implies use of
WIRE_HSMD_REVOKE_COMMITMENT_TX; prune branches that can't happen.
2024-05-14 10:39:12 -05:00
Christian Decker
24ec17126c channeld: Adjust the feerate security margin profile
The feerate security margin is a multiplicative factor applied to the
feerate of some transactions in order to guarantee that the
transaction remains publishable and has a sufficient chance of being
confirmed, that we can base some of our decisions on that.

The multiplicative factor is >=1 and was so far a constant 2. This
might have been sensible in the low-fee environment, where the fees
are expected to oscillate, and almost guaranteeing that we will
eventually have rising feerates but in high-fee environments that is
no longer the case, and the 100% margin that the multiplicator 2
brings is excessive. We therefore opt to start out with 100%, then
linearly interpolate up to a given maxfeerate (which does not have to
be a real feerate ever reached, it just indicates the feerate after
which we apply the constant 10% margin.

Fixes #6974
Closes #6976
[Fixed up all the other changes required, including spendable calcualtion
 comments and unit test and pytest tests --RR]
2024-05-13 14:06:45 -05:00
Rusty Russell
e30c835f72 common: add sciddir_or_pubkey type.
This is proposed to be added to bolt 12, so we need a type to
represent it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
5d061c4cf4 global: remove tags from BOLT quotes now dual-funding is in master
A few of them had minor wording changes, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 16:14:23 -05:00
Rusty Russell
2cb6da14fb BOLT: catch up now Dual-funding is included.
Mainly we don't need to patch the spec anywhere near as much.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 16:14:23 -05:00