btcjson,wire: fix invalid use of string(x) to convert byte value

This commit is contained in:
Federico Bond 2020-08-27 21:30:27 -03:00 committed by Jake Sylvestre
parent d13e907952
commit 35194e2dac
2 changed files with 2 additions and 2 deletions

View file

@ -201,7 +201,7 @@ func TestAssignFieldErrors(t *testing.T) {
}{
{
name: "general incompatible int -> string",
dest: string(0),
dest: "\x00",
src: int(0),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},

View file

@ -213,7 +213,7 @@ func readMessageHeader(r io.Reader) (int, *messageHeader, error) {
readElements(hr, &hdr.magic, &command, &hdr.length, &hdr.checksum)
// Strip trailing zeros from command string.
hdr.command = string(bytes.TrimRight(command[:], string(0)))
hdr.command = string(bytes.TrimRight(command[:], "\x00"))
return n, &hdr, nil
}