multi: use the "errors" package everywhere

Replace all usages of the "github.com/go-errors/errors" and
"github.com/pkg/errors" packages with the standard lib's "errors"
package. This ensures that error wrapping and `errors.Is` checks will
work as expected.
This commit is contained in:
Elle Mouton committed 2025-06-30 09:46:55 +02:00
1 parent 5f961e4349
commit 8cf567b948
44 files changed
+114 -109

No files matched your search

+1 -1
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"net"
"os"
@@ -12,7 +13,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/go-errors/errors"
mig "github.com/lightningnetwork/lnd/channeldb/migration"
"github.com/lightningnetwork/lnd/channeldb/migration12"
"github.com/lightningnetwork/lnd/channeldb/migration13"
+3 -2
View File
@@ -2,10 +2,11 @@ package channeldb
import (
"bytes"
"errors"
"fmt"
"testing"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/stretchr/testify/require"
)
@@ -48,7 +49,7 @@ func applyMigration(t *testing.T, beforeMigration, afterMigration func(d *DB),
if dryRun && r != ErrDryRunMigrationOK {
t.Fatalf("expected dry run migration OK")
}
err = errors.New(r)
err = fmt.Errorf("%v", r)
}
if err == nil && shouldFail {
+1 -1
View File
@@ -3,6 +3,7 @@ package lnwire
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"image/color"
"io"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/tor"
)
+1 -2
View File
@@ -9,7 +9,6 @@ import (
"io"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/tlv"
)
@@ -1451,7 +1450,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
return &FailInvalidBlinding{}, nil
default:
return nil, errors.Errorf("unknown error code: %v", code)
return nil, fmt.Errorf("unknown error code: %v", code)
}
}
+2 -2
View File
@@ -1,9 +1,9 @@
package migration_01_to_11
import (
"fmt"
"testing"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/kvdb"
)
@@ -33,7 +33,7 @@ func applyMigration(t *testing.T, beforeMigration, afterMigration func(d *DB),
defer func() {
if r := recover(); r != nil {
err = errors.New(r)
err = fmt.Errorf("%v", r)
}
if err == nil && shouldFail {
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha256"
"encoding/binary"
"errors"
"fmt"
"math/rand"
"reflect"
@@ -12,7 +13,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntypes"
+1 -1
View File
@@ -3,11 +3,11 @@ package channeldb
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"sync"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire"
)
+1 -1
View File
@@ -1,11 +1,11 @@
package channeldb
import (
"errors"
"reflect"
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -5,6 +5,7 @@ import (
crand "crypto/rand"
"crypto/sha256"
"encoding/binary"
"errors"
"fmt"
"io"
"math/rand"
@@ -19,7 +20,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2"
+1 -1
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/hex"
"errors"
"fmt"
prand "math/rand"
"net"
@@ -20,7 +21,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightninglabs/neutrino/cache"
"github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs"
+1 -1
View File
@@ -1,11 +1,11 @@
package discovery
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
+15 -16
View File
@@ -3,6 +3,7 @@ package funding
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
"sync"
@@ -18,7 +19,6 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/chanacceptor"
"github.com/lightningnetwork/lnd/channeldb"
@@ -4436,8 +4436,8 @@ func (f *Manager) newChanAnnouncement(localPubKey,
// channel announcement.
storedFwdingPolicy, err := f.getInitialForwardingPolicy(chanID)
if err != nil && !errors.Is(err, channeldb.ErrChannelNotFound) {
return nil, errors.Errorf("unable to generate channel "+
"update announcement: %v", err)
return nil, fmt.Errorf("unable to generate channel "+
"update announcement: %w", err)
}
switch {
@@ -4480,13 +4480,13 @@ func (f *Manager) newChanAnnouncement(localPubKey,
}
sig, err := f.cfg.SignMessage(f.cfg.IDKeyLoc, chanUpdateMsg, true)
if err != nil {
return nil, errors.Errorf("unable to generate channel "+
"update announcement signature: %v", err)
return nil, fmt.Errorf("unable to generate channel "+
"update announcement signature: %w", err)
}
chanUpdateAnn.Signature, err = lnwire.NewSigFromSignature(sig)
if err != nil {
return nil, errors.Errorf("unable to generate channel "+
"update announcement signature: %v", err)
return nil, fmt.Errorf("unable to generate channel "+
"update announcement signature: %w", err)
}
// The channel existence proofs itself is currently announced in
@@ -4502,15 +4502,15 @@ func (f *Manager) newChanAnnouncement(localPubKey,
}
nodeSig, err := f.cfg.SignMessage(f.cfg.IDKeyLoc, chanAnnMsg, true)
if err != nil {
return nil, errors.Errorf("unable to generate node "+
"signature for channel announcement: %v", err)
return nil, fmt.Errorf("unable to generate node "+
"signature for channel announcement: %w", err)
}
bitcoinSig, err := f.cfg.SignMessage(
localFundingKey.KeyLocator, chanAnnMsg, true,
)
if err != nil {
return nil, errors.Errorf("unable to generate bitcoin "+
"signature for node public key: %v", err)
return nil, fmt.Errorf("unable to generate bitcoin "+
"signature for node public key: %w", err)
}
// Finally, we'll generate the announcement proof which we'll use to
@@ -5172,13 +5172,13 @@ func (f *Manager) cancelReservationCtx(peerKey *btcec.PublicKey,
nodeReservations, ok := f.activeReservations[peerIDKey]
if !ok {
// No reservations for this node.
return nil, errors.Errorf("no active reservations for peer(%x)",
return nil, fmt.Errorf("no active reservations for peer(%x)",
peerIDKey[:])
}
ctx, ok := nodeReservations[pendingChanID]
if !ok {
return nil, errors.Errorf("unknown channel (id: %x) for "+
return nil, fmt.Errorf("unknown channel (id: %x) for "+
"peer(%x)", pendingChanID[:], peerIDKey[:])
}
@@ -5191,8 +5191,7 @@ func (f *Manager) cancelReservationCtx(peerKey *btcec.PublicKey,
}
if err := ctx.reservation.Cancel(); err != nil {
return nil, errors.Errorf("unable to cancel reservation: %v",
err)
return nil, fmt.Errorf("unable to cancel reservation: %w", err)
}
delete(nodeReservations, pendingChanID)
@@ -5239,7 +5238,7 @@ func (f *Manager) getReservationCtx(peerKey *btcec.PublicKey,
f.resMtx.RUnlock()
if !ok {
return nil, errors.Errorf("unknown channel (id: %x) for "+
return nil, fmt.Errorf("unknown channel (id: %x) for "+
"peer(%x)", pendingChanID[:], peerIDKey[:])
}
+1 -2
View File
@@ -19,7 +19,6 @@ require (
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/go-errors/errors v1.0.1
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/websocket v1.5.0
@@ -48,7 +47,7 @@ require (
github.com/lightningnetwork/lnd/tor v1.1.6
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796
github.com/miekg/dns v1.1.43
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.11.1
github.com/stretchr/testify v1.9.0
github.com/tv42/zbase32 v0.0.0-20160707012821-501572607d02
-2
View File
@@ -156,8 +156,6 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
+9 -11
View File
@@ -2,6 +2,7 @@ package graph
import (
"context"
"errors"
"fmt"
"sync"
"sync/atomic"
@@ -9,7 +10,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs"
graphdb "github.com/lightningnetwork/lnd/graph/db"
@@ -875,8 +875,8 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
// already have.
lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node)
if err != nil {
return errors.Errorf("unable to query for the "+
"existence of node: %v", err)
return fmt.Errorf("unable to query for the "+
"existence of node: %w", err)
}
if !exists {
return NewErrf(ErrIgnored, "Ignoring node announcement"+
@@ -1004,8 +1004,8 @@ func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
}
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
return errors.Errorf("unable to add node %x to the "+
"graph: %v", node.PubKeyBytes, err)
return fmt.Errorf("unable to add node %x to the "+
"graph: %w", node.PubKeyBytes, err)
}
log.Tracef("Updated vertex data for node=%x", node.PubKeyBytes)
@@ -1051,7 +1051,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
edge.ChannelID,
)
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
return errors.Errorf("unable to check for edge existence: %v",
return fmt.Errorf("unable to check for edge existence: %w",
err)
}
if isZombie {
@@ -1109,8 +1109,7 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
err = b.cfg.ChainView.UpdateFilter(filterUpdate, b.bestHeight.Load())
if err != nil {
return errors.Errorf("unable to update chain "+
"view: %v", err)
return fmt.Errorf("unable to update chain view: %w", err)
}
return nil
@@ -1152,8 +1151,7 @@ func (b *Builder) updateEdge(ctx context.Context,
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
b.cfg.Graph.HasChannelEdge(policy.ChannelID)
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
return errors.Errorf("unable to check for edge existence: %v",
err)
return fmt.Errorf("unable to check for edge existence: %w", err)
}
// If the channel is marked as a zombie in our database, and
@@ -1212,7 +1210,7 @@ func (b *Builder) updateEdge(ctx context.Context,
// Now that we know this isn't a stale update, we'll apply the new edge
// policy to the proper directional edge within the channel graph.
if err = b.cfg.Graph.UpdateEdgePolicy(ctx, policy, op...); err != nil {
err := errors.Errorf("unable to add channel: %v", err)
err := fmt.Errorf("unable to add channel: %w", err)
log.Error(err)
return err
}
+1 -1
View File
@@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"image/color"
"math/rand"
@@ -19,7 +20,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db"
+2 -3
View File
@@ -1,6 +1,7 @@
package graphdb
import (
"errors"
"fmt"
"image/color"
"net"
@@ -11,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lnutils"
@@ -412,8 +412,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
// being connected.
edgeInfo, _, _, err := c.FetchChannelEdgesByID(m.ChannelID)
if err != nil {
return errors.Errorf("unable fetch channel edge: %v",
err)
return fmt.Errorf("unable fetch channel edge: %w", err)
}
// If the flag is one, then the advertising node is actually
+5 -3
View File
@@ -1,6 +1,8 @@
package graph
import "github.com/go-errors/errors"
import (
"fmt"
)
// ErrorCode is used to represent the various errors that can occur within this
// package.
@@ -21,7 +23,7 @@ const (
// this structure carries additional information about error code in order to
// be able distinguish errors outside of the current package.
type Error struct {
err *errors.Error
err error
code ErrorCode
}
@@ -39,7 +41,7 @@ var _ error = (*Error)(nil)
func NewErrf(code ErrorCode, format string, a ...interface{}) *Error {
return &Error{
code: code,
err: errors.Errorf(format, a...),
err: fmt.Errorf(format, a...),
}
}
+1 -1
View File
@@ -2,10 +2,10 @@ package htlcswitch
import (
"bytes"
"errors"
"fmt"
"sync"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/kvdb"
+1 -1
View File
@@ -2,11 +2,11 @@ package htlcswitch
import (
"crypto/sha256"
"errors"
"fmt"
"sync"
"sync/atomic"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
+1 -1
View File
@@ -1,6 +1,6 @@
package htlcswitch
import "github.com/go-errors/errors"
import "errors"
var (
// ErrLinkShuttingDown signals that the link is shutting down.
+1 -1
View File
@@ -5,6 +5,7 @@ import (
"context"
"crypto/sha256"
"encoding/binary"
"errors"
"fmt"
"io"
"net"
@@ -18,7 +19,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
+1 -1
View File
@@ -2,9 +2,9 @@ package htlcswitch
import (
"bytes"
"errors"
"io"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/kvdb"
+1 -1
View File
@@ -1,9 +1,9 @@
package htlcswitch
import (
"errors"
"sync"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb"
)
+1 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"crypto/sha256"
"errors"
"fmt"
"io"
mrand "math/rand"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
+21 -21
View File
@@ -7,6 +7,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"net"
"os"
@@ -21,7 +22,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
@@ -395,12 +395,12 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
aliceStoredChannels, err = dbAlice.ChannelStateDB().
FetchOpenChannels(aliceKeyPub)
if err != nil {
return nil, errors.Errorf("unable to fetch alice "+
"channel: %v", err)
return nil, fmt.Errorf("unable to fetch alice "+
"channel: %w", err)
}
default:
return nil, errors.Errorf("unable to fetch alice channel: "+
"%v", err)
return nil, fmt.Errorf("unable to fetch alice "+
"channel: %w", err)
}
var aliceStoredChannel *channeldb.OpenChannel
@@ -421,8 +421,8 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
lnwallet.WithAuxSigner(signerMock),
)
if err != nil {
return nil, errors.Errorf("unable to create new channel: %v",
err)
return nil, fmt.Errorf("unable to create new "+
"channel: %w", err)
}
return newAliceChannel, nil
@@ -436,19 +436,19 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
case kvdb.ErrDatabaseNotOpen:
dbBob = channeldb.OpenForTesting(t, dbBob.Path())
if err != nil {
return nil, errors.Errorf("unable to reopen bob "+
"db: %v", err)
return nil, fmt.Errorf("unable to reopen bob "+
"db: %w", err)
}
bobStoredChannels, err = dbBob.ChannelStateDB().
FetchOpenChannels(bobKeyPub)
if err != nil {
return nil, errors.Errorf("unable to fetch bob "+
"channel: %v", err)
return nil, fmt.Errorf("unable to fetch bob "+
"channel: %w", err)
}
default:
return nil, errors.Errorf("unable to fetch bob channel: "+
"%v", err)
return nil, fmt.Errorf("unable to fetch bob channel: "+
"%w", err)
}
var bobStoredChannel *channeldb.OpenChannel
@@ -469,8 +469,8 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
lnwallet.WithAuxSigner(signerMock),
)
if err != nil {
return nil, errors.Errorf("unable to create new channel: %v",
err)
return nil, fmt.Errorf("unable to create new "+
"channel: %w", err)
}
return newBobChannel, nil
}
@@ -881,16 +881,16 @@ func createClusterChannels(t *testing.T, aliceToBob, bobToCarol btcutil.Amount)
bobPrivKey, aliceToBob, aliceToBob, 0, 0, firstChanID,
)
if err != nil {
return nil, nil, errors.Errorf("unable to create "+
"alice<->bob channel: %v", err)
return nil, nil, fmt.Errorf("unable to create "+
"alice<->bob channel: %w", err)
}
secondBobChannel, carolChannel, err := createTestChannel(t, bobPrivKey,
carolPrivKey, bobToCarol, bobToCarol, 0, 0, secondChanID,
)
if err != nil {
return nil, nil, errors.Errorf("unable to create "+
"bob<->carol channel: %v", err)
return nil, nil, fmt.Errorf("unable to create "+
"bob<->carol channel: %w", err)
}
restoreFromDb := func() (*clusterChannels, error) {
@@ -1070,8 +1070,8 @@ func createMirroredChannel(t *testing.T, aliceToBob,
aliceToBob, bobToAlice, 0, 0, firstChanID,
)
if err != nil {
return nil, nil, errors.Errorf("unable to create "+
"alice<->bob channel: %v", err)
return nil, nil, fmt.Errorf("unable to create "+
"alice<->bob channel: %w", err)
}
return alice, bob, nil
+1 -1
View File
@@ -2,11 +2,11 @@ package itest
import (
"bytes"
"errors"
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
+1 -1
View File
@@ -2,13 +2,13 @@ package itest
import (
"bytes"
"errors"
"fmt"
"testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntest"
+1 -1
View File
@@ -1,12 +1,12 @@
package itest
import (
"errors"
"fmt"
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
+1 -1
View File
@@ -1,12 +1,12 @@
package itest
import (
"errors"
"fmt"
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/chainreg"
"github.com/lightningnetwork/lnd/lnrpc"
+17 -5
View File
@@ -3,6 +3,7 @@ package lntest
import (
"context"
"fmt"
"runtime/debug"
"strings"
"testing"
"time"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb/etcd"
@@ -293,10 +293,22 @@ func (h *HarnessTest) Stop() {
// represented as fatal.
func (h *HarnessTest) RunTestCase(testCase *TestCase) {
defer func() {
if err := recover(); err != nil {
description := errors.Wrap(err, 2).ErrorStack()
h.Fatalf("Failed: (%v) panic with: \n%v",
testCase.Name, description)
if r := recover(); r != nil {
// Wrap the recovered panic in an error.
var err error
switch v := r.(type) {
case error:
err = v
default:
err = fmt.Errorf("%v", v)
}
// Capture and print the stack trace.
stack := debug.Stack()
// Fail the test with panic info and stack.
h.Fatalf("Failed: (%v) panic with: %v\n%s",
testCase.Name, err, stack)
}
}()
+1 -1
View File
@@ -3,6 +3,7 @@ package lnwire
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"image/color"
"io"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/tor"
)
+1 -2
View File
@@ -9,7 +9,6 @@ import (
"io"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv"
)
@@ -1513,7 +1512,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
return &FailInvalidBlinding{}, nil
default:
return nil, errors.Errorf("unknown error code: %v", code)
return nil, fmt.Errorf("unknown error code: %v", code)
}
}
+3 -4
View File
@@ -14,7 +14,6 @@ import (
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tlv"
"github.com/pkg/errors"
)
const (
@@ -279,13 +278,13 @@ func validateChannelUpdate1Fields(capacity btcutil.Amount,
// The maxHTLC flag is mandatory.
if !msg.MessageFlags.HasMaxHtlc() {
return errors.Errorf("max htlc flag not set for channel "+
return fmt.Errorf("max htlc flag not set for channel "+
"update %v", spew.Sdump(msg))
}
maxHtlc := msg.HtlcMaximumMsat
if maxHtlc == 0 || maxHtlc < msg.HtlcMinimumMsat {
return errors.Errorf("invalid max htlc for channel "+
return fmt.Errorf("invalid max htlc for channel "+
"update %v", spew.Sdump(msg))
}
@@ -294,7 +293,7 @@ func validateChannelUpdate1Fields(capacity btcutil.Amount,
// capacity.
capacityMsat := lnwire.NewMSatFromSatoshis(capacity)
if capacityMsat != 0 && maxHtlc > capacityMsat {
return errors.Errorf("max_htlc (%v) for channel update "+
return fmt.Errorf("max_htlc (%v) for channel update "+
"greater than capacity (%v)", maxHtlc, capacityMsat)
}
+2 -2
View File
@@ -2,13 +2,13 @@ package netann
import (
"bytes"
"fmt"
"image/color"
"net"
"time"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
@@ -110,7 +110,7 @@ func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
return err
}
return errors.Errorf("signature on NodeAnnouncement(%x) is "+
return fmt.Errorf("signature on NodeAnnouncement(%x) is "+
"invalid: %x", nodeKey.SerializeCompressed(),
msgBuf.Bytes())
}
+1 -1
View File
@@ -1,10 +1,10 @@
package routing
import (
"errors"
"testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnwallet"
+1 -1
View File
@@ -1,12 +1,12 @@
package routing
import (
"errors"
"fmt"
"sync"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
+1 -1
View File
@@ -2,12 +2,12 @@ package routing
import (
"context"
"errors"
"sync/atomic"
"testing"
"time"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch"
+1 -1
View File
@@ -1,12 +1,12 @@
package routing
import (
"errors"
"fmt"
"math"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)
+1 -1
View File
@@ -2,6 +2,7 @@ package routing
import (
"context"
"errors"
"fmt"
"math"
"math/big"
@@ -13,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/amp"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock"
+1 -2
View File
@@ -20,7 +20,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock"
@@ -189,7 +188,7 @@ func createTestNode() (*models.LightningNode, error) {
priv, err := btcec.NewPrivateKey()
if err != nil {
return nil, errors.Errorf("unable create private key: %v", err)
return nil, fmt.Errorf("unable create private key: %w", err)
}
pub := priv.PubKey().SerializeCompressed()
+1 -1
View File
@@ -5,6 +5,7 @@ import (
"context"
"crypto/rand"
"encoding/hex"
"errors"
"fmt"
"math/big"
prand "math/rand"
@@ -23,7 +24,6 @@ import (
"github.com/btcsuite/btcd/connmgr"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/autopilot"
+1 -1
View File
@@ -1,10 +1,10 @@
package shachain
import (
"errors"
"reflect"
"testing"
"github.com/go-errors/errors"
"github.com/stretchr/testify/require"
)
+3 -2
View File
@@ -2,10 +2,11 @@ package shachain
import (
"encoding/binary"
"errors"
"fmt"
"io"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/go-errors/errors"
)
// Store is an interface which serves as an abstraction over data structure
@@ -117,7 +118,7 @@ func (store *RevocationStore) LookUp(v uint64) (*chainhash.Hash, error) {
return &element.hash, nil
}
return nil, errors.Errorf("unable to derive hash #%v", ind)
return nil, fmt.Errorf("unable to derive hash #%v", ind)
}
// AddNextEntry attempts to store the given hash within its internal storage in