mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-23 12:13:50 +02:00
multi: Add --tor.encryptkey flag functionality to encrypt the Tor private key on disk
It's possible that a user might not want the Tor private key to sit on the disk in plaintext (it is a private key after all). So this commit adds a new flag to encrypt the Tor private key on disk using the wallet's seed. When the --tor.encryptkey flag is used, LND will still write the Tor key to the same file, however it will now be encrypted intead of plaintext. This essentially uses the same method to encrypt the Tor private key as is used to encrypt the Static Channel Backup file.
This commit is contained in:
11
server.go
11
server.go
@@ -47,6 +47,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lncfg"
|
||||
"github.com/lightningnetwork/lnd/lnencrypt"
|
||||
"github.com/lightningnetwork/lnd/lnpeer"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
@@ -2766,13 +2767,21 @@ func (s *server) createNewHiddenService() error {
|
||||
listenPorts = append(listenPorts, port)
|
||||
}
|
||||
|
||||
encrypter, err := lnencrypt.KeyRingEncrypter(s.cc.KeyRing)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Once the port mapping has been set, we can go ahead and automatically
|
||||
// create our onion service. The service's private key will be saved to
|
||||
// disk in order to regain access to this service when restarting `lnd`.
|
||||
onionCfg := tor.AddOnionConfig{
|
||||
VirtualPort: defaultPeerPort,
|
||||
TargetPorts: listenPorts,
|
||||
Store: tor.NewOnionFile(s.cfg.Tor.PrivateKeyPath, 0600),
|
||||
Store: tor.NewOnionFile(
|
||||
s.cfg.Tor.PrivateKeyPath, 0600, s.cfg.Tor.EncryptKey,
|
||||
encrypter,
|
||||
),
|
||||
}
|
||||
|
||||
switch {
|
||||
|
Reference in New Issue
Block a user