示例#1
0
QString MyMoneyOfxConnector::password() const
{
  // if we don't find a password in the wallet, we use the old method
  // and retrieve it from the settings stored in the KMyMoney data storage.
  // in case we don't have a password on file, we ask the user
  QString key = OFX_PASSWORD_KEY(m_fiSettings.value("url"), m_fiSettings.value("uniqueId"));
  QString pwd = m_fiSettings.value("password");

  // now check for the wallet
  Wallet *wallet = openSynchronousWallet();
  if (wallet
      && !Wallet::keyDoesNotExist(Wallet::NetworkWallet(), Wallet::PasswordFolder(), key)) {
    wallet->setFolder(Wallet::PasswordFolder());
    wallet->readPassword(key, pwd);
  }

  if (pwd.isEmpty()) {
    QPointer<KPasswordDialog> dlg = new KPasswordDialog(0);
    dlg->setPrompt(i18n("Enter your password for account <b>%1</b>").arg(m_account.name()));
    if (dlg->exec())
      pwd = dlg->password();
    delete dlg;
  }
  return pwd;
}
示例#2
0
void NetworkAccount::readPassword()
{
    if(!storePasswd())
        return;

    // ### workaround for broken Wallet::keyDoesNotExist() which returns wrong
    // results for new entries without closing and reopening the wallet
    if(Wallet::isOpen(Wallet::NetworkWallet()))
    {
        Wallet *wallet = kmkernel->wallet();
        if(!wallet || !wallet->hasEntry("account-" + QString::number(mId)))
            return;
    }
    else
    {
        if(Wallet::keyDoesNotExist(Wallet::NetworkWallet(), "kmail", "account-" + QString::number(mId)))
            return;
    }

    if(kmkernel->wallet())
    {
        QString passwd;
        kmkernel->wallet()->readPassword("account-" + QString::number(mId), passwd);
        setPasswd(passwd, true);
        mPasswdDirty = false;
    }
}
示例#3
0
void CoreScript::AddTech()
{
	tech += TECH_ADDED_BY_VISITOR;
	tech = Clamp( tech, 0.0, Min( double(TECH_MAX), double( MaxTech() ) - 0.01 ));
	achievement.techLevel = Max(achievement.techLevel, (int)tech);

	int team = ParentChit()->Team();
	int superTeam = Team::Instance()->SuperTeam(team);
	if (team != superTeam) {
		CoreScript* super = CoreScript::GetCoreFromTeam(superTeam);
		if (super) {
			super->AddTech();

			// EXPERIMENTAL: also transfer Au
			Wallet* wallet = parentChit->GetWallet();
			GLASSERT(wallet);
			if (wallet 
				&& super->ParentChit()->GetWallet() 
				&& (wallet->Gold() > (GOLD_XFER_TAKEOVER *3/2))) 
			{
				int gold = GOLD_XFER_TAKEOVER / 10;
				super->ParentChit()->GetWallet()->Deposit(wallet, gold);
			}
		}
	}
}
示例#4
0
Status
bridgeWatcherStart(Wallet &self)
{
    if (watchers_.end() != watchers_.find(self.id()))
        return ABC_ERROR(ABC_CC_Error,
                         "Watcher already exists for " + self.id());

    watchers_[self.id()].reset(new WatcherInfo(self));

    return Status();
}
示例#5
0
//public member functions
void Command::parse(char* args[])
{
    mainArg = argToStr(args[1]);
    Wallet wallet;
    
    if(mainArg == "getnewaddress")
    {
        wallet.walletName = argToStr(args[2]);
        wallet.getNewAddress();
    }
}
示例#6
0
void MapScene::ItemTapped(const gamui::UIItem* item)
{
	Vector2I sector = { 0, 0 };
	Vector2I v = data->destSector;
	CoreScript* cs = CoreScript::GetCore(v);
	CoreScript* homeCore = lumosChitBag->GetHomeCore();

	if (item == &okay) {
		data->destSector.Zero();
		lumosGame->PopScene();
	}
	else if (item == &gridTravel) {
		lumosGame->PopScene();
	}
	else if (item == &viewButton) {
		data->view = true;
		lumosGame->PopScene();
	}
	else if (item == &mapImage) {
		float x = 0, y = 0;
		gamui2D.GetRelativeTap(&x, &y);
		sector.x = int(x * float(NUM_SECTORS));
		sector.y = int(y * float(NUM_SECTORS));
		data->destSector = sector;
		DrawMap();
		EnableButtons();
	}
	else if (item == &mapImage2) {
		float x = 0, y = 0;
		gamui2D.GetRelativeTap(&x, &y);
		Rectangle2I b = MapBounds2();
		sector.x = b.min.x + int(x * float(b.Width()));
		sector.y = b.min.y + int(y * float(b.Height()));
		data->destSector = sector;
		DrawMap();
		EnableButtons();
	}
	else if (item == &warButton) {
		Team::Instance()->War(cs, homeCore, true, &lumosChitBag->GetSim()->GetCachedWeb());
		DrawMap();
		EnableButtons();
	}
	else if (item == &peaceButton) {
		int cost = Team::Instance()->Peace(cs, homeCore, false, &lumosChitBag->GetSim()->GetCachedWeb());
		Wallet* wallet = homeCore->ParentChit()->GetWallet();
		if (wallet->HasGold(cost)) {
			ReserveBank::Instance()->GetWallet()->Deposit(wallet, cost);
			Team::Instance()->Peace(cs, homeCore, true, &lumosChitBag->GetSim()->GetCachedWeb());
			DrawMap();
			EnableButtons();
		}
	}
}
示例#7
0
文件: Source.cpp 项目: agbares/CIS22C
//Get values from wallet class and display them on screen
void viewWallet(Wallet &myWallet)
{
	cout << endl << "	***Viewing Wallet***" << endl << endl
		<< "	 1: Dollars: " << fixed << setprecision(2) << myWallet.getMoney(Wallet::DOLLAR) << "\n"
		<< "	 2: Dinars: " << fixed << setprecision(2) << myWallet.getMoney(Wallet::DINAR) << "\n"
		<< "	 3: Euro: " << fixed << setprecision(2) << myWallet.getMoney(Wallet::EURO) << "\n"
		<< "	 4: Peso: " << fixed << setprecision(2) << myWallet.getMoney(Wallet::PESO) << "\n"
		<< "	 5: Pound: " << fixed << setprecision(2) << myWallet.getMoney(Wallet::POUND) << "\n"
		<< endl << endl;

	system("pause");
}
示例#8
0
void PasswordHandler::onWalletOpened(bool success)
{
#if USE_KWALLET
    Wallet *wallet = qobject_cast<Wallet*>( sender() );
    if (wallet && success) {
        // read and store the password
        password();
        emit passwordAvailable();
    }
    if (wallet) {
        wallet->deleteLater();
    }
#else
    Q_UNUSED(success);
#endif
}
示例#9
0
tABC_CC ABC_BridgeWatcherConnect(Wallet &self, tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;
    tABC_GeneralInfo *ppInfo = NULL;
    const char *szServer = FALLBACK_OBELISK;

    Watcher *watcher = nullptr;
    ABC_CHECK_NEW(watcherFind(watcher, self));

    // Pick a server:
    if (isTestnet())
    {
        szServer = TESTNET_OBELISK;
    }
    else if (ABC_CC_Ok == ABC_GeneralGetInfo(&ppInfo, pError) &&
        0 < ppInfo->countObeliskServers)
    {
        ++gLastObelisk;
        if (ppInfo->countObeliskServers <= gLastObelisk)
            gLastObelisk = 0;
        szServer = ppInfo->aszObeliskServers[gLastObelisk];
    }

    // Connect:
    ABC_DebugLog("Wallet %s connecting to %s", self.id().c_str(), szServer);
    watcher->connect(szServer);

exit:
    ABC_GeneralFreeInfo(ppInfo);
    return cc;
}
示例#10
0
static bc::hd_private_key
mainBranch(const Wallet &wallet)
{
    return bc::hd_private_key(wallet.bitcoinKey()).
           generate_private_key(0).
           generate_private_key(0);
}
示例#11
0
Status
bridgeWatcherDelete(Wallet &self)
{
    watcherSave(self).log(); // Failure is not fatal
    watchers_.erase(self.id());

    return Status();
}
示例#12
0
tABC_CC ABC_BridgeWatcherDelete(Wallet &self, tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;

    watcherSave(self); // Failure is not fatal
    watchers_.erase(self.id());

    return cc;
}
示例#13
0
文件: Source.cpp 项目: agbares/CIS22C
//Calls function from wallet class to set all values to zero
void emptyWallet(Wallet &myWallet)
{
	cout << endl << "	***Emptying Wallet...***" << endl;
	
	myWallet.emptyWallet();
	
	cout << endl << "	***Wallet Emptied***" << endl;

	system("pause");
}
示例#14
0
// return 0 on success, -1 on error or not found, -2 on user reject
// if success, password contain the password
int SQLManager::readCredentials(const QString &name, QString &password)
{
  Wallet *wallet = openWallet();

  if (!wallet) // user reject
    return -2;

  QMap<QString, QString> map;

  if (wallet->readMap(name, map) == 0)
  {
    if (!map.isEmpty())
    {
      password = map.value("password");
      return 0;
    }
  }

  return -1;
}
示例#15
0
static Status
watcherFind(WatcherInfo *&result, Wallet &self)
{
    std::string id = self.id();
    auto row = watchers_.find(id);
    if (row == watchers_.end())
        return ABC_ERROR(ABC_CC_Synchronizing, "Cannot find watcher for " + id);

    result = row->second.get();
    return Status();
}
示例#16
0
// return 0 on success, -1 on error, -2 on user reject
int SQLManager::storeCredentials(const Connection &conn)
{
  // Sqlite is without password, avoid to open wallet
  if (conn.driver.contains("QSQLITE"))
    return 0;

  Wallet *wallet = openWallet();

  if (!wallet) // user reject
    return -2;

  QMap<QString, QString> map;

  map["driver"] = conn.driver.toUpper();
  map["hostname"] = conn.hostname.toUpper();
  map["port"] = QString::number(conn.port);
  map["database"] = conn.database.toUpper();
  map["username"] = conn.username;
  map["password"] = conn.password;

  return (wallet->writeMap(conn.name, map) == 0) ? 0 : -1;
}
示例#17
0
 void queueWriteOAuthCredentials() {
     if (wallet != NULL && wallet->isOpen())
         p->writeOAuthCredentials(true);
     else {
         /// Wallet is closed or not initialized
         if (wallet != NULL)
             /// Delete existing but closed wallet, will be replaced by new, open wallet soon
             delete wallet;
         p->setEnabled(false);
         p->setCursor(Qt::WaitCursor);
         wallet = Wallet::openWallet(Wallet::NetworkWallet(), p->winId(), Wallet::Asynchronous);
         connect(wallet, &Wallet::walletOpened, p, &ZoteroBrowser::writeOAuthCredentials);
     }
 }
