void WalletLegacySerializer::saveKeys(CryptoNote::ISerializer& serializer) {
  CryptoNote::KeysStorage keys;
  CryptoNote::AccountKeys acc = account.getAccountKeys();

  keys.creationTimestamp = account.get_createtime();
  keys.spendPublicKey = acc.address.spendPublicKey;
  keys.spendSecretKey = acc.spendSecretKey;
  keys.viewPublicKey = acc.address.viewPublicKey;
  keys.viewSecretKey = acc.viewSecretKey;

  keys.serialize(serializer, "keys");
}
void WalletLegacySerializer::loadKeys(CryptoNote::ISerializer& serializer) {
    CryptoNote::KeysStorage keys;

    keys.serialize(serializer, "keys");

    CryptoNote::AccountKeys acc;
    acc.address.spendPublicKey = keys.spendPublicKey;
    acc.spendSecretKey = keys.spendSecretKey;
    acc.address.viewPublicKey = keys.viewPublicKey;
    acc.viewSecretKey = keys.viewSecretKey;

    account.setAccountKeys(acc);
    account.set_createtime(keys.creationTimestamp);
}
Exemplo n.º 3
0
void WalletSerializer::loadWalletV1Keys(CryptoNote::BinaryInputStreamSerializer& serializer) {
  CryptoNote::KeysStorage keys;
  keys.serialize(serializer, "keys");

  m_viewPublicKey = keys.viewPublicKey;
  m_viewSecretKey = keys.viewSecretKey;

  WalletRecord wallet;
  wallet.spendPublicKey = keys.spendPublicKey;
  wallet.spendSecretKey = keys.spendSecretKey;
  wallet.actualBalance = 0;
  wallet.pendingBalance = 0;
  wallet.creationTimestamp = static_cast<time_t>(keys.creationTimestamp);

  m_walletsContainer.get<RandomAccessIndex>().push_back(wallet);
}
void WalletLegacySerializer::loadKeys(CryptoNote::ISerializer& serializer) {
  CryptoNote::KeysStorage keys;

  try {
    keys.serialize(serializer, "keys");
  } catch (const std::runtime_error&) {
    throw std::system_error(make_error_code(CryptoNote::error::WRONG_PASSWORD));
  }

  CryptoNote::AccountKeys acc;
  acc.address.spendPublicKey = keys.spendPublicKey;
  acc.spendSecretKey = keys.spendSecretKey;
  acc.address.viewPublicKey = keys.viewPublicKey;
  acc.viewSecretKey = keys.viewSecretKey;

  account.setAccountKeys(acc);
  account.set_createtime(keys.creationTimestamp);
}
void WalletSerializerV1::loadWalletV1Keys(CryptoNote::BinaryInputStreamSerializer& serializer) {
  CryptoNote::KeysStorage keys;

  try {
    keys.serialize(serializer, "keys");
  } catch (const std::runtime_error&) {
    throw std::system_error(make_error_code(CryptoNote::error::WRONG_PASSWORD));
  }

  m_viewPublicKey = keys.viewPublicKey;
  m_viewSecretKey = keys.viewSecretKey;

  WalletRecord wallet;
  wallet.spendPublicKey = keys.spendPublicKey;
  wallet.spendSecretKey = keys.spendSecretKey;
  wallet.actualBalance = 0;
  wallet.pendingBalance = 0;
  wallet.creationTimestamp = static_cast<time_t>(keys.creationTimestamp);

  m_walletsContainer.get<RandomAccessIndex>().push_back(wallet);
}