Esempio n. 1
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();
}
Esempio n. 2
0
Status
syncMakeRepo(const std::string &syncDir)
{
    AutoSyncLock lock(gSyncMutex);

    git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
    opts.flags |= GIT_REPOSITORY_INIT_MKDIR;
    opts.flags |= GIT_REPOSITORY_INIT_MKPATH;

    AutoFree<git_repository, git_repository_free> repo;
    ABC_CHECK_GIT(git_repository_init_ext(&repo.get(), syncDir.c_str(), &opts));

    return Status();
}
Esempio n. 3
0
Status
syncRepo(const std::string &syncDir, const std::string &syncKey, bool &dirty)
{
    AutoSyncLock lock(gSyncMutex);

    AutoFree<git_repository, git_repository_free> repo;
    ABC_CHECK_GIT(git_repository_open(&repo.get(), syncDir.c_str()));

    std::string url;

    ABC_CHECK(syncUrl(url, syncKey));

    for (int i = 0; i < syncServers.size(); i++)
    {
        ABC_CHECK(syncUrl(url, syncKey, true));
        if (sync_fetch(repo, url.c_str()) >= 0)
        {
            ABC_DebugLog("Syncing to: %s", url.c_str());
            break;
        }
        else
        {
            ABC_DebugLog("FAIlED Syncing to: %s", url.c_str());
        }
    }

    int files_changed, need_push;
    ABC_CHECK_GIT(sync_master(repo, &files_changed, &need_push));

    if (need_push)
        ABC_CHECK_GIT(sync_push(repo, url.c_str()));

    // If this fails, the app has been shut down, leaving us for dead.
    // We will crash anyhow, but this at least makes it official:
    assert(gContext);

    dirty = !!files_changed;
    return Status();
}
Esempio n. 4
0
/**
 * Create a label based off the user settings
 *
 * @param pszLabel       The label will be returned in this parameter
 * @param pError         A pointer to the location to store the error if there is one
 */
static
tABC_CC ABC_TxBuildFromLabel(Wallet &self,
                             const char **pszLabel, tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;
    ABC_SET_ERR_CODE(pError, ABC_CC_Ok);

    AutoFree<tABC_AccountSettings, ABC_FreeAccountSettings> pSettings;

    ABC_CHECK_NULL(pszLabel);
    *pszLabel = NULL;

    ABC_CHECK_RET(ABC_AccountSettingsLoad(self.account, &pSettings.get(), pError));

    if (pSettings->bNameOnPayments && pSettings->szFullName)
    {
        *pszLabel = stringCopy(pSettings->szFullName);
    }

exit:
    return cc;
}
Esempio n. 5
0
Status
AddressJson::unpack(Address &result)
{
    Address out;

    // Main json:
    ABC_CHECK(indexOk());
    out.index = index();
    ABC_CHECK(addressOk());
    out.address = address();

    // State json:
    AddressStateJson stateJson = state();
    out.recyclable = stateJson.recyclable();
    out.time = stateJson.time();

    // Details json:
    AutoFree<tABC_TxDetails, ABC_TxDetailsFree> pDetails;
    ABC_CHECK_OLD(ABC_TxDetailsDecode(get(), &pDetails.get(), &error));
    out.metadata = TxMetadata(pDetails);

    result = std::move(out);
    return Status();
}