2022-07-04 21:14:13 +00:00
|
|
|
#include "General.h"
|
|
|
|
|
|
|
|
#include "Utils.h"
|
2022-07-07 18:16:59 +00:00
|
|
|
|
|
|
|
#include <libstatus.h>
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
namespace Status::StatusGo::General
|
|
|
|
{
|
|
|
|
|
|
|
|
RpcResponse<QJsonObject> initKeystore(const char* keystoreDir)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto result = InitKeystore(const_cast<char*>(keystoreDir));
|
|
|
|
QJsonObject jsonResult;
|
2022-10-19 13:41:53 +00:00
|
|
|
if(!Utils::checkReceivedResponse(result, jsonResult))
|
|
|
|
{
|
2022-07-04 21:14:13 +00:00
|
|
|
throw std::domain_error("parsing response failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
return Utils::buildPrivateRPCResponse(jsonResult);
|
|
|
|
}
|
2022-10-19 13:41:53 +00:00
|
|
|
catch(std::exception& e)
|
2022-07-04 21:14:13 +00:00
|
|
|
{
|
|
|
|
// TODO: either use optional/smartpointers or exceptions instead of plain objects
|
|
|
|
auto response = RpcResponse<QJsonObject>(QJsonObject());
|
|
|
|
// TODO: don't translate exception messages. Exceptions are for developers and should never reach users
|
|
|
|
response.error.message = QObject::tr("an error opening accounts occurred, msg: %1").arg(e.what());
|
|
|
|
return response;
|
|
|
|
}
|
2022-10-19 13:41:53 +00:00
|
|
|
catch(...)
|
2022-07-04 21:14:13 +00:00
|
|
|
{
|
|
|
|
auto response = RpcResponse<QJsonObject>(QJsonObject());
|
|
|
|
response.error.message = QObject::tr("an error opening accounts occurred");
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
} // namespace Status::StatusGo::General
|