Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
3b6b5b5
Source dirs created
sergey-chernikov Aug 10, 2020
c666642
Merge branch 'bs_dev' into terminal_arch_refactor
sergey-chernikov Aug 11, 2020
9763abe
WIP 1
sergey-chernikov Aug 17, 2020
db3ec43
WIP 2
sergey-chernikov Aug 20, 2020
cbe6858
RFQ script
sergey-chernikov Aug 21, 2020
5a97924
Merged with bs_dev
sergey-chernikov Aug 22, 2020
0e329e5
WIP 3
sergey-chernikov Aug 25, 2020
c581411
WIP 4
sergey-chernikov Aug 28, 2020
47d77a6
Merge branch 'bs_dev' into terminal_arch_refactor
sergey-chernikov Aug 28, 2020
182be37
WIP 5
sergey-chernikov Sep 4, 2020
150bec9
Merged with bs_dev
sergey-chernikov Sep 4, 2020
04c676a
Another build fix
sergey-chernikov Sep 7, 2020
a4fb04b
Address list display
sergey-chernikov Sep 7, 2020
737067b
Wallet balances
sergey-chernikov Sep 8, 2020
afab345
TX list support
sergey-chernikov Sep 11, 2020
f2f3cfe
TX and address details
sergey-chernikov Sep 14, 2020
e15963c
Merged with bs_dev
sergey-chernikov Sep 15, 2020
5e8d769
merged with bs_dev
sergey-chernikov Sep 16, 2020
71a2e49
Explorer functionality
sergey-chernikov Sep 18, 2020
4764424
Removed REQUIRED when searching for LibZMQ
sergey-chernikov Sep 21, 2020
63808ee
Updated common
sergey-chernikov Sep 21, 2020
d461079
WIP 7
sergey-chernikov Sep 23, 2020
f890760
Merged with bs_dev
sergey-chernikov Sep 23, 2020
a623c29
Manual create TX implemented
sergey-chernikov Sep 29, 2020
7001609
TX tray notifications
sergey-chernikov Sep 29, 2020
1179001
TX list fixes
sergey-chernikov Sep 30, 2020
59dfef8
Merged with bs_dev
sergey-chernikov Sep 30, 2020
dd630e8
Settings GUI reimplemented
sergey-chernikov Oct 2, 2020
f589256
Merged with bs_dev
sergey-chernikov Oct 5, 2020
d7368ad
Build fix
sergey-chernikov Oct 5, 2020
014041e
Initial login support
sergey-chernikov Oct 7, 2020
9d21b5c
Merge branch 'bs_dev' into terminal_arch_refactor
sergey-chernikov Oct 7, 2020
9751964
proxy/matching login
sergey-chernikov Oct 7, 2020
2491c16
MD prices
sergey-chernikov Oct 9, 2020
2f382f8
Auth address management
sergey-chernikov Oct 14, 2020
251cdc4
Merged with bs_dev
sergey-chernikov Oct 14, 2020
5abbb8b
FX RFQ sending
sergey-chernikov Oct 16, 2020
6466d24
Celer as a separate lib
sergey-chernikov Oct 19, 2020
8c65a96
Trade blotter
sergey-chernikov Oct 20, 2020
01cc4ea
Send XBT RFQ
sergey-chernikov Oct 26, 2020
85ef564
Merged with bs_dev
sergey-chernikov Oct 26, 2020
c1a669e
Properly display futures in MD view
Ation Nov 2, 2020
1c3527b
Select futures group in UI for RFQ
Ation Nov 2, 2020
c948f3c
Fix submit RFQ for a future
Ation Nov 2, 2020
9650714
Submit quote on future step1
Ation Nov 3, 2020
f7e534f
Rename future to subproduct
Ation Nov 4, 2020
fc38810
Minor fixes for price updates
Ation Nov 4, 2020
4b3ae27
Minor UI fixes
Ation Nov 4, 2020
1cd9ca0
Few fixes to futures quote processing
Ation Nov 4, 2020
7f4bf21
Minor fix to future quote accepting
Ation Nov 4, 2020
1131619
Trade type reported explicitly to blotter
Ation Nov 5, 2020
9467d52
XBT RFQ is working
sergey-chernikov Nov 10, 2020
691d6fd
Merged with bs_dev
sergey-chernikov Nov 10, 2020
b7b16c8
Display total delivery for futures
Ation Nov 10, 2020
d476256
Display delivery obligations notifications
Ation Nov 13, 2020
105e906
WIP RFQ reply
sergey-chernikov Nov 13, 2020
c455610
RFQ reply - FX
sergey-chernikov Nov 16, 2020
85bfd87
Create tx for delivery
Ation Nov 17, 2020
f99414a
Return user address for delivery
Ation Nov 18, 2020
1641146
Fix on delivery message processing
Ation Nov 18, 2020
7e541c0
XBT dealing
sergey-chernikov Nov 19, 2020
98e4bb6
Merge branch 'bs_dev' into terminal_arch_refactor
sergey-chernikov Nov 19, 2020
bdd5876
Update background role
Ation Nov 24, 2020
1f318d1
Display delivery obligations in trade blotter
Ation Nov 24, 2020
4b202ef
JSON API
sergey-chernikov Nov 24, 2020
4c5c922
Display obligations properly
Ation Nov 25, 2020
d98d4fd
Switch to a new update message
Ation Nov 25, 2020
d345f8d
Fix obligations display
Ation Nov 25, 2020
e14f074
Create TX for delivery obligation
Ation Nov 25, 2020
a4c79da
Merge branch 'bs_dev' into futures_dev
Ation Nov 25, 2020
ccdb13e
JSON API fixes
sergey-chernikov Nov 25, 2020
399bc8a
Add BsServer to JSON API
sergey-chernikov Nov 25, 2020
7dd45a1
Fix build
Ation Nov 26, 2020
c279a48
Moved MessageUtils from terminal/Core to common
sergey-chernikov Nov 27, 2020
df4c4de
API changes
sergey-chernikov Dec 1, 2020
f67dc9a
Group rename
Ation Dec 3, 2020
349790f
Compile fixes for GCC
pavel-kokolemin Dec 3, 2020
be97e91
Merge pull request #934 from BlockSettle/gcc_compile_fixes
sergey-chernikov Dec 3, 2020
1f734aa
auto sign
sergey-chernikov Dec 3, 2020
ee25c92
Duiplicate cash settled MD
Ation Dec 3, 2020
5f65aa5
Merge pull request #935 from BlockSettle/fake_cash_settled_md
pavel-kokolemin Dec 3, 2020
bf06e8d
WIP Futures ticker
pavel-kokolemin Dec 3, 2020
d978245
Fix RFQRequestWidget::checkConditions
pavel-kokolemin Dec 3, 2020
f6ccca6
Send future request to proxy
pavel-kokolemin Dec 3, 2020
90b9f4f
Merge pull request #937 from BlockSettle/futures_ticker
Ation Dec 4, 2020
fc02ecf
ZC UTXO reservation support
sergey-chernikov Dec 4, 2020
e56c6c6
CacheFile refactor (use only STL)
sergey-chernikov Dec 4, 2020
c23ab25
FX settlement tests
sergey-chernikov Dec 7, 2020
46759ae
XBT settlement tests
sergey-chernikov Dec 9, 2020
d190b89
Switch to C++17
sergey-chernikov Dec 9, 2020
f4afb2f
C++17 compatibility
sergey-chernikov Dec 9, 2020
fbe6e95
Multiple tests run crash fixes
sergey-chernikov Dec 10, 2020
de757f4
Update futures ticker UI
pavel-kokolemin Dec 9, 2020
c9da957
Merge pull request #938 from BlockSettle/futures_ui_updates_2
Ation Dec 10, 2020
5579308
Wallet actions in signer
sergey-chernikov Dec 10, 2020
28204b4
Wallet backup with new Armory code
sergey-chernikov Dec 11, 2020
63ee6a4
Update ZMQ
Ation Dec 11, 2020
ddd44d2
Use correct futures price depending on volume
pavel-kokolemin Dec 14, 2020
48badae
Rename MDField::desc
pavel-kokolemin Dec 14, 2020
ed00f6c
Merge pull request #939 from BlockSettle/futures_ui_updates_3
Ation Dec 14, 2020
e1180be
Fix display for price book
Ation Dec 14, 2020
9f98c00
Wallet import and address creation
sergey-chernikov Dec 14, 2020
b18299b
Wallet scan and removal
sergey-chernikov Dec 17, 2020
e5e1a0d
Rename future
Ation Dec 17, 2020
0d809fd
One more rename
Ation Dec 18, 2020
cf453ea
Update widget selection
Ation Dec 18, 2020
2b3083c
Updte blotter
Ation Dec 21, 2020
41c1eec
Merge pull request #941 from BlockSettle/futures_products_rename
pavel-kokolemin Dec 22, 2020
3aef7d8
Minor fixes for 1day MD
Ation Dec 23, 2020
b447249
Enable deliverable futures
pavel-kokolemin Dec 23, 2020
5f27f9f
Merge pull request #942 from BlockSettle/api_server_6
Ation Dec 23, 2020
39fdc91
Update charting widget for new groups
Ation Dec 23, 2020
68925eb
Merge branch 'futures_dev' of github.com:BlockSettle/terminal into fu…
Ation Dec 23, 2020
cca6d40
Set focus to amount field when product selected
pavel-kokolemin Dec 24, 2020
49f9669
Merge pull request #943 from BlockSettle/fix_futures_focus
Ation Dec 24, 2020
a24a46b
Update submodules
Ation Dec 28, 2020
cd0ea18
Allow sending delivery addr
pavel-kokolemin Dec 31, 2020
f1c4562
Fix futures balances
pavel-kokolemin Dec 31, 2020
3bd64ea
Merge pull request #944 from BlockSettle/delivery_addr
Ation Jan 4, 2021
85063f8
Merge with latest common
sergey-chernikov Jan 6, 2021
96763e1
Merge from common/terminal_arch_refactor
sergey-chernikov Jan 7, 2021
38ac4ef
Switch to C++17
sergey-chernikov Jan 8, 2021
7ef7f41
Fix build
Ation Jan 8, 2021
265784e
Fix osx build
Ation Jan 8, 2021
1184982
Start of deprecated code removal
sergey-chernikov Jan 8, 2021
b867184
Updated common
sergey-chernikov Jan 8, 2021
7473c41
Fix for settlement tests
sergey-chernikov Jan 8, 2021
d81bc6d
Merged common/bs_dev
sergey-chernikov Jan 11, 2021
1e665b6
Fix crash
sergey-chernikov Jan 12, 2021
a4a4a0b
Add profit/loss calculation
pavel-kokolemin Jan 12, 2021
c386dbb
Merge remote-tracking branch 'origin/merge_common_tar' into profit_loss
pavel-kokolemin Jan 13, 2021
17fdaa8
Update futures confirm/error message box text
pavel-kokolemin Jan 13, 2021
113af6d
Merge pull request #945 from BlockSettle/merge_common_tar
Ation Jan 13, 2021
ee50f3c
Merge pull request #947 from BlockSettle/profit_loss
Ation Jan 13, 2021
8213895
Add delivery notification message
pavel-kokolemin Jan 13, 2021
993fa4d
Merge pull request #948 from BlockSettle/delivery_notifications
Ation Jan 13, 2021
8c9d2b4
Move settlement in blotter
Ation Jan 14, 2021
670a3a9
Tiny UI fix for the future delivery confirmation
pavel-kokolemin Jan 15, 2021
61ea42e
Fix DeliveryObligation message box
pavel-kokolemin Jan 15, 2021
f86500d
Merge pull request #949 from BlockSettle/ui_fix
Ation Jan 15, 2021
1b86f8d
Fix create delivery tx
pavel-kokolemin Jan 15, 2021
7ce6ff3
Merge pull request #950 from BlockSettle/ui_fix
Ation Jan 15, 2021
c98b312
Removed more unused code
sergey-chernikov Jan 18, 2021
50a07fb
Add PriceAmount tests
pavel-kokolemin Jan 19, 2021
c438bde
Merge pull request #951 from BlockSettle/price_amount
Ation Jan 19, 2021
506c9c2
Portfolio tab is now functional
sergey-chernikov Jan 19, 2021
c82ad9e
Merge branch 'bs_dev' into terminal_arch_refactor
sergey-chernikov Jan 19, 2021
01daaf2
IM balance fixes
pavel-kokolemin Jan 20, 2021
3994b09
Auto sign obligation delivery
sergey-chernikov Jan 21, 2021
a43c158
Merge pull request #953 from BlockSettle/im_balance_fixes
Ation Jan 21, 2021
7bd1327
Merge pull request #954 from BlockSettle/auto_sign_delivery_oblig
Ation Jan 21, 2021
bdc491e
Auto send delivery obligation with Auth eID wallet
sergey-chernikov Jan 21, 2021
153dc93
Merge branch 'futures_dev' into auto_sign_delivery_oblig
sergey-chernikov Jan 21, 2021
02c3054
Avoid crashing on clean start
sergey-chernikov Jan 21, 2021
0886b98
uncomment rank check
sergey-chernikov Jan 22, 2021
878e49d
Fix data races in SignerAdapter
pavel-kokolemin Jan 22, 2021
6e02d5a
Fix minor startup TSAN reports
pavel-kokolemin Jan 22, 2021
620b85e
Merge pull request #956 from BlockSettle/terminal_arch_refactor_races…
sergey-chernikov Jan 22, 2021
ab8763d
Merge pull request #955 from BlockSettle/auto_sign_delivery_oblig
Ation Jan 22, 2021
8bd5f20
Fix crash in UtxoReservationManager
pavel-kokolemin Jan 22, 2021
7e63025
Merge pull request #957 from BlockSettle/terminal_arch_refactor_races…
sergey-chernikov Jan 22, 2021
c505527
Prevent chart tab from crashing the terminal
sergey-chernikov Jan 22, 2021
558df85
Prevent chart tab from crashing the terminal
sergey-chernikov Jan 22, 2021
61e7376
Display delivery status
Ation Jan 22, 2021
049b076
Per-order blotter updates
pavel-kokolemin Jan 26, 2021
3114791
Merge pull request #958 from BlockSettle/order_ids
sergey-chernikov Jan 27, 2021
a047f61
Use per-order blotter updates
pavel-kokolemin Feb 5, 2021
9df336f
Merge pull request #959 from BlockSettle/api_updates_4
sergey-chernikov Feb 5, 2021
aa16d4f
Updated common
sergey-chernikov Feb 10, 2021
8c497a3
reduce amount of .ui files included in GUI/QtWidgets
sergey-chernikov Feb 10, 2021
434bb3c
fix order blotter expanding on insert
Ation Feb 10, 2021
be887ac
Merge pull request #960 from BlockSettle/fix_blotter_collapsing
sergey-chernikov Feb 10, 2021
43a3849
dedicated message clock
sergey-chernikov Feb 16, 2021
572cdbc
Try to fix blotter updates
pavel-kokolemin Feb 18, 2021
7114d2e
Merge pull request #961 from BlockSettle/fix_blotter_updates
sergey-chernikov Feb 24, 2021
d688c66
Add json lib
Ation Mar 3, 2021
4770ddf
Merge pull request #962 from BlockSettle/add_json_lib
sergey-chernikov Mar 3, 2021
7deeae5
Disable RBF for simple payment TX
sergey-chernikov Mar 24, 2021
52a3e64
Merge pull request #963 from BlockSettle/eurd_oblig_no_rbf
Ation Mar 24, 2021
6ef7a41
fix wallet unit test, update common
goatpig Mar 29, 2021
9e18d28
Merge pull request #964 from BlockSettle/fix_wallet_test
sergey-chernikov Mar 29, 2021
a745634
merged with terminal_arch_refactor
sergey-chernikov Mar 29, 2021
988b6dc
renamed TxN to TxCount where appropriate
sergey-chernikov Apr 1, 2021
f73de31
Merge branch 'terminal_arch_refactor' into futures_dev
Ation Apr 5, 2021
ff4bae9
Update copy years according to commit history
Ation Apr 5, 2021
eca8555
Add missing copyright headers
Ation Apr 5, 2021
26f6005
fix year
Ation Apr 5, 2021
d99e28c
Merge pull request #966 from BlockSettle/update_copy_years
sergey-chernikov Apr 5, 2021
7e976d3
Envelope structure rework in adapters
sergey-chernikov May 11, 2021
1611b25
build fixes
sergey-chernikov May 11, 2021
740cb7c
another round of envelope rework
sergey-chernikov May 18, 2021
65a62a8
merge with bs_dev
sergey-chernikov May 19, 2021
cec0586
merged with terminal_arch_refactor
sergey-chernikov May 19, 2021
2f40a61
Merge pull request #965 from BlockSettle/futures_dev
sergey-chernikov Jan 12, 2022
57bf9dd
Simplified initial build
sergey-chernikov Jan 14, 2022
046fb6a
[LEV-2349] Basic wallet/TX functionality
sergey-chernikov Aug 5, 2022
61ae495
BIP39 wallet import/create support
sergey-chernikov Aug 22, 2022
ef28a8a
[LEV-2510] Armory connection refactor
sergey-chernikov Aug 23, 2022
5d35fc3
[LEV-2511] Delete wallet
sergey-chernikov Aug 23, 2022
af0de2a
fixup
sergey-chernikov Aug 24, 2022
45f8fbd
[LEV-2513] wallet/address balance update fixes
sergey-chernikov Aug 24, 2022
50227cf
[LEV-2512] wallet rescan improvements
sergey-chernikov Aug 26, 2022
189a3d6
update common
sergey-chernikov Aug 29, 2022
a0c8639
[LEV-2519] TX split across HD wallets
sergey-chernikov Aug 30, 2022
53109be
[LEV-2522] Optional QtQuick GUI (now empty)
sergey-chernikov Sep 1, 2022
2e9ebf0
Merge pull request #974 from BlockSettle/lev-2522_qml_gui
sergey-chernikov Feb 13, 2023
1d88c17
Merge pull request #973 from BlockSettle/lev-2519_tx_split
sergey-chernikov Feb 13, 2023
4843224
Merge pull request #972 from BlockSettle/lev-2512_rescan_at_import
sergey-chernikov Feb 13, 2023
bb85f64
Merge pull request #971 from BlockSettle/lev-2513_address_balance
sergey-chernikov Feb 13, 2023
2ae9c96
Merge pull request #970 from BlockSettle/lev-2511_delete_wallet
sergey-chernikov Feb 13, 2023
fb5bd93
Merge pull request #969 from BlockSettle/lev-2510_armory_conn_refactor
sergey-chernikov Feb 13, 2023
625ac26
Merge pull request #968 from BlockSettle/lev-2351_12_word_seed
sergey-chernikov Feb 13, 2023
d3afbf7
Merge pull request #967 from BlockSettle/simplification
sergey-chernikov Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ build_terminal/
generated_proto/
terminal.*/
BlockSettleHW/ledger/hidapi/*
GUI/QtWidgets/ui/*
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "Celer"]
path = Celer
url = ../Celer
[submodule "common"]
path = common
url = ../common
[submodule "AuthAPI"]
path = AuthAPI
url = https://github.com/autheid/AuthAPI.git
1 change: 0 additions & 1 deletion AuthAPI
Submodule AuthAPI deleted from 14a152
6 changes: 5 additions & 1 deletion BlockSettleApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,23 @@ ELSE ()
ENDIF ()

TARGET_LINK_LIBRARIES( ${BLOCKSETTLE_APP_NAME}
${TERMINAL_CORE_NAME}
${TERMINAL_GUI_QT_NAME}
${TERMINAL_GUI_QTQUICK_NAME}
${BLOCKSETTLE_UI_LIBRARY_NAME}
${BS_NETWORK_LIB_NAME}
${CPP_WALLET_LIB_NAME}
${CRYPTO_LIB_NAME}
${BOTAN_LIB}
${ZMQ_LIB}
${QRENCODE_LIB}
${QT_LINUX_LIBS}
${WS_LIB}
Qt5::Qml
Qt5::Core
Qt5::Widgets
Qt5::Gui
Qt5::QSQLiteDriverPlugin
Qt5::Sql
Qt5::Network
Qt5::PrintSupport
Qt5::Core
Expand Down
263 changes: 98 additions & 165 deletions BlockSettleApp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
/*

***********************************************************************************
* Copyright (C) 2018 - 2020, BlockSettle AB
* Copyright (C) 2018 - 2021, BlockSettle AB
* Distributed under the GNU Affero General Public License (AGPL v3)
* See LICENSE or http://www.gnu.org/licenses/agpl.html
*
**********************************************************************************

*/
#include <QApplication>
#include <QBitmap>
#include <QCoreApplication>
#include <QDateTime>
#include <QDirIterator>
#include <QFile>
#include <QFontDatabase>
#include <QLockFile>
#include <QDir>
#include <QFileInfo>
#include <QScreen>
#include <QStandardPaths>
#include <QThread>
#include <QtPlugin>

