Skip to content

Commit

Permalink
Properly import account keys
Browse files Browse the repository at this point in the history
instead of memcpy because AccountKeys is non-trivially copyable type
  • Loading branch information
aivve committed May 9, 2024
1 parent 27636b3 commit 60720a6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

#include "MainWindow.h"

#include <Common/Base58.h>
#include <Common/StringTools.h>
#include <Common/Util.h>
#include "Common/Base58.h"
#include "Common/StringTools.h"
#include "Common/Util.h"
#include "CryptoNoteCore/CryptoNoteTools.h"
#include "AboutDialog.h"
#include "AnimatedLabel.h"
#include "AddressBookModel.h"
Expand Down Expand Up @@ -486,7 +487,9 @@ void MainWindow::importKey() {
CryptoNote::AccountKeys keys;
if (Tools::Base58::decode_addr(keyString.toStdString(), addressPrefix, data) && addressPrefix == CurrencyAdapter::instance().getAddressPrefix() &&
data.size() == sizeof(keys)) {
std::memcpy(&keys, data.data(), sizeof(keys));
if (!fromBinaryArray(keys, Common::asBinaryArray(data))) {
QMessageBox::warning(this, tr("Wallet keys are not valid"), tr("Failed to parse account keys"), QMessageBox::Ok);
}
if (WalletAdapter::instance().isOpen()) {
WalletAdapter::instance().close();
}
Expand Down

0 comments on commit 60720a6

Please sign in to comment.