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 2025-08-19 14:52:28 -03:00
parent f3d52ba7a8
commit 612ad7da27
No known key found for this signature in database
5 changed files with 10 additions and 7 deletions

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.
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
// just use a generic error to fail the channel.

View file

@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
moreInfo = fmt.Sprintf("Expected %v, got %v.",
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.

View file

@ -136,7 +136,8 @@ func IPLockChecker() (string, checkers.Func) {
// check.
pr, ok := peer.FromContext(ctx)
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())
if err != nil {
@ -144,8 +145,8 @@ func IPLockChecker() (string, checkers.Func) {
}
if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) {
msg := "macaroon locked to different IP address"
return fmt.Errorf(msg)
return fmt.Errorf("macaroon locked to different IP " +
"address")
}
return nil
}

View file

@ -7986,7 +7986,7 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
errMsg := "cannot set both FeeRate and FeeRatePpm at the " +
"same time"
return nil, status.Errorf(codes.InvalidArgument, errMsg)
return nil, status.Errorf(codes.InvalidArgument, "%v", errMsg)
// If the request is using fee_rate.
case req.FeeRate != 0:

View file

@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
moreInfo = fmt.Sprintf("Expected %v, got %v.",
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.