#include <memory>

#include "ApplicationSettings.h"
#include "BSErrorCode.h"
#include "BSMessageBox.h"
#include "BSTerminalMainWindow.h"
#include "BSTerminalSplashScreen.h"
#include "EncryptionUtils.h"

#include "btc/ecc.h"

#include "AppNap.h"
#include "Adapters/BlockchainAdapter.h"
#include "Adapters/WalletsAdapter.h"
#include "ApiAdapter.h"
#include "ApiJson.h"
#include "AssetsAdapter.h"
#include "BsServerAdapter.h"
#include "QtGuiAdapter.h"
#include "QtQuickAdapter.h"
#include "SettingsAdapter.h"
#include "SignerAdapter.h"
#include <spdlog/spdlog.h>
#include <spdlog/sinks/daily_file_sink.h>

//#include "AppNap.h"

#ifdef USE_QWindowsIntegrationPlugin
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Expand All @@ -49,16 +53,30 @@ Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
Q_IMPORT_PLUGIN(QCupsPrinterSupportPlugin)
#endif // USE_QXcbIntegrationPlugin

#ifdef STATIC_BUILD
Q_IMPORT_PLUGIN(QSQLiteDriverPlugin)
Q_IMPORT_PLUGIN(QICOPlugin)

#ifdef STATIC_BUILD
#if defined (Q_OS_LINUX)
Q_IMPORT_PLUGIN(QtQuick2PrivateWidgetsPlugin)
#endif

