Skip to content

Commit 612ad7d

Browse files
committed
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.
1 parent f3d52ba commit 612ad7d

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

chanacceptor/rpcacceptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func (r *RPCAcceptor) validateAcceptorResponse(dustLimit btcutil.Amount,
548548

549549
// If we reject the channel, and have a custom error, then we use it.
550550
case haveCustomError:
551-
return false, fmt.Errorf(req.Error), nil, nil
551+
return false, fmt.Errorf("%s", req.Error), nil, nil
552552

553553
// Otherwise, we have rejected the channel with no custom error, so we
554554
// just use a generic error to fail the channel.

channeldb/migration_01_to_11/zpay32/bech32.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
7676
moreInfo = fmt.Sprintf("Expected %v, got %v.",
7777
expected, checksum)
7878
}
79-
return "", nil, fmt.Errorf("checksum failed. " + moreInfo)
79+
80+
return "", nil, fmt.Errorf("checksum failed. %s", moreInfo)
8081
}
8182

8283
// We exclude the last 6 bytes, which is the checksum.

macaroons/constraints.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,17 @@ func IPLockChecker() (string, checkers.Func) {
136136
// check.
137137
pr, ok := peer.FromContext(ctx)
138138
if !ok {
139-
return fmt.Errorf("unable to get peer info from context")
139+
return fmt.Errorf("unable to get peer info from " +
140+
"context")
140141
}
141142
peerAddr, _, err := net.SplitHostPort(pr.Addr.String())
142143
if err != nil {
143144
return fmt.Errorf("unable to parse peer address")
144145
}
145146

146147
if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) {
147-
msg := "macaroon locked to different IP address"
148-
return fmt.Errorf(msg)
148+
return fmt.Errorf("macaroon locked to different IP " +
149+
"address")
149150
}
150151
return nil
151152
}

rpcserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7986,7 +7986,7 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
79867986
errMsg := "cannot set both FeeRate and FeeRatePpm at the " +
79877987
"same time"
79887988

7989-
return nil, status.Errorf(codes.InvalidArgument, errMsg)
7989+
return nil, status.Errorf(codes.InvalidArgument, "%v", errMsg)
79907990

79917991
// If the request is using fee_rate.
79927992
case req.FeeRate != 0:

zpay32/bech32.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
7676
moreInfo = fmt.Sprintf("Expected %v, got %v.",
7777
expected, checksum)
7878
}
79-
return "", nil, fmt.Errorf("checksum failed. " + moreInfo)
79+
80+
return "", nil, fmt.Errorf("checksum failed. %s", moreInfo)
8081
}
8182

8283
// We exclude the last 6 bytes, which is the checksum.

0 commit comments

Comments
 (0)