Derive per-channel destination and shutdown scripts for improved on-chain privacy#4756
Derive per-channel destination and shutdown scripts for improved on-chain privacy#4756Abeeujah wants to merge 4 commits into
Conversation
|
I've assigned @wpaulino as a reviewer! |
|
No new issues found. This is the same commit (
Correction to my prior review: my earlier "compile failure" claim about The previously-posted inline comments still stand (they are unchanged in this commit):
Non-blocking note (carried over): for externally-supplied |
Previously, `KeysManager` used a single global `destination_script` and `shutdown_pubkey` for all channels. With V2 remote key derivation enabled, each channel now gets a unique destination and cooperative-close script derived from its `channel_keys_id`. This improves on-chain privacy by avoiding script reuse across channels. Funds sent to per-channel scripts remain recoverable from the seed alone by scanning for scripts returned by `possible_v2_static_output_spks`. A new `find_static_output_key` method added on `KeysManager` locates the correct spending key for `StaticOutput` descriptors, supporting both legacy (global) and per-channel keys. The watchtower justice transaction test is updated to use legacy V1 keys since per-channel destination scripts cannot be predicted before channel creation.
`get_shutdown_scriptpubkey` now takes a `channel_keys_id` parameter, allowing signers to derive a unique shutdown script per channel. When `v2_remote_key_derivation` is enabled, `KeysManager` uses `channel_keys_id` to derive a fresh per-channel cooperative-close script from the shutdown key, avoiding address reuse across channels and improving on-chain privacy.
Verify that v2 (static_remote_key) destination and shutdown scripts are per-channel, distinct from each other, non-legacy, re-derivable across restarts, and recoverable via chain scan. Also confirm that v1 scripts remain static and that `find_static_output_key` correctly resolves scripts under various scenarios.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4756 +/- ##
==========================================
- Coverage 86.96% 86.30% -0.67%
==========================================
Files 161 160 -1
Lines 111648 111680 +32
Branches 111648 111680 +32
==========================================
- Hits 97099 96384 -715
- Misses 12045 12654 +609
- Partials 2504 2642 +138
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generate unique per-channel destination and shutdown scripts when V2 remote key derivation is enabled. Previously,
KeysManagerused a single global destination_script and shutdown_pubkey for all channels, causing address reuseacross channels.
Changes:
channel_keys_id.get_shutdown_script_pubkeynow takeschannel_keys_idto produce unique cooperative-close scripts per channel.Funds sent to per-channel scripts remain recoverable from seed alone via possible_v2_static_output_spks. A new
find_static_output_key method supports spending both legacy (global) and per-channel keys.
closes #1139