mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 02:30:14 +02:00
Fix writing backup instructions when restoring wallet backup
This commit is contained in:
parent
6b7c997a4c
commit
5be9f2022e
2 changed files with 13 additions and 10 deletions
|
@ -105,19 +105,19 @@ RSA* readKeys(const char* filename) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeBackupInstructions() {
|
bool Wallet::writeBackupInstructions() {
|
||||||
QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
|
QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
|
||||||
QString filename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
||||||
QFile outputFile(filename);
|
QFile outputFile(outputFilename);
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
|
||||||
if (QFile::exists(filename))
|
if (QFile::exists(outputFilename) || getKeyFilePath() == "")
|
||||||
{
|
{
|
||||||
QFile::remove(filename);
|
return false;
|
||||||
}
|
}
|
||||||
QFile::copy(inputFilename, filename);
|
QFile::copy(inputFilename, outputFilename);
|
||||||
|
|
||||||
if (QFile::exists(filename) && outputFile.open(QIODevice::ReadWrite)) {
|
if (QFile::exists(outputFilename) && outputFile.open(QIODevice::ReadWrite)) {
|
||||||
|
|
||||||
QByteArray fileData = outputFile.readAll();
|
QByteArray fileData = outputFile.readAll();
|
||||||
QString text(fileData);
|
QString text(fileData);
|
||||||
|
@ -132,7 +132,7 @@ bool writeBackupInstructions() {
|
||||||
retval = true;
|
retval = true;
|
||||||
qCDebug(commerce) << "wrote html file successfully";
|
qCDebug(commerce) << "wrote html file successfully";
|
||||||
} else {
|
} else {
|
||||||
qCDebug(commerce) << "failed to open output html file" << filename;
|
qCDebug(commerce) << "failed to open output html file" << outputFilename;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,6 @@ bool writeKeys(const char* filename, RSA* keys) {
|
||||||
QFile(QString(filename)).remove();
|
QFile(QString(filename)).remove();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeBackupInstructions();
|
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
qCDebug(commerce) << "wrote keys successfully";
|
qCDebug(commerce) << "wrote keys successfully";
|
||||||
|
@ -359,6 +357,8 @@ bool Wallet::setPassphrase(const QString& passphrase) {
|
||||||
|
|
||||||
_publicKeys.clear();
|
_publicKeys.clear();
|
||||||
|
|
||||||
|
writeBackupInstructions();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,6 +526,8 @@ bool Wallet::generateKeyPair() {
|
||||||
qCInfo(commerce) << "Generating keypair.";
|
qCInfo(commerce) << "Generating keypair.";
|
||||||
auto keyPair = generateRSAKeypair();
|
auto keyPair = generateRSAKeypair();
|
||||||
|
|
||||||
|
writeBackupInstructions();
|
||||||
|
|
||||||
// TODO: redo this soon -- need error checking and so on
|
// TODO: redo this soon -- need error checking and so on
|
||||||
writeSecurityImage(_securityImage, keyFilePath());
|
writeSecurityImage(_securityImage, keyFilePath());
|
||||||
QString oldKey = _publicKeys.count() == 0 ? "" : _publicKeys.last();
|
QString oldKey = _publicKeys.count() == 0 ? "" : _publicKeys.last();
|
||||||
|
|
|
@ -80,6 +80,7 @@ private:
|
||||||
void updateImageProvider();
|
void updateImageProvider();
|
||||||
bool writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath);
|
bool writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath);
|
||||||
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
||||||
|
bool writeBackupInstructions();
|
||||||
|
|
||||||
bool verifyOwnerChallenge(const QByteArray& encryptedText, const QString& publicKey, QString& decryptedText);
|
bool verifyOwnerChallenge(const QByteArray& encryptedText, const QString& publicKey, QString& decryptedText);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue