Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. int main()
  2. {
  3.     std::cout << "TurtleCoin v" << PROJECT_VERSION << " Simplewallet" << std::endl;
  4.  
  5.     Action action = getAction();
  6.  
  7.     auto wallet = init();
  8.  
  9.     std::cout << "3" << std::endl;
  10.  
  11.     std::shared_ptr<WalletInfo> walletInfo(nullptr);
  12.  
  13.     if (action == Generate)
  14.     {
  15.         walletInfo = generateWallet(wallet);
  16.     }
  17.     else if (action == Open)
  18.     {
  19.         walletInfo = openWallet(wallet);
  20.     }
  21.     else if (action == Import)
  22.     {
  23.         walletInfo = importWallet(wallet);
  24.     }
  25.     else if (action == SeedImport)
  26.     {
  27.         walletInfo = mnemonicImportWallet(wallet);
  28.     }
  29.  
  30.     welcomeMsg();
  31.     inputLoop(walletInfo);
  32.  
  33.     std::cout << "Bye." << std::endl;
  34. }
  35.  
  36. std::shared_ptr<CryptoNote::WalletGreen> init()
  37. {
  38.     /* We need to pass in a logger, but we don't want to print out all the
  39.        crap to the console that walletgreen does. So, we just never init this
  40.        properly and it just gets logged to the void. */
  41.     Logging::LoggerManager logManager;
  42.     Logging::ConsoleLogger consoleLogger;
  43.  
  44.     /* Actually right now we have it enabled for debugging. But we'll disable
  45.        it later.
  46.        >10 years later still enabled */
  47.     logManager.setMaxLevel(Logging::INFO);
  48.     logManager.addLogger(consoleLogger);
  49.  
  50.     Logging::LoggerRef logger(logManager, "simplewallet");
  51.  
  52.     CryptoNote::Currency currency = CryptoNote::CurrencyBuilder(logManager).currency();
  53.  
  54.     /* Hard coded for now. Arguments might come later. This lets us talk
  55.        to good old turtlecoind. */
  56.     CryptoNote::NodeRpcProxy node("localhost", 11898, logger.getLogger());
  57.  
  58.     /* Wow c++ great syntax you've got here LMAO */
  59.     std::promise<std::error_code> errorPromise;
  60.     std::future<std::error_code> error = errorPromise.get_future();
  61.     auto callback = [&errorPromise](std::error_code e) {errorPromise.set_value(e); };
  62.  
  63.     node.init(callback);
  64.  
  65.     if (error.get())
  66.     {
  67.         throw("Shit's fucking fucked big time mate");
  68.     }
  69.  
  70.     /* I actually have no idea what the fuck this does */
  71.     System::Dispatcher dispatcher;
  72.  
  73.     std::cout << "1" << std::endl;
  74.  
  75.     auto walletPtr = std::make_shared<CryptoNote::WalletGreen>(dispatcher, currency, node, logger.getLogger());
  76.  
  77.     std::cout << "2" << std::endl;
  78.  
  79.     return walletPtr;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement