Could it be this simple?

This commit is contained in:
Zach Fox 2017-11-07 12:12:27 -08:00
parent f248eb5518
commit 8f54c106f6
3 changed files with 26 additions and 4 deletions

View file

@ -90,6 +90,15 @@ void Ledger::buy(const QString& hfc_key, int cost, const QString& asset_id, cons
signedSend("transaction", transactionString, hfc_key, "buy", "buySuccess", "buyFailure", controlled_failure);
}
void Ledger::receiveAtSuccess(QNetworkReply& reply) {
auto wallet = DependencyManager::get<Wallet>();
QByteArray response = reply.readAll();
QJsonObject data = QJsonDocument::fromJson(response).object();
if (data["status"] == "fail") { // Not on "The List" for receiving HFC
wallet->setMustRegenerateKeypair(true);
}
}
bool Ledger::receiveAt(const QString& hfc_key, const QString& old_key, const QString& machine_fingerprint) {
auto accountManager = DependencyManager::get<AccountManager>();
if (!accountManager->isLoggedIn()) {

View file

@ -327,6 +327,12 @@ Wallet::Wallet() {
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
uint status;
if (_mustRegenerateKeypair) {
_mustRegenerateKeypair = false;
resetKeysOnly();
generateKeyPair();
}
if (wallet->getKeyFilePath() == "" || !wallet->getSecurityImage()) {
status = (uint)WalletStatus::WALLET_STATUS_NOT_SET_UP;
} else if (!wallet->walletIsAuthenticatedWithPassphrase()) {
@ -661,9 +667,13 @@ QString Wallet::getKeyFilePath() {
}
}
void Wallet::reset() {
void Wallet::resetKeysOnly() {
_publicKeys.clear();
QFile keyFile(keyFilePath());
keyFile.remove();
}
void Wallet::reset() {
delete _securityImage;
_securityImage = nullptr;
@ -671,9 +681,7 @@ void Wallet::reset() {
updateImageProvider();
_passphrase->clear();
QFile keyFile(keyFilePath());
keyFile.remove();
resetKeysOnly();
}
bool Wallet::writeWallet(const QString& newPassphrase) {
RSA* keys = readKeys(keyFilePath().toStdString().c_str());

View file

@ -49,6 +49,7 @@ public:
bool walletIsAuthenticatedWithPassphrase();
bool changePassphrase(const QString& newPassphrase);
void resetKeysOnly();
void reset();
void getWalletStatus();
@ -59,6 +60,8 @@ public:
WALLET_STATUS_READY
};
void setMustRegenerateKeypair(const bool& val) { _mustRegenerateKeypair = val; }
signals:
void securityImageResult(bool exists);
void keyFilePathIfExistsResult(const QString& path);
@ -83,6 +86,8 @@ private:
bool writeBackupInstructions();
void account();
bool _mustRegenerateKeypair { false };
};
#endif // hifi_Wallet_h