lnd+config: Move to FileExists function in lnrpc package

This commit is contained in:
Orbital
2022-12-02 21:32:30 -06:00
parent c0f44a17b7
commit 21816d9118
3 changed files with 10 additions and 20 deletions

View File

@@ -210,7 +210,9 @@ func (t *TLSManager) generateOrRenewCert() (*tls.Config, func(), error) {
// the encrypted form.
func (t *TLSManager) generateCertPair(keyRing keychain.SecretKeyRing) error {
// Ensure we create TLS key and certificate if they don't exist.
if fileExists(t.cfg.TLSCertPath) || fileExists(t.cfg.TLSKeyPath) {
if lnrpc.FileExists(t.cfg.TLSCertPath) ||
lnrpc.FileExists(t.cfg.TLSKeyPath) {
// Handle discrepencies related to the TLSEncryptKey setting.
return t.ensureEncryption(keyRing)
}
@@ -597,18 +599,6 @@ func (t *TLSManager) deleteEphemeralSettings() {
t.ephemeralCertPath = ""
}
// fileExists reports whether the named file or directory exists.
// This function is taken from https://github.com/btcsuite/btcd
func fileExists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}
// IsCertExpired checks if the current TLS certificate is expired.
func (t *TLSManager) IsCertExpired(keyRing keychain.SecretKeyRing) (bool,
time.Time, error) {