示例#18
0
Wallet *Wallet::openWallet(const QString &name, WId w, OpenType ot)
{
    if(ot == Asynchronous)
    {
        Wallet *wallet = new Wallet(-1, name);
        DCOPRef("kded", "kwalletd").send("openAsynchronous", name, wallet->objId(), uint(w));
        return wallet;
    }

    // avoid deadlock if the app has some popup open (#65978/#71048)
    while(QWidget *widget = qApp->activePopupWidget())
        widget->close();

    bool isPath = ot == Path;
    DCOPReply r;

    if(isPath)
    {
        r = DCOPRef("kded", "kwalletd").call("openPath", name, uint(w));
    }
    else
    {
        r = DCOPRef("kded", "kwalletd").call("open", name, uint(w));
    }

    if(r.isValid())
    {
        int drc = -1;
        r.get(drc);
        if(drc != -1)
        {
            return new Wallet(drc, name);
        }
    }

    return 0;
}
示例#19
0
tABC_CC ABC_BridgeWatcherStart(Wallet &self,
                               tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;

    std::string id = self.id();

    if (watchers_.end() != watchers_.find(id))
        ABC_RET_ERROR(ABC_CC_Error, ("Watcher already exists for " + id).c_str());

    watchers_[id].reset(new WatcherInfo(self));

    watcherLoad(self); // Failure is not fatal

exit:
    return cc;
}
示例#20
0
tABC_CC ABC_BridgeWatchAddr(Wallet &self,
                            const char *pubAddress,
                            tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;

    ABC_DebugLog("Watching %s for %s", pubAddress, self.id().c_str());
    bc::payment_address addr;

    WatcherInfo *watcherInfo = nullptr;
    ABC_CHECK_NEW(watcherFind(watcherInfo, self));

    if (!addr.set_encoded(pubAddress))
    {
        cc = ABC_CC_Error;
        ABC_DebugLog("Invalid pubAddress %s\n", pubAddress);
        goto exit;
    }
    watcherInfo->addresses.insert(pubAddress);
    watcherInfo->watcher.watch_address(addr);

exit:
    return cc;
}
示例#21
0
 WatcherInfo(Wallet &wallet):
     wallet(wallet),
     parent_(wallet.shared_from_this())
 {
 }
