hsmtool: implement new "derivetoremote" method

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.
This commit is contained in:
Matt Whitlock
2024-05-26 16:31:58 -04:00
committed by Rusty Russell
parent 6724db65de
commit cc0f66f07b
3 changed files with 58 additions and 2 deletions

View File

@@ -53,6 +53,15 @@ and is usually no greater than the number of channels that the node has
ever had.
Specify *password* if the `hsm_secret_path` is encrypted.
**derivetoremote** *node\_id* *channel\_dbid* \[*commitment\_point*\] *hsm\_secret*
Derive the private key to our funds from a remote unilateral close of a channel.
The peer must be the one to close the channel (and the funds will remain
unrecoverable until the channel is closed).
*channel\_dbid* is the identifier of the channel in the CLN database.
If *commitment\_point* is omitted, then the channel is assumed to have been
negotiated with `option_static_remotekey`;
otherwise, *commitment\_point* is the remote per-commitment point.
**generatehsm** *hsm\_secret\_path* \[*lang* *seed\_phrase* \[*passphrase*\]\]
Generates a new hsm\_secret using BIP39. If lang, seed\_phrase and optional passphrase are not provided they will be prompted for. *lang* can be "en" (English), "es" (Spanish), "fr" (French), "it" ("Italian"), "jp" (Japanese), "zhs" (Chinese Simplified) or "zht" ("Chinese Traditional"). Note that the seed phrase consists of multiple words, so should be surrounded by quotes.