int64_t StrToInt64(const std::string& str, bool divisible) { // copy original, so it remains unchanged std::string strAmount (str); int64_t nAmount = 0; // check for a negative (minus sign) and invalidate if present size_t negSignPos = strAmount.find("-"); if (negSignPos != std::string::npos) return 0; // convert the string into a usable int64 if (divisible) { // check for existance of decimal point size_t pos = strAmount.find("."); if (pos == std::string::npos) { // no decimal point but divisible so pad 8 zeros on right strAmount += "00000000"; } else { // check for existence of second decimal point, if so invalidate amount size_t posSecond = strAmount.find(".", pos + 1); if (posSecond != std::string::npos) return 0; if ((strAmount.size() - pos) < 9) { // there are decimals either exact or not enough, pad as needed std::string strRightOfDecimal = strAmount.substr(pos + 1); unsigned int zerosToPad = 8 - strRightOfDecimal.size(); // do we need to pad? if (zerosToPad > 0) { for (unsigned int it = 0; it != zerosToPad; it++) { strAmount += "0"; } } } else { // there are too many decimals, truncate after 8 strAmount = strAmount.substr(0, pos + 9); } } strAmount.erase(std::remove(strAmount.begin(), strAmount.end(), '.'), strAmount.end()); try { nAmount = boost::lexical_cast<int64_t>(strAmount); } catch (const boost::bad_lexical_cast &e) {} } else { size_t pos = strAmount.find("."); std::string newStrAmount = strAmount.substr(0, pos); try { nAmount = boost::lexical_cast<int64_t>(newStrAmount); } catch (const boost::bad_lexical_cast &e) {} } return nAmount; }
void ObfuscationConfig::clickMax() { configure(true, 1000, 16); QString strAmount(BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), 1000 * COIN)); QMessageBox::information(this, tr("Obfuscation Configuration"), tr( "Obfuscation was successfully set to maximum (%1 and 16 rounds). You can change this at any time by opening ION's configuration screen.") .arg(strAmount)); close(); }
void DarksendConfig::clickHigh() { configure(true, 1000, 8); QString strAmount(BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), 1000 * COIN)); QMessageBox::information(this, tr("Darksend Configuration"), tr( "Darksend was successfully set to high (%1 and 8 rounds). You can change this at any time by opening Midnight's configuration screen." ).arg(strAmount) ); close(); }
void DarksendConfig::clickBasic() { configure(true, 1000, 2); QString strAmount(SyscoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), 100000 * COIN)); QMessageBox::information(this, tr("PrivateSend Configuration"), tr( "PrivateSend was successfully set to basic (%1 and 2 rounds). You can change this at any time by opening Syscoin's configuration screen." ).arg(strAmount) ); close(); }
void OT_API_notarizeWithdrawal(const char * SERVER_ID, const char * USER_ID, const char * ACCT_ID, const char * AMOUNT) { OT_ASSERT(NULL != SERVER_ID); OT_ASSERT(NULL != USER_ID); OT_ASSERT(NULL != ACCT_ID); OT_ASSERT(NULL != AMOUNT); OTIdentifier theServerID(SERVER_ID), theUserID(USER_ID), theAcctID(ACCT_ID); OTString strAmount(AMOUNT); g_OT_API.notarizeWithdrawal(theServerID, theUserID, theAcctID, strAmount); }
void OT_API_withdrawVoucher(const char * SERVER_ID, const char * USER_ID, const char * ACCT_ID, const char * RECIPIENT_USER_ID, const char * CHEQUE_MEMO, const char * AMOUNT) { OT_ASSERT(NULL != SERVER_ID); OT_ASSERT(NULL != USER_ID); OT_ASSERT(NULL != ACCT_ID); OT_ASSERT(NULL != RECIPIENT_USER_ID); OT_ASSERT(NULL != CHEQUE_MEMO); OT_ASSERT(NULL != AMOUNT); OTIdentifier theServerID(SERVER_ID), theUserID(USER_ID), theAcctID(ACCT_ID), theRecipientUserID(RECIPIENT_USER_ID); OTString strMemo(CHEQUE_MEMO), strAmount(AMOUNT); g_OT_API.withdrawVoucher(theServerID, theUserID, theAcctID, theRecipientUserID, strMemo, strAmount); }
void OT_API_notarizeTransfer(const char * SERVER_ID, const char * USER_ID, const char * ACCT_FROM, const char * ACCT_TO, const char * AMOUNT, const char * NOTE) { OT_ASSERT(NULL != SERVER_ID); OT_ASSERT(NULL != USER_ID); OT_ASSERT(NULL != ACCT_FROM); OT_ASSERT(NULL != ACCT_TO); OT_ASSERT(NULL != AMOUNT); OT_ASSERT(NULL != NOTE); OTIdentifier theServerID(SERVER_ID), theUserID(USER_ID); OTIdentifier theFromAcct(ACCT_FROM), theToAcct(ACCT_TO); OTString strAmount(AMOUNT), strNote(NOTE); g_OT_API.notarizeTransfer(theServerID, theUserID, theFromAcct, theToAcct, strAmount, strNote); }