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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:

# If you change this value, please change it in the following files as well:
# /Dockerfile
GO_VERSION: 1.24.0
GO_VERSION: 1.24.6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in the commit message: "upgarde"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


jobs:
########################
Expand Down
240 changes: 111 additions & 129 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,149 +1,131 @@
version: "2"
run:
go: "1.24"

# timeout for analysis
timeout: 4m

go: "1.23"

linters-settings:
govet:
# Don't report about shadowed variables
shadowing: false

gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true

tagliatelle:
case:
rules:
json: snake

whitespace:
multi-func: true
multi-if: true

gosec:
excludes:
- G402 # Look for bad TLS connection settings.
- G306 # Poor file permissions used when writing to a new file.
- G115 # Integer overflow conversion.

staticcheck:
checks: [ "-SA1019" ]

linters:
enable-all: true
default: all
disable:
# Global variables are used in many places throughout the code base.
- gochecknoglobals

# Some lines are over 80 characters on purpose and we don't want to make them
# even longer by marking them as 'nolint'.
- lll

# We want to allow short variable names.
- varnamelen

# We want to allow TODOs.
- godox

# We have long functions, especially in tests. Moving or renaming those would
# trigger funlen problems that we may not want to solve at that time.
- funlen

# Disable for now as we haven't yet tuned the sensitivity to our codebase
# yet. Enabling by default for example, would also force new contributors to
# potentially extensively refactor code, when they want to smaller change to
# land.
- gocyclo
- gocognit
- containedctx
- contextcheck
- cyclop

# Instances of table driven tests that don't pre-allocate shouldn't trigger
# the linter.
- prealloc

# Init functions are used by loggers throughout the codebase.
- gochecknoinits

# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
- depguard
- dogsled
- err113
- errname
- errorlint

# New linters that need a code adjustment first.
- wrapcheck
- nolintlint
- paralleltest
- tparallel
- testpackage
- gofumpt
- exhaustive
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- gocyclo
- godox
- gomoddirectives
- inamedparam
- interfacebloat
- intrange
- ireturn
- maintidx
- nlreturn
- dogsled
- gci
- containedctx
- contextcheck
- errname
- err113
- mnd
- noctx
- nestif
- wsl
- exhaustive
- forcetypeassert
- nilerr
- nilnil
- stylecheck
- thelper
- revive
- tagalign
- depguard
- interfacebloat
- inamedparam
- intrange
- nlreturn
- noctx
- nolintlint
- paralleltest
- perfsprint
- prealloc
- protogetter
- revive
- tagalign
- testifylint

# Additions compared to LND
- exhaustruct

