Skip to content

Commit

Permalink
remove CryptoNote namespace from NULL_SECRET_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
exploshot committed Dec 24, 2019
1 parent 4944891 commit 0cdfbed
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/CryptoNoteWrapper/WalletGreenWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include "Wallet/WalletGreen.h"
#include "Wallet/WalletErrors.h"

using namespace Qwertycoin;

namespace WalletGui {

namespace {
Expand Down Expand Up @@ -256,7 +258,7 @@ IWalletAdapter::WalletInitStatus WalletGreenWorker::createWithKeys(const QString
int errorCode = 0;
try {
m_wallet->initializeWithViewKey(std::string(_walletPath.toLocal8Bit().data()), "", _accountKeys.viewKeys.secretKey);
if (std::memcmp(&_accountKeys.spendKeys.secretKey, &CryptoNote::NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0) {
if (std::memcmp(&_accountKeys.spendKeys.secretKey, &NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0) {
m_wallet->createAddress(_accountKeys.spendKeys.publicKey);
} else {
m_wallet->createAddress(_accountKeys.spendKeys.secretKey);
Expand Down Expand Up @@ -295,7 +297,7 @@ IWalletAdapter::WalletInitStatus WalletGreenWorker::createWithKeysAndTimestamp(c
int errorCode = 0;
try {
m_wallet->initializeWithViewKeyAndTimestamp(std::string(_walletPath.toLocal8Bit().data()), "", _accountKeys.viewKeys.secretKey, _creationTimestamp);
if (std::memcmp(&_accountKeys.spendKeys.secretKey, &CryptoNote::NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0) {
if (std::memcmp(&_accountKeys.spendKeys.secretKey, &NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0) {
m_wallet->createAddress(_accountKeys.spendKeys.publicKey);
} else {
m_wallet->createAddressWithTimestamp(_accountKeys.spendKeys.secretKey, _creationTimestamp);
Expand Down Expand Up @@ -597,12 +599,12 @@ Crypto::SecretKey WalletGreenWorker::getTransactionSecretKey(quintptr _transacti
if (_transaction.secretKey) {
txKey = _transaction.secretKey.get();
} else {
txKey = CryptoNote::NULL_SECRET_KEY;
txKey = NULL_SECRET_KEY;
}
// txKey = _transaction.secretKey;
} catch (const std::exception& _error) {
WalletLogger::critical(tr("[Wallet] Get transaction key error: %1").arg(_error.what()));
txKey = CryptoNote::NULL_SECRET_KEY;
txKey = NULL_SECRET_KEY;
}
});

Expand Down Expand Up @@ -710,7 +712,7 @@ IWalletAdapter::SendTransactionStatus WalletGreenWorker::sendTransaction(const C
SemaphoreLocker locker(m_walletSemaphore);
int errorCode = 0;
quintptr newTransactionId = CryptoNote::WALLET_INVALID_TRANSACTION_ID;
Crypto::SecretKey newTransactionKey = CryptoNote::NULL_SECRET_KEY;
Crypto::SecretKey newTransactionKey = NULL_SECRET_KEY;
WalletLogger::debug(tr("[Wallet] Sending transaction..."));
m_dispatcher->remoteSpawn([this, &_transactionParameters, &errorCode, &newTransactionId, &newTransactionKey]() {
SemaphoreUnlocker unlocker(m_walletSemaphore);
Expand Down Expand Up @@ -790,7 +792,7 @@ QString WalletGreenWorker::getBalanceProof(quint64& _amount, QString& _message)

Crypto::SecretKey viewSecretKey = accountKeys.viewKeys.secretKey;

if (accountKeys.spendKeys.secretKey == CryptoNote::NULL_SECRET_KEY) {
if (accountKeys.spendKeys.secretKey == NULL_SECRET_KEY) {
throw std::runtime_error("Reserve proof can only be generated by a full wallet");
}

Expand Down
6 changes: 4 additions & 2 deletions src/Gui/Common/KeyDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "Style/Style.h"
#include "ui_KeyDialog.h"

using namespace Qwertycoin;

namespace WalletGui {

namespace {
Expand Down Expand Up @@ -60,7 +62,7 @@ bool isTrackingKeys(const QByteArray& _array) {
}

AccountKeys accountKeys = convertByteArrayToAccountKeys(_array);
return (std::memcmp(&accountKeys.spendKeys.secretKey, &CryptoNote::NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0);
return (std::memcmp(&accountKeys.spendKeys.secretKey, &NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0);
}

}
Expand Down Expand Up @@ -216,7 +218,7 @@ void KeyDialog::keyChanged() {
accountKeys = convertByteArrayToAccountKeys(_array);
}

m_isTracking = (std::memcmp(&accountKeys.spendKeys.secretKey, &CryptoNote::NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0);
m_isTracking = (std::memcmp(&accountKeys.spendKeys.secretKey, &NULL_SECRET_KEY, sizeof(Crypto::SecretKey)) == 0);

setWindowTitle(m_isTracking ? tr("Import tracking key") : tr("Import key"));
if (m_isTracking) {
Expand Down
6 changes: 4 additions & 2 deletions src/Gui/Common/TransactionDetailsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

Q_DECLARE_METATYPE(QList<CryptoNote::WalletTransfer>)

using namespace Qwertycoin;

namespace WalletGui {

namespace {
Expand Down Expand Up @@ -164,7 +166,7 @@ TransactionDetailsDialog::TransactionDetailsDialog(ICryptoNoteAdapter* _cryptoNo

Crypto::SecretKey tx_key = m_cryptoNoteAdapter->getNodeAdapter()->getWalletAdapter()->getTransactionSecretKey(static_cast<size_t>(m_index.row()));
QString transactionKey;
if (tx_key != CryptoNote::NULL_SECRET_KEY) {
if (tx_key != NULL_SECRET_KEY) {
transactionKey = QString::fromStdString(Common::podToHex(tx_key));
} else {
transactionKey = QString("(n/a)");
Expand Down Expand Up @@ -211,7 +213,7 @@ QString TransactionDetailsDialog::getTxProof(const QModelIndex& _index) const {
Crypto::SecretKey txKey = m_cryptoNoteAdapter->getNodeAdapter()->getWalletAdapter()->getTransactionSecretKey(static_cast<size_t>(m_index.row()));
QString address_str = QString::fromStdString(transfer.address);
CryptoNote::AccountPublicAddress addr;
if (m_cryptoNoteAdapter->parseAccountAddressString(address_str, addr) && transfer.amount > 0 && txKey != CryptoNote::NULL_SECRET_KEY) {
if (m_cryptoNoteAdapter->parseAccountAddressString(address_str, addr) && transfer.amount > 0 && txKey != NULL_SECRET_KEY) {
proof = m_cryptoNoteAdapter->getTxProof(txHash, addr, txKey);
}
return proof;
Expand Down
4 changes: 3 additions & 1 deletion src/Models/TransfersModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

Q_DECLARE_METATYPE(QList<CryptoNote::WalletTransfer>)

using namespace Qwertycoin;

namespace WalletGui {

namespace {
Expand Down Expand Up @@ -153,7 +155,7 @@ QVariant TransfersModel::getDecorationRole(const QModelIndex& _index) const {
Crypto::SecretKey txKey = m_cryptoNoteAdapter->getNodeAdapter()->getWalletAdapter()->getTransactionSecretKey(static_cast<size_t>(m_transactionIndex.row()));
QString address_str = QString::fromStdString(transfer.address);
CryptoNote::AccountPublicAddress addr;
if (m_cryptoNoteAdapter->parseAccountAddressString(address_str, addr) && transfer.amount > 0 && txKey != CryptoNote::NULL_SECRET_KEY) {
if (m_cryptoNoteAdapter->parseAccountAddressString(address_str, addr) && transfer.amount > 0 && txKey != NULL_SECRET_KEY) {
painter.drawPixmap(7,12, icon.width(), icon.height(), icon);
}
return pixmap;
Expand Down

0 comments on commit 0cdfbed

Please sign in to comment.