mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Merge branch 'master' into tablet_extended_sounds
This commit is contained in:
commit
9f8f28dd1e
9 changed files with 24 additions and 34 deletions
|
@ -55,6 +55,7 @@ Item {
|
||||||
text: "DEBUG: Clear Cached Passphrase";
|
text: "DEBUG: Clear Cached Passphrase";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
commerce.setPassphrase("");
|
commerce.setPassphrase("");
|
||||||
|
sendSignalToWallet({method: 'passphraseReset'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
|
|
|
@ -318,7 +318,7 @@ Rectangle {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
onSendSignalToWallet: {
|
onSendSignalToWallet: {
|
||||||
if (msg.method === 'walletReset') {
|
if (msg.method === 'walletReset' || msg.method === 'passphraseReset') {
|
||||||
sendToScript(msg);
|
sendToScript(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,7 @@ Rectangle {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (passphraseSelection.validateAndSubmitPassphrase()) {
|
if (passphraseSelection.validateAndSubmitPassphrase()) {
|
||||||
root.lastPage = "choosePassphrase";
|
root.lastPage = "choosePassphrase";
|
||||||
commerce.balance(); // Do this here so that keys are generated. Order might change as backend changes?
|
commerce.generateKeyPair();
|
||||||
choosePassphraseContainer.visible = false;
|
choosePassphraseContainer.visible = false;
|
||||||
privateKeysReadyContainer.visible = true;
|
privateKeysReadyContainer.visible = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: tabletButton
|
id: tabletButton
|
||||||
|
|
||||||
|
property string captionColorOverride: ""
|
||||||
property var uuid;
|
property var uuid;
|
||||||
property string icon: "icons/tablet-icons/edit-i.svg"
|
property string icon: "icons/tablet-icons/edit-i.svg"
|
||||||
property string hoverIcon: tabletButton.icon
|
property string hoverIcon: tabletButton.icon
|
||||||
|
@ -102,7 +104,7 @@ Item {
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
color: "#ffffff"
|
color: captionColorOverride !== "" ? captionColorOverride: "#ffffff"
|
||||||
text: tabletButton.text
|
text: tabletButton.text
|
||||||
font.bold: true
|
font.bold: true
|
||||||
font.pixelSize: 18
|
font.pixelSize: 18
|
||||||
|
|
|
@ -86,7 +86,7 @@ void QmlCommerce::history() {
|
||||||
|
|
||||||
void QmlCommerce::setPassphrase(const QString& passphrase) {
|
void QmlCommerce::setPassphrase(const QString& passphrase) {
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
if (wallet->getPassphrase() && !wallet->getPassphrase()->isEmpty()) {
|
if(wallet->getPassphrase() && !wallet->getPassphrase()->isEmpty() && !passphrase.isEmpty()) {
|
||||||
wallet->changePassphrase(passphrase);
|
wallet->changePassphrase(passphrase);
|
||||||
} else {
|
} else {
|
||||||
wallet->setPassphrase(passphrase);
|
wallet->setPassphrase(passphrase);
|
||||||
|
@ -94,6 +94,12 @@ void QmlCommerce::setPassphrase(const QString& passphrase) {
|
||||||
getWalletAuthenticatedStatus();
|
getWalletAuthenticatedStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlCommerce::generateKeyPair() {
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
wallet->generateKeyPair();
|
||||||
|
getWalletAuthenticatedStatus();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlCommerce::reset() {
|
void QmlCommerce::reset() {
|
||||||
auto ledger = DependencyManager::get<Ledger>();
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
||||||
Q_INVOKABLE void balance();
|
Q_INVOKABLE void balance();
|
||||||
Q_INVOKABLE void inventory();
|
Q_INVOKABLE void inventory();
|
||||||
Q_INVOKABLE void history();
|
Q_INVOKABLE void history();
|
||||||
|
Q_INVOKABLE void generateKeyPair();
|
||||||
Q_INVOKABLE void reset();
|
Q_INVOKABLE void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,8 @@ RSA* readPrivateKey(const char* filename) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCDebug(commerce) << "couldn't parse" << filename;
|
qCDebug(commerce) << "couldn't parse" << filename;
|
||||||
|
// if the passphrase is wrong, then let's not cache it
|
||||||
|
DependencyManager::get<Wallet>()->setPassphrase("");
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -273,8 +275,6 @@ void Wallet::setPassphrase(const QString& passphrase) {
|
||||||
}
|
}
|
||||||
_passphrase = new QString(passphrase);
|
_passphrase = new QString(passphrase);
|
||||||
|
|
||||||
// no matter what, we now need to clear the keys as they
|
|
||||||
// need to be read using this passphrase
|
|
||||||
_publicKeys.clear();
|
_publicKeys.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,28 +413,10 @@ bool Wallet::walletIsAuthenticatedWithPassphrase() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wallet::createIfNeeded() {
|
bool Wallet::generateKeyPair() {
|
||||||
if (_publicKeys.count() > 0) return false;
|
|
||||||
|
|
||||||
// FIXME: initialize OpenSSL elsewhere soon
|
// FIXME: initialize OpenSSL elsewhere soon
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
// try to read existing keys if they exist...
|
|
||||||
auto publicKey = readPublicKey(keyFilePath().toStdString().c_str());
|
|
||||||
if (publicKey.size() > 0) {
|
|
||||||
if (auto key = readPrivateKey(keyFilePath().toStdString().c_str()) ) {
|
|
||||||
qCDebug(commerce) << "read private key";
|
|
||||||
RSA_free(key);
|
|
||||||
// K -- add the public key since we have a legit private key associated with it
|
|
||||||
_publicKeys.push_back(publicKey.toBase64());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qCInfo(commerce) << "Creating wallet.";
|
|
||||||
return generateKeyPair();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Wallet::generateKeyPair() {
|
|
||||||
qCInfo(commerce) << "Generating keypair.";
|
qCInfo(commerce) << "Generating keypair.";
|
||||||
auto keyPair = generateRSAKeypair();
|
auto keyPair = generateRSAKeypair();
|
||||||
sendKeyFilePathIfExists();
|
sendKeyFilePathIfExists();
|
||||||
|
@ -453,7 +435,6 @@ bool Wallet::generateKeyPair() {
|
||||||
|
|
||||||
QStringList Wallet::listPublicKeys() {
|
QStringList Wallet::listPublicKeys() {
|
||||||
qCInfo(commerce) << "Enumerating public keys.";
|
qCInfo(commerce) << "Enumerating public keys.";
|
||||||
createIfNeeded();
|
|
||||||
return _publicKeys;
|
return _publicKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,12 +553,8 @@ void Wallet::reset() {
|
||||||
|
|
||||||
// tell the provider we got nothing
|
// tell the provider we got nothing
|
||||||
updateImageProvider();
|
updateImageProvider();
|
||||||
delete _passphrase;
|
_passphrase->clear();
|
||||||
|
|
||||||
// for now we need to maintain the hard-coded passphrase.
|
|
||||||
// FIXME: remove this line as part of wiring up the passphrase
|
|
||||||
// and probably set it to nullptr
|
|
||||||
_passphrase = new QString("pwd");
|
|
||||||
|
|
||||||
QFile keyFile(keyFilePath());
|
QFile keyFile(keyFilePath());
|
||||||
QFile imageFile(imageFilePath());
|
QFile imageFile(imageFilePath());
|
||||||
|
@ -608,6 +585,7 @@ bool Wallet::changePassphrase(const QString& newPassphrase) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCDebug(commerce) << "couldn't read keys";
|
qCDebug(commerce) << "couldn't decrypt keys with current passphrase, clearing";
|
||||||
|
setPassphrase(QString(""));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ public:
|
||||||
|
|
||||||
~Wallet();
|
~Wallet();
|
||||||
// These are currently blocking calls, although they might take a moment.
|
// These are currently blocking calls, although they might take a moment.
|
||||||
bool createIfNeeded();
|
|
||||||
bool generateKeyPair();
|
bool generateKeyPair();
|
||||||
QStringList listPublicKeys();
|
QStringList listPublicKeys();
|
||||||
QString signWithKey(const QByteArray& text, const QString& key);
|
QString signWithKey(const QByteArray& text, const QString& key);
|
||||||
|
|
|
@ -71,6 +71,10 @@
|
||||||
case 'maybeEnableHmdPreview':
|
case 'maybeEnableHmdPreview':
|
||||||
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
|
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
|
||||||
break;
|
break;
|
||||||
|
case 'passphraseReset':
|
||||||
|
onButtonClicked();
|
||||||
|
onButtonClicked();
|
||||||
|
break;
|
||||||
case 'walletReset':
|
case 'walletReset':
|
||||||
onButtonClicked();
|
onButtonClicked();
|
||||||
onButtonClicked();
|
onButtonClicked();
|
||||||
|
|
Loading…
Reference in a new issue