Skip to content

Commit 959dcf3

Browse files
committed
multi: fix linter issues
1 parent 729e71f commit 959dcf3

File tree

14 files changed

+34
-38
lines changed

14 files changed

+34
-38
lines changed

btc/bip39.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"encoding/hex"
77
"errors"
88
"fmt"
9+
"os"
10+
"strings"
11+
"syscall"
12+
913
"github.com/btcsuite/btcd/chaincfg"
1014
"github.com/btcsuite/btcutil/hdkeychain"
1115
"github.com/guggero/chantools/bip39"
1216
"golang.org/x/crypto/pbkdf2"
1317
"golang.org/x/crypto/ssh/terminal"
14-
"os"
15-
"strings"
16-
"syscall"
1718
)
1819

1920
const (

cmd/chantools/derivekey.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
56
"github.com/btcsuite/btcutil"
67
"github.com/btcsuite/btcutil/hdkeychain"
78
"github.com/guggero/chantools/lnd"
@@ -86,7 +87,7 @@ func deriveKey(extendedKey *hdkeychain.ExtendedKey, path string,
8687
return fmt.Errorf("could not create address: %v", err)
8788
}
8889

89-
privKey, xPriv := "n/a", "n/a"
90+
privKey, xPriv := na, na
9091
if !neuter {
9192
privKey, xPriv = wif.String(), child.String()
9293
}
@@ -96,7 +97,7 @@ func deriveKey(extendedKey *hdkeychain.ExtendedKey, path string,
9697
pubKey.SerializeCompressed(), neutered, addrP2WKH, addrP2PKH,
9798
privKey, xPriv,
9899
)
99-
fmt.Printf(result)
100+
fmt.Println(result)
100101

101102
// For the tests, also log as trace level which is disabled by default.
102103
log.Tracef(result)

cmd/chantools/derivekey_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package main
22

33
import (
4-
"github.com/guggero/chantools/btc"
5-
"github.com/guggero/chantools/lnd"
64
"os"
75
"testing"
86

7+
"github.com/guggero/chantools/btc"
8+
"github.com/guggero/chantools/lnd"
99
"github.com/stretchr/testify/require"
1010
)
1111

cmd/chantools/forceclose.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
type forceCloseCommand struct {
23-
ApiURL string
23+
APIURL string
2424
ChannelDB string
2525
Publish bool
2626

@@ -54,7 +54,7 @@ blocks) transaction *or* they have a watch tower looking out for them.
5454
RunE: cc.Execute,
5555
}
5656
cc.cmd.Flags().StringVar(
57-
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
57+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
5858
"be esplora compatible)",
5959
)
6060
cc.cmd.Flags().StringVar(
@@ -92,7 +92,7 @@ func (c *forceCloseCommand) Execute(_ *cobra.Command, _ []string) error {
9292
if err != nil {
9393
return err
9494
}
95-
return forceCloseChannels(c.ApiURL, extendedKey, entries, db, c.Publish)
95+
return forceCloseChannels(c.APIURL, extendedKey, entries, db, c.Publish)
9696
}
9797

9898
func forceCloseChannels(apiURL string, extendedKey *hdkeychain.ExtendedKey,

cmd/chantools/rescuefunding.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ func (c *rescueFundingCommand) Execute(_ *cobra.Command, _ []string) error {
147147
return fmt.Errorf("error parsing sweep addr: %v", err)
148148
}
149149

150-
if c.FeeRate < 0 {
151-
return fmt.Errorf("satperbyte must be greater than 0")
152-
}
153-
154150
return rescueFunding(
155151
db, signer, dbOp, chainOp, sweepScript,
156152
btcutil.Amount(c.FeeRate),

cmd/chantools/root.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"bytes"
66
"encoding/json"
77
"fmt"
8-
"github.com/guggero/chantools/btc"
98
"io/ioutil"
109
"os"
1110
"strings"
@@ -15,6 +14,7 @@ import (
1514
"github.com/btcsuite/btcd/chaincfg"
1615
"github.com/btcsuite/btclog"
1716
"github.com/btcsuite/btcutil/hdkeychain"
17+
"github.com/guggero/chantools/btc"
1818
"github.com/guggero/chantools/dataformat"
1919
"github.com/guggero/chantools/lnd"
2020
"github.com/lightningnetwork/lnd/build"
@@ -27,6 +27,7 @@ import (
2727
const (
2828
defaultAPIURL = "https://blockstream.info/api"
2929
version = "0.8.0"
30+
na = "n/a"
3031

3132
Commit = ""
3233
)
@@ -67,7 +68,7 @@ Complete documentation is available at https://github.com/guggero/chantools/.`,
6768
DisableAutoGenTag: true,
6869
}
6970

70-
func init() {
71+
func main() {
7172
rootCmd.PersistentFlags().BoolVarP(
7273
&Testnet, "testnet", "t", false, "Indicates if testnet "+
7374
"parameters should be used",
@@ -100,9 +101,7 @@ func init() {
100101
newVanityGenCommand(),
101102
newWalletInfoCommand(),
102103
)
103-
}
104104

105-
func main() {
106105
if err := rootCmd.Execute(); err != nil {
107106
_, _ = fmt.Fprintln(os.Stderr, err)
108107
os.Exit(1)

cmd/chantools/root_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"bytes"
5-
"fmt"
65
"io/ioutil"
76
"os"
87
"path"
@@ -36,9 +35,9 @@ const (
3635

3736
var (
3837
datePattern = regexp.MustCompile(
39-
"\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} ",
38+
`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} `,
4039
)
41-
addressPattern = regexp.MustCompile("\\(0x[0-9a-f]{10}\\)")
40+
addressPattern = regexp.MustCompile(`\(0x[0-9a-f]{10}\)`)
4241
)
4342

4443
type harness struct {
@@ -80,10 +79,10 @@ func (h *harness) clearLog() {
8079
h.logBuffer.Reset()
8180
}
8281

83-
func (h *harness) assertLogContains(format string, args ...interface{}) {
82+
func (h *harness) assertLogContains(format string) {
8483
h.t.Helper()
8584

86-
require.Contains(h.t, h.logBuffer.String(), fmt.Sprintf(format, args...))
85+
require.Contains(h.t, h.logBuffer.String(), format)
8786
}
8887

8988
func (h *harness) assertLogEqual(a, b string) {

cmd/chantools/showrootkey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (c *showRootKeyCommand) Execute(_ *cobra.Command, _ []string) error {
4040
}
4141

4242
result := fmt.Sprintf(showRootKeyFormat, extendedKey)
43-
fmt.Printf(result)
43+
fmt.Println(result)
4444

4545
// For the tests, also log as trace level which is disabled by default.
4646
log.Tracef(result)

cmd/chantools/showrootkey_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package main
22

33
import (
4-
"github.com/guggero/chantools/btc"
54
"os"
65
"testing"
76

7+
"github.com/guggero/chantools/btc"
88
"github.com/guggero/chantools/lnd"
99
"github.com/stretchr/testify/require"
1010
)
@@ -64,4 +64,4 @@ func TestShowRootKeyBIP39WithPassphre(t *testing.T) {
6464
require.NoError(t, err)
6565

6666
h.assertLogContains(rootKeyBip39Passphrase)
67-
}
67+
}

cmd/chantools/summary.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
type summaryCommand struct {
15-
ApiURL string
15+
APIURL string
1616

1717
inputs *inputFlags
1818
cmd *cobra.Command
@@ -32,7 +32,7 @@ chantools summary --fromchanneldb ~/.lnd/data/graph/mainnet/channel.db`,
3232
RunE: cc.Execute,
3333
}
3434
cc.cmd.Flags().StringVar(
35-
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
35+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
3636
"be esplora compatible)",
3737
)
3838

@@ -47,7 +47,7 @@ func (c *summaryCommand) Execute(_ *cobra.Command, _ []string) error {
4747
if err != nil {
4848
return err
4949
}
50-
return summarizeChannels(c.ApiURL, entries)
50+
return summarizeChannels(c.APIURL, entries)
5151
}
5252

5353
func summarizeChannels(apiURL string,

0 commit comments

Comments
 (0)