Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1.64.6
plugins:
- module: 'github.com/lightninglabs/lightning-terminal/tools/linters'
path: ./tools/linters
13 changes: 12 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ run:
- dev

linters-settings:
custom:
ll:
type: "module"
description: "Custom lll linter with 'S' log line exclusion."
settings:
# Max line length, lines longer will be reported.
line-length: 80
# Tab width in spaces.
tab-width: 8
# The regex that we will use to detect the start of an `S` log line.
log-regex: "^\\s*.*(L|l)og\\.(Info|Debug|Trace|Warn|Error|Critical)S\\("
govet:
# Don't report about shadowed variables
check-shadowing: false
Expand All @@ -39,7 +50,7 @@ linters-settings:

linters:
enable:
- lll
- ll
- gofmt
- tagliatelle
- whitespace
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ check-go-version: check-go-version-dockerfile check-go-version-yaml

lint: check-go-version docker-tools
@$(call print, "Linting source.")
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
$(DOCKER_TOOLS) custom-gcl run -v $(LINT_WORKERS)

mod:
@$(call print, "Tidying modules.")
Expand Down
1 change: 1 addition & 0 deletions accounts/checkers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func NewAccountChecker(service Service,
)
}

// nolint:ll
checkers := CheckerMap{
// Invoices:
"/lnrpc.Lightning/AddInvoice": mid.NewResponseRewriter(
Expand Down
1 change: 1 addition & 0 deletions accounts/checkers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ func TestAccountCheckers(t *testing.T) {
originalRequest: &lnrpc.PendingChannelsRequest{},
originalResponse: &lnrpc.PendingChannelsResponse{
TotalLimboBalance: 123456,
// nolint:ll
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
{},
},
Expand Down
2 changes: 1 addition & 1 deletion accounts/store_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
// SQLQueries is a subset of the sqlc.Queries interface that can be used
// to interact with accounts related tables.
//
//nolint:lll
//nolint:ll
type SQLQueries interface {
AddAccountInvoice(ctx context.Context, arg sqlc.AddAccountInvoiceParams) error
DeleteAccount(ctx context.Context, id int64) error
Expand Down
4 changes: 3 additions & 1 deletion accounts/tlv.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ func PaymentEntryMapEncoder(w io.Writer, val any, buf *[8]byte) error {
}

// PaymentEntryMapDecoder decodes a map of payment entries.
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte, _ uint64) error {
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte,
_ uint64) error {

if typ, ok := val.(*AccountPayments); ok {
numItems, err := tlv.ReadVarInt(r, buf)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion autopilotserver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var ErrVersionIncompatible = fmt.Errorf("litd version is not compatible " +

// Config holds the configuration options for the autopilot server client.
//
//nolint:lll
//nolint:ll
type Config struct {
// Disable will disable the autopilot client.
Disable bool `long:"disable" description:"disable the autopilot client"`
Expand Down
7 changes: 5 additions & 2 deletions autopilotserver/mock/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ func (m *Server) GetPrivacyFlags(remoteKey *btcec.PublicKey) (
key := hex.EncodeToString(remoteKey.SerializeCompressed())
sess, ok := m.sessions[key]
if !ok {
return session.PrivacyFlags{}, fmt.Errorf("no such client found")
return session.PrivacyFlags{},
fmt.Errorf("no such client found")
}

privacyFlags, err := session.Deserialize(sess.privacyFlags)
Expand Down Expand Up @@ -436,7 +437,9 @@ func rulesToRPC(rulesMap map[string]*RuleRanges) (
return res, nil
}

func permissionsToRPC(ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {
func permissionsToRPC(
ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {

res := make([]*autopilotserverrpc.Permissions, len(ps))

for method, ops := range ps {
Expand Down
3 changes: 2 additions & 1 deletion cmd/litcli/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ var updateAccountCommand = cli.Command{
Name: "update",
ShortName: "u",
Usage: "Update an existing off-chain account.",
ArgsUsage: "[id | label] new_balance [new_expiration_date] [--save_to=]",
ArgsUsage: "[id | label] new_balance [new_expiration_date] " +
"[--save_to=]",
Description: "Updates an existing off-chain account and sets " +
"either a new balance or new expiration date or both.",
Flags: []cli.Flag{
Expand Down
3 changes: 2 additions & 1 deletion cmd/litcli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ var listActionsCommand = cli.Command{
Name: "state",
Usage: "The action state to filter on. If not set, " +
"then actions of any state will be returned. " +
"Options include: 'pending', 'done' and 'error'.",
"Options include: 'pending', 'done' and " +
"'error'.",
},
cli.Uint64Flag{
Name: "index_offset",
Expand Down
10 changes: 5 additions & 5 deletions cmd/litcli/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ var addAutopilotSessionCmd = cli.Command{
},
cli.StringFlag{
Name: "privacy-flags",
Usage: "String representation of privacy flags to set " +
"for the session. Each individual flag will " +
"remove privacy from certain aspects of " +
"messages transmitted to autopilot. " +
"The strongest privacy is on by " +
Usage: "String representation of privacy flags " +
"to set for the session. Each individual " +
"flag will remove privacy from certain " +
"aspects of messages transmitted to " +
"autopilot. The strongest privacy is on by " +
"default and an empty string means full " +
"privacy. Some features may not be able to " +
"run correctly with full privacy, see the " +
Expand Down
8 changes: 4 additions & 4 deletions cmd/litcli/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var litCommands = []cli.Command{
Name: "bakesupermacaroon",
Usage: "Bake a new super macaroon with all of LiT's active " +
"permissions",
Description: "Bake a new super macaroon with all of LiT's active " +
"permissions.",
Description: "Bake a new super macaroon with all of LiT's " +
"active permissions.",
Category: "LiT",
Action: bakeSuperMacaroon,
Flags: []cli.Flag{
Expand Down Expand Up @@ -47,8 +47,8 @@ var litCommands = []cli.Command{
Name: "getinfo",
Usage: "Returns basic information related to the active " +
"daemon",
Description: "Returns basic information related to the active " +
"daemon.",
Description: "Returns basic information related to the " +
"active daemon.",
Category: "LiT",
Action: getInfo,
},
Expand Down
21 changes: 10 additions & 11 deletions cmd/litcli/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,16 @@ func addSession(cli *cli.Context) error {
sessionExpiry := time.Now().Add(sessionLength).Unix()

ctx := getContext()
resp, err := client.AddSession(
ctx, &litrpc.AddSessionRequest{
Label: cli.String("label"),
SessionType: sessType,
ExpiryTimestampSeconds: uint64(sessionExpiry),
MailboxServerAddr: cli.String("mailboxserveraddr"),
DevServer: cli.Bool("devserver"),
MacaroonCustomPermissions: macPerms,
AccountId: cli.String("account_id"),
},
)
req := litrpc.AddSessionRequest{
Label: cli.String("label"),
SessionType: sessType,
ExpiryTimestampSeconds: uint64(sessionExpiry),
MailboxServerAddr: cli.String("mailboxserveraddr"),
DevServer: cli.Bool("devserver"),
MacaroonCustomPermissions: macPerms,
AccountId: cli.String("account_id"),
}
resp, err := client.AddSession(ctx, &req)
if err != nil {
return err
}
Expand Down
31 changes: 21 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var (
// all config items of its enveloping subservers, each prefixed with their
// daemon's short name.
//
//nolint:lll
//nolint:ll
type Config struct {
ShowVersion bool `long:"version" description:"Display version information and exit."`

Expand Down Expand Up @@ -284,6 +284,8 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string,
// defaultConfig returns a configuration struct with all default values set.
func defaultConfig() *Config {
defaultLogCfg := build.DefaultLogConfig()

// nolint:ll
return &Config{
HTTPSListen: defaultHTTPSListen,
TLSCertPath: DefaultTLSCertPath,
Expand Down Expand Up @@ -539,10 +541,15 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
// the remote connection as well.
defaultFaradayCfg := faraday.DefaultConfig()
if cfg.faradayRemote && cfg.Network != DefaultNetwork {
if cfg.Remote.Faraday.MacaroonPath == defaultFaradayCfg.MacaroonPath {
cfg.Remote.Faraday.MacaroonPath = cfg.Faraday.MacaroonPath
if cfg.Remote.Faraday.MacaroonPath ==
defaultFaradayCfg.MacaroonPath {

cfg.Remote.Faraday.MacaroonPath =
cfg.Faraday.MacaroonPath
}
if cfg.Remote.Faraday.TLSCertPath == defaultFaradayCfg.TLSCertPath {
if cfg.Remote.Faraday.TLSCertPath ==
defaultFaradayCfg.TLSCertPath {

cfg.Remote.Faraday.TLSCertPath = cfg.Faraday.TLSCertPath
}
}
Expand All @@ -553,9 +560,10 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
cfg.faradayRpcConfig.MacaroonPath = cfg.Faraday.MacaroonPath

if cfg.Faraday.ChainConn {
cfg.faradayRpcConfig.BitcoinClient, err = chain.NewBitcoinClient(
cfg.Faraday.Bitcoin,
)
cfg.faradayRpcConfig.BitcoinClient, err =
chain.NewBitcoinClient(
cfg.Faraday.Bitcoin,
)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -583,13 +591,16 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {

defaultTapCfg := tapcfg.DefaultConfig()
if cfg.tapRemote && cfg.Network != DefaultNetwork {
if cfg.Remote.TaprootAssets.MacaroonPath == defaultTapCfg.RpcConf.MacaroonPath {
if cfg.Remote.TaprootAssets.MacaroonPath ==
defaultTapCfg.RpcConf.MacaroonPath {

macaroonPath := cfg.TaprootAssets.RpcConf.MacaroonPath
cfg.Remote.TaprootAssets.MacaroonPath = macaroonPath
}
if cfg.Remote.TaprootAssets.TLSCertPath == defaultTapCfg.RpcConf.TLSCertPath {
tlsCertPath := cfg.TaprootAssets.RpcConf.TLSCertPath
if cfg.Remote.TaprootAssets.TLSCertPath ==
defaultTapCfg.RpcConf.TLSCertPath {

tlsCertPath := cfg.TaprootAssets.RpcConf.TLSCertPath
cfg.Remote.TaprootAssets.TLSCertPath = tlsCertPath
}
}
Expand Down
2 changes: 1 addition & 1 deletion config_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var defaultSqliteDatabasePath = filepath.Join(
// features not yet available in production. Since our itests are built with
// the dev tag, we can test these features in our itests.
//
// nolint:lll
// nolint:ll
type DevConfig struct {
// DatabaseBackend is the database backend we will use for storing all
// account related data. While this feature is still in development, we
Expand Down
2 changes: 1 addition & 1 deletion db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (

// PostgresConfig holds the postgres database configuration.
//
// nolint:lll
// nolint:ll
type PostgresConfig struct {
SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."`
Host string `long:"host" description:"Database server hostname."`
Expand Down
2 changes: 1 addition & 1 deletion db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
// SqliteConfig holds all the config arguments needed to interact with our
// sqlite DB.
//
// nolint: lll
// nolint:ll
type SqliteConfig struct {
// SkipMigrations if true, then all the tables will be created on start
// up if they don't already exist.
Expand Down
10 changes: 6 additions & 4 deletions firewall/caveats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ const (
// formatted as a caveat and then parsed again successfully.
func TestInterceptMetaInfo(t *testing.T) {
info := &InterceptMetaInfo{
ActorName: "autopilot",
Feature: "re-balance",
Trigger: "channel 7413345453234435345 depleted",
Intent: "increase outbound liquidity by 2000000 sats",
ActorName: "autopilot",
Feature: "re-balance",
Trigger: "channel 7413345453234435345 depleted",
Intent: "increase outbound liquidity by 2000000 " +
"sats",
StructuredJsonData: "{}",
}

Expand Down Expand Up @@ -93,6 +94,7 @@ func TestParseMetaInfoCaveat(t *testing.T) {
// caveat and then parsed again successfully.
func TestInterceptRule(t *testing.T) {
rules := &InterceptRules{
// nolint:ll
FeatureRules: map[string]map[string]string{
"AutoFees": {
"first-hop-ignore-list": "03abcd...,02badb01...",
Expand Down
4 changes: 2 additions & 2 deletions firewall/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package firewall

// Config holds all config options for the firewall.
//
//nolint:lll
//nolint:ll
type Config struct {
RequestLogger *RequestLoggerConfig `group:"request-logger" namespace:"request-logger" description:"request logger settings"`
}

// RequestLoggerConfig holds all the config options for the request logger.
//
//nolint:lll
//nolint:ll
type RequestLoggerConfig struct {
RequestLoggerLevel RequestLoggerLevel `long:"level" description:"Set the request logger level. Options include 'all', 'full' and 'interceptor''"`
}
Expand Down
Loading
Loading