Skip to content

Commit d173f8c

Browse files
authored
Merge pull request #138 from starius/update-lnd-v0.18.0-beta
update dependencies (LND v0.18.0-beta and co)
2 parents 1f43c4a + 65d6e52 commit d173f8c

Some content is hidden

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

63 files changed

+1198
-798
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
# go needs absolute directories, using the $HOME variable doesn't work here.
1717
GOCACHE: /home/runner/work/go/pkg/build
1818
GOPATH: /home/runner/work/go
19-
GO_VERSION: 1.21.3
19+
GO_VERSION: 1.22.3
2020

2121
jobs:
2222
########################

.golangci.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
run:
22
# timeout for analysis
3-
deadline: 4m
3+
timeout: 4m
44

55
linters-settings:
66
govet:
@@ -12,7 +12,7 @@ linters-settings:
1212
whitespace:
1313
multi-func: true
1414
multi-if: true
15-
tagliatelle:
15+
tagliatelle:
1616
case:
1717
rules:
1818
json: snake
@@ -31,17 +31,15 @@ linters:
3131
- gochecknoglobals
3232
- gosec
3333
- funlen
34-
- maligned
3534
- varnamelen
3635
- wrapcheck
3736
- testpackage
3837
- gomnd
39-
- goerr113
38+
- err113
4039
- exhaustruct
4140
- forbidigo
4241
- gocognit
4342
- nestif
44-
- ifshort
4543
- wsl
4644
- cyclop
4745
- gocyclo
@@ -53,16 +51,9 @@ linters:
5351
- noctx
5452
- gofumpt
5553
- exhaustive
56-
57-
# deprecated
58-
- interfacer
59-
- scopelint
60-
- golint
61-
- exhaustivestruct
62-
- nosnakecase
63-
- deadcode
64-
- structcheck
65-
- varcheck
54+
- protogetter
55+
- depguard
56+
- mnd
6657

6758
issues:
6859
exclude-rules:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $ sudo mv chantools-*/chantools /usr/local/bin/
3939

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

