generate new domain keypair on domain ID change

This commit is contained in:
Stephen Birarda 2016-02-22 10:28:32 -08:00
parent 837c4c0810
commit e30b2b7051
3 changed files with 14 additions and 8 deletions

View file

@ -349,7 +349,8 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
// nodes will currently use this to add resources to data-web that relate to our domain
const QVariant* idValueVariant = valueForKeyPath(settingsMap, METAVERSE_DOMAIN_ID_KEY_PATH);
if (idValueVariant) {
nodeList->setSessionUUID(idValueVariant->toString());
QUuid domainID { idValueVariant->toString() };
nodeList->setSessionUUID(domainID);
}
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
@ -490,7 +491,8 @@ void DomainServer::setupICEHeartbeatForFullNetworking() {
// to send ICE heartbeats we'd better have a private key locally with an uploaded public key
auto& accountManager = AccountManager::getInstance();
if (!accountManager.getAccountInfo().hasPrivateKey()) {
auto domainID = accountManager.getAccountInfo().getDomainID();
if (!accountManager.getAccountInfo().hasPrivateKey() || domainID != limitedNodeList->getSessionUUID()) {
accountManager.generateNewDomainKeypair(limitedNodeList->getSessionUUID());
}

View file

@ -175,12 +175,12 @@ void DataServerAccountInfo::setPrivateKey(const QByteArray& privateKey) {
QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info) {
out << info._accessToken << info._username << info._xmppPassword << info._discourseApiKey
<< info._walletID << info._privateKey;
<< info._walletID << info._privateKey << info._domainID;
return out;
}
QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info) {
in >> info._accessToken >> info._username >> info._xmppPassword >> info._discourseApiKey
>> info._walletID >> info._privateKey;
>> info._walletID >> info._privateKey >> info._domainID;
return in;
}

View file

@ -42,10 +42,6 @@ public:
const QUuid& getWalletID() const { return _walletID; }
void setWalletID(const QUuid& walletID);
QByteArray getUsernameSignature(const QUuid& connectionToken);
bool hasPrivateKey() const { return !_privateKey.isEmpty(); }
void setPrivateKey(const QByteArray& privateKey);
qint64 getBalance() const { return _balance; }
float getBalanceInSatoshis() const { return _balance / SATOSHIS_PER_CREDIT; }
@ -54,6 +50,13 @@ public:
void setHasBalance(bool hasBalance) { _hasBalance = hasBalance; }
Q_INVOKABLE void setBalanceFromJSON(QNetworkReply& requestReply);
QByteArray getUsernameSignature(const QUuid& connectionToken);
bool hasPrivateKey() const { return !_privateKey.isEmpty(); }
void setPrivateKey(const QByteArray& privateKey);
void setDomainID(const QUuid& domainID) { _domainID = domainID; }
const QUuid& getDomainID() const { return _domainID; }
bool hasProfile() const;
void setProfileInfoFromJSON(const QJsonObject& jsonObject);
@ -72,6 +75,7 @@ private:
QUuid _walletID;
qint64 _balance;
bool _hasBalance;
QUuid _domainID; // if this holds account info for a domain, this holds the ID of that domain
QByteArray _privateKey;
};