Skip to content

Commit

Permalink
Merge pull request #138 from starius/update-lnd-v0.18.0-beta
Browse files Browse the repository at this point in the history
update dependencies (LND v0.18.0-beta and co)
  • Loading branch information
guggero authored Jun 18, 2024
2 parents 1f43c4a + 65d6e52 commit d173f8c
Show file tree
Hide file tree
Showing 63 changed files with 1,198 additions and 798 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
# go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go
GO_VERSION: 1.21.3
GO_VERSION: 1.22.3

jobs:
########################
Expand Down
21 changes: 6 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
# timeout for analysis
deadline: 4m
timeout: 4m

linters-settings:
govet:
Expand All @@ -12,7 +12,7 @@ linters-settings:
whitespace:
multi-func: true
multi-if: true
tagliatelle:
tagliatelle:
case:
rules:
json: snake
Expand All @@ -31,17 +31,15 @@ linters:
- gochecknoglobals
- gosec
- funlen
- maligned
- varnamelen
- wrapcheck
- testpackage
- gomnd
- goerr113
- err113
- exhaustruct
- forbidigo
- gocognit
- nestif
- ifshort
- wsl
- cyclop
- gocyclo
Expand All @@ -53,16 +51,9 @@ linters:
- noctx
- gofumpt
- exhaustive

# deprecated
- interfacer
- scopelint
- golint
- exhaustivestruct
- nosnakecase
- deadcode
- structcheck
- varcheck
- protogetter
- depguard
- mnd

issues:
exclude-rules:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ sudo mv chantools-*/chantools /usr/local/bin/

If there isn't a pre-built binary for your operating system or architecture
available or you want to build `chantools` from source for another reason, you
need to make sure you have `go 1.21.x` (or later) and `make` installed and can
need to make sure you have `go 1.22.3` (or later) and `make` installed and can
then run the following commands:

