本文整理汇总了C++中cryptonote::WalletGreen::transfer方法的典型用法代码示例。如果您正苦于以下问题:C++ WalletGreen::transfer方法的具体用法?C++ WalletGreen::transfer怎么用?C++ WalletGreen::transfer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptonote::WalletGreen
的用法示例。
在下文中一共展示了WalletGreen::transfer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMultipleTransactions
void sendMultipleTransactions(CryptoNote::WalletGreen &wallet,
std::vector<CryptoNote::TransactionParameters>
transfers)
{
size_t numTxs = transfers.size();
size_t currentTx = 1;
std::cout << "Your transaction has been split up into " << numTxs
<< " separate transactions of "
<< formatAmount(transfers[0].destinations[0].amount)
<< ". It may take some time to send all the transactions, "
<< "please be patient." << std::endl << std::endl;
for (auto tx : transfers)
{
while (true)
{
std::cout << "Attempting to send transaction "
<< InformationMsg(std::to_string(currentTx))
<< " of " << InformationMsg(std::to_string(numTxs))
<< std::endl;
wallet.updateInternalCache();
uint64_t neededBalance = tx.destinations[0].amount + tx.fee;
if (neededBalance < wallet.getActualBalance())
{
size_t id = wallet.transfer(tx);
CryptoNote::WalletTransaction sentTx
= wallet.getTransaction(id);
std::cout << SuccessMsg("Transaction has been sent!")
<< std::endl
<< SuccessMsg("Hash: "
+ Common::podToHex(sentTx.hash))
<< std::endl << std::endl;
break;
}
std::cout << "Not enough balance available to send transaction, "
<< "this is because some of your balance is used when "
<< "sending another transaction to help hide the size "
<< "of your transaction, and is locked for a short "
<< "time. It will return shortly." << std::endl
<< "Needed balance: " << formatAmount(neededBalance)
<< std::endl << "Available balance: "
<< formatAmount(wallet.getActualBalance())
<< std::endl << "Locked balance: "
<< formatAmount(wallet.getPendingBalance())
<< std::endl << "Will try again in 5 seconds..."
<< std::endl << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5));
}
currentTx++;
}
std::cout << SuccessMsg("All transactions sent!") << std::endl;
}