Status
watcherSave(Wallet &self)
{
    Watcher *watcher = nullptr;
    ABC_CHECK(watcherFind(watcher, self));

    auto data = watcher->serialize();;
    ABC_CHECK(fileSave(data, watcherPath(self)));

    return Status();
}
static Status
watcherLoad(Wallet &self)
{
    Watcher *watcher = nullptr;
    ABC_CHECK(watcherFind(watcher, self));

    DataChunk data;
    ABC_CHECK(fileLoad(data, watcherPath(self)));
    if (!watcher->load(data))
        return ABC_ERROR(ABC_CC_Error, "Unable to load serialized watcher");

    return Status();
}
Status
loginServerUploadLogs(const Account *account)
{
    const auto url = ABC_SERVER_ROOT "/account/debug";
    JsonPtr json;
    HttpReply reply;
    DataChunk logData = debugLogLoad();

    if (account)
    {
        JsonArray jsonArray;
        auto ids = account->wallets.list();
        for (const auto &id: ids)
        {
            std::shared_ptr<Wallet> wallet;
            if (cacheWallet(wallet, nullptr, id.c_str()))
            {
                DataChunk watchData;
                ABC_CHECK(fileLoad(watchData, watcherPath(*wallet)));
                jsonArray.append(
                    json_string(base64Encode(watchData).c_str()));
            }
        }

        json.reset(json_pack("{ss, ss, ss}",
                             ABC_SERVER_JSON_L1_FIELD, base64Encode(account->login.lobby.authId()).c_str(),
                             ABC_SERVER_JSON_LP1_FIELD, base64Encode(account->login.authKey()).c_str(),
                             "log", base64Encode(logData).c_str()));
        if (jsonArray)
            json_object_set(json.get(), "watchers", jsonArray.get());
    }
    else
    {
        json.reset(json_pack("{ss}", "log", base64Encode(logData).c_str()));
    }

    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    return Status();
}