Q_IMPORT_PLUGIN(QtQuick2Plugin)
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
Q_IMPORT_PLUGIN(QtQuickControls2Plugin)
Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin)
//Q_IMPORT_PLUGIN(QtQuickControls1Plugin)
Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
Q_IMPORT_PLUGIN(QmlFolderListModelPlugin)
Q_IMPORT_PLUGIN(QmlSettingsPlugin)
//Q_IMPORT_PLUGIN(QtLabsPlatformPlugin)
#endif // STATIC_BUILD

Q_DECLARE_METATYPE(ArmorySettings)
Q_DECLARE_METATYPE(AsyncClient::LedgerDelegate)
Q_DECLARE_METATYPE(BinaryData)
Q_DECLARE_METATYPE(bs::error::AuthAddressSubmitResult);
Q_DECLARE_METATYPE(CelerAPI::CelerMessageType);
Q_DECLARE_METATYPE(SecureBinaryData)
Q_DECLARE_METATYPE(std::shared_ptr<std::promise<bool>>)
Q_DECLARE_METATYPE(std::string)
Expand Down Expand Up @@ -109,12 +127,11 @@ static void checkStyleSheet(QApplication &app)

QFileInfo info = QFileInfo(QLatin1String(styleSheetFileName));

static QDateTime lastTimestamp = info.lastModified();
static auto lastTimestamp = info.lastModified();

if (lastTimestamp == info.lastModified()) {
return;
}

lastTimestamp = info.lastModified();

QFile stylesheetFile(styleSheetFileName);
Expand All @@ -125,7 +142,7 @@ static void checkStyleSheet(QApplication &app)
app.setStyleSheet(QString::fromLatin1(stylesheetFile.readAll()));
}

QScreen *getDisplay(QPoint position)
static QScreen *getDisplay(QPoint position)
{
for (auto currentScreen : QGuiApplication::screens()) {
if (currentScreen->availableGeometry().contains(position, false)) {
Expand All @@ -136,163 +153,79 @@ QScreen *getDisplay(QPoint position)
return QGuiApplication::primaryScreen();
}

static int runUnchecked(QApplication *app, const std::shared_ptr<ApplicationSettings> &settings
, BSTerminalSplashScreen &splashScreen, QLockFile &lockFile)
{
BSTerminalMainWindow mainWindow(settings, splashScreen, lockFile);

#if defined (Q_OS_MAC)
MacOsApp *macApp = (MacOsApp*)(app);

QObject::connect(macApp, &MacOsApp::reactivateTerminal, &mainWindow, &BSTerminalMainWindow::onReactivate);
#endif

if (!settings->get<bool>(ApplicationSettings::launchToTray)) {
mainWindow.loadPositionAndShow();
}

mainWindow.postSplashscreenActions();

bs::disableAppNap();

return app->exec();
}

static int runChecked(QApplication *app, const std::shared_ptr<ApplicationSettings> &settings
, BSTerminalSplashScreen &splashScreen, QLockFile &lockFile)
{
try {
return runUnchecked(app, settings, splashScreen, lockFile);
}
catch (const std::exception &e) {
std::cerr << "Failed to start BlockSettle Terminal: " << e.what() << std::endl;
BSMessageBox(BSMessageBox::critical, app->tr("BlockSettle Terminal")
, app->tr("Unhandled exception detected: %1").arg(QLatin1String(e.what()))).exec();
return EXIT_FAILURE;
}
}

static int GuiApp(int &argc, char** argv)
{
Q_INIT_RESOURCE(armory);
Q_INIT_RESOURCE(tradinghelp);
Q_INIT_RESOURCE(wallethelp);

QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

#if defined (Q_OS_MAC)
MacOsApp app(argc, argv);
#else
QApplication app(argc, argv);
#endif


QApplication::setQuitOnLastWindowClosed(false);

QFileInfo localStyleSheetFile(QLatin1String("stylesheet.css"));

QFile stylesheetFile(localStyleSheetFile.exists()
? localStyleSheetFile.fileName()
: QLatin1String(":/STYLESHEET"));

if (stylesheetFile.open(QFile::ReadOnly)) {
app.setStyleSheet(QString::fromLatin1(stylesheetFile.readAll()));
QPalette p = QApplication::palette();
p.setColor(QPalette::Disabled, QPalette::Light, QColor(10,22,25));
QApplication::setPalette(p);
}

#ifndef NDEBUG
// Start monitoring to update stylesheet live when file is changed on the disk
QTimer timer;
QObject::connect(&timer, &QTimer::timeout, &app, [&app] {
checkStyleSheet(app);
});
timer.start(100);
#endif

QDirIterator it(QLatin1String(":/resources/Raleway/"));
while (it.hasNext()) {
QFontDatabase::addApplicationFont(it.next());
}

QString location = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
#ifndef NDEBUG
QString userName = QDir::home().dirName();
QString lockFilePath = location + QLatin1String("/blocksettle-") + userName + QLatin1String(".lock");
#else
QString lockFilePath = location + QLatin1String("/blocksettle.lock");
#endif
QLockFile lockFile(lockFilePath);
lockFile.setStaleLockTime(0);

if (!lockFile.tryLock()) {
BSMessageBox box(BSMessageBox::info, app.tr("BlockSettle Terminal")
, app.tr("BlockSettle Terminal is already running")
, app.tr("Stop the other BlockSettle Terminal instance. If no other " \
"instance is running, delete the lockfile (%1).").arg(lockFilePath));
return box.exec();
}

qRegisterMetaType<ArmorySettings>();
qRegisterMetaType<AsyncClient::LedgerDelegate>();
qRegisterMetaType<BinaryData>();
qRegisterMetaType<bs::error::AuthAddressSubmitResult>();
qRegisterMetaType<bs::network::UserType>();
qRegisterMetaType<CelerAPI::CelerMessageType>();
qRegisterMetaType<QVector<int>>();
qRegisterMetaType<SecureBinaryData>();
qRegisterMetaType<std::shared_ptr<std::promise<bool>>>();
qRegisterMetaType<std::string>();
qRegisterMetaType<std::vector<BinaryData>>();
qRegisterMetaType<std::vector<UTXO>>();
qRegisterMetaType<UTXO>();

// load settings
auto settings = std::make_shared<ApplicationSettings>();
if (!settings->LoadApplicationSettings(app.arguments())) {
BSMessageBox errorMessage(BSMessageBox::critical, app.tr("Error")
, app.tr("Failed to parse command line arguments")
, settings->ErrorText());
errorMessage.exec();
return EXIT_FAILURE;
}

QString logoIcon;
logoIcon = QLatin1String(":/SPLASH_LOGO");

QPixmap splashLogo(logoIcon);
const int splashScreenWidth = 400;
BSTerminalSplashScreen splashScreen(splashLogo.scaledToWidth(splashScreenWidth, Qt::SmoothTransformation));

auto mainGeometry = settings->get<QRect>(ApplicationSettings::GUI_main_geometry);
auto currentDisplay = getDisplay(mainGeometry.center());
auto splashGeometry = splashScreen.geometry();
splashGeometry.moveCenter(currentDisplay->geometry().center());
splashScreen.setGeometry(splashGeometry);

app.processEvents();

#ifdef NDEBUG
return runChecked(&app, settings, splashScreen, lockFile);
#else
return runUnchecked(&app, settings, splashScreen, lockFile);
#endif
}

int main(int argc, char** argv)
{
srand(std::time(nullptr));

// Initialize libbtc, BIP 150, and BIP 151. 150 uses the proprietary "public"
// Armory setting designed to allow the ArmoryDB server to not have to verify
// clients. Prevents us from having to import tons of keys into the server.
btc_ecc_start();
CryptoECDSA::setupContext();
startupBIP151CTX();
startupBIP150CTX(4);

return GuiApp(argc, argv);
QStringList args;
for (int i = 0; i < argc; ++i) {
args << QLatin1String(argv[i]);
}
#ifdef NDEBUG
try {
#endif //NDEBUG
const auto &settings = std::make_shared<ApplicationSettings>(QLatin1Literal("BlockSettle Terminal")
, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ QDir::separator() + ApplicationSettings::appSubDir());
const auto &adSettings = std::make_shared<SettingsAdapter>(settings, args);
const auto &logMgr = adSettings->logManager();
spdlog::set_default_logger(logMgr->logger());

bs::message::TerminalInprocBus inprocBus(logMgr->logger());
inprocBus.addAdapter(adSettings);

const auto &apiAdapter = std::make_shared<ApiAdapter>(logMgr->logger("API"));
std::shared_ptr<ApiBusAdapter> guiAdapter;
if (adSettings->guiMode() == "qtwidgets") {
guiAdapter = std::make_shared<QtGuiAdapter>(logMgr->logger("ui"));
}
else if (adSettings->guiMode() == "qtquick") {
guiAdapter = std::make_shared<QtQuickAdapter>(logMgr->logger("ui"));
}
else {
throw std::runtime_error("unknown GUI mode " + adSettings->guiMode());
}
apiAdapter->add(guiAdapter);
apiAdapter->add(std::make_shared<ApiJsonAdapter>(logMgr->logger("json")));
inprocBus.addAdapter(apiAdapter);

const auto &signAdapter = std::make_shared<SignerAdapter>(logMgr->logger());
inprocBus.addAdapterWithQueue(signAdapter, "signer");

const auto& userBlockchain = bs::message::UserTerminal::create(bs::message::TerminalUsers::Blockchain);
const auto& userWallets = bs::message::UserTerminal::create(bs::message::TerminalUsers::Wallets);
//inprocBus.addAdapter(std::make_shared<AssetsAdapter>(logMgr->logger()));
inprocBus.addAdapterWithQueue(std::make_shared<WalletsAdapter>(logMgr->logger()
, userWallets, signAdapter->createClient(), userBlockchain), "wallets");
inprocBus.addAdapter(std::make_shared<BsServerAdapter>(logMgr->logger("bscon")));
//inprocBus.addAdapter(std::make_shared<MatchingAdapter>(logMgr->logger("match")));
//inprocBus.addAdapter(std::make_shared<SettlementAdapter>(logMgr->logger("settl")));
//inprocBus.addAdapter(std::make_shared<MktDataAdapter>(logMgr->logger("md")));
//inprocBus.addAdapter(std::make_shared<MDHistAdapter>(logMgr->logger("mdh")));
//inprocBus.addAdapter(std::make_shared<ChatAdapter>(logMgr->logger("chat")));
inprocBus.addAdapterWithQueue(std::make_shared<BlockchainAdapter>(logMgr->logger()
, userBlockchain), /*"blkchain_conn"*/"signer");

if (!inprocBus.run(argc, argv)) {
logMgr->logger()->error("No runnable adapter found on main inproc bus");
return EXIT_FAILURE;
}
#ifdef NDEBUG
}
catch (const std::exception &e) {
std::cerr << "Failed to start BlockSettle Terminal: " << e.what() << std::endl;
BSMessageBox(BSMessageBox::critical, QObject::tr("BlockSettle Terminal")
, QObject::tr("Unhandled exception detected: %1").arg(QLatin1String(e.what()))).exec();
return EXIT_FAILURE;
}
#endif //NDEBUG
}

#include "main.moc"
2 changes: 1 addition & 1 deletion BlockSettleHW/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
#
# ***********************************************************************************
# * Copyright (C) 2020 - 2020, BlockSettle AB
# * Copyright (C) 2020 - 2021, BlockSettle AB
# * Distributed under the GNU Affero General Public License (AGPL v3)
# * See LICENSE or http://www.gnu.org/licenses/agpl.html
# *
Expand Down
2 changes: 1 addition & 1 deletion BlockSettleHW/hwcommonstructure.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*

***********************************************************************************
* Copyright (C) 2020 - 2020, BlockSettle AB
* Copyright (C) 2020 - 2021, BlockSettle AB
* Distributed under the GNU Affero General Public License (AGPL v3)
* See LICENSE or http://www.gnu.org/licenses/agpl.html
*
Expand Down
Loading