Skip to content

Commit 1252fc8

Browse files
committed
linter: fix lint issues after migrating to golangci-lint v2
1 parent 3d15dfc commit 1252fc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+164
-89
lines changed

assets/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ func getClientConn(config *TapdConfig) (*grpc.ClientConn, error) {
290290
return nil, err
291291
}
292292
mac := &macaroon.Macaroon{}
293-
if err := mac.UnmarshalBinary(macBytes); err != nil {
293+
err = mac.UnmarshalBinary(macBytes)
294+
if err != nil {
294295
return nil, err
295296
}
296297

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ var (
9393
// Client performs the client side part of swaps. This interface exists to be
9494
// able to implement a stub.
9595
type Client struct {
96+
clientConfig
97+
9698
started uint32 // To be used atomically.
9799
errChan chan error
98100

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

108110
resumeReady chan struct{}
109111
wg sync.WaitGroup
110-
111-
clientConfig
112112
}
113113

114114
// ClientConfig is the exported configuration structure that is required to

cmd/loop/instantout.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func instantOut(ctx *cli.Context) error {
4040
// Otherwise, strings.Split returns a slice of length one with an empty
4141
// element.
4242
var outgoingChanSet []uint64
43+
4344
if ctx.IsSet("channel") {
4445
chanStrings := strings.Split(ctx.String("channel"), ",")
4546
for _, chanString := range chanStrings {
@@ -48,6 +49,7 @@ func instantOut(ctx *cli.Context) error {
4849
return fmt.Errorf("error parsing channel id "+
4950
"\"%v\"", chanString)
5051
}
52+
5153
outgoingChanSet = append(outgoingChanSet, chanID)
5254
}
5355
}
@@ -87,6 +89,7 @@ func instantOut(ctx *cli.Context) error {
8789
}
8890

8991
fmt.Printf("Available reservations: \n\n")
92+
9093
for _, res := range confirmedReservations {
9194
idx++
9295
fmt.Printf("Reservation %v: shortid %x, amt %v, expiry "+
@@ -111,6 +114,7 @@ func instantOut(ctx *cli.Context) error {
111114
selectedReservations [][]byte
112115
selectedAmt uint64
113116
)
117+
114118
switch answer {
115119
case "ALL":
116120
for _, res := range confirmedReservations {
@@ -127,18 +131,21 @@ func instantOut(ctx *cli.Context) error {
127131
default:
128132
selectedIndexes := strings.Split(answer, ",")
129133
selectedIndexMap := make(map[int]struct{})
134+
130135
for _, idxStr := range selectedIndexes {
131136
idx, err := strconv.Atoi(idxStr)
132137
if err != nil {
133138
return err
134139
}
140+
135141
if idx < 0 {
136142
return fmt.Errorf("invalid index %v", idx)
137143
}
138144

139145
if idx > len(confirmedReservations) {
140146
return fmt.Errorf("invalid index %v", idx)
141147
}
148+
142149
if _, ok := selectedIndexMap[idx]; ok {
143150
return fmt.Errorf("duplicate index %v", idx)
144151
}
@@ -164,6 +171,7 @@ func instantOut(ctx *cli.Context) error {
164171
if err != nil {
165172
return err
166173
}
174+
167175
fmt.Println()
168176
fmt.Printf(satAmtFmt, "Estimated on-chain fee:", quote.SweepFeeSat)
169177
fmt.Printf(satAmtFmt, "Service fee:", quote.ServiceFeeSat)
@@ -172,6 +180,7 @@ func instantOut(ctx *cli.Context) error {
172180
fmt.Printf("CONTINUE SWAP? (y/n): ")
173181

174182
fmt.Scanln(&answer)
183+
175184
if answer != "y" {
176185
return errors.New("swap canceled")
177186
}
@@ -187,7 +196,6 @@ func instantOut(ctx *cli.Context) error {
187196
DestAddr: ctx.String("addr"),
188197
},
189198
)
190-
191199
if err != nil {
192200
return err
193201
}
@@ -228,5 +236,6 @@ func listInstantOuts(ctx *cli.Context) error {
228236
}
229237

230238
printRespJSON(resp)
239+
231240
return nil
232241
}

cmd/loop/l402.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func listAuth(ctx *cli.Context) error {
4848
tokens := make([]*printableToken, len(resp.Tokens))
4949
for i, t := range resp.Tokens {
5050
mac := &macaroon.Macaroon{}
51+
5152
err := mac.UnmarshalBinary(t.BaseMacaroon)
5253
if err != nil {
5354
return fmt.Errorf("unable to unmarshal macaroon: %v",

cmd/loop/liquidity.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ func setRule(ctx *cli.Context) error {
8787
pubkey route.Vertex
8888
pubkeyRule bool
8989
)
90+
9091
chanID, err := strconv.ParseUint(ctx.Args().First(), 10, 64)
9192
if err != nil {
9293
pubkey, err = route.NewVertexFromStr(ctx.Args().First())
9394
if err != nil {
9495
return fmt.Errorf("please provide a valid pubkey: "+
9596
"%v, or short channel ID", err)
9697
}
98+
9799
pubkeyRule = true
98100
}
99101

@@ -177,6 +179,7 @@ func setRule(ctx *cli.Context) error {
177179
ChannelId: chanID,
178180
Type: looprpc.LiquidityRuleType_THRESHOLD,
179181
}
182+
180183
if ctx.IsSet("type") {
181184
switch ctx.String("type") {
182185
case "in":
@@ -406,6 +409,7 @@ func setParams(ctx *cli.Context) error {
406409
if ctx.IsSet("maxswapfee") {
407410
feeRate := ctx.Float64("maxswapfee")
408411
params.MaxSwapFeePpm, err = ppmFromPercentage(feeRate)
412+
409413
if err != nil {
410414
return err
411415
}
@@ -425,6 +429,7 @@ func setParams(ctx *cli.Context) error {
425429
if ctx.IsSet("feepercent") {
426430
feeRate := ctx.Float64("feepercent")
427431
params.FeePpm, err = ppmFromPercentage(feeRate)
432+
428433
if err != nil {
429434
return err
430435
}
@@ -447,6 +452,7 @@ func setParams(ctx *cli.Context) error {
447452
if ctx.IsSet("maxprepayfee") {
448453
feeRate := ctx.Float64("maxprepayfee")
449454
params.MaxPrepayRoutingFeePpm, err = ppmFromPercentage(feeRate)
455+
450456
if err != nil {
451457
return err
452458
}
@@ -551,6 +557,7 @@ func setParams(ctx *cli.Context) error {
551557
map[string]*looprpc.EasyAssetAutoloopParams,
552558
)
553559
}
560+
554561
if _, ok := params.EasyAssetParams[ctx.String("asset_id")]; !ok { //nolint:lll
555562
params.EasyAssetParams[ctx.String("asset_id")] =
556563
&looprpc.EasyAssetAutoloopParams{}
@@ -572,6 +579,7 @@ func setParams(ctx *cli.Context) error {
572579
return fmt.Errorf("asset_id must be set to use " +
573580
"asset_easyautoloop")
574581
}
582+
575583
params.EasyAssetParams[ctx.String("asset_id")].
576584
Enabled = ctx.Bool("asset_easyautoloop")
577585
flagSet = true
@@ -582,6 +590,7 @@ func setParams(ctx *cli.Context) error {
582590
return fmt.Errorf("asset_id must be set to use " +
583591
"asset_localbalance")
584592
}
593+
585594
params.EasyAssetParams[ctx.String("asset_id")].
586595
LocalTargetAssetAmt = ctx.Uint64("asset_localbalance")
587596
flagSet = true

cmd/loop/loopin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ func loopIn(ctx *cli.Context) error {
126126

127127
// Validate our label early so that we can fail before getting a quote.
128128
label := ctx.String(labelFlag.Name)
129-
if err := labels.Validate(label); err != nil {
129+
err = labels.Validate(label)
130+
if err != nil {
130131
return err
131132
}
132133

133134
var lastHop []byte
135+
134136
if ctx.IsSet(lastHopFlag.Name) {
135137
lastHopVertex, err := route.NewVertexFromStr(
136138
ctx.String(lastHopFlag.Name),
@@ -207,6 +209,7 @@ func loopIn(ctx *cli.Context) error {
207209

208210
fmt.Printf("Swap initiated\n")
209211
fmt.Printf("ID: %v\n", resp.Id)
212+
210213
if resp.HtlcAddressP2Tr != "" {
211214
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
212215
} else {

cmd/loop/loopout.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func loopOut(ctx *cli.Context) error {
148148
// Otherwise, strings.Split returns a slice of length one with an empty
149149
// element.
150150
var outgoingChanSet []uint64
151+
151152
if ctx.IsSet("channel") {
152153
if ctx.IsSet("asset_id") {
153154
return fmt.Errorf("channel flag is not supported when " +
@@ -166,7 +167,8 @@ func loopOut(ctx *cli.Context) error {
166167

167168
// Validate our label early so that we can fail before getting a quote.
168169
label := ctx.String(labelFlag.Name)
169-
if err := labels.Validate(label); err != nil {
170+
err = labels.Validate(label)
171+
if err != nil {
170172
return err
171173
}
172174

@@ -177,6 +179,7 @@ func loopOut(ctx *cli.Context) error {
177179
}
178180

179181
var destAddr string
182+
180183
var account string
181184
switch {
182185
case ctx.IsSet("addr"):
@@ -338,6 +341,7 @@ func loopOut(ctx *cli.Context) error {
338341
fmt.Printf("Swap initiated\n")
339342
fmt.Printf("ID: %x\n", resp.IdBytes)
340343
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress) // nolint:staticcheck
344+
341345
if resp.ServerMessage != "" {
342346
fmt.Printf("Server message: %v\n", resp.ServerMessage)
343347
}

cmd/loop/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func printJSON(resp interface{}) {
140140
if err != nil {
141141
fatal(err)
142142
}
143+
143144
out.WriteString("\n")
144145
_, _ = out.WriteTo(os.Stdout)
145146
}
@@ -446,7 +447,8 @@ func readMacaroon(macPath string) (grpc.DialOption, error) {
446447
}
447448

448449
mac := &macaroon.Macaroon{}
449-
if err = mac.UnmarshalBinary(macBytes); err != nil {
450+
err = mac.UnmarshalBinary(macBytes)
451+
if err != nil {
450452
return nil, fmt.Errorf("unable to decode macaroon: %v", err)
451453
}
452454

cmd/loop/staticaddr.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func listDeposits(ctx *cli.Context) error {
261261
defer cleanup()
262262

263263
var filterState looprpc.DepositState
264+
264265
switch ctx.String("filter") {
265266
case "":
266267
// If no filter is specified, we'll default to showing all.
@@ -417,6 +418,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
417418
if len(utxos) == 0 {
418419
return nil, fmt.Errorf("no utxos specified")
419420
}
421+
420422
for _, utxo := range utxos {
421423
outpoint, err := NewProtoOutPoint(utxo)
422424
if err != nil {
@@ -509,7 +511,8 @@ func staticAddressLoopIn(ctx *cli.Context) error {
509511
)
510512

511513
// Validate our label early so that we can fail before getting a quote.
512-
if err := labels.Validate(label); err != nil {
514+
err = labels.Validate(label)
515+
if err != nil {
513516
return err
514517
}
515518

@@ -550,6 +553,7 @@ func staticAddressLoopIn(ctx *cli.Context) error {
550553
}
551554

552555
var depositOutpoints []string
556+
553557
switch {
554558
case isAllSelected == isUtxoSelected:
555559
return errors.New("must select either all or some utxos")

cmd/loop/swaps.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func listSwaps(ctx *cli.Context) error {
6262
filter := &looprpc.ListSwapsFilter{}
6363

6464
// Set the swap type filter.
65+
6566
switch {
6667
case ctx.Bool("loop_out_only"):
6768
filter.SwapType = looprpc.ListSwapsFilter_LOOP_OUT
@@ -150,6 +151,7 @@ func swapInfo(ctx *cli.Context) error {
150151
args := ctx.Args()
151152

152153
var id string
154+
153155
switch {
154156
case ctx.IsSet("id"):
155157
id = ctx.String("id")

0 commit comments

Comments
 (0)