multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using non-wrapping format verbs.
This commit is contained in:
103 files changed
+426
-390
No files matched your search
@@ -156,7 +156,7 @@ func (r *RPCKeyRing) SendOutputs(outputs []*wire.TxOut,
|
||||
&txIn.PreviousOutPoint,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error looking up utxo: %v", err)
|
||||
return nil, fmt.Errorf("error looking up utxo: %w", err)
|
||||
}
|
||||
|
||||
if txscript.IsPayToTaproot(info.PkScript) {
|
||||
@@ -201,7 +201,7 @@ func (r *RPCKeyRing) SignPsbt(packet *psbt.Packet) ([]uint32, error) {
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := packet.Serialize(&buf); err != nil {
|
||||
return nil, fmt.Errorf("error serializing PSBT: %v", err)
|
||||
return nil, fmt.Errorf("error serializing PSBT: %w", err)
|
||||
}
|
||||
|
||||
resp, err := r.walletClient.SignPsbt(ctxt, &walletrpc.SignPsbtRequest{
|
||||
@@ -217,7 +217,7 @@ func (r *RPCKeyRing) SignPsbt(packet *psbt.Packet) ([]uint32, error) {
|
||||
bytes.NewReader(resp.SignedPsbt), false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing signed PSBT: %v", err)
|
||||
return nil, fmt.Errorf("error parsing signed PSBT: %w", err)
|
||||
}
|
||||
|
||||
// The caller expects the packet to be modified instead of a new
|
||||
@@ -349,7 +349,7 @@ func (r *RPCKeyRing) FinalizePsbt(packet *psbt.Packet, _ string) error {
|
||||
var witnessBytes bytes.Buffer
|
||||
err = psbt.WriteTxWitness(&witnessBytes, script.Witness)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error serializing witness: %v", err)
|
||||
return fmt.Errorf("error serializing witness: %w", err)
|
||||
}
|
||||
packet.Inputs[idx].FinalScriptWitness = witnessBytes.Bytes()
|
||||
packet.Inputs[idx].FinalScriptSig = script.SigScript
|
||||
@@ -359,7 +359,7 @@ func (r *RPCKeyRing) FinalizePsbt(packet *psbt.Packet, _ string) error {
|
||||
// broadcast.
|
||||
err = psbt.MaybeFinalizeAll(packet)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error finalizing PSBT: %v", err)
|
||||
return fmt.Errorf("error finalizing PSBT: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -732,7 +732,7 @@ func (r *RPCKeyRing) MuSig2CreateSession(bipVersion input.MuSig2Version,
|
||||
|
||||
info.CombinedKey, err = schnorr.ParsePubKey(resp.CombinedKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing combined key: %v", err)
|
||||
return nil, fmt.Errorf("error parsing combined key: %w", err)
|
||||
}
|
||||
|
||||
if tweaks.HasTaprootTweak() {
|
||||
@@ -891,7 +891,7 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
|
||||
|
||||
packet, err := packetFromTx(tx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error converting TX into PSBT: %v", err)
|
||||
return nil, fmt.Errorf("error converting TX into PSBT: %w", err)
|
||||
}
|
||||
|
||||
// We need to add witness information for all inputs! Otherwise, we'll
|
||||
@@ -1157,7 +1157,7 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := packet.Serialize(&buf); err != nil {
|
||||
return nil, fmt.Errorf("error serializing PSBT: %v", err)
|
||||
return nil, fmt.Errorf("error serializing PSBT: %w", err)
|
||||
}
|
||||
|
||||
resp, err := r.walletClient.SignPsbt(
|
||||
@@ -1173,7 +1173,7 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
|
||||
bytes.NewReader(resp.SignedPsbt), false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing signed PSBT: %v", err)
|
||||
return nil, fmt.Errorf("error parsing signed PSBT: %w", err)
|
||||
}
|
||||
|
||||
// We expect a signature in the input now.
|
||||
@@ -1278,12 +1278,12 @@ func connectRPC(hostPort, tlsCertPath, macaroonPath string,
|
||||
}
|
||||
mac := &macaroon.Macaroon{}
|
||||
if err := mac.UnmarshalBinary(macBytes); err != nil {
|
||||
return nil, fmt.Errorf("error decoding macaroon: %v", err)
|
||||
return nil, fmt.Errorf("error decoding macaroon: %w", err)
|
||||
}
|
||||
|
||||
macCred, err := macaroons.NewMacaroonCredential(mac)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating creds: %v", err)
|
||||
return nil, fmt.Errorf("error creating creds: %w", err)
|
||||
}
|
||||
|
||||
opts := []grpc.DialOption{
|
||||
|
||||
Reference in new issue
Block a user