```bash
Expand Down Expand Up @@ -519,4 +519,4 @@ Legend:

[discussions]: https://github.com/lightningnetwork/lnd/discussions

[zombie-recovery]: doc/zombierecovery.md
[zombie-recovery]: doc/zombierecovery.md
4 changes: 2 additions & 2 deletions bip39/wordlist_english.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
package bip39

import (
"fmt"
"hash/crc32"
"strconv"
"strings"
)

Expand All @@ -14,7 +14,7 @@ func init() { //nolint:gochecknoinits
// $ crc32 english.txt
// c1dbd296
checksum := crc32.ChecksumIEEE([]byte(english))
if fmt.Sprintf("%x", checksum) != "c1dbd296" {
if strconv.FormatUint(uint64(checksum), 16) != "c1dbd296" {
panic("english checksum invalid")
}
}
Expand Down
14 changes: 7 additions & 7 deletions btc/bitcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (

type KeyExporter interface {
Header() string
Format(*hdkeychain.ExtendedKey, *chaincfg.Params, string, uint32,
uint32) (string, error)
Trailer(uint32) string
Format(hdKey *hdkeychain.ExtendedKey, params *chaincfg.Params,
path string, branch, index uint32) (string, error)
Trailer(birthdayBlock uint32) string
}

// ParseFormat parses the given format name and returns its associated print
Expand Down Expand Up @@ -67,7 +67,7 @@ func ExportKeys(extendedKey *hdkeychain.ExtendedKey, strPaths []string,
path := paths[idx]

// External branch first (<DerivationPath>/0/i).
for i := uint32(0); i < recoveryWindow; i++ {
for i := range recoveryWindow {
path := append(path, 0, i)
derivedKey, err := lnd.DeriveChildren(extendedKey, path)
if err != nil {
Expand All @@ -83,7 +83,7 @@ func ExportKeys(extendedKey *hdkeychain.ExtendedKey, strPaths []string,
}

// Now the internal branch (<DerivationPath>/1/i).
for i := uint32(0); i < recoveryWindow; i++ {
for i := range recoveryWindow {
path := append(path, 1, i)
derivedKey, err := lnd.DeriveChildren(extendedKey, path)
if err != nil {
Expand Down Expand Up @@ -254,7 +254,7 @@ func (p *Electrum) Header() string {
}

func (p *Electrum) Format(hdKey *hdkeychain.ExtendedKey,
params *chaincfg.Params, path string, branch, index uint32) (string,
params *chaincfg.Params, path string, _, _ uint32) (string,
error) {

privKey, err := hdKey.ECPrivKey()
Expand Down Expand Up @@ -285,7 +285,7 @@ func (d *Descriptors) Header() string {
}

func (d *Descriptors) Format(hdKey *hdkeychain.ExtendedKey,
params *chaincfg.Params, path string, branch, index uint32) (string,
params *chaincfg.Params, _ string, _, _ uint32) (string,
error) {

privKey, err := hdKey.ECPrivKey()
Expand Down
4 changes: 2 additions & 2 deletions btc/descriptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func descriptorSumPolymod(symbols []uint64) uint64 {
for _, value := range symbols {
top := chk >> 35
chk = (chk&0x7ffffffff)<<5 ^ value
for i := 0; i < 5; i++ {
for i := range 5 {
if (top>>i)&1 != 0 {
chk ^= generator[i]
}
Expand Down Expand Up @@ -57,7 +57,7 @@ func DescriptorSumCreate(s string) string {
symbols := append(descriptorSumExpand(s), 0, 0, 0, 0, 0, 0, 0, 0)
checksum := descriptorSumPolymod(symbols) ^ 1
builder := strings.Builder{}
for i := 0; i < 8; i++ {
for i := range 8 {
builder.WriteByte(checksumCharset[(checksum>>(5*(7-i)))&31])
}
return s + "#" + builder.String()
Expand Down
4 changes: 2 additions & 2 deletions btc/explorer_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (a *ExplorerAPI) Outpoint(addr string) (*TX, int, error) {
}
}

return nil, 0, fmt.Errorf("no tx found")
return nil, 0, errors.New("no tx found")
}

func (a *ExplorerAPI) Spends(addr string) ([]*TX, error) {
Expand Down Expand Up @@ -193,7 +193,7 @@ func (a *ExplorerAPI) Address(outpoint string) (string, error) {
}

func (a *ExplorerAPI) PublishTx(rawTxHex string) (string, error) {
url := fmt.Sprintf("%s/tx", a.BaseURL)
url := a.BaseURL + "/tx"
resp, err := http.Post(url, "text/plain", strings.NewReader(rawTxHex))
if err != nil {
return "", fmt.Errorf("error posting data to API '%s', "+
Expand Down
5 changes: 3 additions & 2 deletions cmd/chantools/chanbackup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"

"github.com/lightninglabs/chantools/lnd"
Expand Down Expand Up @@ -50,12 +51,12 @@ func (c *chanBackupCommand) Execute(_ *cobra.Command, _ []string) error {

// Check that we have a backup file.
if c.MultiFile == "" {
return fmt.Errorf("backup file is required")
return errors.New("backup file is required")
}

// Check that we have a channel DB.
if c.ChannelDB == "" {
return fmt.Errorf("channel DB is required")
return errors.New("channel DB is required")
}
db, err := lnd.OpenDB(c.ChannelDB, true)
if err != nil {
Expand Down
15 changes: 8 additions & 7 deletions cmd/chantools/closepoolaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/hex"
"errors"
"fmt"

"github.com/btcsuite/btcd/btcec/v2"
Expand Down Expand Up @@ -292,7 +293,7 @@ func closePoolAccount(extendedKey *hdkeychain.ExtendedKey, apiURL string,
signDesc.SignMethod = input.TaprootScriptSpendSignMethod
}
feeRateKWeight := chainfee.SatPerKVByte(1000 * feeRate).FeePerKWeight()
totalFee := feeRateKWeight.FeeForWeight(int64(estimator.Weight()))
totalFee := feeRateKWeight.FeeForWeight(estimator.Weight())

// Add our sweep destination output.
sweepTx.TxOut = []*wire.TxOut{{
Expand Down Expand Up @@ -367,7 +368,7 @@ func bruteForceAccountScript(accountBaseKey *hdkeychain.ExtendedKey,
maxNumBatchKeys uint32, targetScript []byte) (*poolAccount, error) {

// The outermost loop is over the possible accounts.
for i := uint32(0); i < maxNumAccounts; i++ {
for i := range maxNumAccounts {
accountExtendedKey, err := accountBaseKey.DeriveNonStandard(i)
if err != nil {
return nil, fmt.Errorf("error deriving account key: "+
Expand Down Expand Up @@ -430,7 +431,7 @@ func bruteForceAccountScript(accountBaseKey *hdkeychain.ExtendedKey,
log.Debugf("Tried account index %d of %d", i, maxNumAccounts)
}

return nil, fmt.Errorf("account script not derived")
return nil, errors.New("account script not derived")
}

func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
Expand All @@ -442,7 +443,7 @@ func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
return nil, err
}
if script.Class() != txscript.WitnessV0ScriptHashTy {
return nil, fmt.Errorf("incompatible script class")
return nil, errors.New("incompatible script class")
}

traderKeyTweak := poolscript.TraderKeyTweak(batchKey, secret, traderKey)
Expand Down Expand Up @@ -492,7 +493,7 @@ func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
}, nil
}

return nil, fmt.Errorf("account script not derived")
return nil, errors.New("account script not derived")
}

func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
Expand All @@ -504,7 +505,7 @@ func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
return nil, err
}
if parsedScript.Class() != txscript.WitnessV1TaprootTy {
return nil, fmt.Errorf("incompatible script class")
return nil, errors.New("incompatible script class")
}

traderKeyTweak := poolscript.TraderKeyTweak(batchKey, secret, traderKey)
Expand Down Expand Up @@ -601,5 +602,5 @@ func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
}, nil
}

return nil, fmt.Errorf("account script not derived")
return nil, errors.New("account script not derived")
}
2 changes: 0 additions & 2 deletions cmd/chantools/closepoolaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ func TestClosePoolAccount(t *testing.T) {
)

for _, tc := range testAccounts {
tc := tc

t.Run(tc.name, func(tt *testing.T) {
tt.Parallel()

Expand Down
5 changes: 3 additions & 2 deletions cmd/chantools/compactdb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"

"github.com/coreos/bbolt"
Expand Down Expand Up @@ -52,10 +53,10 @@ to create a copy of it to a destination file, compacting it in the process.`,
func (c *compactDBCommand) Execute(_ *cobra.Command, _ []string) error {
// Check that we have a source and destination channel DB.
if c.SourceDB == "" {
return fmt.Errorf("source channel DB is required")
return errors.New("source channel DB is required")
}
if c.DestDB == "" {
return fmt.Errorf("destination channel DB is required")
return errors.New("destination channel DB is required")
}
if c.TxMaxSize <= 0 {
c.TxMaxSize = defaultTxMaxSize
Expand Down
5 changes: 3 additions & 2 deletions cmd/chantools/createwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -63,7 +64,7 @@ func (c *createWalletCommand) Execute(_ *cobra.Command, _ []string) error {

// Check that we have a wallet DB.
if c.WalletDBDir == "" {
return fmt.Errorf("wallet DB directory is required")
return errors.New("wallet DB directory is required")
}

// Make sure the directory (and parents) exists.
Expand Down Expand Up @@ -143,7 +144,7 @@ func (c *createWalletCommand) Execute(_ *cobra.Command, _ []string) error {
}

if !bytes.Equal(pw, pw2) {
return fmt.Errorf("passwords don't match")
return errors.New("passwords don't match")
}

if len(pw) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion cmd/chantools/deletepayments.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"

"github.com/lightninglabs/chantools/lnd"
Expand Down Expand Up @@ -45,7 +46,7 @@ run lnd ` + lndVersion + ` or later after using this command!'`,
func (c *deletePaymentsCommand) Execute(_ *cobra.Command, _ []string) error {
// Check that we have a channel DB.
if c.ChannelDB == "" {
return fmt.Errorf("channel DB is required")
return errors.New("channel DB is required")
}
db, err := lnd.OpenDB(c.ChannelDB, false)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/chantools/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func newDocCommand() *cobra.Command {
Use: "doc",
Short: "Generate the markdown documentation of all commands",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return doc.GenMarkdownTree(rootCmd, "./doc")
},
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/chantools/doublespendinputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -96,7 +97,7 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {

// Make sure we have at least one input.
if len(c.InputOutpoints) == 0 {
return fmt.Errorf("inputoutpoints are required")
return errors.New("inputoutpoints are required")
}

api := newExplorerAPI(c.APIURL)
Expand Down Expand Up @@ -226,7 +227,7 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {

// Calculate the fee.
feeRateKWeight := chainfee.SatPerKVByte(1000 * c.FeeRate).FeePerKWeight()
totalFee := feeRateKWeight.FeeForWeight(int64(estimator.Weight()))
totalFee := feeRateKWeight.FeeForWeight(estimator.Weight())

// Create the transaction.
tx := wire.NewMsgTx(2)
Expand Down Expand Up @@ -308,7 +309,7 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {
func iterateOverPath(baseKey *hdkeychain.ExtendedKey, addr btcutil.Address,
path []uint32, maxTries uint32) (*hdkeychain.ExtendedKey, error) {

for i := uint32(0); i < maxTries; i++ {
for i := range maxTries {
// Check for both the external and internal branch.
for _, branch := range []uint32{0, 1} {
// Create the path to derive the key.
Expand Down
Loading

0 comments on commit d173f8c

Please sign in to comment.