mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
multi: wrap all errors
This commit is contained in:
parent
9a28a4c105
commit
648fb22f63
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
2
lnd.go
2
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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
|
10
rpcserver.go
10
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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user