multi: fix non-constant input of fmt.Errorf

Fixed multiple cases in which a non-constact string variable was used as a
format string for fmt.Errorf.
This commit is contained in:
Boris Nagaev committed 2025-08-30 14:13:44 -03:00
1 parent f3d52ba7a8
commit 612ad7da27
5 files changed
+10 -7

No files matched your search

+1 -1
View File
@@ -548,7 +548,7 @@ func (r *RPCAcceptor) validateAcceptorResponse(dustLimit btcutil.Amount,
// If we reject the channel, and have a custom error, then we use it. // If we reject the channel, and have a custom error, then we use it.
case haveCustomError: case haveCustomError:
return false, fmt.Errorf(req.Error), nil, nil return false, fmt.Errorf("%s", req.Error), nil, nil
// Otherwise, we have rejected the channel with no custom error, so we // Otherwise, we have rejected the channel with no custom error, so we
// just use a generic error to fail the channel. // just use a generic error to fail the channel.
@@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
moreInfo = fmt.Sprintf("Expected %v, got %v.", moreInfo = fmt.Sprintf("Expected %v, got %v.",
expected, checksum) expected, checksum)
} }
return "", nil, fmt.Errorf("checksum failed. " + moreInfo)
return "", nil, fmt.Errorf("checksum failed. %s", moreInfo)
} }
// We exclude the last 6 bytes, which is the checksum. // We exclude the last 6 bytes, which is the checksum.
+4 -3
View File
@@ -136,7 +136,8 @@ func IPLockChecker() (string, checkers.Func) {
// check. // check.
pr, ok := peer.FromContext(ctx) pr, ok := peer.FromContext(ctx)
if !ok { if !ok {
return fmt.Errorf("unable to get peer info from context") return fmt.Errorf("unable to get peer info from " +
"context")
} }
peerAddr, _, err := net.SplitHostPort(pr.Addr.String()) peerAddr, _, err := net.SplitHostPort(pr.Addr.String())
if err != nil { if err != nil {
@@ -144,8 +145,8 @@ func IPLockChecker() (string, checkers.Func) {
} }
if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) { if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) {
msg := "macaroon locked to different IP address" return fmt.Errorf("macaroon locked to different IP " +
return fmt.Errorf(msg) "address")
} }
return nil return nil
} }
+1 -1
View File
@@ -7986,7 +7986,7 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
errMsg := "cannot set both FeeRate and FeeRatePpm at the " + errMsg := "cannot set both FeeRate and FeeRatePpm at the " +
"same time" "same time"
return nil, status.Errorf(codes.InvalidArgument, errMsg) return nil, status.Errorf(codes.InvalidArgument, "%v", errMsg)
// If the request is using fee_rate. // If the request is using fee_rate.
case req.FeeRate != 0: case req.FeeRate != 0:
+2 -1
View File
@@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
moreInfo = fmt.Sprintf("Expected %v, got %v.", moreInfo = fmt.Sprintf("Expected %v, got %v.",
expected, checksum) expected, checksum)
} }
return "", nil, fmt.Errorf("checksum failed. " + moreInfo)
return "", nil, fmt.Errorf("checksum failed. %s", moreInfo)
} }
// We exclude the last 6 bytes, which is the checksum. // We exclude the last 6 bytes, which is the checksum.