2022-01-05 11:04:30 +01:00
|
|
|
package rpcwallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/lightningnetwork/lnd/lncfg"
|
|
|
|
)
|
|
|
|
|
|
|
|
// HealthCheck returns a health check function for the given remote signing
|
|
|
|
// configuration.
|
|
|
|
func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error {
|
|
|
|
return func() error {
|
2022-03-16 15:11:17 +01:00
|
|
|
conn, err := connectRPC(
|
2022-01-05 11:04:30 +01:00
|
|
|
cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("error connecting to the remote "+
|
|
|
|
"signing node through RPC: %v", err)
|
|
|
|
}
|
|
|
|
|
2022-03-16 15:11:17 +01:00
|
|
|
defer func() {
|
|
|
|
err = conn.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Warnf("Failed to close health check "+
|
|
|
|
"connection to remote signing node: %v",
|
|
|
|
err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2022-01-05 11:04:30 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|