Skip to content

hsmtool: implement new derivetoremote method#7344

Merged
rustyrussell merged 1 commit intoElementsProject:masterfrom
whitslack:hsmtool-derivetoremote
Jul 8, 2025
Merged

hsmtool: implement new derivetoremote method#7344
rustyrussell merged 1 commit intoElementsProject:masterfrom
whitslack:hsmtool-derivetoremote

Conversation

@whitslack
Copy link
Collaborator

@whitslack whitslack commented May 26, 2024

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.


Motivation: I implemented this method so that I could import my funds from remote unilateral closures into other wallets. While guesstoremote could mostly get the job done, it's needlessly slow when we already know the database ID of the channel, and it doesn't work at all for channels that were negotiated without option_static_remotekey.

@whitslack
Copy link
Collaborator Author

@ShahanaFarooqui: Since you're touching hsmtool, would you take a look at this PR? I just recently had another use for this function, as I needed to CPFP a peer's unilateral closure, and thus I needed to derive the private key for my P2WPKH output of the peer's commitment transaction so I could sign a child transaction with it. Of course I can continue to apply this patch to my hsmtool locally, but if I keep finding uses for this function, then I would expect others would find it useful as well. Thanks.

@ShahanaFarooqui
Copy link
Collaborator

@whitslack I would have helped in reviewing it, but it is a bit beyond my expertise! 😊

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.
@whitslack whitslack force-pushed the hsmtool-derivetoremote branch from 1a2d773 to 0b23a45 Compare January 5, 2025 09:34
@rustyrussell rustyrussell added this to the v25.09 milestone Jul 8, 2025
@rustyrussell rustyrussell merged commit cc0f66f into ElementsProject:master Jul 8, 2025
@whitslack whitslack deleted the hsmtool-derivetoremote branch July 8, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants