Skip to content

Commit

Permalink
fix walletadaptater
Browse files Browse the repository at this point in the history
  • Loading branch information
Acktarius committed Feb 9, 2025
1 parent 2a231ed commit 9b569c1
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"sparse_hash_set": "cpp",
"sparsetable": "cpp",
"locale": "cpp",
"regex": "cpp"
"regex": "cpp",
"format": "cpp"
}
}
87 changes: 80 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.10)

cmake_policy(SET CMP0020 NEW) # Qt linking policy

include(CryptoNoteWallet.cmake)
include(QREncode.cmake)
Expand All @@ -14,7 +16,7 @@ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION)

set(CRYPTONOTE_LIB cryptonote)
set(CMAKE_PREFIX_PATH "C:\\Qt\\5.11.0\\msvc2017_64\\lib\\cmake\\")
set(CMAKE_PREFIX_PATH "C:\\Qt-ack2\\5.15.2\\msvc2019_64\\lib\\cmake\\")

include_directories(${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -24,11 +26,22 @@ include_directories(${CMAKE_BINARY_DIR}
cryptonote/include
cryptonote/src)

find_package(Qt5Gui REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Network Widgets Charts REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Charts)

if(WIN32)
set(Boost_DEBUG ON) # This will show detailed Boost discovery info
set(Boost_NO_SYSTEM_PATHS ON) # Don't search system paths
set(BOOST_ROOT "C:/local/boost_1_78_0")
set(BOOST_INCLUDEDIR "${BOOST_ROOT}")
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib64-msvc-14.2") # Changed to 14.2 for VC142
else()
set(Boost_DEBUG ON) # Keep debug info for troubleshooting
set(Boost_NO_SYSTEM_PATHS OFF) # Allow system paths on Unix-like systems
endif()

set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_STATIC_LIBS ON)
if(WIN32)
Expand All @@ -37,7 +50,16 @@ else(WIN32)
set(Boost_USE_STATIC_RUNTIME ON)
endif(WIN32)

find_package(Boost 1.55 REQUIRED COMPONENTS date_time filesystem program_options regex serialization system thread chrono)
find_package(Boost 1.55 REQUIRED COMPONENTS
date_time
filesystem
program_options
regex
serialization
system
thread
chrono
)
if ((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54))
message(SEND_ERROR "Boost version 1.54 is unsupported, more details are available here http://goo.gl/RrCFmA")
endif ()
Expand Down Expand Up @@ -221,6 +243,11 @@ if (WIN32)
set(BUILD_RESOURCES conceal.rc)
set(QTMAIN Qt5::WinMain)

add_definitions(
-D_CRT_SECURE_NO_WARNINGS
-D_WINSOCK_DEPRECATED_NO_WARNINGS
)

elseif (UNIX)
if (APPLE)
enable_language(ASM)
Expand Down Expand Up @@ -290,9 +317,12 @@ elseif (WIN32)
endif (APPLE)

# qt5_use_modules(${PROJECT_NAME} Widgets Gui Network)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::Network)
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
)
if(Qt5Charts_FOUND)
add_definitions(/DHAVE_CHART)
target_link_libraries(${PROJECT_NAME} Qt5::Charts)
Expand Down Expand Up @@ -375,3 +405,46 @@ elseif (WIN32)
endif (APPLE)

include(CPack)

if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Running windeployqt..."
COMMAND "${_qt5Core_install_prefix}/bin/windeployqt.exe" --no-compiler-runtime \"$<TARGET_FILE:${PROJECT_NAME}>\"
COMMENT "Deploying Qt dependencies..."
)
endif()

# Find required packages
find_package(OpenSSL REQUIRED)

target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::Charts
OpenSSL::SSL
OpenSSL::Crypto
)

# Ensure OpenSSL DLLs are copied to build directory
if(WIN32)
# OpenSSL v3 from command line path
file(COPY
"${OPENSSL_ROOT_DIR}/bin/libssl-3-x64.dll"
"${OPENSSL_ROOT_DIR}/bin/libcrypto-3-x64.dll"
DESTINATION ${CMAKE_BINARY_DIR}/Release
)

# OpenSSL v1.1 from Qt directory
get_filename_component(QT_ROOT "${CMAKE_PREFIX_PATH}" PATH) # Go up to lib
get_filename_component(QT_ROOT "${QT_ROOT}" PATH) # Go up to msvc2019_64
get_filename_component(QT_ROOT "${QT_ROOT}" PATH) # Go up to 5.15.2
get_filename_component(QT_ROOT "${QT_ROOT}" PATH) # Go up to Qt root

file(COPY
"${QT_ROOT}/Tools/mingw1120_64/opt/bin/libssl-1_1-x64.dll"
"${QT_ROOT}/Tools/mingw1120_64/opt/bin/libcrypto-1_1-x64.dll"
DESTINATION ${CMAKE_BINARY_DIR}/Release
)
endif()
3 changes: 1 addition & 2 deletions cryptonote/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ compile_commands.json
*.ipch
*.bin
*.json
*.json
*.json
cmake-build*
47 changes: 31 additions & 16 deletions installer/windows/ConcealInstaller.iss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#define Dependency_NoExampleSetup

#define AppSetupName 'Conceal Desktop'
#define AppVersion '6.6.2'
#define AppSetupName 'Conceal-Desktop'
#define AppVersion '6.7.3'
#define AppPublisher 'Conceal Network'
#define AppCopyright 'Copyright (C) Conceal Network 2020'
#define AppURL 'https://conceal.network'
Expand Down Expand Up @@ -52,8 +52,6 @@ ArchitecturesInstallIn64BitMode=x64

LicenseFile={#LicenseFile}

#define UseVC2015To2022

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"

Expand All @@ -64,16 +62,29 @@ Root: HKLM; Subkey: "Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Unins

[Files]
Source: "{#LicenseFile}"; DestDir: "{app}";
Source: "build\{#AppExe}"; DestDir: "{app}"; DestName: "{#AppExe}";
Source: "build\Qt5Core.dll"; DestDir: "{app}";
Source: "build\Qt5Gui.dll"; DestDir: "{app}";
Source: "build\Qt5Network.dll"; DestDir: "{app}";
Source: "build\Qt5Widgets.dll"; DestDir: "{app}";
Source: "build\Qt5Charts.dll"; DestDir: "{app}";
Source: "build\libcrypto*.dll"; DestDir: "{app}";
Source: "build\libssl*.dll"; DestDir: "{app}";
Source: "build\platforms\qwindows.dll"; DestDir: "{app}/platforms";

Source: "..\..\build\Release\{#AppExe}"; DestDir: "{app}"; DestName: "{#AppExe}";
Source: "..\..\build\Release\Qt5Core.dll"; DestDir: "{app}";
Source: "..\..\build\Release\Qt5Gui.dll"; DestDir: "{app}";
Source: "..\..\build\Release\Qt5Network.dll"; DestDir: "{app}";
Source: "..\..\build\Release\Qt5Widgets.dll"; DestDir: "{app}";
Source: "..\..\build\Release\Qt5Charts.dll"; DestDir: "{app}";
Source: "..\..\build\Release\Qt5Svg.dll"; DestDir: "{app}";
Source: "..\..\build\Release\libcrypto*.dll"; DestDir: "{app}";
Source: "..\..\build\Release\libssl*.dll"; DestDir: "{app}";
Source: "..\..\build\Release\libGLESv2.dll"; DestDir: "{app}";
Source: "..\..\build\Release\libEGL.dll"; DestDir: "{app}";
Source: "..\..\build\Release\D3Dcompiler_47.dll"; DestDir: "{app}";
Source: "..\..\build\Release\opengl32sw.dll"; DestDir: "{app}";

; Qt plugins
Source: "..\..\build\Release\bearer\*"; DestDir: "{app}\bearer"; Flags: recursesubdirs
Source: "..\..\build\Release\iconengines\*"; DestDir: "{app}\iconengines"; Flags: recursesubdirs
Source: "..\..\build\Release\imageformats\*"; DestDir: "{app}\imageformats"; Flags: recursesubdirs
Source: "..\..\build\Release\platforms\*"; DestDir: "{app}\platforms"; Flags: recursesubdirs
Source: "..\..\build\Release\styles\*"; DestDir: "{app}\styles"; Flags: recursesubdirs

; Qt translations
Source: "..\..\build\Release\translations\*.qm"; DestDir: "{app}\translations";

[Icons]
Name: "{group}\{#AppSetupName}"; Filename: "{app}\{#AppExe}"; Tasks: desktopicon
Expand Down Expand Up @@ -784,11 +795,15 @@ UninstallDisplayIcon={app}\MyProgram.exe
SourceDir=src
OutputDir={#SourcePath}\bin
AllowNoIcons=yes
PrivilegesRequired=admin
WizardImageFile=Image.bmp
WizardSmallImageFile=SmallImage.bmp

; remove next line if you only deploy 32-bit binaries and dependencies
PrivilegesRequired=admin
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64

LicenseFile={#LicenseFile}

[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: nl; MessagesFile: "compiler:Languages\Dutch.isl"
Expand Down
2 changes: 1 addition & 1 deletion installer/windows/license.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright 2018-2021 - Conceal.Network
Copyright 2018-2025 - Conceal.Network
25 changes: 13 additions & 12 deletions src/WalletAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,19 @@ bool WalletAdapter::importLegacyWallet(const QString &_password) {
Settings::instance().setEncrypted(!_password.isEmpty());
try {
fileName.replace(fileName.lastIndexOf(".keys"), 5, ".wallet");

m_wallet.reset();
return false;
Settings::instance().setWalletFile(fileName);
return true;
} catch (std::system_error& _err) {
} catch (const std::system_error& _err) {
if (_err.code().value() == cn::error::WRONG_PASSWORD) {
Settings::instance().setEncrypted(true);
Q_EMIT openWalletWithPasswordSignal(!_password.isEmpty());
}
} catch (std::runtime_error&) {
m_wallet.reset();
return false;
} catch (const std::exception&) { // Catches both runtime_error and other exceptions
m_wallet.reset();
return false;
}

m_wallet.reset();
return false;
}

void WalletAdapter::close() {
Expand Down Expand Up @@ -375,23 +373,24 @@ void WalletAdapter::sendTransaction(QVector<cn::WalletOrder>& _transfers,
const QVector<cn::WalletMessage>& _messages,
quint64 _mixin)
{
QMutexLocker locker(&m_mutex);
try
{
crypto::SecretKey _transactionsk;
cn::TransactionParameters sendParams;
{ QMutexLocker locker(&m_mutex);
sendParams.destinations = std::vector<cn::WalletOrder>(_transfers.begin(), _transfers.end());
sendParams.messages = std::vector<cn::WalletMessage>(_messages.begin(), _messages.end());
sendParams.unlockTimestamp = 0;
sendParams.changeDestination = m_wallet->getAddress(0);

}
if (!_paymentId.isEmpty()) {
cn::addPaymentIdToExtra(_paymentId.toStdString(), sendParams.extra);
}

{ QMutexLocker locker(&m_mutex);
m_sentTransactionId = m_wallet->transfer(sendParams, _transactionsk);
Q_EMIT walletStateChangedSignal(tr("Sending transaction"), "");
LoggerAdapter::instance().log("Transaction sent by WalletGreen");
}
}
catch (std::system_error&)
{
Expand All @@ -407,11 +406,13 @@ quint64 WalletAdapter::getTransferCount(cn::TransactionId id) const {
}

void WalletAdapter::optimizeWallet() {
QMutexLocker locker(&m_mutex);
LoggerAdapter::instance().log("attempt to optimize wallet");
try {
QMutexLocker locker(&m_mutex);
m_sentTransactionId = m_wallet->createOptimizationTransaction(m_wallet->getAddress(0));
Q_EMIT walletStateChangedSignal(tr("Optimizing wallet"), "");
} catch (std::system_error&) {
LoggerAdapter::instance().log("quit silently optimize, criteria not met");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/languages/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2960,17 +2960,17 @@ Your wallet will be optimized automatically every 15 minutes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="418"/>
<location filename="../WalletAdapter.cpp" line="407"/>
<source>Sending transaction</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="446"/>
<location filename="../WalletAdapter.cpp" line="428"/>
<source>Optimizing wallet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="466"/>
<location filename="../WalletAdapter.cpp" line="449"/>
<source>Sending message</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2204,17 +2204,17 @@ Your wallet will be optimized automatically every 15 minutes.</source>
<translation></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="418"/>
<location filename="../WalletAdapter.cpp" line="407"/>
<source>Sending transaction</source>
<translation></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="446"/>
<location filename="../WalletAdapter.cpp" line="426"/>
<source>Optimizing wallet</source>
<translation></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="466"/>
<location filename="../WalletAdapter.cpp" line="447"/>
<source>Sending message</source>
<translation></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/languages/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2872,17 +2872,17 @@ Your wallet will be optimized automatically every 15 minutes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="418"/>
<location filename="../WalletAdapter.cpp" line="407"/>
<source>Sending transaction</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="446"/>
<location filename="../WalletAdapter.cpp" line="428"/>
<source>Optimizing wallet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="466"/>
<location filename="../WalletAdapter.cpp" line="449"/>
<source>Sending message</source>
<translation type="unfinished"></translation>
</message>
Expand Down
6 changes: 3 additions & 3 deletions src/languages/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2776,17 +2776,17 @@ Your wallet will be optimized automatically every 15 minutes.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="418"/>
<location filename="../WalletAdapter.cpp" line="407"/>
<source>Sending transaction</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="446"/>
<location filename="../WalletAdapter.cpp" line="428"/>
<source>Optimizing wallet</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../WalletAdapter.cpp" line="466"/>
<location filename="../WalletAdapter.cpp" line="449"/>
<source>Sending message</source>
<translation type="unfinished"></translation>
</message>
Expand Down

0 comments on commit 9b569c1

Please sign in to comment.