diff --git a/autopilot/agent.go b/autopilot/agent.go index 9aef4f9f4..d9c35a685 100644 --- a/autopilot/agent.go +++ b/autopilot/agent.go @@ -648,7 +648,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32, // to open channels to. scores, err = chooseN(numChans, scores) if err != nil { - return fmt.Errorf("unable to make weighted choice: %v", + return fmt.Errorf("unable to make weighted choice: %w", err) } diff --git a/autopilot/combinedattach.go b/autopilot/combinedattach.go index 0a7e3557b..b43856d24 100644 --- a/autopilot/combinedattach.go +++ b/autopilot/combinedattach.go @@ -84,7 +84,7 @@ func (c *WeightedCombAttachment) NodeScores(g ChannelGraph, chans []LocalChannel g, chans, chanSize, nodes, ) if err != nil { - return nil, fmt.Errorf("unable to get sub score: %v", + return nil, fmt.Errorf("unable to get sub score: %w", err) } diff --git a/autopilot/manager.go b/autopilot/manager.go index cf30aca82..e5999f518 100644 --- a/autopilot/manager.go +++ b/autopilot/manager.go @@ -341,7 +341,7 @@ func (m *Manager) queryHeuristics(nodes map[NodeID]struct{}, localState bool) ( m.cfg.PilotCfg.Graph, totalChans, chanSize, nodes, ) if err != nil { - return nil, fmt.Errorf("unable to get sub score: %v", + return nil, fmt.Errorf("unable to get sub score: %w", err) } diff --git a/brontide/listener.go b/brontide/listener.go index e3f93a665..ba210853c 100644 --- a/brontide/listener.go +++ b/brontide/listener.go @@ -91,7 +91,7 @@ func (l *Listener) listen() { // rejectedConnErr is a helper function that prepends the remote address of the // failed connection attempt to the original error message. func rejectedConnErr(err error, remoteAddr string) error { - return fmt.Errorf("unable to accept connection from %v: %v", remoteAddr, + return fmt.Errorf("unable to accept connection from %v: %w", remoteAddr, err) } diff --git a/cert/selfsigned.go b/cert/selfsigned.go index 748eeba77..c956afb00 100644 --- a/cert/selfsigned.go +++ b/cert/selfsigned.go @@ -261,7 +261,7 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string, &template, &priv.PublicKey, priv, ) if err != nil { - return nil, nil, fmt.Errorf("failed to create certificate: %v", + return nil, nil, fmt.Errorf("failed to create certificate: %w", err) } @@ -270,13 +270,13 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string, certBuf, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}, ) if err != nil { - return nil, nil, fmt.Errorf("failed to encode certificate: %v", + return nil, nil, fmt.Errorf("failed to encode certificate: %w", err) } keybytes, err := x509.MarshalECPrivateKey(priv) if err != nil { - return nil, nil, fmt.Errorf("unable to encode privkey: %v", + return nil, nil, fmt.Errorf("unable to encode privkey: %w", err) } keyBuf := &bytes.Buffer{} @@ -284,7 +284,7 @@ func GenCertPair(org string, tlsExtraIPs, tlsExtraDomains []string, keyBuf, &pem.Block{Type: "EC PRIVATE KEY", Bytes: keybytes}, ) if err != nil { - return nil, nil, fmt.Errorf("failed to encode private key: %v", + return nil, nil, fmt.Errorf("failed to encode private key: %w", err) } diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index d268c8374..c4813cd2f 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -792,8 +792,8 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, // proceed with fallback methods. jsonErr, ok := err.(*btcjson.RPCError) if !ok || jsonErr.Code != btcjson.ErrRPCNoTxInfo { - return nil, fmt.Errorf("unable to query for txid %v: %v", - outpoint.Hash, err) + return nil, fmt.Errorf("unable to query for txid "+ + "%v: %w", outpoint.Hash, err) } } diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 430a10661..89cedffc9 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -886,8 +886,8 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, // proceed with fallback methods. jsonErr, ok := err.(*btcjson.RPCError) if !ok || jsonErr.Code != btcjson.ErrRPCNoTxInfo { - return nil, fmt.Errorf("unable to query for txid %v: %v", - outpoint.Hash, err) + return nil, fmt.Errorf("unable to query for txid %v: "+ + "%w", outpoint.Hash, err) } } diff --git a/chainntnfs/interface.go b/chainntnfs/interface.go index 0f2fe27e4..e40c271b4 100644 --- a/chainntnfs/interface.go +++ b/chainntnfs/interface.go @@ -483,13 +483,13 @@ func GetCommonBlockAncestorHeight(chainConn ChainConn, reorgHash, for reorgHash != chainHash { reorgHeader, err := chainConn.GetBlockHeader(&reorgHash) if err != nil { - return 0, fmt.Errorf("unable to get header for hash=%v: %v", - reorgHash, err) + return 0, fmt.Errorf("unable to get header for "+ + "hash=%v: %w", reorgHash, err) } chainHeader, err := chainConn.GetBlockHeader(&chainHash) if err != nil { - return 0, fmt.Errorf("unable to get header for hash=%v: %v", - chainHash, err) + return 0, fmt.Errorf("unable to get header for "+ + "hash=%v: %w", chainHash, err) } reorgHash = reorgHeader.PrevBlock chainHash = chainHeader.PrevBlock @@ -497,8 +497,8 @@ func GetCommonBlockAncestorHeight(chainConn ChainConn, reorgHash, verboseHeader, err := chainConn.GetBlockHeaderVerbose(&chainHash) if err != nil { - return 0, fmt.Errorf("unable to get verbose header for hash=%v: %v", - chainHash, err) + return 0, fmt.Errorf("unable to get verbose header for "+ + "hash=%v: %w", chainHash, err) } return verboseHeader.Height, nil @@ -719,7 +719,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest, } return nil, TxNotFoundIndex, - fmt.Errorf("unable to query for txid %v: %v", + fmt.Errorf("unable to query for txid %v: %w", r.TxID, err) } @@ -728,13 +728,13 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest, rawTx, err := hex.DecodeString(rawTxRes.Hex) if err != nil { return nil, TxNotFoundIndex, - fmt.Errorf("unable to deserialize tx %v: %v", + fmt.Errorf("unable to deserialize tx %v: %w", r.TxID, err) } var tx wire.MsgTx if err := tx.Deserialize(bytes.NewReader(rawTx)); err != nil { return nil, TxNotFoundIndex, - fmt.Errorf("unable to deserialize tx %v: %v", + fmt.Errorf("unable to deserialize tx %v: %w", r.TxID, err) } @@ -759,13 +759,14 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest, if err != nil { return nil, TxNotFoundIndex, fmt.Errorf("unable to get block hash %v for "+ - "historical dispatch: %v", rawTxRes.BlockHash, err) + "historical dispatch: %w", rawTxRes.BlockHash, + err) } block, err := chainConn.GetBlock(blockHash) if err != nil { return nil, TxNotFoundIndex, fmt.Errorf("unable to get block with hash %v for "+ - "historical dispatch: %v", blockHash, err) + "historical dispatch: %w", blockHash, err) } // In the modern chain (the only one we really care about for LN), the diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index b2e00da80..80e210c2f 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -582,8 +582,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ // can compute the current block hash. blockHash, err := n.p2pNode.GetBlockHash(int64(scanHeight)) if err != nil { - return nil, fmt.Errorf("unable to get header for height=%v: %v", - scanHeight, err) + return nil, fmt.Errorf("unable to get header for "+ + "height=%v: %w", scanHeight, err) } // With the hash computed, we can now fetch the basic filter for this @@ -600,8 +600,8 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ neutrino.MaxBatchSize(int64(scanHeight-startHeight+1)), ) if err != nil { - return nil, fmt.Errorf("unable to retrieve regular filter for "+ - "height=%v: %v", scanHeight, err) + return nil, fmt.Errorf("unable to retrieve regular "+ + "filter for height=%v: %w", scanHeight, err) } // In the case that the filter exists, we'll attempt to see if diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go index c3d428611..036da71a5 100644 --- a/chainreg/chainregistry.go +++ b/chainreg/chainregistry.go @@ -763,11 +763,11 @@ func NewChainControl(walletConfig lnwallet.Config, lnWallet, err := lnwallet.NewLightningWallet(walletConfig) if err != nil { - return nil, ccCleanup, fmt.Errorf("unable to create wallet: %v", + return nil, ccCleanup, fmt.Errorf("unable to create wallet: %w", err) } if err := lnWallet.Startup(); err != nil { - return nil, ccCleanup, fmt.Errorf("unable to create wallet: %v", + return nil, ccCleanup, fmt.Errorf("unable to create wallet: %w", err) } diff --git a/channeldb/codec.go b/channeldb/codec.go index a79ef8558..07f125742 100644 --- a/channeldb/codec.go +++ b/channeldb/codec.go @@ -78,7 +78,8 @@ func WriteElement(w io.Writer, element interface{}) error { if e.PubKey != nil { if err := binary.Write(w, byteOrder, true); err != nil { - return fmt.Errorf("error writing serialized element: %s", err) + return fmt.Errorf("error writing serialized "+ + "element: %w", err) } return WriteElement(w, e.PubKey) diff --git a/channeldb/db.go b/channeldb/db.go index 34d621a68..93bb239bb 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -643,7 +643,7 @@ func (c *ChannelStateDB) fetchNodeChannels(chainBucket kvdb.RBucket) ( oChannel, err := fetchOpenChannel(chanBucket, &outPoint) if err != nil { return fmt.Errorf("unable to read channel data for "+ - "chan_point=%v: %v", outPoint, err) + "chan_point=%v: %w", outPoint, err) } oChannel.Db = c diff --git a/channeldb/migration21/current/current_codec.go b/channeldb/migration21/current/current_codec.go index c78319a4f..d4a28e69b 100644 --- a/channeldb/migration21/current/current_codec.go +++ b/channeldb/migration21/current/current_codec.go @@ -83,7 +83,8 @@ func WriteElement(w io.Writer, element interface{}) error { if e.PubKey != nil { if err := binary.Write(w, byteOrder, true); err != nil { - return fmt.Errorf("error writing serialized element: %s", err) + return fmt.Errorf("error writing serialized "+ + "element: %w", err) } return WriteElement(w, e.PubKey) diff --git a/channeldb/migration21/legacy/legacy_codec.go b/channeldb/migration21/legacy/legacy_codec.go index 8416ff39b..e14a42a5c 100644 --- a/channeldb/migration21/legacy/legacy_codec.go +++ b/channeldb/migration21/legacy/legacy_codec.go @@ -81,7 +81,8 @@ func WriteElement(w io.Writer, element interface{}) error { if e.PubKey != nil { if err := binary.Write(w, byteOrder, true); err != nil { - return fmt.Errorf("error writing serialized element: %s", err) + return fmt.Errorf("error writing serialized "+ + "element: %w", err) } return WriteElement(w, e.PubKey) diff --git a/channeldb/migration25/migration.go b/channeldb/migration25/migration.go index 257d8272c..53bff3642 100644 --- a/channeldb/migration25/migration.go +++ b/channeldb/migration25/migration.go @@ -93,7 +93,7 @@ func findOpenChannels(openChanBucket kvdb.RBucket) ([]*OpenChannel, error) { // open channels as they don't have any revocation logs and // their current commitments reflect the initial balances. if err := FetchChanCommitments(chanBucket, c); err != nil { - return fmt.Errorf("unable to fetch chan commits: %v", + return fmt.Errorf("unable to fetch chan commits: %w", err) } diff --git a/channeldb/migration27/migration.go b/channeldb/migration27/migration.go index a6f7b1a96..85b1d52c9 100644 --- a/channeldb/migration27/migration.go +++ b/channeldb/migration27/migration.go @@ -79,7 +79,7 @@ func findHistoricalChannels(historicalBucket kvdb.RBucket) ([]*OpenChannel, // Try to fetch channel info in old format. err = fetchChanInfoCompatible(chanBucket, c, true) if err != nil { - return fmt.Errorf("%s: fetch chan info got: %v", + return fmt.Errorf("%s: fetch chan info got: %w", c.FundingOutpoint, err) } diff --git a/channeldb/migration30/migration.go b/channeldb/migration30/migration.go index 406cc291a..83a9cee8f 100644 --- a/channeldb/migration30/migration.go +++ b/channeldb/migration30/migration.go @@ -254,7 +254,7 @@ func writeRevocationLogs(openChanBucket kvdb.RwBucket, logEntrykey := mig24.MakeLogKey(entry.commitHeight) err = logBucket.Put(logEntrykey[:], b.Bytes()) if err != nil { - return fmt.Errorf("putRevocationLog err: %v", + return fmt.Errorf("putRevocationLog err: %w", err) } } diff --git a/channeldb/migration_01_to_11/codec.go b/channeldb/migration_01_to_11/codec.go index a87f6eda7..ca2f5cff6 100644 --- a/channeldb/migration_01_to_11/codec.go +++ b/channeldb/migration_01_to_11/codec.go @@ -70,7 +70,7 @@ func WriteElement(w io.Writer, element interface{}) error { if e.PubKey != nil { if err := binary.Write(w, byteOrder, true); err != nil { - return fmt.Errorf("error writing serialized element: %s", err) + return fmt.Errorf("error writing serialized element: %w", err) } return WriteElement(w, e.PubKey) diff --git a/channeldb/migration_01_to_11/graph.go b/channeldb/migration_01_to_11/graph.go index 0f36a78ed..9035e3e6f 100644 --- a/channeldb/migration_01_to_11/graph.go +++ b/channeldb/migration_01_to_11/graph.go @@ -1140,7 +1140,7 @@ func deserializeChanEdgePolicy(r io.Reader, node, err := fetchLightningNode(nodes, pub[:]) if err != nil { - return nil, fmt.Errorf("unable to fetch node: %x, %v", + return nil, fmt.Errorf("unable to fetch node: %x, %w", pub[:], err) } edge.Node = &node diff --git a/channeldb/migration_01_to_11/migrations.go b/channeldb/migration_01_to_11/migrations.go index 6ae25e210..5027034cb 100644 --- a/channeldb/migration_01_to_11/migrations.go +++ b/channeldb/migration_01_to_11/migrations.go @@ -516,7 +516,7 @@ func MigratePruneEdgeUpdateIndex(tx kvdb.RwTx) error { // well. edgeIndex, err := edges.CreateBucketIfNotExists(edgeIndexBucket) if err != nil { - return fmt.Errorf("error creating edge index bucket: %s", err) + return fmt.Errorf("error creating edge index bucket: %w", err) } if edgeIndex == nil { return fmt.Errorf("unable to create/fetch edge index " + @@ -546,7 +546,7 @@ func MigratePruneEdgeUpdateIndex(tx kvdb.RwTx) error { return nil }) if err != nil { - return fmt.Errorf("unable to gather existing edge policies: %v", + return fmt.Errorf("unable to gather existing edge policies: %w", err) } @@ -560,7 +560,7 @@ func MigratePruneEdgeUpdateIndex(tx kvdb.RwTx) error { return nil }) if err != nil { - return fmt.Errorf("unable to gather existing edge updates: %v", + return fmt.Errorf("unable to gather existing edge updates: %w", err) } diff --git a/channeldb/migration_01_to_11/zpay32/amountunits.go b/channeldb/migration_01_to_11/zpay32/amountunits.go index 0cc1fcdbe..938a0b0ef 100644 --- a/channeldb/migration_01_to_11/zpay32/amountunits.go +++ b/channeldb/migration_01_to_11/zpay32/amountunits.go @@ -136,7 +136,7 @@ func encodeAmount(msat lnwire.MilliSatoshi) (string, error) { // Should always be expressible in pico BTC. pico, err := fromMSat['p'](msat) if err != nil { - return "", fmt.Errorf("unable to express %d msat as pBTC: %v", + return "", fmt.Errorf("unable to express %d msat as pBTC: %w", msat, err) } shortened := strconv.FormatUint(pico, 10) + "p" diff --git a/channeldb/payment_control.go b/channeldb/payment_control.go index 4ad29167e..bd83e32cc 100644 --- a/channeldb/payment_control.go +++ b/channeldb/payment_control.go @@ -229,7 +229,7 @@ func (p *PaymentControl) InitPayment(paymentHash lntypes.Hash, return bucket.Delete(paymentFailInfoKey) }) if err != nil { - return err + return fmt.Errorf("unable to init payment: %w", err) } return updateErr diff --git a/channeldb/payments.go b/channeldb/payments.go index 15bcd8342..a1baa07f7 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -615,7 +615,7 @@ func (d *DB) QueryPayments(query PaymentsQuery) (PaymentsResponse, error) { err = indexes.ForEach(countFn) } if err != nil { - return fmt.Errorf("error counting payments: %v", + return fmt.Errorf("error counting payments: %w", err) } diff --git a/cmd/lncli/cmd_macaroon.go b/cmd/lncli/cmd_macaroon.go index 92a96c43c..54e03057a 100644 --- a/cmd/lncli/cmd_macaroon.go +++ b/cmd/lncli/cmd_macaroon.go @@ -361,7 +361,7 @@ func printMacaroon(ctx *cli.Context) error { case args.Present(): macBytes, err = hex.DecodeString(args.First()) if err != nil { - return fmt.Errorf("unable to hex decode macaroon: %v", + return fmt.Errorf("unable to hex decode macaroon: %w", err) } diff --git a/cmd/lncli/cmd_open_channel.go b/cmd/lncli/cmd_open_channel.go index d7081e4e0..74cb1668a 100644 --- a/cmd/lncli/cmd_open_channel.go +++ b/cmd/lncli/cmd_open_channel.go @@ -602,7 +602,7 @@ func openChannelPsbt(rpcCtx context.Context, ctx *cli.Context, // Recv blocks until a message or error arrives. resp, err := stream.Recv() if err == io.EOF { - srvErr <- fmt.Errorf("lnd shutting down: %v", + srvErr <- fmt.Errorf("lnd shutting down: %w", err) return } else if err != nil { @@ -685,7 +685,7 @@ func openChannelPsbt(rpcCtx context.Context, ctx *cli.Context, } fundedPsbt, err := decodePsbt(inputPsbt) if err != nil { - return fmt.Errorf("psbt decode failed: %v", + return fmt.Errorf("psbt decode failed: %w", err) } verifyMsg := &lnrpc.FundingTransitionMsg{ @@ -873,14 +873,14 @@ func batchOpenChannel(ctx *cli.Context) error { for idx, jsonChannel := range jsonChannels { pubKeyBytes, err := hex.DecodeString(jsonChannel.NodePubkey) if err != nil { - return fmt.Errorf("error parsing node pubkey hex: %v", + return fmt.Errorf("error parsing node pubkey hex: %w", err) } pendingChanBytes, err := hex.DecodeString( jsonChannel.PendingChanID, ) if err != nil { - return fmt.Errorf("error parsing pending chan ID: %v", + return fmt.Errorf("error parsing pending chan ID: %w", err) } diff --git a/cmd/lncli/cmd_payments.go b/cmd/lncli/cmd_payments.go index 9ba6f296d..550bb8f3e 100644 --- a/cmd/lncli/cmd_payments.go +++ b/cmd/lncli/cmd_payments.go @@ -525,13 +525,13 @@ func sendPaymentRequest(ctx *cli.Context, recordID, err := strconv.ParseUint(kv[0], 10, 64) if err != nil { - return fmt.Errorf("invalid data format: %v", + return fmt.Errorf("invalid data format: %w", err) } hexValue, err := hex.DecodeString(kv[1]) if err != nil { - return fmt.Errorf("invalid data format: %v", + return fmt.Errorf("invalid data format: %w", err) } @@ -1514,7 +1514,7 @@ func forwardingHistory(ctx *cli.Context) error { case args.Present(): i, err := strconv.ParseInt(args.First(), 10, 64) if err != nil { - return fmt.Errorf("unable to decode index_offset: %v", + return fmt.Errorf("unable to decode index_offset: %w", err) } indexOffset = uint32(i) @@ -1527,7 +1527,7 @@ func forwardingHistory(ctx *cli.Context) error { case args.Present(): m, err := strconv.ParseInt(args.First(), 10, 64) if err != nil { - return fmt.Errorf("unable to decode max_events: %v", + return fmt.Errorf("unable to decode max_events: %w", err) } maxEvents = uint32(m) @@ -1616,7 +1616,7 @@ func buildRoute(ctx *cli.Context) error { for _, k := range hops { pubkey, err := route.NewVertexFromStr(k) if err != nil { - return fmt.Errorf("error parsing %v: %v", k, err) + return fmt.Errorf("error parsing %v: %w", k, err) } rpcHops = append(rpcHops, pubkey[:]) } @@ -1757,7 +1757,7 @@ func deletePayments(ctx *cli.Context) error { case singlePayment: paymentHash, err = hex.DecodeString(ctx.String("payment_hash")) if err != nil { - return fmt.Errorf("error decoding payment_hash: %v", + return fmt.Errorf("error decoding payment_hash: %w", err) } @@ -1766,7 +1766,7 @@ func deletePayments(ctx *cli.Context) error { FailedHtlcsOnly: failedHTLCsOnly, }) if err != nil { - return fmt.Errorf("error deleting single payment: %v", + return fmt.Errorf("error deleting single payment: %w", err) } diff --git a/cmd/lncli/cmd_profile.go b/cmd/lncli/cmd_profile.go index 0f350e5c2..21666be96 100644 --- a/cmd/lncli/cmd_profile.go +++ b/cmd/lncli/cmd_profile.go @@ -150,7 +150,7 @@ func profileAdd(ctx *cli.Context) error { // All done, store the updated profile file. f.Profiles = append(f.Profiles, profile) if err = saveProfileFile(defaultProfileFile, f); err != nil { - return fmt.Errorf("error writing profile file %s: %v", + return fmt.Errorf("error writing profile file %s: %w", defaultProfileFile, err) } @@ -443,7 +443,7 @@ func profileAddMacaroon(ctx *cli.Context) error { selectedProfile.Macaroons.Jar, macEntry, ) if err = saveProfileFile(defaultProfileFile, f); err != nil { - return fmt.Errorf("error writing profile file %s: %v", + return fmt.Errorf("error writing profile file %s: %w", defaultProfileFile, err) } diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index da03b67a3..10bb55a95 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -1811,7 +1811,7 @@ func getChanInfo(ctx *cli.Context) error { case ctx.Args().Present(): chanID, err = strconv.ParseUint(ctx.Args().First(), 10, 64) if err != nil { - return fmt.Errorf("error parsing chan_id: %s", err) + return fmt.Errorf("error parsing chan_id: %w", err) } default: return fmt.Errorf("chan_id argument missing") diff --git a/cmd/lncli/macaroon_jar.go b/cmd/lncli/macaroon_jar.go index 2c140fa6d..f54f29a26 100644 --- a/cmd/lncli/macaroon_jar.go +++ b/cmd/lncli/macaroon_jar.go @@ -67,7 +67,7 @@ func (e *macaroonEntry) loadMacaroon( macBytes, err = decryptMacaroon(parts[1], parts[2], pw) if err != nil { - return nil, fmt.Errorf("unable to decrypt macaroon: %v", + return nil, fmt.Errorf("unable to decrypt macaroon: %w", err) } } else { @@ -142,7 +142,7 @@ func decryptMacaroon(keyB64, dataB64 string, pw []byte) ([]byte, error) { key := &snacl.SecretKey{} err = key.Unmarshal(keyData) if err != nil { - return nil, fmt.Errorf("could not unmarshal encryption key: %v", + return nil, fmt.Errorf("could not unmarshal encryption key: %w", err) } @@ -155,7 +155,7 @@ func decryptMacaroon(keyB64, dataB64 string, pw []byte) ([]byte, error) { } macBytes, err := key.Decrypt(encryptedMac) if err != nil { - return nil, fmt.Errorf("could not decrypt macaroon data: %v", + return nil, fmt.Errorf("could not decrypt macaroon data: %w", err) } return macBytes, nil diff --git a/cmd/lncli/profile.go b/cmd/lncli/profile.go index 9c6680542..90ac69c0e 100644 --- a/cmd/lncli/profile.go +++ b/cmd/lncli/profile.go @@ -224,7 +224,7 @@ func loadProfileFile(file string) (*profileFile, error) { content, err := ioutil.ReadFile(file) if err != nil { - return nil, fmt.Errorf("could not load profile file %s: %v", + return nil, fmt.Errorf("could not load profile file %s: %w", file, err) } f := &profileFile{} @@ -262,7 +262,7 @@ func (f *profileFile) unmarshalJSON(content []byte) error { func (f *profileFile) marshalJSON() ([]byte, error) { b, err := json.Marshal(f) if err != nil { - return nil, fmt.Errorf("error JSON marshalling profile: %v", + return nil, fmt.Errorf("error JSON marshalling profile: %w", err) } diff --git a/cmd/lncli/walletrpc_active.go b/cmd/lncli/walletrpc_active.go index 5118ddd2f..bb1fb4ecc 100644 --- a/cmd/lncli/walletrpc_active.go +++ b/cmd/lncli/walletrpc_active.go @@ -1235,8 +1235,8 @@ func fundPsbt(ctx *cli.Context) error { // entry must be present. jsonMap := []byte(ctx.String("outputs")) if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil { - return fmt.Errorf("error parsing outputs JSON: %v", - err) + return fmt.Errorf("error parsing outputs "+ + "JSON: %w", err) } tpl.Outputs = amountToAddr } diff --git a/config_builder.go b/config_builder.go index 002ae288a..bbf291506 100644 --- a/config_builder.go +++ b/config_builder.go @@ -568,7 +568,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context, ) cleanUpTasks = append(cleanUpTasks, pccCleanup) if err != nil { - err := fmt.Errorf("unable to create partial chain control: %v", + err := fmt.Errorf("unable to create partial chain control: %w", err) d.logger.Error(err) return nil, nil, nil, err @@ -1073,7 +1073,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase( if err != nil { cleanUp() - err := fmt.Errorf("unable to open %s database: %v", + err := fmt.Errorf("unable to open %s database: %w", lncfg.NSTowerClientDB, err) d.logger.Error(err) return nil, nil, err @@ -1088,7 +1088,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase( if err != nil { cleanUp() - err := fmt.Errorf("unable to open %s database: %v", + err := fmt.Errorf("unable to open %s database: %w", lncfg.NSTowerServerDB, err) d.logger.Error(err) return nil, nil, err @@ -1303,7 +1303,7 @@ func importWatchOnlyAccounts(wallet *wallet.Wallet, addrSchema, ) if err != nil { - return fmt.Errorf("could not import account %v: %v", + return fmt.Errorf("could not import account %v: %w", name, err) } } diff --git a/contractcourt/breach_arbitrator.go b/contractcourt/breach_arbitrator.go index 0e33dc571..017e8bdac 100644 --- a/contractcourt/breach_arbitrator.go +++ b/contractcourt/breach_arbitrator.go @@ -931,7 +931,7 @@ func (b *BreachArbitrator) cleanupBreach(chanPoint *wire.OutPoint) error { // info from the database. err = b.cfg.Store.Remove(chanPoint) if err != nil { - return fmt.Errorf("unable to remove retribution from db: %v", + return fmt.Errorf("unable to remove retribution from db: %w", err) } diff --git a/discovery/gossiper.go b/discovery/gossiper.go index e1884445e..507035e70 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1647,7 +1647,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { return nil }) if err != nil && err != channeldb.ErrGraphNoEdgesFound { - return fmt.Errorf("unable to retrieve outgoing channels: %v", + return fmt.Errorf("unable to retrieve outgoing channels: %w", err) } @@ -1873,7 +1873,7 @@ func (d *AuthenticatedGossiper) processRejectedEdge( // to the database. err = d.cfg.Router.AddProof(chanAnnMsg.ShortChannelID, proof) if err != nil { - err := fmt.Errorf("unable add proof to shortChanID=%v: %v", + err := fmt.Errorf("unable add proof to shortChanID=%v: %w", chanAnnMsg.ShortChannelID, err) log.Error(err) return nil, err @@ -1910,7 +1910,7 @@ func (d *AuthenticatedGossiper) addNode(msg *lnwire.NodeAnnouncement, op ...batch.SchedulerOption) error { if err := routing.ValidateNodeAnn(msg); err != nil { - return fmt.Errorf("unable to validate node announcement: %v", + return fmt.Errorf("unable to validate node announcement: %w", err) } diff --git a/discovery/message_store.go b/discovery/message_store.go index cf228eee7..10fa51623 100644 --- a/discovery/message_store.go +++ b/discovery/message_store.go @@ -72,7 +72,7 @@ func NewMessageStore(db kvdb.Backend) (*MessageStore, error) { return err }) if err != nil { - return nil, fmt.Errorf("unable to create required buckets: %v", + return nil, fmt.Errorf("unable to create required buckets: %w", err) } diff --git a/discovery/syncer.go b/discovery/syncer.go index b567a6940..b910151cb 100644 --- a/discovery/syncer.go +++ b/discovery/syncer.go @@ -1252,7 +1252,7 @@ func (g *GossipSyncer) replyShortChanIDs(query *lnwire.QueryShortChanIDs) error query.ChainHash, query.ShortChanIDs, ) if err != nil { - return fmt.Errorf("unable to fetch chan anns for %v..., %v", + return fmt.Errorf("unable to fetch chan anns for %v..., %w", query.ShortChanIDs[0].ToUint64(), err) } diff --git a/feature/manager.go b/feature/manager.go index 991d5c611..98317eb8f 100644 --- a/feature/manager.go +++ b/feature/manager.go @@ -211,7 +211,7 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) { fv := lnwire.NewFeatureVector(raw, lnwire.Features) err := ValidateDeps(fv) if err != nil { - return nil, fmt.Errorf("invalid feature set %v: %v", + return nil, fmt.Errorf("invalid feature set %v: %w", set, err) } } diff --git a/funding/batch.go b/funding/batch.go index 30eac1478..fc050cdf5 100644 --- a/funding/batch.go +++ b/funding/batch.go @@ -226,7 +226,7 @@ func (b *Batcher) BatchFund(ctx context.Context, "chan ID") } } else if _, err := rand.Read(pendingChanID[:]); err != nil { - return nil, fmt.Errorf("error making temp chan ID: %v", + return nil, fmt.Errorf("error making temp chan ID: %w", err) } @@ -265,7 +265,7 @@ func (b *Batcher) BatchFund(ctx context.Context, }, }) if err != nil { - return nil, fmt.Errorf("error parsing channel %d: %v", + return nil, fmt.Errorf("error parsing channel %d: %w", idx, err) } diff --git a/funding/manager.go b/funding/manager.go index 86e70c17c..e110269a7 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -1123,7 +1123,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel, case markedOpen: err := f.sendChannelReady(channel, lnChannel) if err != nil { - return fmt.Errorf("failed sending channelReady: %v", + return fmt.Errorf("failed sending channelReady: %w", err) } @@ -1137,7 +1137,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel, ) if err != nil { return fmt.Errorf("error setting channel state to"+ - " channelReadySent: %v", err) + " channelReadySent: %w", err) } log.Debugf("Channel(%v) with ShortChanID %v: successfully "+ @@ -1207,7 +1207,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel, // shutdown. err = f.deleteChannelOpeningState(&channel.FundingOutpoint) if err != nil { - return fmt.Errorf("error deleting channel state: %v", + return fmt.Errorf("error deleting channel state: %w", err) } @@ -2757,7 +2757,7 @@ func (f *Manager) fundingTimeout(c *channeldb.OpenChannel, if err := c.CloseChannel( closeInfo, channeldb.ChanStatusLocalCloseInitiator, ); err != nil { - return fmt.Errorf("failed closing channel %v: %v", + return fmt.Errorf("failed closing channel %v: %w", c.FundingOutpoint, err) } @@ -4784,7 +4784,7 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) { } if err := msg.Peer.SendMessage(true, &fundingOpen); err != nil { - e := fmt.Errorf("unable to send funding request message: %v", + e := fmt.Errorf("unable to send funding request message: %w", err) log.Errorf(e.Error()) diff --git a/input/musig2.go b/input/musig2.go index 28a15af73..589152282 100644 --- a/input/musig2.go +++ b/input/musig2.go @@ -587,7 +587,7 @@ func DeserializePartialSignature(scalarBytes []byte) (*musig2.PartialSignature, sig := &musig2.PartialSignature{} if err := sig.Decode(bytes.NewReader(scalarBytes)); err != nil { - return nil, fmt.Errorf("error decoding partial signature: %v", + return nil, fmt.Errorf("error decoding partial signature: %w", err) } diff --git a/kvdb/bolt_compact.go b/kvdb/bolt_compact.go index 6597eb2d5..b477e206b 100644 --- a/kvdb/bolt_compact.go +++ b/kvdb/bolt_compact.go @@ -90,7 +90,7 @@ func (cmd *compacter) execute() (int64, int64, error) { Timeout: cmd.dbTimeout, }) if err != nil { - return 0, 0, fmt.Errorf("error opening source database: %v", + return 0, 0, fmt.Errorf("error opening source database: %w", err) } defer func() { @@ -105,7 +105,7 @@ func (cmd *compacter) execute() (int64, int64, error) { }) if err != nil { return 0, 0, fmt.Errorf("error opening destination database: "+ - "%v", err) + "%w", err) } defer func() { if err := dst.Close(); err != nil { @@ -122,7 +122,7 @@ func (cmd *compacter) execute() (int64, int64, error) { fi, err = os.Stat(cmd.dstPath) if err != nil { return 0, 0, fmt.Errorf("error determining destination "+ - "database size: %v", err) + "database size: %w", err) } else if fi.Size() == 0 { return 0, 0, fmt.Errorf("zero db size") } diff --git a/lnd.go b/lnd.go index 0034f134b..f4ef03a07 100644 --- a/lnd.go +++ b/lnd.go @@ -91,7 +91,7 @@ func AdminAuthOptions(cfg *Config, skipMacaroons bool) ([]grpc.DialOption, mac := &macaroon.Macaroon{} if err = mac.UnmarshalBinary(macBytes); err != nil { - return nil, fmt.Errorf("unable to decode macaroon: %v", + return nil, fmt.Errorf("unable to decode macaroon: %w", err) } diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index e2b98efa7..662c0d08d 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -252,7 +252,7 @@ func (s *Server) ImportGraph(ctx context.Context, } if err := graphDB.AddLightningNode(node); err != nil { - return nil, fmt.Errorf("unable to add node %v: %v", + return nil, fmt.Errorf("unable to add node %v: %w", rpcNode.PubKey, err) } @@ -285,7 +285,7 @@ func (s *Server) ImportGraph(ctx context.Context, edge.ChannelPoint = *channelPoint if err := graphDB.AddChannelEdge(edge); err != nil { - return nil, fmt.Errorf("unable to add edge %v: %v", + return nil, fmt.Errorf("unable to add edge %v: %w", rpcEdge.ChanPoint, err) } diff --git a/lnrpc/routerrpc/router_server.go b/lnrpc/routerrpc/router_server.go index 7ed683f24..194bdc996 100644 --- a/lnrpc/routerrpc/router_server.go +++ b/lnrpc/routerrpc/router_server.go @@ -1140,7 +1140,7 @@ func toPairSnapshot(pairResult *PairHistory) (*routing.MissionControlPairSnapsho pairResult.History.FailTime, ) if err != nil { - return nil, fmt.Errorf("%v invalid failure: %v", pairPrefix, + return nil, fmt.Errorf("%v invalid failure: %w", pairPrefix, err) } @@ -1150,7 +1150,7 @@ func toPairSnapshot(pairResult *PairHistory) (*routing.MissionControlPairSnapsho pairResult.History.SuccessTime, ) if err != nil { - return nil, fmt.Errorf("%v invalid success: %v", pairPrefix, + return nil, fmt.Errorf("%v invalid success: %w", pairPrefix, err) } diff --git a/lnrpc/signrpc/signer_server.go b/lnrpc/signrpc/signer_server.go index a84ea68ff..c29d495eb 100644 --- a/lnrpc/signrpc/signer_server.go +++ b/lnrpc/signrpc/signer_server.go @@ -710,14 +710,14 @@ func (s *Server) VerifyMessage(_ context.Context, // for Schnorr signatures. pubkey, err := schnorr.ParsePubKey(in.Pubkey) if err != nil { - return nil, fmt.Errorf("unable to parse pubkey: %v", + return nil, fmt.Errorf("unable to parse pubkey: %w", err) } sigParsed, err := schnorr.ParseSignature(in.Signature) if err != nil { return nil, fmt.Errorf("can't parse Schnorr "+ - "signature: %v", err) + "signature: %w", err) } var digest []byte @@ -746,7 +746,7 @@ func (s *Server) VerifyMessage(_ context.Context, } sig, err := wireSig.ToSignature() if err != nil { - return nil, fmt.Errorf("failed to convert from wire format: %v", + return nil, fmt.Errorf("failed to convert from wire format: %w", err) } @@ -874,7 +874,7 @@ func (s *Server) MuSig2CombineKeys(_ context.Context, // Are there any tweaks to apply to the combined public key? tweaks, err := UnmarshalTweaks(in.Tweaks, in.TaprootTweak) if err != nil { - return nil, fmt.Errorf("error unmarshaling tweak options: %v", + return nil, fmt.Errorf("error unmarshaling tweak options: %w", err) } @@ -1014,7 +1014,7 @@ func (s *Server) MuSig2CreateSession(_ context.Context, // Are there any tweaks to apply to the combined public key? tweaks, err := UnmarshalTweaks(in.Tweaks, in.TaprootTweak) if err != nil { - return nil, fmt.Errorf("error unmarshaling tweak options: %v", + return nil, fmt.Errorf("error unmarshaling tweak options: %w", err) } @@ -1139,7 +1139,7 @@ func (s *Server) MuSig2CombineSig(_ context.Context, in.OtherPartialSignatures, ) if err != nil { - return nil, fmt.Errorf("error parsing partial signatures: %v", + return nil, fmt.Errorf("error parsing partial signatures: %w", err) } diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index 05b20c339..b25c187ff 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -1038,7 +1038,7 @@ func (w *WalletKit) BumpFee(ctx context.Context, // with an unconfirmed transaction. _, currentHeight, err := w.cfg.Chain.GetBestBlock() if err != nil { - return nil, fmt.Errorf("unable to retrieve current height: %v", + return nil, fmt.Errorf("unable to retrieve current height: %w", err) } @@ -2607,7 +2607,7 @@ func (w *WalletKit) ImportTapscript(_ context.Context, taprootScope := waddrmgr.KeyScopeBIP0086 addr, err := w.cfg.Wallet.ImportTaprootScript(taprootScope, tapscript) if err != nil { - return nil, fmt.Errorf("error importing script into wallet: %v", + return nil, fmt.Errorf("error importing script into wallet: %w", err) } diff --git a/lnrpc/wtclientrpc/wtclient.go b/lnrpc/wtclientrpc/wtclient.go index 459ce3240..5ddb99d37 100644 --- a/lnrpc/wtclientrpc/wtclient.go +++ b/lnrpc/wtclientrpc/wtclient.go @@ -208,7 +208,8 @@ func (c *WatchtowerClient) AddTower(ctx context.Context, c.cfg.Resolver, ) if err != nil { - return nil, fmt.Errorf("invalid address %v: %v", req.Address, err) + return nil, fmt.Errorf("invalid address %v: %w", req.Address, + err) } towerAddr := &lnwire.NetAddress{ diff --git a/lntest/bitcoind_common.go b/lntest/bitcoind_common.go index b5c43c448..657da7cd3 100644 --- a/lntest/bitcoind_common.go +++ b/lntest/bitcoind_common.go @@ -192,7 +192,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string, client, err := rpcclient.New(&rpcCfg, nil) if err != nil { _ = cleanUp() - return nil, nil, fmt.Errorf("unable to create rpc client: %v", + return nil, nil, fmt.Errorf("unable to create rpc client: %w", err) } diff --git a/lntest/node/harness_node.go b/lntest/node/harness_node.go index fb0eea014..00424184e 100644 --- a/lntest/node/harness_node.go +++ b/lntest/node/harness_node.go @@ -294,14 +294,14 @@ func (hn *HarnessNode) ReadMacaroon(macPath string, timeout time.Duration) ( err := wait.NoError(func() error { macBytes, err := ioutil.ReadFile(macPath) if err != nil { - return fmt.Errorf("error reading macaroon file: %v", + return fmt.Errorf("error reading macaroon file: %w", err) } newMac := &macaroon.Macaroon{} if err = newMac.UnmarshalBinary(macBytes); err != nil { return fmt.Errorf("error unmarshalling macaroon "+ - "file: %v", err) + "file: %w", err) } mac = newMac @@ -619,7 +619,7 @@ func (hn *HarnessNode) cleanup() error { if hn.Cfg.backupDBDir != "" { err := os.RemoveAll(hn.Cfg.backupDBDir) if err != nil { - return fmt.Errorf("unable to remove backup dir: %v", + return fmt.Errorf("unable to remove backup dir: %w", err) } } diff --git a/lnwallet/btcwallet/psbt.go b/lnwallet/btcwallet/psbt.go index 0bea6a695..0fdf76c38 100644 --- a/lnwallet/btcwallet/psbt.go +++ b/lnwallet/btcwallet/psbt.go @@ -450,7 +450,7 @@ func signSegWitV0(in *psbt.PInput, tx *wire.MsgTx, in.SighashType, privKey, ) if err != nil { - return fmt.Errorf("error signing input %d: %v", idx, err) + return fmt.Errorf("error signing input %d: %w", idx, err) } in.PartialSigs = append(in.PartialSigs, &psbt.PartialSig{ PubKey: pubKeyBytes, @@ -472,7 +472,7 @@ func signSegWitV1KeySpend(in *psbt.PInput, tx *wire.MsgTx, privKey, ) if err != nil { - return fmt.Errorf("error signing taproot input %d: %v", idx, + return fmt.Errorf("error signing taproot input %d: %w", idx, err) } @@ -492,7 +492,7 @@ func signSegWitV1ScriptSpend(in *psbt.PInput, tx *wire.MsgTx, in.WitnessUtxo.PkScript, leaf, in.SighashType, privKey, ) if err != nil { - return fmt.Errorf("error signing taproot script input %d: %v", + return fmt.Errorf("error signing taproot script input %d: %w", idx, err) } diff --git a/lnwallet/chanfunding/psbt_assembler.go b/lnwallet/chanfunding/psbt_assembler.go index 5132f1296..885fb7b46 100644 --- a/lnwallet/chanfunding/psbt_assembler.go +++ b/lnwallet/chanfunding/psbt_assembler.go @@ -192,7 +192,7 @@ func (i *PsbtIntent) FundingParams() (btcutil.Address, int64, *psbt.Packet, // Encode the address in the human-readable bech32 format. addr, err := script.Address(i.netParams) if err != nil { - return nil, 0, nil, fmt.Errorf("unable to encode address: %v", + return nil, 0, nil, fmt.Errorf("unable to encode address: %w", err) } @@ -204,7 +204,7 @@ func (i *PsbtIntent) FundingParams() (btcutil.Address, int64, *psbt.Packet, packet, err = psbt.New(nil, nil, 2, 0, nil) if err != nil { return nil, 0, nil, fmt.Errorf("unable to create "+ - "PSBT: %v", err) + "PSBT: %w", err) } } packet.UnsignedTx.TxOut = append(packet.UnsignedTx.TxOut, out) diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index e85d87e39..5a16490e5 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -533,12 +533,12 @@ func (r *RPCKeyRing) SignMessageSchnorr(keyLoc keychain.KeyLocator, if err != nil { considerShutdown(err) return nil, fmt.Errorf("error signing message in remote "+ - "signer instance: %v", err) + "signer instance: %w", err) } sigParsed, err := schnorr.ParseSignature(resp.Signature) if err != nil { - return nil, fmt.Errorf("can't parse schnorr signature: %v", + return nil, fmt.Errorf("can't parse schnorr signature: %w", err) } return sigParsed, nil @@ -634,7 +634,7 @@ func (r *RPCKeyRing) ComputeInputScript(tx *wire.MsgTx, // input. sig, err := r.remoteSign(tx, signDesc, witnessProgram) if err != nil { - return nil, fmt.Errorf("error signing with remote instance: %v", + return nil, fmt.Errorf("error signing with remote instance: %w", err) } @@ -740,7 +740,7 @@ func (r *RPCKeyRing) MuSig2CreateSession(bipVersion input.MuSig2Version, resp.TaprootInternalKey, ) if err != nil { - return nil, fmt.Errorf("error parsing internal key: %v", + return nil, fmt.Errorf("error parsing internal key: %w", err) } } @@ -1261,7 +1261,7 @@ func connectRPC(hostPort, tlsCertPath, macaroonPath string, certBytes, err := ioutil.ReadFile(tlsCertPath) if err != nil { - return nil, fmt.Errorf("error reading TLS cert file %v: %v", + return nil, fmt.Errorf("error reading TLS cert file %v: %w", tlsCertPath, err) } @@ -1273,7 +1273,7 @@ func connectRPC(hostPort, tlsCertPath, macaroonPath string, macBytes, err := ioutil.ReadFile(macaroonPath) if err != nil { - return nil, fmt.Errorf("error reading macaroon file %v: %v", + return nil, fmt.Errorf("error reading macaroon file %v: %w", macaroonPath, err) } mac := &macaroon.Macaroon{} @@ -1297,7 +1297,7 @@ func connectRPC(hostPort, tlsCertPath, macaroonPath string, defer cancel() conn, err := grpc.DialContext(ctxt, hostPort, opts...) if err != nil { - return nil, fmt.Errorf("unable to connect to RPC server: %v", + return nil, fmt.Errorf("unable to connect to RPC server: %w", err) } diff --git a/peer/brontide.go b/peer/brontide.go index 187fbafe1..984a52809 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -3352,7 +3352,7 @@ func (p *Brontide) handleInitMsg(msg *lnwire.Init) error { // those presented in the local features fields. err := msg.Features.Merge(msg.GlobalFeatures) if err != nil { - return fmt.Errorf("unable to merge legacy global features: %v", + return fmt.Errorf("unable to merge legacy global features: %w", err) } diff --git a/routing/missioncontrol_store.go b/routing/missioncontrol_store.go index a6c98571f..dd60d9346 100644 --- a/routing/missioncontrol_store.go +++ b/routing/missioncontrol_store.go @@ -75,7 +75,7 @@ func newMissionControlStore(db kvdb.Backend, maxRecords int, err := kvdb.Update(db, func(tx kvdb.RwTx) error { resultsBucket, err := tx.CreateTopLevelBucket(resultsKey) if err != nil { - return fmt.Errorf("cannot create results bucket: %v", + return fmt.Errorf("cannot create results bucket: %w", err) } diff --git a/rpcperms/middleware_handler.go b/rpcperms/middleware_handler.go index 9b1d77a54..296203787 100644 --- a/rpcperms/middleware_handler.go +++ b/rpcperms/middleware_handler.go @@ -418,7 +418,7 @@ func NewMessageInterceptionRequest(ctx context.Context, case proto.Message: req.ProtoSerialized, err = proto.Marshal(t) if err != nil { - return nil, fmt.Errorf("cannot marshal proto msg: %v", + return nil, fmt.Errorf("cannot marshal proto msg: %w", err) } req.ProtoTypeName = string(proto.MessageName(t)) diff --git a/rpcserver.go b/rpcserver.go index f321bbdcf..517bca41e 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1919,7 +1919,7 @@ func newPsbtAssembler(req *lnrpc.OpenChannelRequest, normalizedMinConfs int32, bytes.NewReader(psbtShim.BasePsbt), false, ) if err != nil { - return nil, fmt.Errorf("error parsing base PSBT: %v", + return nil, fmt.Errorf("error parsing base PSBT: %w", err) } } @@ -2144,7 +2144,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest, in.CloseAddress, r.cfg.ActiveNetParams.Params, ) if err != nil { - return nil, fmt.Errorf("error parsing upfront shutdown: %v", + return nil, fmt.Errorf("error parsing upfront shutdown: %w", err) } @@ -6513,7 +6513,7 @@ func (r *rpcServer) StopDaemon(_ context.Context, // otherwise some funds wouldn't be picked up. isRecoveryMode, progress, err := r.server.cc.Wallet.GetRecoveryInfo() if err != nil { - return nil, fmt.Errorf("unable to get wallet recovery info: %v", + return nil, fmt.Errorf("unable to get wallet recovery info: %w", err) } if isRecoveryMode && progress < 1 { @@ -7211,7 +7211,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context, } timeSlice, err := r.server.miscDB.ForwardingLog().Query(eventQuery) if err != nil { - return nil, fmt.Errorf("unable to query forwarding log: %v", + return nil, fmt.Errorf("unable to query forwarding log: %w", err) } @@ -8013,7 +8013,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context, false, ) if err != nil { - return nil, fmt.Errorf("error parsing psbt: %v", + return nil, fmt.Errorf("error parsing psbt: %w", err) } diff --git a/walletunlocker/service.go b/walletunlocker/service.go index d896c2d88..bde5c7a56 100644 --- a/walletunlocker/service.go +++ b/walletunlocker/service.go @@ -882,7 +882,7 @@ func (u *UnlockerService) ChangePassword(ctx context.Context, err = macaroonService.Close() if err != nil { - return nil, fmt.Errorf("could not close macaroon service: %v", + return nil, fmt.Errorf("could not close macaroon service: %w", err) } diff --git a/watchtower/wtclient/session_negotiator.go b/watchtower/wtclient/session_negotiator.go index 1f92660db..ea17c5b47 100644 --- a/watchtower/wtclient/session_negotiator.go +++ b/watchtower/wtclient/session_negotiator.go @@ -475,7 +475,7 @@ func (n *sessionNegotiator) tryAddress(sessionKey keychain.SingleKeyECDH, err = n.cfg.DB.CreateClientSession(dbClientSession) if err != nil { - return fmt.Errorf("unable to persist ClientSession: %v", + return fmt.Errorf("unable to persist ClientSession: %w", err) } diff --git a/watchtower/wtclient/session_queue.go b/watchtower/wtclient/session_queue.go index 786410515..41ae28f2f 100644 --- a/watchtower/wtclient/session_queue.go +++ b/watchtower/wtclient/session_queue.go @@ -527,7 +527,7 @@ func (q *sessionQueue) nextStateUpdate() (*wtwire.StateUpdate, bool, hint, encBlob, err := task.craftSessionPayload(q.cfg.Signer) if err != nil { // TODO(conner): mark will not send - err := fmt.Errorf("unable to craft session payload: %v", + err := fmt.Errorf("unable to craft session payload: %w", err) return nil, false, wtdb.BackupID{}, err } @@ -665,7 +665,7 @@ func (q *sessionQueue) sendStateUpdate(conn wtserver.Peer, switch { case err == wtdb.ErrUnallocatedLastApplied: // TODO(conner): borked watchtower - err = fmt.Errorf("unable to ack seqnum=%d: %v", + err = fmt.Errorf("unable to ack seqnum=%d: %w", stateUpdate.SeqNum, err) q.log.Errorf("SessionQueue(%v) failed to ack update: %v", q.ID(), err) @@ -673,14 +673,14 @@ func (q *sessionQueue) sendStateUpdate(conn wtserver.Peer, case err == wtdb.ErrLastAppliedReversion: // TODO(conner): borked watchtower - err = fmt.Errorf("unable to ack seqnum=%d: %v", + err = fmt.Errorf("unable to ack seqnum=%d: %w", stateUpdate.SeqNum, err) q.log.Errorf("SessionQueue(%s) failed to ack update: %v", q.ID(), err) return err case err != nil: - err = fmt.Errorf("unable to ack seqnum=%d: %v", + err = fmt.Errorf("unable to ack seqnum=%d: %w", stateUpdate.SeqNum, err) q.log.Errorf("SessionQueue(%s) failed to ack update: %v", q.ID(), err) diff --git a/zpay32/amountunits.go b/zpay32/amountunits.go index f53f3ff00..8dcfb7c10 100644 --- a/zpay32/amountunits.go +++ b/zpay32/amountunits.go @@ -136,7 +136,7 @@ func encodeAmount(msat lnwire.MilliSatoshi) (string, error) { // Should always be expressible in pico BTC. pico, err := fromMSat['p'](msat) if err != nil { - return "", fmt.Errorf("unable to express %d msat as pBTC: %v", + return "", fmt.Errorf("unable to express %d msat as pBTC: %w", msat, err) } shortened := strconv.FormatUint(pico, 10) + "p"