mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:56:29 +02:00
reset wallet
This commit is contained in:
parent
a73d548ffc
commit
b8da08ca42
7 changed files with 46 additions and 1 deletions
|
@ -31,6 +31,7 @@ Item {
|
||||||
|
|
||||||
// "Unavailable"
|
// "Unavailable"
|
||||||
RalewayRegular {
|
RalewayRegular {
|
||||||
|
id: helpText;
|
||||||
text: "Help me!";
|
text: "Help me!";
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
@ -43,6 +44,18 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter;
|
horizontalAlignment: Text.AlignHCenter;
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
|
HifiControlsUit.Button {
|
||||||
|
color: hifi.buttons.black;
|
||||||
|
colorScheme: hifi.colorSchemes.dark;
|
||||||
|
anchors.bottom: helpText.bottom;
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter;
|
||||||
|
height: 50;
|
||||||
|
width: 250;
|
||||||
|
text: "Testing: Reset Wallet!";
|
||||||
|
onClicked: {
|
||||||
|
commerce.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// FUNCTION DEFINITIONS START
|
// FUNCTION DEFINITIONS START
|
||||||
|
|
|
@ -111,3 +111,10 @@ void Ledger::inventory(const QStringList& keys) {
|
||||||
void Ledger::history(const QStringList& keys) {
|
void Ledger::history(const QStringList& keys) {
|
||||||
keysQuery("history", "historySuccess", "historyFailure");
|
keysQuery("history", "historySuccess", "historyFailure");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The api/failResponse is called just for the side effect of logging.
|
||||||
|
void Ledger::resetSuccess(QNetworkReply& reply) { apiResponse("reset", reply); }
|
||||||
|
void Ledger::resetFailure(QNetworkReply& reply) { failResponse("reset", reply); }
|
||||||
|
void Ledger::reset() {
|
||||||
|
send("reset_user_hfc_account", "resetSuccess", "resetFailure", QNetworkAccessManager::PutOperation, QJsonObject());
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ public:
|
||||||
void balance(const QStringList& keys);
|
void balance(const QStringList& keys);
|
||||||
void inventory(const QStringList& keys);
|
void inventory(const QStringList& keys);
|
||||||
void history(const QStringList& keys);
|
void history(const QStringList& keys);
|
||||||
|
void reset();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void buyResult(QJsonObject result);
|
void buyResult(QJsonObject result);
|
||||||
|
@ -48,6 +49,8 @@ public slots:
|
||||||
void inventoryFailure(QNetworkReply& reply);
|
void inventoryFailure(QNetworkReply& reply);
|
||||||
void historySuccess(QNetworkReply& reply);
|
void historySuccess(QNetworkReply& reply);
|
||||||
void historyFailure(QNetworkReply& reply);
|
void historyFailure(QNetworkReply& reply);
|
||||||
|
void resetSuccess(QNetworkReply& reply);
|
||||||
|
void resetFailure(QNetworkReply& reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject apiResponse(const QString& label, QNetworkReply& reply);
|
QJsonObject apiResponse(const QString& label, QNetworkReply& reply);
|
||||||
|
|
|
@ -85,3 +85,10 @@ void QmlCommerce::getKeyFilePathIfExists() {
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
wallet->sendKeyFilePathIfExists();
|
wallet->sendKeyFilePathIfExists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlCommerce::reset() {
|
||||||
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
ledger->reset();
|
||||||
|
wallet->reset();
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ protected:
|
||||||
Q_INVOKABLE void setPassphrase(const QString& passphrase);
|
Q_INVOKABLE void setPassphrase(const QString& passphrase);
|
||||||
Q_INVOKABLE void getPassphraseSetupStatus();
|
Q_INVOKABLE void getPassphraseSetupStatus();
|
||||||
Q_INVOKABLE void getKeyFilePathIfExists();
|
Q_INVOKABLE void getKeyFilePathIfExists();
|
||||||
|
Q_INVOKABLE void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_QmlCommerce_h
|
#endif // hifi_QmlCommerce_h
|
||||||
|
|
|
@ -464,7 +464,9 @@ void Wallet::getSecurityImage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// decrypt and return
|
// decrypt and return
|
||||||
if (decryptFile(imageFilePath(), &data, &dataLen)) {
|
QString filePath(imageFilePath());
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
if (fileInfo.exists() && decryptFile(filePath, &data, &dataLen)) {
|
||||||
// create the pixmap
|
// create the pixmap
|
||||||
_securityImage = new QPixmap();
|
_securityImage = new QPixmap();
|
||||||
_securityImage->loadFromData(data, dataLen, "jpg");
|
_securityImage->loadFromData(data, dataLen, "jpg");
|
||||||
|
@ -488,3 +490,13 @@ void Wallet::sendKeyFilePathIfExists() {
|
||||||
emit keyFilePathIfExistsResult("");
|
emit keyFilePathIfExistsResult("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallet::reset() {
|
||||||
|
_publicKeys.clear();
|
||||||
|
delete _securityImage;
|
||||||
|
delete _passphrase;
|
||||||
|
QFile keyFile(keyFilePath());
|
||||||
|
QFile imageFile(imageFilePath());
|
||||||
|
keyFile.remove();
|
||||||
|
imageFile.remove();
|
||||||
|
}
|
|
@ -40,6 +40,8 @@ public:
|
||||||
void setPassphrase(const QString& passphrase);
|
void setPassphrase(const QString& passphrase);
|
||||||
QString* getPassphrase() { return _passphrase; }
|
QString* getPassphrase() { return _passphrase; }
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void securityImageResult(bool exists) ;
|
void securityImageResult(bool exists) ;
|
||||||
void keyFilePathIfExistsResult(const QString& path);
|
void keyFilePathIfExistsResult(const QString& path);
|
||||||
|
|
Loading…
Reference in a new issue