mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-07 22:10:27 +02:00
lnrpc+rpcserver: add new GetDebugInfo RPC method
This commit is contained in:
40
rpcserver.go
40
rpcserver.go
@ -10,6 +10,8 @@ import (
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -330,6 +332,19 @@ func MainRPCServerPermissions() map[string][]bakery.Op {
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
}},
|
||||
"/lnrpc.Lightning/GetDebugInfo": {{
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
}, {
|
||||
Entity: "offchain",
|
||||
Action: "read",
|
||||
}, {
|
||||
Entity: "onchain",
|
||||
Action: "read",
|
||||
}, {
|
||||
Entity: "peers",
|
||||
Action: "read",
|
||||
}},
|
||||
"/lnrpc.Lightning/GetRecoveryInfo": {{
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
@ -3020,6 +3035,31 @@ func (r *rpcServer) GetInfo(_ context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetDebugInfo returns debug information concerning the state of the daemon
|
||||
// and its subsystems. This includes the full configuration and the latest log
|
||||
// entries from the log file.
|
||||
func (r *rpcServer) GetDebugInfo(_ context.Context,
|
||||
_ *lnrpc.GetDebugInfoRequest) (*lnrpc.GetDebugInfoResponse, error) {
|
||||
|
||||
flatConfig, err := configToFlatMap(*r.cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting config to flat map: "+
|
||||
"%w", err)
|
||||
}
|
||||
|
||||
logFileName := filepath.Join(r.cfg.LogDir, defaultLogFilename)
|
||||
logContent, err := os.ReadFile(logFileName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading log file '%s': %w",
|
||||
logFileName, err)
|
||||
}
|
||||
|
||||
return &lnrpc.GetDebugInfoResponse{
|
||||
Config: flatConfig,
|
||||
Log: strings.Split(string(logContent), "\n"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetRecoveryInfo returns a boolean indicating whether the wallet is started
|
||||
// in recovery mode, whether the recovery is finished, and the progress made
|
||||
// so far.
|
||||
|
Reference in New Issue
Block a user