- testpackage
- thelper
- tparallel
- varnamelen
- wrapcheck
- wsl
- funcorder
- wsl_v5
- noinlineerr
settings:
gosec:
excludes:
- G402
- G306
- G115
staticcheck:
checks:
- -SA1019
tagliatelle:
case:
rules:
json: snake
whitespace:
multi-if: true
multi-func: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- forbidigo
- gosec
- unparam
path: _test\.go
- linters:
- gosec
path: _mock\.go
- linters:
- errcheck
- forbidigo
path: cmd/loopd/*
- linters:
- forbidigo
path: loopd/*
- linters:
- errcheck
- forbidigo
path: cmd/loop/*
- linters:
- forbidigo
path: fsm/stateparser/*
- linters:
- lll
path: loopd/config.go
- linters:
- lll
path: loopdb/*
paths:
- \.pb\.go$
- \.pb\.gw\.go$
- third_party$
- builtin$
- examples$
issues:
# Only show newly introduced problems.
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250

exclude-files:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"

exclude-rules:
# Allow fmt.Printf() in test files
- path: _test\.go
linters:
- forbidigo
- unparam
- gosec
- path: _mock\.go
linters:
- gosec

# Allow fmt.Printf() in loopd
- path: cmd/loopd/*
linters:
- forbidigo
- errcheck
- path: loopd/*
linters:
- forbidigo

# Allow fmt.Printf() in loop
- path: cmd/loop/*
linters:
- forbidigo
- errcheck

# Allow fmt.Printf() in stateparser
- path: fsm/stateparser/*
linters:
- forbidigo
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- \.pb\.go$
- \.pb\.gw\.go$
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ var (
// Client performs the client side part of swaps. This interface exists to be
// able to implement a stub.
type Client struct {
clientConfig

started uint32 // To be used atomically.
errChan chan error

Expand All @@ -107,8 +109,6 @@ type Client struct {

resumeReady chan struct{}
wg sync.WaitGroup

clientConfig
}

// ClientConfig is the exported configuration structure that is required to
Expand Down
2 changes: 1 addition & 1 deletion cmd/loop/instantout.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func instantOut(ctx *cli.Context) error {
DestAddr: ctx.String("addr"),
},
)

if err != nil {
return err
}
Expand Down Expand Up @@ -228,5 +227,6 @@ func listInstantOuts(ctx *cli.Context) error {
}

printRespJSON(resp)

return nil
}
1 change: 1 addition & 0 deletions cmd/loop/loopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func loopIn(ctx *cli.Context) error {

fmt.Printf("Swap initiated\n")
fmt.Printf("ID: %v\n", resp.Id)

if resp.HtlcAddressP2Tr != "" {
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
} else {
Expand Down
6 changes: 4 additions & 2 deletions cmd/loop/loopout.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ func loopOut(ctx *cli.Context) error {
"address to sweep the loop amount to")
}

var destAddr string
var account string
var (
destAddr string
account string
)
switch {
case ctx.IsSet("addr"):
destAddr = ctx.String("addr")
Expand Down
1 change: 1 addition & 0 deletions cmd/loop/staticaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
if len(utxos) == 0 {
return nil, fmt.Errorf("no utxos specified")
}

for _, utxo := range utxos {
outpoint, err := NewProtoOutPoint(utxo)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cost_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost,
error) {

// First make sure that this swap is actually finished.
// First, make sure that this swap is actually finished.
if loopOutSwap.State().State.IsPending() {
return loopdb.SwapCost{}, fmt.Errorf("swap is not yet finished")
}
Expand All @@ -41,8 +41,8 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
}

// The swap hash is given and we don't need to get it from the
// swap invoice, however we'll decode it anyway to get the invoice amount
// that was paid in case we don't have the payment anymore.
// swap invoice, however we'll decode it anyway to get the invoice
// amount that was paid in case we don't have the payment anymore.
_, _, swapHash, swapPaymentAmount, err := swap.DecodeInvoice(
params, loopOutSwap.Contract.SwapInvoice,
)
Expand Down Expand Up @@ -195,6 +195,6 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices,
return err
}

// Finally mark the migration as done.
// Finally, mark the migration as done.
return db.SetMigration(ctx, costMigrationID)
}
10 changes: 3 additions & 7 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ type executorConfig struct {
}

// executor is responsible for executing swaps.
//
// TODO(roasbeef): rename to SubSwapper.
type executor struct {
sync.Mutex
executorConfig

wg sync.WaitGroup
newSwaps chan genericSwap
currentHeight uint32
ready chan struct{}

sync.Mutex

executorConfig
}

// newExecutor returns a new swap executor instance.
Expand Down Expand Up @@ -80,7 +77,6 @@ func (s *executor) run(mainCtx context.Context,
for {
blockEpochChan, blockErrorChan, err =
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)

if err == nil {
break
}
Expand Down
2 changes: 1 addition & 1 deletion fsm/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func NewStateMachine(states States, observerSize int) *StateMachine {
func NewStateMachineWithState(states States, current StateType,
observerSize int) *StateMachine {

observers := []Observer{}
var observers []Observer
var defaultObserver *CachedObserver

if observerSize > 0 {
Expand Down
Loading