diff --git a/types/types.go b/types/types.go index f9d1961c1..a35e3dae8 100644 --- a/types/types.go +++ b/types/types.go @@ -49,11 +49,15 @@ type RPCResponse struct { } func NewRPCResponse(id string, res interface{}, err string) RPCResponse { - raw := json.RawMessage(wire.JSONBytes(res)) + var raw *json.RawMessage + if res != nil { + rawMsg := json.RawMessage(wire.JSONBytes(res)) + raw = &rawMsg + } return RPCResponse{ JSONRPC: "2.0", ID: id, - Result: &raw, + Result: raw, Error: err, } }