示例#22
0
static Status
bridgeDoSweep(Wallet &wallet, PendingSweep &sweep,
              tABC_BitCoin_Event_Callback fAsyncCallback, void *pData)
{
    // Find utxos for this address:
    AddressSet addresses;
    addresses.insert(sweep.address);
    auto utxos = wallet.txCache.get_utxos(addresses);

    // Bail out if there are no funds to sweep:
    if (!utxos.size())
    {
        // Tell the GUI if there were funds in the past:
        if (wallet.txCache.has_history(sweep.address))
        {
            ABC_DebugLog("IncomingSweep callback: wallet %s, value: 0",
                         wallet.id().c_str());
            tABC_AsyncBitCoinInfo info;
            info.pData = pData;
            info.eventType = ABC_AsyncEventType_IncomingSweep;
            Status().toError(info.status, ABC_HERE());
            info.szWalletUUID = wallet.id().c_str();
            info.szTxID = nullptr;
            info.sweepSatoshi = 0;
            fAsyncCallback(&info);

            sweep.done = true;
        }
        return Status();
    }

    // Build a transaction:
    bc::transaction_type tx;
    tx.version = 1;
    tx.locktime = 0;

    // Set up the output:
    Address address;
    wallet.addresses.getNew(address);
    bc::transaction_output_type output;
    ABC_CHECK(outputScriptForAddress(output.script, address.address));
    tx.outputs.push_back(output);

    // Set up the inputs:
    uint64_t fee, funds;
    ABC_CHECK(inputsPickMaximum(fee, funds, tx, utxos));
    if (outputIsDust(funds))
        return ABC_ERROR(ABC_CC_InsufficientFunds, "Not enough funds");
    tx.outputs[0].value = funds;

    // Now sign that:
    KeyTable keys;
    keys[sweep.address] = sweep.key;
    ABC_CHECK(signTx(tx, wallet.txCache, keys));

    // Send:
    bc::data_chunk raw_tx(satoshi_raw_size(tx));
    bc::satoshi_save(tx, raw_tx.begin());
    ABC_CHECK(broadcastTx(wallet, raw_tx));

    // Calculate transaction information:
    const auto info = wallet.txCache.txInfo(tx, wallet.addresses.list());

    // Save the transaction metadata:
    Tx meta;
    meta.ntxid = info.ntxid;
    meta.txid = info.txid;
    meta.timeCreation = time(nullptr);
    meta.internal = true;
    meta.metadata.amountSatoshi = funds;
    meta.metadata.amountFeesAirbitzSatoshi = 0;
    ABC_CHECK(gContext->exchangeCache.satoshiToCurrency(
                  meta.metadata.amountCurrency, info.balance,
                  static_cast<Currency>(wallet.currency())));
    ABC_CHECK(wallet.txs.save(meta));

    // Update the transaction cache:
    if (wallet.txCache.insert(tx))
        watcherSave(wallet).log(); // Failure is not fatal
    wallet.balanceDirty();
    ABC_CHECK(wallet.addresses.markOutputs(info.ios));

    // Done:
    ABC_DebugLog("IncomingSweep callback: wallet %s, txid: %s, value: %d",
                 wallet.id().c_str(), info.txid.c_str(), output.value);
    tABC_AsyncBitCoinInfo async;
    async.pData = pData;
    async.eventType = ABC_AsyncEventType_IncomingSweep;
    Status().toError(async.status, ABC_HERE());
    async.szWalletUUID = wallet.id().c_str();
    async.szTxID = info.txid.c_str();
    async.sweepSatoshi = output.value;
    fAsyncCallback(&async);

    sweep.done = true;

    return Status();
}
示例#23
0
static Status
bridgeTxCallback(Wallet &wallet,
                 const libbitcoin::transaction_type &tx,
                 tABC_BitCoin_Event_Callback fAsyncCallback, void *pData)
{
    const auto addresses = wallet.addresses.list();
    const auto info = wallet.txCache.txInfo(tx, addresses);

    // Does this transaction concern us?
    if (wallet.txCache.isRelevant(tx, addresses))
    {
        // Does the transaction already exist?
        Tx meta;
        if (!wallet.txs.get(meta, info.ntxid))
        {
            meta.ntxid = info.ntxid;
            meta.txid = info.txid;
            meta.timeCreation = time(nullptr);
            meta.internal = false;

            // Grab metadata from the address:
            TxMetadata metadata;
            for (const auto &io: info.ios)
            {
                Address address;
                if (wallet.addresses.get(address, io.address))
                    meta.metadata = address.metadata;
            }
            meta.metadata.amountSatoshi = info.balance;
            meta.metadata.amountFeesMinersSatoshi = info.fee;
            ABC_CHECK(gContext->exchangeCache.satoshiToCurrency(
                          meta.metadata.amountCurrency, info.balance,
                          static_cast<Currency>(wallet.currency())));

            // Save the metadata:
            ABC_CHECK(wallet.txs.save(meta));

            // Update the transaction cache:
            watcherSave(wallet).log(); // Failure is not fatal
            wallet.balanceDirty();
            ABC_CHECK(wallet.addresses.markOutputs(info.ios));

            // Update the GUI:
            ABC_DebugLog("IncomingBitCoin callback: wallet %s, txid: %s",
                         wallet.id().c_str(), info.txid.c_str());
            tABC_AsyncBitCoinInfo async;
            async.pData = pData;
            async.eventType = ABC_AsyncEventType_IncomingBitCoin;
            Status().toError(async.status, ABC_HERE());
            async.szWalletUUID = wallet.id().c_str();
            async.szTxID = info.txid.c_str();
            async.sweepSatoshi = 0;
            fAsyncCallback(&async);
        }
        else
        {
            // Update the transaction cache:
            watcherSave(wallet).log(); // Failure is not fatal
            wallet.balanceDirty();
            ABC_CHECK(wallet.addresses.markOutputs(info.ios));

            // Update the GUI:
            ABC_DebugLog("BalanceUpdate callback: wallet %s, txid: %s",
                         wallet.id().c_str(), info.txid.c_str());
            tABC_AsyncBitCoinInfo async;
            async.pData = pData;
            async.eventType = ABC_AsyncEventType_BalanceUpdate;
            Status().toError(async.status, ABC_HERE());
            async.szWalletUUID = wallet.id().c_str();
            async.szTxID = info.txid.c_str();
            async.sweepSatoshi = 0;
            fAsyncCallback(&async);
        }
    }
    else
    {
        ABC_DebugLog("New (irrelevant) transaction:  wallet %s, txid: %s",
                     wallet.id().c_str(), info.txid.c_str());
    }

    return Status();
}
示例#24
0
文件: main.cpp 项目: dervish77/adgf
int main()
{
    // use object of Wallet directly

    cout << "Using Wallet class directly" << endl;
    cout << endl;

    Wallet myWallet;  // create object of Wallet on stack

    myWallet.SetMoney( 100 );
    cout << "myWallet has $" << myWallet.GetMoney() << endl;

    cout << "adding $20" << endl;
    myWallet.Add( 20 );
    cout << "myWallet now has $" << myWallet.GetMoney() << endl;

    cout << "spending $40" << endl;
    myWallet.Remove( 40 );
    cout << "myWallet now has $" << myWallet.GetMoney() << endl;
    cout << endl;

    // use pointer to Wallet object

    cout << "Using Wallet class via pointer" << endl;
    cout << endl;

    Wallet* pWallet;
    pWallet = new Wallet;  // create new object of Wallet on heap

    pWallet->SetMoney( 100 );
    cout << "Wallet via pWallet has $" << pWallet->GetMoney() << endl;

    cout << "adding $20" << endl;
    pWallet->Add( 20 );
    cout << "Wallet via pWallet now has $" << pWallet->GetMoney() << endl;

    cout << "spending $40" << endl;
    pWallet->Remove( 40 );
    cout << "Wallet via pWallet now has $" << pWallet->GetMoney() << endl;
    cout << endl;

    delete pWallet;  // delete object on heap

    return 0;
}
示例#25
0
 WatcherInfo(Wallet &wallet):
     parent_(wallet.shared_from_this()),
     watcher(wallet.txCache, wallet.addressCache),
     wallet(wallet)
 {
 }
