本文整理汇总了C++中cryptonote::WalletGreen::getTransactionCount方法的典型用法代码示例。如果您正苦于以下问题:C++ WalletGreen::getTransactionCount方法的具体用法?C++ WalletGreen::getTransactionCount怎么用?C++ WalletGreen::getTransactionCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptonote::WalletGreen
的用法示例。
在下文中一共展示了WalletGreen::getTransactionCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveCSV
void saveCSV(CryptoNote::WalletGreen &wallet, CryptoNote::INode &node)
{
const size_t numTransactions = wallet.getTransactionCount();
std::ofstream csv;
csv.open(WalletConfig::csvFilename);
if (!csv)
{
std::cout << WarningMsg("Couldn't open transactions.csv file for "
"saving!")
<< std::endl
<< WarningMsg("Ensure it is not open in any other "
"application.")
<< std::endl;
return;
}
std::cout << InformationMsg("Saving CSV file...") << std::endl;
/* Create CSV header */
csv << "Timestamp,Block Height,Hash,Amount,In/Out"
<< std::endl;
/* Loop through transactions */
for (size_t i = 0; i < numTransactions; i++)
{
const CryptoNote::WalletTransaction t = wallet.getTransaction(i);
/* Ignore fusion transactions */
if (t.totalAmount == 0)
{
continue;
}
const std::string amount = formatAmountBasic(std::abs(t.totalAmount));
const std::string direction = t.totalAmount > 0 ? "IN" : "OUT";
csv << unixTimeToDate(t.timestamp) << "," /* Timestamp */
<< t.blockHeight << "," /* Block Height */
<< Common::podToHex(t.hash) << "," /* Hash */
<< amount << "," /* Amount */
<< direction /* In/Out */
<< std::endl;
}
csv.close();
std::cout << SuccessMsg("CSV successfully written to ")
<< SuccessMsg(WalletConfig::csvFilename)
<< SuccessMsg("!")
<< std::endl;
}
示例2: listTransfers
void listTransfers(bool incoming, bool outgoing,
CryptoNote::WalletGreen &wallet, CryptoNote::INode &node)
{
const size_t numTransactions = wallet.getTransactionCount();
int64_t totalSpent = 0;
int64_t totalReceived = 0;
for (size_t i = 0; i < numTransactions; i++)
{
const CryptoNote::WalletTransaction t = wallet.getTransaction(i);
if (t.totalAmount < 0 && outgoing)
{
printOutgoingTransfer(t, node);
totalSpent += -t.totalAmount;
}
else if (t.totalAmount > 0 && incoming)
{
printIncomingTransfer(t, node);
totalReceived += t.totalAmount;
}
}
if (incoming)
{
std::cout << SuccessMsg("Total received: "
+ formatAmount(totalReceived))
<< std::endl;
}
if (outgoing)
{
std::cout << WarningMsg("Total spent: " + formatAmount(totalSpent))
<< std::endl;
}
}