本文整理汇总了C++中cryptonote::Currency::formatAmount方法的典型用法代码示例。如果您正苦于以下问题:C++ Currency::formatAmount方法的具体用法?C++ Currency::formatAmount怎么用?C++ Currency::formatAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptonote::Currency
的用法示例。
在下文中一共展示了Currency::formatAmount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
logger(ERROR, BRIGHT_RED) << "Wallet password not set.";
return 1;
}
std::string wallet_file = command_line::get_arg(vm, arg_wallet_file);
std::string wallet_password = command_line::get_arg(vm, arg_password);
std::string daemon_address = command_line::get_arg(vm, arg_daemon_address);
std::string daemon_host = command_line::get_arg(vm, arg_daemon_host);
uint16_t daemon_port = command_line::get_arg(vm, arg_daemon_port);
if (daemon_host.empty())
daemon_host = "localhost";
if (!daemon_port)
daemon_port = RPC_DEFAULT_PORT;
if (!daemon_address.empty()) {
if (!parseUrlAddress(daemon_address, daemon_host, daemon_port)) {
logger(ERROR, BRIGHT_RED) << "failed to parse daemon address: " << daemon_address;
return 1;
}
}
std::unique_ptr<INode> node(new NodeRpcProxy(daemon_host, daemon_port));
std::promise<std::error_code> errorPromise;
std::future<std::error_code> error = errorPromise.get_future();
auto callback = [&errorPromise](std::error_code e) {errorPromise.set_value(e); };
node->init(callback);
if (error.get()) {
logger(ERROR, BRIGHT_RED) << ("failed to init NodeRPCProxy");
return 1;
}
std::unique_ptr<IWalletLegacy> wallet(new WalletLegacy(currency, *node.get()));
std::string walletFileName;
try {
walletFileName = ::tryToOpenWalletOrLoadKeysOrThrow(logger, wallet, wallet_file, wallet_password);
logger(INFO) << "available balance: " << currency.formatAmount(wallet->actualBalance()) <<
", locked amount: " << currency.formatAmount(wallet->pendingBalance());
logger(INFO, BRIGHT_GREEN) << "Loaded ok";
} catch (const std::exception& e) {
logger(ERROR, BRIGHT_RED) << "Wallet initialize failed: " << e.what();
return 1;
}
Tools::wallet_rpc_server wrpc(dispatcher, logManager, *wallet, *node, currency, walletFileName);
if (!wrpc.init(vm)) {
logger(ERROR, BRIGHT_RED) << "Failed to initialize wallet rpc server";
return 1;
}
Tools::SignalHandler::install([&wrpc, &wallet] {
wrpc.send_stop_signal();
});
logger(INFO) << "Starting wallet rpc server";
wrpc.run();
logger(INFO) << "Stopped wallet rpc server";
try {
logger(INFO) << "Storing wallet...";
CryptoNote::WalletHelper::storeWallet(*wallet, walletFileName);
logger(INFO, BRIGHT_GREEN) << "Stored ok";
}
catch (const std::exception& e)
{
logger(ERROR, BRIGHT_RED) << "Failed to store wallet: " << e.what();
return 1;
}
} else {
//runs wallet with console interface
CryptoNote::simple_wallet wal(dispatcher, currency, logManager);
if (!wal.init(vm)) {
logger(ERROR, BRIGHT_RED) << "Failed to initialize wallet";
return 1;
}
std::vector<std::string> command = command_line::get_arg(vm, arg_command);
if (!command.empty())
wal.process_command(command);
Tools::SignalHandler::install([&wal] {
wal.stop();
});
wal.run();
if (!wal.deinit()) {
logger(ERROR, BRIGHT_RED) << "Failed to close wallet";
} else {
logger(INFO) << "Wallet closed";
}
}
return 1;
//CATCH_ENTRY_L0("main", 1);
}