本文整理汇总了C++中OT_ME::withdraw_and_send_cash方法的典型用法代码示例。如果您正苦于以下问题:C++ OT_ME::withdraw_and_send_cash方法的具体用法?C++ OT_ME::withdraw_and_send_cash怎么用?C++ OT_ME::withdraw_and_send_cash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OT_ME
的用法示例。
在下文中一共展示了OT_ME::withdraw_and_send_cash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendCash
bool MTSendDlg::sendCash(int64_t amount, QString toNymId, QString fromAcctId, QString note)
{
if (toNymId.size() == 0) {
qDebug() << QString("Cannot send cash to an empty nym id, aborting.");
return false;
}
if (fromAcctId.size() == 0) {
qDebug() << QString("Cannot send cash from an unknown account id, aborting.");
return false;
}
if (amount <= 0) {
qDebug() << QString("Why send 0 (or less) units? Aborting send cash.");
return false;
}
// ------------------------------------------------------------
if (note.isEmpty())
note = tr("From the Qt systray app.");
// ------------------------------------------------------------
std::string str_toNymId (toNymId .toStdString());
std::string str_fromAcctId(fromAcctId.toStdString());
// ------------------------------------------------------------
std::string str_fromNymId(OTAPI_Wrap::GetAccountWallet_NymID (str_fromAcctId));
std::string str_serverId (OTAPI_Wrap::GetAccountWallet_ServerID (str_fromAcctId));
std::string str_assetId (OTAPI_Wrap::GetAccountWallet_AssetTypeID(str_fromAcctId));
// ------------------------------------------------------------
// TODO: for security reasons, we might change the below 'if' so that
// it ONLY checks the cash balance, and not the account balance here.
// This would force the user to withdraw the cash by hand first, before
// sending it (which would make it possible to preserve untraceability.)
//
// Otherwise, if the send_instrument happens directly after the withdrawal,
// the server will be able to tell who the recipient is purely by timing
// analysis, without having to break the Chaumian blinding.
//
int64_t theCashBalance = MTHome::rawCashBalance(QString::fromStdString(str_serverId),
QString::fromStdString(str_assetId),
QString::fromStdString(str_fromNymId));
int64_t theAcctBalance = MTHome::rawAcctBalance(this->m_myAcctId);
if ((amount > theCashBalance) && (amount > (theAcctBalance + theCashBalance)))
{
qDebug() << QString("Aborting send cash: Amount is larger than cash balance, and is also "
"larger than combined cash + account balance.");
return false;
// Note: you may be asking why doesn't the amount only have to be equal
// to the SUM of the two balances? Why must it be available in FULL from
// one or the other? The answer is, because if there is not enough available
// in the purse, or if the tokens there have enough units, but not the right
// denominations to create the amount exactly, then we have to withdraw the
// amount from the account instead. In that case we will want to withdraw the
// full amount, so that we can guarantee that we have tokens of the right
// denominations for that amount.
// NOTE: apparently the high-level API only withdraws the difference, which
// means it could still end up with the right "amount" of cash, but the wrong
// denominations necessary to "make change" for the exact amount.
}
// ------------------------------------------------------------
int64_t SignedAmount = amount;
qDebug() << QString("Sending cash:\n Server:'%1'\n Nym:'%2'\n Acct:'%3'\n ToNym:'%4'\n Amount:'%5'\n Note:'%6'").
arg(str_serverId.c_str()).arg(str_fromNymId.c_str()).arg(str_fromAcctId.c_str()).arg(toNymId).arg(SignedAmount).arg(note);
// ------------------------------------------------------------
OT_ME madeEasy;
bool bReturnValue = false;
{
MTOverrideCursor theSpinner;
bReturnValue = madeEasy.withdraw_and_send_cash(str_fromAcctId, str_toNymId, note.toStdString(), SignedAmount);
}
// ------------------------------------------------------------
return bReturnValue;
// NOTE: We don't retrieve the account files in the case of success, because the
// above function already does all that internally.
}