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