4545
```bash
@@ -519,4 +519,4 @@ Legend:
519519

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

522-
[zombie-recovery]: doc/zombierecovery.md
522+
[zombie-recovery]: doc/zombierecovery.md

bip39/wordlist_english.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
package bip39
44

55
import (
6-
"fmt"
76
"hash/crc32"
7+
"strconv"
88
"strings"
99
)
1010

@@ -14,7 +14,7 @@ func init() { //nolint:gochecknoinits
1414
// $ crc32 english.txt
1515
// c1dbd296
1616
checksum := crc32.ChecksumIEEE([]byte(english))
17-
if fmt.Sprintf("%x", checksum) != "c1dbd296" {
17+
if strconv.FormatUint(uint64(checksum), 16) != "c1dbd296" {
1818
panic("english checksum invalid")
1919
}
2020
}

btc/bitcoind.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const (
2525

2626
type KeyExporter interface {
2727
Header() string
28-
Format(*hdkeychain.ExtendedKey, *chaincfg.Params, string, uint32,
29-
uint32) (string, error)
30-
Trailer(uint32) string
28+
Format(hdKey *hdkeychain.ExtendedKey, params *chaincfg.Params,
29+
path string, branch, index uint32) (string, error)
30+
Trailer(birthdayBlock uint32) string
3131
}
3232

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

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

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

256256
func (p *Electrum) Format(hdKey *hdkeychain.ExtendedKey,
257-
params *chaincfg.Params, path string, branch, index uint32) (string,
257+
params *chaincfg.Params, path string, _, _ uint32) (string,
258258
error) {
259259

260260
privKey, err := hdKey.ECPrivKey()
@@ -285,7 +285,7 @@ func (d *Descriptors) Header() string {
285285
}
286286

287287
func (d *Descriptors) Format(hdKey *hdkeychain.ExtendedKey,
288-
params *chaincfg.Params, path string, branch, index uint32) (string,
288+
params *chaincfg.Params, _ string, _, _ uint32) (string,
289289
error) {
290290

291291
privKey, err := hdKey.ECPrivKey()

btc/descriptors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func descriptorSumPolymod(symbols []uint64) uint64 {
1919
for _, value := range symbols {
2020
top := chk >> 35
2121
chk = (chk&0x7ffffffff)<<5 ^ value
22-
for i := 0; i < 5; i++ {
22+
for i := range 5 {
2323
if (top>>i)&1 != 0 {
2424
chk ^= generator[i]
2525
}
@@ -57,7 +57,7 @@ func DescriptorSumCreate(s string) string {
5757
symbols := append(descriptorSumExpand(s), 0, 0, 0, 0, 0, 0, 0, 0)
5858
checksum := descriptorSumPolymod(symbols) ^ 1
5959
builder := strings.Builder{}
60-
for i := 0; i < 8; i++ {
60+
for i := range 8 {
6161
builder.WriteByte(checksumCharset[(checksum>>(5*(7-i)))&31])
6262
}
6363
return s + "#" + builder.String()

btc/explorer_api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (a *ExplorerAPI) Outpoint(addr string) (*TX, int, error) {
103103
}
104104
}
105105

106-
return nil, 0, fmt.Errorf("no tx found")
106+
return nil, 0, errors.New("no tx found")
107107
}
108108

109109
func (a *ExplorerAPI) Spends(addr string) ([]*TX, error) {
@@ -193,7 +193,7 @@ func (a *ExplorerAPI) Address(outpoint string) (string, error) {
193193
}
194194

195195
func (a *ExplorerAPI) PublishTx(rawTxHex string) (string, error) {
196-
url := fmt.Sprintf("%s/tx", a.BaseURL)
196+
url := a.BaseURL + "/tx"
197197
resp, err := http.Post(url, "text/plain", strings.NewReader(rawTxHex))
198198
if err != nil {
199199
return "", fmt.Errorf("error posting data to API '%s', "+

cmd/chantools/chanbackup.go

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

33
import (
4+
"errors"
45
"fmt"
56

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

5152
// Check that we have a backup file.
5253
if c.MultiFile == "" {
53-
return fmt.Errorf("backup file is required")
54+
return errors.New("backup file is required")
5455
}
5556

5657
// Check that we have a channel DB.
5758
if c.ChannelDB == "" {
58-
return fmt.Errorf("channel DB is required")
59+
return errors.New("channel DB is required")
5960
}
6061
db, err := lnd.OpenDB(c.ChannelDB, true)
6162
if err != nil {

cmd/chantools/closepoolaccount.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"encoding/hex"
6+
"errors"
67
"fmt"
78

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

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

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

433-
return nil, fmt.Errorf("account script not derived")
434+
return nil, errors.New("account script not derived")
434435
}
435436

436437
func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
@@ -442,7 +443,7 @@ func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
442443
return nil, err
443444
}
444445
if script.Class() != txscript.WitnessV0ScriptHashTy {
445-
return nil, fmt.Errorf("incompatible script class")
446+
return nil, errors.New("incompatible script class")
446447
}
447448

448449
traderKeyTweak := poolscript.TraderKeyTweak(batchKey, secret, traderKey)
@@ -492,7 +493,7 @@ func fastScript(keyIndex, expiryFrom, expiryTo uint32, traderKey, auctioneerKey,
492493
}, nil
493494
}
494495

495-
return nil, fmt.Errorf("account script not derived")
496+
return nil, errors.New("account script not derived")
496497
}
497498

498499
func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
@@ -504,7 +505,7 @@ func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
504505
return nil, err
505506
}
506507
if parsedScript.Class() != txscript.WitnessV1TaprootTy {
507-
return nil, fmt.Errorf("incompatible script class")
508+
return nil, errors.New("incompatible script class")
508509
}
509510

510511
traderKeyTweak := poolscript.TraderKeyTweak(batchKey, secret, traderKey)
@@ -601,5 +602,5 @@ func fastScriptTaproot(scriptVersion poolscript.Version, keyIndex, expiryFrom,
601602
}, nil
602603
}
603604

604-
return nil, fmt.Errorf("account script not derived")
605+
return nil, errors.New("account script not derived")
605606
}

cmd/chantools/closepoolaccount_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ func TestClosePoolAccount(t *testing.T) {
7070
)
7171

7272
for _, tc := range testAccounts {
73-
tc := tc
74-
7573
t.Run(tc.name, func(tt *testing.T) {
7674
tt.Parallel()
7775

cmd/chantools/compactdb.go

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

33
import (
4+
"errors"
45
"fmt"
56

67
"github.com/coreos/bbolt"
@@ -52,10 +53,10 @@ to create a copy of it to a destination file, compacting it in the process.`,
5253
func (c *compactDBCommand) Execute(_ *cobra.Command, _ []string) error {
5354
// Check that we have a source and destination channel DB.
5455
if c.SourceDB == "" {
55-
return fmt.Errorf("source channel DB is required")
56+
return errors.New("source channel DB is required")
5657
}
5758
if c.DestDB == "" {
58-
return fmt.Errorf("destination channel DB is required")
59+
return errors.New("destination channel DB is required")
5960
}
6061
if c.TxMaxSize <= 0 {
6162
c.TxMaxSize = defaultTxMaxSize

cmd/chantools/createwallet.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
"bytes"
5+
"errors"
56
"fmt"
67
"os"
78
"strings"
@@ -63,7 +64,7 @@ func (c *createWalletCommand) Execute(_ *cobra.Command, _ []string) error {
6364

6465
// Check that we have a wallet DB.
6566
if c.WalletDBDir == "" {
66-
return fmt.Errorf("wallet DB directory is required")
67+
return errors.New("wallet DB directory is required")
6768
}
6869

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

145146
if !bytes.Equal(pw, pw2) {
146-
return fmt.Errorf("passwords don't match")
147+
return errors.New("passwords don't match")
147148
}
148149

149150
if len(pw) > 0 {

cmd/chantools/deletepayments.go

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

33
import (
4+
"errors"
45
"fmt"
56

67
"github.com/lightninglabs/chantools/lnd"
@@ -45,7 +46,7 @@ run lnd ` + lndVersion + ` or later after using this command!'`,
4546
func (c *deletePaymentsCommand) Execute(_ *cobra.Command, _ []string) error {
4647
// Check that we have a channel DB.
4748
if c.ChannelDB == "" {
48-
return fmt.Errorf("channel DB is required")
49+
return errors.New("channel DB is required")
4950
}
5051
db, err := lnd.OpenDB(c.ChannelDB, false)
5152
if err != nil {

cmd/chantools/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func newDocCommand() *cobra.Command {
1010
Use: "doc",
1111
Short: "Generate the markdown documentation of all commands",
1212
Hidden: true,
13-
RunE: func(cmd *cobra.Command, args []string) error {
13+
RunE: func(_ *cobra.Command, _ []string) error {
1414
return doc.GenMarkdownTree(rootCmd, "./doc")
1515
},
1616
}

cmd/chantools/doublespendinputs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bytes"
55
"encoding/hex"
6+
"errors"
67
"fmt"
78
"strconv"
89

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

9798
// Make sure we have at least one input.
9899
if len(c.InputOutpoints) == 0 {
99-
return fmt.Errorf("inputoutpoints are required")
100+
return errors.New("inputoutpoints are required")
100101
}
101102

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

227228
// Calculate the fee.
228229
feeRateKWeight := chainfee.SatPerKVByte(1000 * c.FeeRate).FeePerKWeight()
229-
totalFee := feeRateKWeight.FeeForWeight(int64(estimator.Weight()))
230+
totalFee := feeRateKWeight.FeeForWeight(estimator.Weight())
230231

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

311-
for i := uint32(0); i < maxTries; i++ {
312+
for i := range maxTries {
312313
// Check for both the external and internal branch.
313314
for _, branch := range []uint32{0, 1} {
314315
// Create the path to derive the key.

0 commit comments

Comments
 (0)