示例#26
0
void NetworkAccount::writeConfig(KConfig/*Base*/ & config)   /*const*/
{
    KMAccount::writeConfig(config);

    config.writeEntry("login", login());
    config.writeEntry("store-passwd", storePasswd());

    if(storePasswd())
    {
        // write password to the wallet if possbile and necessary
        bool passwdStored = false;
        if(mPasswdDirty)
        {
            Wallet *wallet = kmkernel->wallet();
            if(wallet && wallet->writePassword("account-" + QString::number(mId), passwd()) == 0)
            {
                passwdStored = true;
                mPasswdDirty = false;
                mStorePasswdInConfig = false;
            }
        }
        else
        {
            passwdStored = !mStorePasswdInConfig; // already in the wallet
        }
        // if wallet is not available, write to config file, since the account
        // manager deletes this group, we need to write it always
        if(!passwdStored && (mStorePasswdInConfig || KMessageBox::warningYesNo(0,
                             i18n("KWallet is not available. It is strongly recommended to use "
                                  "KWallet for managing your passwords.\n"
                                  "However, KMail can store the password in its configuration "
                                  "file instead. The password is stored in an obfuscated format, "
                                  "but should not be considered secure from decryption efforts "
                                  "if access to the configuration file is obtained.\n"
                                  "Do you want to store the password for account '%1' in the "
                                  "configuration file?").arg(name()),
                             i18n("KWallet Not Available"),
                             KGuiItem(i18n("Store Password")),
                             KGuiItem(i18n("Do Not Store Password")))
                             == KMessageBox::Yes))
        {
            config.writeEntry("pass", encryptStr(passwd()));
            mStorePasswdInConfig = true;
        }
    }

    // delete password from the wallet if password storage is disabled
    if(!storePasswd() && !Wallet::keyDoesNotExist(
                Wallet::NetworkWallet(), "kmail", "account-" + QString::number(mId)))
    {
        Wallet *wallet = kmkernel->wallet();
        if(wallet)
            wallet->removeEntry("account-" + QString::number(mId));
    }

    config.writeEntry("host", host());
    config.writeEntry("port", static_cast<unsigned int>(port()));
    config.writeEntry("auth", auth());
    config.writeEntry("use-ssl", useSSL());
    config.writeEntry("use-tls", useTLS());

    mSieveConfig.writeConfig(config);
}
示例#27
0
Status
onReceive(Wallet &wallet, const TxInfo &info,
          tABC_BitCoin_Event_Callback fCallback, void *pData)
{
    wallet.balanceDirty();
    ABC_CHECK(wallet.addresses.markOutputs(info));

    // Does the transaction already exist?
    TxMeta meta;
    if (!wallet.txs.get(meta, info.ntxid))
    {
        const auto balance = wallet.addresses.balance(info);

        meta.ntxid = info.ntxid;
        meta.txid = info.txid;
        meta.timeCreation = time(nullptr);
        meta.internal = false;
        meta.airbitzFeeWanted = 0;
        meta.airbitzFeeSent = 0;

        // Receives can accumulate Airbitz fees:
        const auto airbitzFeeInfo = generalAirbitzFeeInfo();
        meta.airbitzFeeWanted = airbitzFeeIncoming(airbitzFeeInfo, balance);
        logInfo("Airbitz fee: " +
                std::to_string(meta.airbitzFeeWanted) + " wanted, " +
                std::to_string(wallet.txs.airbitzFeePending()) + " pending");

        // Grab metadata from the address:
        for (const auto &io: info.ios)
        {
            AddressMeta address;
            if (wallet.addresses.get(address, io.address))
                meta.metadata = address.metadata;
        }
        ABC_CHECK(gContext->exchangeCache.satoshiToCurrency(
                      meta.metadata.amountCurrency, balance,
                      static_cast<Currency>(wallet.currency())));

        // Save the metadata:
        ABC_CHECK(wallet.txs.save(meta, balance, info.fee));

        // Update the GUI:
        ABC_DebugLog("IncomingBitCoin callback: wallet %s, txid: %s",
                     wallet.id().c_str(), info.txid.c_str());
        tABC_AsyncBitCoinInfo async;
        async.pData = pData;
        async.eventType = ABC_AsyncEventType_IncomingBitCoin;
        Status().toError(async.status, ABC_HERE());
        async.szWalletUUID = wallet.id().c_str();
        async.szTxID = info.txid.c_str();
        async.sweepSatoshi = 0;
        fCallback(&async);
    }
    else
    {
        // Update the GUI:
        ABC_DebugLog("BalanceUpdate callback: wallet %s, txid: %s",
                     wallet.id().c_str(), info.txid.c_str());
        tABC_AsyncBitCoinInfo async;
        async.pData = pData;
        async.eventType = ABC_AsyncEventType_BalanceUpdate;
        Status().toError(async.status, ABC_HERE());
        async.szWalletUUID = wallet.id().c_str();
        async.szTxID = info.txid.c_str();
        async.sweepSatoshi = 0;
        fCallback(&async);
    }

    return Status();
}
示例#28
0
文件: Buyer.cpp 项目: myucel/cashlib
void Buyer::makeCoin(Wallet& w, const ZZ& R) {	
	// get coin from wallet
	coin = w.nextCoin(R);
	endorsement = coin.getEndorsement();
	coin.unendorse();
}
示例#29
0
std::string
watcherPath(Wallet &self)
{
    return self.dir() + "watcher.ser";
}
示例#30
0
文件: Source.cpp 项目: agbares/CIS22C
void subtractMoney(Wallet &myWallet)
{
	bool loop = false;

	while (loop == false)
	{
		int choice = 0;

		double currency = 0;

		cout << endl << "	***Subtract Money***" << endl << endl
			<< "	 1: Dollar" << endl
			<< "	 2: Dinar" << endl
			<< "	 3: Euro" << endl
			<< "	 4: Peso" << endl
			<< "	 5: Pound" << endl
			<< "	 6: Exit" << endl << endl
			<< "	 Choice: ";
		cin >> choice;


		switch (choice)
		{
		case 1:
			cout << "How much would you like to subtract? (Format: n.nn)\n";
			cin >> currency;
			myWallet.subtractMoney(Wallet::DOLLAR, currency);

			cout << "Subtracted " << fixed << setprecision(2) << currency << " in dollars to wallet\n" << endl;
			break;

		case 2:
			cout << "How much would you like to subtract? (Format: n.nn)\n";
			cin >> currency;
			myWallet.subtractMoney(Wallet::DINAR, currency);

			cout << "Subtracted " << fixed << setprecision(2) << currency << " in dinars to wallet\n" << endl;
			break;

		case 3:
			cout << "How much would you like to subtract? (Format: n.nn)\n";
			cin >> currency;
			myWallet.subtractMoney(Wallet::EURO, currency);

			cout << "Subtracted " << fixed << setprecision(2) << currency << " in euros to wallet\n" << endl;
			break;

		case 4:
			cout << "How much would you like to subtract? (Format: n.nn)\n";
			cin >> currency;
			myWallet.subtractMoney(Wallet::PESO, currency);

			cout << "Subtracted " << fixed << setprecision(2) << currency << " in pesos to wallet\n" << endl;
			break;

		case 5:
			cout << "How much would you like to subtract? (Format: n.nn)\n";
			cin >> currency;
			myWallet.subtractMoney(Wallet::POUND, currency);

			cout << "Subtracted " << fixed << setprecision(2) << currency << " in pounds to wallet\n" << endl;
			break;

		case 6:
			loop = true;
			break;

		default:
			cout << "\t\t**Please enter a valid choice**\n" << endl;
			break;

		}

	}
}