mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
refactor: use errors.New to replace fmt.Errorf with no parameters
Signed-off-by: LesCyber <andi4cing@gmail.com>
This commit is contained in:
parent
f744a5477f
commit
6afcda712a
12 changed files with 27 additions and 29 deletions
|
@ -3,6 +3,7 @@ package amp
|
|||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
|
@ -139,7 +140,7 @@ func (s *ShardTracker) CancelShard(pid uint64) error {
|
|||
|
||||
c, ok := s.shards[pid]
|
||||
if !ok {
|
||||
return fmt.Errorf("pid not found")
|
||||
return errors.New("pid not found")
|
||||
}
|
||||
delete(s.shards, pid)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package amp
|
|||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// zeroShare is the all-zero 32-byte share.
|
||||
|
@ -97,7 +97,7 @@ func (s *SeedSharer) Root() Share {
|
|||
func (s *SeedSharer) Split() (Sharer, Sharer, error) {
|
||||
// We cannot split the zero-Sharer.
|
||||
if s.curr == zeroShare {
|
||||
return nil, nil, fmt.Errorf("cannot split zero-Sharer")
|
||||
return nil, nil, errors.New("cannot split zero-Sharer")
|
||||
}
|
||||
|
||||
shareLeft, shareRight, err := split(&s.curr)
|
||||
|
|
|
@ -5,7 +5,6 @@ package commands
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
|
@ -80,7 +79,7 @@ func getBlock(ctx *cli.Context) error {
|
|||
blockHashString = args.First()
|
||||
|
||||
default:
|
||||
return fmt.Errorf("hash argument missing")
|
||||
return errors.New("hash argument missing")
|
||||
}
|
||||
|
||||
blockHash, err := chainhash.NewHashFromStr(blockHashString)
|
||||
|
@ -233,7 +232,7 @@ func getBlockHash(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("block height argument missing")
|
||||
return errors.New("block height argument missing")
|
||||
}
|
||||
|
||||
client, cleanUp := getChainClient(ctx)
|
||||
|
|
|
@ -267,7 +267,7 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error {
|
|||
c.Command.Name == "changepassword" ||
|
||||
c.Command.Name == "createwatchonly") {
|
||||
|
||||
return fmt.Errorf("Wallet is already unlocked")
|
||||
return errors.New("Wallet is already unlocked")
|
||||
}
|
||||
|
||||
// lnd might be active, but not possible to contact
|
||||
|
@ -277,7 +277,7 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error {
|
|||
// WalletUnlocker server active) and most likely this
|
||||
// is because of an encrypted wallet.
|
||||
if ok && s.Code() == codes.Unimplemented {
|
||||
return fmt.Errorf("Wallet is encrypted. " +
|
||||
return errors.New("Wallet is encrypted. " +
|
||||
"Please unlock using 'lncli unlock', " +
|
||||
"or set password using 'lncli create'" +
|
||||
" if this is the first time starting " +
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/peersrpc"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -147,7 +145,7 @@ func updateNodeAnnouncement(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
if !change {
|
||||
return fmt.Errorf("no changes for the node information " +
|
||||
return errors.New("no changes for the node information " +
|
||||
"detected")
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ func (e *profileEntry) cert() (*x509.CertPool, error) {
|
|||
|
||||
cp := x509.NewCertPool()
|
||||
if !cp.AppendCertsFromPEM([]byte(e.TLSCert)) {
|
||||
return nil, fmt.Errorf("credentials: failed to append " +
|
||||
return nil, errors.New("credentials: failed to append " +
|
||||
"certificate")
|
||||
}
|
||||
return cp, nil
|
||||
|
@ -140,7 +140,7 @@ func profileFromContext(ctx *cli.Context, store, skipMacaroons bool) (
|
|||
for _, m := range ctx.GlobalStringSlice("metadata") {
|
||||
pair := strings.Split(m, ":")
|
||||
if len(pair) != 2 {
|
||||
return nil, fmt.Errorf("invalid format for metadata " +
|
||||
return nil, errors.New("invalid format for metadata " +
|
||||
"flag; expected \"key:value\"")
|
||||
}
|
||||
|
||||
|
|
|
@ -1930,7 +1930,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
|||
|
||||
splitCookie := strings.Split(string(cookie), ":")
|
||||
if len(splitCookie) != 2 {
|
||||
return fmt.Errorf("cookie file has a wrong " +
|
||||
return errors.New("cookie file has a wrong " +
|
||||
"format")
|
||||
}
|
||||
conf.RPCUser = splitCookie[0]
|
||||
|
@ -1968,7 +1968,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
|||
// the RPC credentials from the configuration. So if lnd wasn't
|
||||
// specified the parameters, then we won't be able to start.
|
||||
if cConfig.SimNet {
|
||||
return fmt.Errorf("rpcuser and rpcpass must be set to your " +
|
||||
return errors.New("rpcuser and rpcpass must be set to your " +
|
||||
"btcd node's RPC parameters for simnet mode")
|
||||
}
|
||||
|
||||
|
@ -2097,7 +2097,7 @@ func extractBtcdRPCParams(btcdConfigPath string) (string, string, error) {
|
|||
}
|
||||
userSubmatches := rpcUserRegexp.FindSubmatch(configContents)
|
||||
if userSubmatches == nil {
|
||||
return "", "", fmt.Errorf("unable to find rpcuser in config")
|
||||
return "", "", errors.New("unable to find rpcuser in config")
|
||||
}
|
||||
|
||||
// Similarly, we'll use another regular expression to find the set
|
||||
|
|
|
@ -272,7 +272,7 @@ func (d *DefaultWalletImpl) ValidateMacaroon(ctx context.Context,
|
|||
// Because the default implementation does not return any permissions,
|
||||
// we shouldn't be registered as an external validator at all and this
|
||||
// should never be invoked.
|
||||
return fmt.Errorf("default implementation does not support external " +
|
||||
return errors.New("default implementation does not support external " +
|
||||
"macaroon validation")
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
|
|||
if d.cfg.WalletUnlockPasswordFile != "" && !walletExists &&
|
||||
!d.cfg.WalletUnlockAllowCreate {
|
||||
|
||||
return nil, nil, nil, fmt.Errorf("wallet unlock password file " +
|
||||
return nil, nil, nil, errors.New("wallet unlock password file " +
|
||||
"was specified but wallet does not exist; initialize " +
|
||||
"the wallet before using auto unlocking")
|
||||
}
|
||||
|
@ -1173,7 +1173,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
|||
return nil, nil, err
|
||||
}
|
||||
if ripInvoices {
|
||||
err = fmt.Errorf("invoices bucket tombstoned, please " +
|
||||
err = errors.New("invoices bucket tombstoned, please " +
|
||||
"switch back to native SQL")
|
||||
d.logger.Error(err)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package fn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -14,7 +14,7 @@ func RecvOrTimeout[T any](c <-chan T, timeout time.Duration) (T, error) {
|
|||
|
||||
case <-time.After(timeout):
|
||||
var zero T
|
||||
return zero, fmt.Errorf("timeout hit")
|
||||
return zero, errors.New("timeout hit")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,6 @@ func RecvResp[T any](r <-chan T, e <-chan error, q <-chan struct{}) (T, error) {
|
|||
return noResp, err
|
||||
|
||||
case <-q:
|
||||
return noResp, fmt.Errorf("quitting")
|
||||
return noResp, errors.New("quitting")
|
||||
}
|
||||
}
|
||||
|
|
2
pilot.go
2
pilot.go
|
@ -66,7 +66,7 @@ func validateAtplCfg(cfg *lncfg.AutoPilot) ([]*autopilot.WeightedHeuristic,
|
|||
}
|
||||
|
||||
if sum != 1.0 {
|
||||
return nil, fmt.Errorf("heuristic weights must sum to 1.0")
|
||||
return nil, errors.New("heuristic weights must sum to 1.0")
|
||||
}
|
||||
return heuristics, nil
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ var (
|
|||
// If the --no-macaroons flag is used to start lnd, the macaroon service
|
||||
// is not initialized. errMacaroonDisabled is then returned when
|
||||
// macaroon related services are used.
|
||||
errMacaroonDisabled = fmt.Errorf("macaroon authentication disabled, " +
|
||||
errMacaroonDisabled = errors.New("macaroon authentication disabled, " +
|
||||
"remove --no-macaroons flag to enable")
|
||||
)
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
|||
decodedAddr, _ := hex.DecodeString(in.Addr)
|
||||
_, err = btcec.ParsePubKey(decodedAddr)
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("cannot send coins to pubkeys")
|
||||
return nil, errors.New("cannot send coins to pubkeys")
|
||||
}
|
||||
|
||||
label, err := labels.ValidateAPI(in.Label)
|
||||
|
@ -1385,7 +1385,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
|||
}
|
||||
|
||||
if fn.HasDuplicates(wireOutpoints) {
|
||||
return nil, fmt.Errorf("selected outpoints contain " +
|
||||
return nil, errors.New("selected outpoints contain " +
|
||||
"duplicate values")
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1400,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
|||
// At this point, the amount shouldn't be set since we've been
|
||||
// instructed to sweep all the coins from the wallet.
|
||||
if in.Amount != 0 {
|
||||
return nil, fmt.Errorf("amount set while SendAll is " +
|
||||
return nil, errors.New("amount set while SendAll is " +
|
||||
"active")
|
||||
}
|
||||
|
||||
|
|
|
@ -572,7 +572,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||
if cfg.ProtocolOptions.TaprootOverlayChans &&
|
||||
implCfg.AuxFundingController.IsNone() {
|
||||
|
||||
return nil, fmt.Errorf("taproot overlay flag set, but not " +
|
||||
return nil, errors.New("taproot overlay flag set, but not " +
|
||||
"aux controllers")
|
||||
}
|
||||
|
||||
|
@ -1428,7 +1428,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||
|
||||
if ourPolicy == nil {
|
||||
// Something is wrong, so return an error.
|
||||
return nil, fmt.Errorf("we don't have an edge")
|
||||
return nil, errors.New("we don't have an edge")
|
||||
}
|
||||
|
||||
err = s.graphDB.DeleteChannelEdges(
|
||||
|
|
Loading…
Add table
Reference in a new issue