示例#1
0
Status
loginServerGetPinPackage(DataSlice DID, DataSlice LPIN1, std::string &result,
                         AuthError &authError)
{
    const auto url = ABC_SERVER_ROOT "/v1/account/pinpackage/get";
    ServerRequestJson json;
    ABC_CHECK(json.set(ABC_SERVER_JSON_DID_FIELD, base64Encode(DID)));
    ABC_CHECK(json.set(ABC_SERVER_JSON_LPIN1_FIELD, base64Encode(LPIN1)));

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply, &authError));

    struct ResultJson:
        public JsonObject
    {
        ABC_JSON_CONSTRUCTORS(ResultJson, JsonObject)
        ABC_JSON_STRING(package, "pin_package", nullptr)
    } resultJson(replyJson.results());

    ABC_CHECK(resultJson.packageOk());
    result = resultJson.package();
    return Status();
}
示例#2
0
Status
loginServerUploadLogs(Account *account)
{
    const auto url = ABC_SERVER_ROOT "/v1/account/debug";
    ServerRequestJson json;

    if (account)
    {
        json.setup(account->login); // Failure is fine

        JsonArray jsonArray;
        auto ids = account->wallets.list();
        for (const auto &id: ids)
        {
            std::shared_ptr<Wallet> wallet = cacheWalletSoft(id);
            if (wallet)
            {
                const auto name = wallet->name();
                logInfo("Wallet '" + name + "' " + id);

                const auto addresses = wallet->addresses.list();
                for (const auto &address: addresses)
                    logInfo(address);
            }

            DataChunk watchData;
            if (fileLoad(watchData, WalletPaths(id).cachePath()))
            {
                jsonArray.append(
                    json_string(base64Encode(watchData).c_str()));
            }
        }
        json.set("watchers", jsonArray); // Failure is fine

        AutoFree<tABC_AccountSettings, accountSettingsFree> settings;
        settings.get() = accountSettingsLoad(*account);
        std::string servers(settings->szOverrideBitcoinServerList);
        std::string strOverride = (settings->bOverrideBitcoinServers ? "true" :
                                   "false");

        logInfo("bOverrideBitcoinServers:" + strOverride);
        logInfo("szOverrideBitcoinServerList:" + servers);
    }

    DataChunk logData = debugLogLoad();
    json.set("log", base64Encode(logData)); // Failure is fine

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));

    return Status();
}
示例#3
0
Status
loginServerOtpEnable(const Login &login, const std::string &otpToken,
                     const long timeout)
{
    const auto url = ABC_SERVER_ROOT "/v1/otp/on";
    ServerRequestJson json;
    ABC_CHECK(json.setup(login));
    ABC_CHECK(json.set(ABC_SERVER_JSON_OTP_SECRET_FIELD, otpToken));
    ABC_CHECK(json.set(ABC_SERVER_JSON_OTP_TIMEOUT,
                       static_cast<json_int_t>(timeout)));

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply));

    return Status();
}
示例#4
0
Status
loginServerCreate(const LoginStore &store, DataSlice LP1,
                  const CarePackage &carePackage,
                  const LoginPackage &loginPackage,
                  const std::string &syncKey)
{
    const auto url = ABC_SERVER_ROOT "/v1/account/create";
    ServerRequestJson json;
    ABC_CHECK(json.setup(store));
    ABC_CHECK(json.passwordAuthSet(base64Encode(LP1)));
    ABC_CHECK(json.set(ABC_SERVER_JSON_CARE_PACKAGE_FIELD, carePackage.encode()));
    ABC_CHECK(json.set(ABC_SERVER_JSON_LOGIN_PACKAGE_FIELD, loginPackage.encode()));
    ABC_CHECK(json.set(ABC_SERVER_JSON_REPO_FIELD, syncKey));

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply));

    return Status();
}
示例#5
0
Status
loginServerWalletActivate(const Login &login, const std::string &syncKey)
{
    const auto url = ABC_SERVER_ROOT "/v1/wallet/activate";
    ServerRequestJson json;
    ABC_CHECK(json.setup(login));
    ABC_CHECK(json.set(ABC_SERVER_JSON_REPO_WALLET_FIELD, syncKey));

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply));

    return Status();
}
示例#6
0
Status
loginServerChangePassword(const Login &login,
                          DataSlice newLP1, DataSlice newLRA1,
                          const CarePackage &carePackage,
                          const LoginPackage &loginPackage)
{
    const auto url = ABC_SERVER_ROOT "/v1/account/password/update";
    ServerRequestJson json;
    ABC_CHECK(json.setup(login));
    ABC_CHECK(json.set(ABC_SERVER_JSON_NEW_LP1_FIELD, base64Encode(newLP1)));
    ABC_CHECK(json.set(ABC_SERVER_JSON_CARE_PACKAGE_FIELD, carePackage.encode()));
    ABC_CHECK(json.set(ABC_SERVER_JSON_LOGIN_PACKAGE_FIELD, loginPackage.encode()));
    if (newLRA1.size())
    {
        ABC_CHECK(json.set(ABC_SERVER_JSON_NEW_LRA1_FIELD, base64Encode(newLRA1)));
    }

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply));

    return Status();
}