void WalletSerializer::loadCurrentVersion(Common::IInputStream& source, const std::string& password) { CryptoNote::CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); generateKey(password, cryptoContext.key); loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext); } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); loadSpentOutputs(source, cryptoContext); loadUnlockTransactionsJobs(source, cryptoContext); loadChange(source, cryptoContext); } if (details && cache) { updateTransactionsBaseStatus(); } }
bool input::init() { quit = false; anykey = false; SDL_EnableKeyRepeat(0,0); // printf("buttons: %i\n", TOTAL_BUTTONS); for (int i=0; i<TOTAL_BUTTONS; i++) { keys.push_back(new button); } //if no config file found then create one if (access(INPUT_CONFIG,F_OK)==-1) { defaultKeys(); } else { if (!loadKeys()) { printf("error reading keys. loading defualt\n"); defaultKeys(); } } if (sizeof(keyTags)/sizeof(char *) != KEY_CONFIG_TOTAL) { printf("Somebody programmed the input file wrong. Probably crash.\n"); return false; } if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) { printf("Unable to initialize input device: %s\n", SDL_GetError()); } return true; }
void WalletSerializerV1::loadWallet(Common::IInputStream& source, const Crypto::chacha8_key& key, uint32_t version) { CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); cryptoContext.key = key; loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext, version); } if (version < 5) { updateTransfersSign(); cache = false; } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); if (version < 5) { loadObsoleteSpentOutputs(source, cryptoContext); } loadUnlockTransactionsJobs(source, cryptoContext); if (version < 5) { loadObsoleteChange(source, cryptoContext); } if (version > 3) { loadUncommitedTransactions(source, cryptoContext); } } else { resetCachedBalance(); } if (details && cache) { updateTransactionsBaseStatus(); } }
void WalletLegacySerializer::deserialize(std::istream& stream, const std::string& password, std::string& cache) { StdInputStream stdStream(stream); CryptoNote::BinaryInputStreamSerializer serializerEncrypted(stdStream); serializerEncrypted.beginObject("wallet"); uint32_t version; serializerEncrypted(version, "version"); Crypto::chacha_iv iv; serializerEncrypted(iv, "iv"); std::string cipher; serializerEncrypted(cipher, "data"); serializerEncrypted.endObject(); std::string plain; decrypt(cipher, plain, iv, password); MemoryInputStream decryptedStream(plain.data(), plain.size()); CryptoNote::BinaryInputStreamSerializer serializer(decryptedStream); loadKeys(serializer); throwIfKeysMissmatch(account.getAccountKeys().viewSecretKey, account.getAccountKeys().address.viewPublicKey); if (account.getAccountKeys().spendSecretKey != NULL_SECRET_KEY) { throwIfKeysMissmatch(account.getAccountKeys().spendSecretKey, account.getAccountKeys().address.spendPublicKey); } else { if (!Crypto::check_key(account.getAccountKeys().address.spendPublicKey)) { throw std::system_error(make_error_code(CryptoNote::error::WRONG_PASSWORD)); } } bool detailsSaved; serializer(detailsSaved, "has_details"); if (detailsSaved) { if (version == 1) { transactionsCache.deserializeLegacyV1(serializer); } else { serializer(transactionsCache, "details"); } } serializer.binary(cache, "cache"); }
void WalletSerializer::deserialize(std::istream& stream, const std::string& password, std::string& cache) { cryptonote::BinaryInputStreamSerializer serializerEncrypted(stream); serializerEncrypted.beginObject("wallet"); uint32_t version; serializerEncrypted(version, "version"); crypto::chacha8_iv iv; serializerEncrypted(iv, "iv"); std::string cipher; serializerEncrypted(cipher, "data"); serializerEncrypted.endObject(); std::string plain; decrypt(cipher, plain, iv, password); std::stringstream decryptedStream(plain); cryptonote::BinaryInputStreamSerializer serializer(decryptedStream); try { loadKeys(serializer); throwIfKeysMissmatch(account.get_keys().m_view_secret_key, account.get_keys().m_account_address.m_viewPublicKey); throwIfKeysMissmatch(account.get_keys().m_spend_secret_key, account.get_keys().m_account_address.m_spendPublicKey); } catch (std::exception&) { throw std::system_error(make_error_code(cryptonote::error::WRONG_PASSWORD)); } bool detailsSaved; serializer(detailsSaved, "has_details"); if (detailsSaved) { serializer(transactionsCache, "details"); } serializer.binary(cache, "cache"); }
char HAnimationCurve::load(AAnimationCurve * curve) { int t = 0; readIntAttr(".animcurve_type", &t); if(t == AAnimationCurve::TTA) curve->setCurveType(AAnimationCurve::TTA); else if(t == AAnimationCurve::TTL) curve->setCurveType(AAnimationCurve::TTL); else if(t == AAnimationCurve::TTU) curve->setCurveType(AAnimationCurve::TTU); else std::cout<<"\n warnning: anim curve type is unknown"; int n = 0; readIntAttr(".n_keys", &n); loadKeys(curve, n); return 1; }
void KeybJoyKeys::loadKeys(void) { loadKeys(0); loadKeys(1); }