multi: fix linter issues

pull/17/head v0.8.0
Oliver Gugger 3 years ago
parent 729e71f751
commit 959dcf3f95
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -6,14 +6,15 @@ import (
"encoding/hex"
"errors"
"fmt"
"os"
"strings"
"syscall"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/guggero/chantools/bip39"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/ssh/terminal"
"os"
"strings"
"syscall"
)
const (

@ -2,6 +2,7 @@ package main
import (
"fmt"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/guggero/chantools/lnd"
@ -86,7 +87,7 @@ func deriveKey(extendedKey *hdkeychain.ExtendedKey, path string,
return fmt.Errorf("could not create address: %v", err)
}
privKey, xPriv := "n/a", "n/a"
privKey, xPriv := na, na
if !neuter {
privKey, xPriv = wif.String(), child.String()
}
@ -96,7 +97,7 @@ func deriveKey(extendedKey *hdkeychain.ExtendedKey, path string,
pubKey.SerializeCompressed(), neutered, addrP2WKH, addrP2PKH,
privKey, xPriv,
)
fmt.Printf(result)
fmt.Println(result)
// For the tests, also log as trace level which is disabled by default.
log.Tracef(result)

@ -1,11 +1,11 @@
package main
import (
"github.com/guggero/chantools/btc"
"github.com/guggero/chantools/lnd"
"os"
"testing"
"github.com/guggero/chantools/btc"
"github.com/guggero/chantools/lnd"
"github.com/stretchr/testify/require"
)

@ -20,7 +20,7 @@ import (
)
type forceCloseCommand struct {
ApiURL string
APIURL string
ChannelDB string
Publish bool
@ -54,7 +54,7 @@ blocks) transaction *or* they have a watch tower looking out for them.
RunE: cc.Execute,
}
cc.cmd.Flags().StringVar(
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
"be esplora compatible)",
)
cc.cmd.Flags().StringVar(
@ -92,7 +92,7 @@ func (c *forceCloseCommand) Execute(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}
return forceCloseChannels(c.ApiURL, extendedKey, entries, db, c.Publish)
return forceCloseChannels(c.APIURL, extendedKey, entries, db, c.Publish)
}
func forceCloseChannels(apiURL string, extendedKey *hdkeychain.ExtendedKey,

@ -147,10 +147,6 @@ func (c *rescueFundingCommand) Execute(_ *cobra.Command, _ []string) error {
return fmt.Errorf("error parsing sweep addr: %v", err)
}
if c.FeeRate < 0 {
return fmt.Errorf("satperbyte must be greater than 0")
}
return rescueFunding(
db, signer, dbOp, chainOp, sweepScript,
btcutil.Amount(c.FeeRate),

@ -5,7 +5,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/guggero/chantools/btc"
"io/ioutil"
"os"
"strings"
@ -15,6 +14,7 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btclog"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/guggero/chantools/btc"
"github.com/guggero/chantools/dataformat"
"github.com/guggero/chantools/lnd"
"github.com/lightningnetwork/lnd/build"
@ -27,6 +27,7 @@ import (
const (
defaultAPIURL = "https://blockstream.info/api"
version = "0.8.0"
na = "n/a"
Commit = ""
)
@ -67,7 +68,7 @@ Complete documentation is available at https://github.com/guggero/chantools/.`,
DisableAutoGenTag: true,
}
func init() {
func main() {
rootCmd.PersistentFlags().BoolVarP(
&Testnet, "testnet", "t", false, "Indicates if testnet "+
"parameters should be used",
@ -100,9 +101,7 @@ func init() {
newVanityGenCommand(),
newWalletInfoCommand(),
)
}
func main() {
if err := rootCmd.Execute(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)

@ -2,7 +2,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path"
@ -36,9 +35,9 @@ const (
var (
datePattern = regexp.MustCompile(
"\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3} ",
`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} `,
)
addressPattern = regexp.MustCompile("\\(0x[0-9a-f]{10}\\)")
addressPattern = regexp.MustCompile(`\(0x[0-9a-f]{10}\)`)
)
type harness struct {
@ -80,10 +79,10 @@ func (h *harness) clearLog() {
h.logBuffer.Reset()
}
func (h *harness) assertLogContains(format string, args ...interface{}) {
func (h *harness) assertLogContains(format string) {
h.t.Helper()
require.Contains(h.t, h.logBuffer.String(), fmt.Sprintf(format, args...))
require.Contains(h.t, h.logBuffer.String(), format)
}
func (h *harness) assertLogEqual(a, b string) {

@ -40,7 +40,7 @@ func (c *showRootKeyCommand) Execute(_ *cobra.Command, _ []string) error {
}
result := fmt.Sprintf(showRootKeyFormat, extendedKey)
fmt.Printf(result)
fmt.Println(result)
// For the tests, also log as trace level which is disabled by default.
log.Tracef(result)

@ -1,10 +1,10 @@
package main
import (
"github.com/guggero/chantools/btc"
"os"
"testing"
"github.com/guggero/chantools/btc"
"github.com/guggero/chantools/lnd"
"github.com/stretchr/testify/require"
)
@ -64,4 +64,4 @@ func TestShowRootKeyBIP39WithPassphre(t *testing.T) {
require.NoError(t, err)
h.assertLogContains(rootKeyBip39Passphrase)
}
}

@ -12,7 +12,7 @@ import (
)
type summaryCommand struct {
ApiURL string
APIURL string
inputs *inputFlags
cmd *cobra.Command
@ -32,7 +32,7 @@ chantools summary --fromchanneldb ~/.lnd/data/graph/mainnet/channel.db`,
RunE: cc.Execute,
}
cc.cmd.Flags().StringVar(
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
"be esplora compatible)",
)
@ -47,7 +47,7 @@ func (c *summaryCommand) Execute(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}
return summarizeChannels(c.ApiURL, entries)
return summarizeChannels(c.APIURL, entries)
}
func summarizeChannels(apiURL string,

@ -24,7 +24,7 @@ const (
)
type sweepTimeLockCommand struct {
ApiURL string
APIURL string
Publish bool
SweepAddr string
MaxCsvLimit uint16
@ -55,7 +55,7 @@ parameter to 144.`,
RunE: cc.Execute,
}
cc.cmd.Flags().StringVar(
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
"be esplora compatible)",
)
cc.cmd.Flags().BoolVar(
@ -105,7 +105,7 @@ func (c *sweepTimeLockCommand) Execute(_ *cobra.Command, _ []string) error {
c.FeeRate = defaultFeeSatPerVByte
}
return sweepTimeLock(
extendedKey, c.ApiURL, entries, c.SweepAddr, c.MaxCsvLimit,
extendedKey, c.APIURL, entries, c.SweepAddr, c.MaxCsvLimit,
c.Publish, c.FeeRate,
)
}

@ -26,7 +26,7 @@ const (
)
type sweepTimeLockManualCommand struct {
ApiURL string
APIURL string
Publish bool
SweepAddr string
MaxCsvLimit uint16
@ -65,7 +65,7 @@ address is always the one that's longer (because it's P2WSH and not P2PKH).`,
RunE: cc.Execute,
}
cc.cmd.Flags().StringVar(
&cc.ApiURL, "apiurl", defaultAPIURL, "API URL to use (must "+
&cc.APIURL, "apiurl", defaultAPIURL, "API URL to use (must "+
"be esplora compatible)",
)
cc.cmd.Flags().BoolVar(
@ -122,7 +122,7 @@ func (c *sweepTimeLockManualCommand) Execute(_ *cobra.Command, _ []string) error
}
return sweepTimeLockManual(
extendedKey, c.ApiURL, c.SweepAddr, c.TimeLockAddr,
extendedKey, c.APIURL, c.SweepAddr, c.TimeLockAddr,
remoteRevPoint, c.MaxCsvLimit, c.Publish, c.FeeRate,
)
}

@ -163,7 +163,7 @@ func (c *walletInfoCommand) Execute(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}
rootKey := "n/a"
rootKey := na
if c.WithRootKey {
masterHDPrivKey, err := decryptRootKey(db, privateWalletPw)
if err != nil {
@ -177,7 +177,7 @@ func (c *walletInfoCommand) Execute(_ *cobra.Command, _ []string) error {
scopeInfo,
)
fmt.Printf(result)
fmt.Println(result)
// For the tests, also log as trace level which is disabled by default.
log.Tracef(result)

@ -12,7 +12,7 @@ require (
github.com/coreos/bbolt v1.3.3
github.com/davecgh/go-spew v1.1.1
github.com/gohugoio/hugo v0.79.1 // indirect
github.com/jessevdk/go-flags v1.4.0
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/lightningnetwork/lnd v0.11.1-beta
github.com/ltcsuite/ltcd v0.0.0-20191228044241-92166e412499 // indirect
github.com/miekg/dns v1.1.26 // indirect

Loading…
Cancel
Save