Skip to content

Commit 9727cd2

Browse files
committed
Release 0.90.0
2 parents 7a6e4a8 + 6e01abb commit 9727cd2

17 files changed

+105
-83
lines changed

BlockSettleUILib/AuthAddressConfirmDialog.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ namespace {
2020
constexpr auto UiTimerInterval = std::chrono::milliseconds(250);
2121
}
2222

23-
AuthAddressConfirmDialog::AuthAddressConfirmDialog(BsClient *bsClient, const bs::Address& address
23+
AuthAddressConfirmDialog::AuthAddressConfirmDialog(const std::weak_ptr<BsClient> &bsClient, const bs::Address& address
2424
, const std::shared_ptr<AuthAddressManager>& authManager, const std::shared_ptr<ApplicationSettings> &settings, QWidget* parent)
25-
: QDialog(parent)
26-
, ui_{new Ui::AuthAddressConfirmDialog()}
27-
, address_{address}
28-
, authManager_{authManager}
29-
, bsClient_{bsClient}
25+
: QDialog(parent)
26+
, ui_{new Ui::AuthAddressConfirmDialog()}
27+
, address_{address}
28+
, authManager_{authManager}
3029
, settings_(settings)
30+
, bsClient_(bsClient)
3131
{
3232
ui_->setupUi(this);
3333

@@ -81,9 +81,12 @@ void AuthAddressConfirmDialog::onCancelPressed()
8181
void AuthAddressConfirmDialog::reject()
8282
{
8383
progressTimer_.stop();
84-
if (bsClient_) {
85-
bsClient_->cancelActiveSign();
84+
85+
auto bsClient = bsClient_.lock();
86+
if (bsClient) {
87+
bsClient->cancelActiveSign();
8688
}
89+
8790
QDialog::reject();
8891
}
8992

BlockSettleUILib/AuthAddressConfirmDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AuthAddressConfirmDialog : public QDialog
3131
Q_OBJECT
3232

3333
public:
34-
AuthAddressConfirmDialog(BsClient *bsClient,
34+
AuthAddressConfirmDialog(const std::weak_ptr<BsClient> &bsClient,
3535
const bs::Address& address,
3636
const std::shared_ptr<AuthAddressManager>& authManager,
3737
const std::shared_ptr<ApplicationSettings> &settings,
@@ -61,7 +61,7 @@ private slots:
6161
QTimer progressTimer_;
6262
std::chrono::steady_clock::time_point startTime_;
6363

64-
QPointer<BsClient> bsClient_;
64+
std::weak_ptr<BsClient> bsClient_;
6565
};
6666

6767
#endif // AUTH_ADDRESS_CONFIRMATION_DIALOG_H__

BlockSettleUILib/AuthAddressDialog.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void AuthAddressDialog::setAddressToVerify(const QString &addr)
212212
}
213213
}
214214

215-
void AuthAddressDialog::setBsClient(BsClient *bsClient)
215+
void AuthAddressDialog::setBsClient(const std::weak_ptr<BsClient> &bsClient)
216216
{
217217
bsClient_ = bsClient;
218218
}
@@ -329,6 +329,8 @@ void AuthAddressDialog::revokeSelectedAddress()
329329

330330
void AuthAddressDialog::onAuthAddressConfirmationRequired(float validationAmount)
331331
{
332+
auto bsClient = bsClient_.lock();
333+
332334
const bool testnet = settings_->get<NetworkType>(ApplicationSettings::netType) == NetworkType::TestNet;
333335
const auto eurBalance = assetManager_->getBalance("EUR");
334336
if (validationAmount > eurBalance) {
@@ -342,8 +344,8 @@ void AuthAddressDialog::onAuthAddressConfirmationRequired(float validationAmount
342344
warnFunds.enableRichText();
343345
warnFunds.exec();
344346

345-
if (bsClient_) {
346-
bsClient_->cancelActiveSign();
347+
if (bsClient) {
348+
bsClient->cancelActiveSign();
347349
}
348350
setLastSubmittedAddress({});
349351

@@ -376,16 +378,18 @@ void AuthAddressDialog::onAuthAddressConfirmationRequired(float validationAmount
376378
if (promptResult == QDialog::Accepted) {
377379
ConfirmAuthAddressSubmission();
378380
} else {
379-
if (bsClient_) {
380-
bsClient_->cancelActiveSign();
381+
if (bsClient) {
382+
bsClient->cancelActiveSign();
381383
}
382384
setLastSubmittedAddress({});
383385
}
384386
}
385387

386388
void AuthAddressDialog::ConfirmAuthAddressSubmission()
387389
{
388-
if (!bsClient_) {
390+
auto bsClient = bsClient_.lock();
391+
392+
if (!bsClient) {
389393
SPDLOG_LOGGER_ERROR(logger_, "bsClient_ in not set");
390394
return;
391395
}
@@ -394,7 +398,7 @@ void AuthAddressDialog::ConfirmAuthAddressSubmission()
394398
return;
395399
}
396400

397-
AuthAddressConfirmDialog confirmDlg{bsClient_.data(), lastSubmittedAddress_, authAddressManager_, settings_, this};
401+
AuthAddressConfirmDialog confirmDlg{bsClient_, lastSubmittedAddress_, authAddressManager_, settings_, this};
398402

399403
auto result = confirmDlg.exec();
400404

BlockSettleUILib/AuthAddressDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Q_OBJECT
4444
~AuthAddressDialog() override;
4545

4646
void setAddressToVerify(const QString &addr);
47-
void setBsClient(BsClient *bsClient);
47+
void setBsClient(const std::weak_ptr<BsClient> &bsClient);
4848

4949
signals:
5050
void askForConfirmation(const QString &address, double txAmount);
@@ -95,7 +95,7 @@ private slots:
9595
std::shared_ptr<ApplicationSettings> settings_;
9696
QPointer<AuthAdressControlProxyModel> model_;
9797
bs::Address defaultAddr_;
98-
QPointer<BsClient> bsClient_;
98+
std::weak_ptr<BsClient> bsClient_;
9999
ValidityFlag validityFlag_;
100100

101101
bs::Address lastSubmittedAddress_{};

BlockSettleUILib/BSTerminalMainWindow.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,21 @@ void BSTerminalMainWindow::onLoginProceed(const NetworkSettings &networkSettings
13971397
return;
13981398
}
13991399

1400-
LoginWindow loginDialog(logMgr_->logger("autheID"), applicationSettings_, &cbApprovePuB_, &cbApproveProxy_, this);
1400+
auto logger = logMgr_->logger("proxy");
1401+
1402+
BsClientParams params;
1403+
params.connectAddress = networkSettings.proxy.host;
1404+
params.connectPort = networkSettings.proxy.port;
1405+
params.context = std::make_shared<ZmqContext>(logger);
1406+
params.newServerKeyCallback = cbApproveProxy_;
1407+
1408+
auto bsClient = std::make_shared<BsClient>(logger, params);
1409+
1410+
// Must be connected before loginDialog.exec call (balances could be received before loginDialog.exec returns)!
1411+
connect(bsClient.get(), &BsClient::balanceLoaded, assetManager_.get(), &AssetManager::fxBalanceLoaded);
1412+
connect(bsClient.get(), &BsClient::balanceUpdated, assetManager_.get(), &AssetManager::onAccountBalanceLoaded);
1413+
1414+
LoginWindow loginDialog(logger, bsClient, applicationSettings_, this);
14011415

14021416
int rc = loginDialog.exec();
14031417

@@ -1442,15 +1456,15 @@ void BSTerminalMainWindow::onLoginProceed(const NetworkSettings &networkSettings
14421456

14431457
currentUserLogin_ = loginDialog.email();
14441458

1445-
networkSettingsReceived(loginDialog.networkSettings(), NetworkSettingsClient::MarketData);
1459+
networkSettingsReceived(networkSettings, NetworkSettingsClient::MarketData);
14461460

14471461
chatTokenData_ = loginDialog.result()->chatTokenData;
14481462
chatTokenSign_ = loginDialog.result()->chatTokenSign;
14491463
tryLoginIntoChat();
14501464

1451-
bsClient_ = loginDialog.getClient();
1452-
ccFileManager_->setBsClient(bsClient_.get());
1453-
authAddrDlg_->setBsClient(bsClient_.get());
1465+
bsClient_ = bsClient;
1466+
ccFileManager_->setBsClient(bsClient);
1467+
authAddrDlg_->setBsClient(bsClient);
14541468

14551469
ccFileManager_->setCcAddressesSigned(loginDialog.result()->ccAddressesSigned);
14561470
authManager_->setAuthAddressesSigned(loginDialog.result()->authAddressesSigned);

BlockSettleUILib/BSTerminalMainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private slots:
327327
};
328328
std::unique_ptr<MainWinACT> act_;
329329

330-
std::unique_ptr<BsClient> bsClient_;
330+
std::shared_ptr<BsClient> bsClient_;
331331

332332
Chat::ChatClientServicePtr chatClientServicePtr_;
333333

BlockSettleUILib/LoginWindow.cpp

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ namespace {
3535
}
3636

3737
LoginWindow::LoginWindow(const std::shared_ptr<spdlog::logger> &logger
38+
, const std::shared_ptr<BsClient> &bsClient
3839
, std::shared_ptr<ApplicationSettings> &settings
39-
, ZmqBipNewKeyCb *cbApprovePub
40-
, ZmqBipNewKeyCb *cbApproveProxy
4140
, QWidget* parent)
4241
: QDialog(parent)
4342
, ui_(new Ui::LoginWindow())
4443
, logger_(logger)
4544
, settings_(settings)
46-
, cbApprovePub_(cbApprovePub)
47-
, cbApproveProxy_(cbApproveProxy)
45+
, bsClient_(bsClient)
4846
{
4947
ui_->setupUi(this);
5048
ui_->progressBar->setMaximum(kAutheIdTimeout * 2); // update every 0.5 sec
@@ -95,6 +93,9 @@ LoginWindow::LoginWindow(const std::shared_ptr<spdlog::logger> &logger
9593
timer_.start();
9694

9795
updateState();
96+
97+
connect(bsClient_.get(), &BsClient::startLoginDone, this, &LoginWindow::onStartLoginDone);
98+
connect(bsClient_.get(), &BsClient::getLoginResultDone, this, &LoginWindow::onGetLoginResultDone);
9899
}
99100

100101
LoginWindow::~LoginWindow() = default;
@@ -126,16 +127,6 @@ QString LoginWindow::email() const
126127
return ui_->lineEditUsername->text().toLower();
127128
}
128129

129-
std::unique_ptr<BsClient> LoginWindow::getClient()
130-
{
131-
return std::move(bsClient_);
132-
}
133-
134-
const NetworkSettings &LoginWindow::networkSettings() const
135-
{
136-
return networkSettingsLoader_->settings();
137-
}
138-
139130
void LoginWindow::onStartLoginDone(AutheIDClient::ErrorType errorCode)
140131
{
141132
if (errorCode != AutheIDClient::NoError) {
@@ -226,34 +217,12 @@ void LoginWindow::onAuthPressed()
226217

227218
timeLeft_ = kAutheIdTimeout;
228219

229-
networkSettingsLoader_ = std::make_unique<NetworkSettingsLoader>(logger_
230-
, settings_->pubBridgeHost(), settings_->pubBridgePort(), *cbApprovePub_);
231-
232-
connect(networkSettingsLoader_.get(), &NetworkSettingsLoader::succeed, this, [this] {
233-
setState(WaitLoginResult);
234-
235-
QString login = ui_->lineEditUsername->text().trimmed();
236-
ui_->lineEditUsername->setText(login);
237-
238-
BsClientParams params;
239-
params.connectAddress = networkSettingsLoader_->settings().proxy.host;
240-
params.connectPort = networkSettingsLoader_->settings().proxy.port;
241-
params.context = std::make_shared<ZmqContext>(logger_);
242-
params.newServerKeyCallback = *cbApproveProxy_;
243-
244-
bsClient_ = std::make_unique<BsClient>(logger_, params);
245-
connect(bsClient_.get(), &BsClient::startLoginDone, this, &LoginWindow::onStartLoginDone);
246-
connect(bsClient_.get(), &BsClient::getLoginResultDone, this, &LoginWindow::onGetLoginResultDone);
247-
248-
bsClient_->startLogin(login.toStdString());
249-
});
220+
setState(WaitLoginResult);
250221

251-
connect(networkSettingsLoader_.get(), &NetworkSettingsLoader::failed, this, [this](const QString &errorMsg) {
252-
BSMessageBox(BSMessageBox::critical, tr("Network settings"), errorMsg, this).exec();
253-
setState(Idle);
254-
});
222+
QString login = ui_->lineEditUsername->text().trimmed();
223+
ui_->lineEditUsername->setText(login);
255224

256-
networkSettingsLoader_->loadSettings();
225+
bsClient_->startLogin(login.toStdString());
257226

258227
if (ui_->checkBoxRememberUsername->isChecked()) {
259228
settings_->set(ApplicationSettings::rememberLoginUserName, true);

BlockSettleUILib/LoginWindow.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <QDialog>
1616
#include <memory>
1717
#include "AutheIDClient.h"
18-
#include "ZMQ_BIP15X_Helpers.h"
1918

2019
namespace Ui {
2120
class LoginWindow;
@@ -28,7 +27,6 @@ struct BsClientLoginResult;
2827
struct NetworkSettings;
2928

3029
class ApplicationSettings;
31-
class NetworkSettingsLoader;
3230
class BsClient;
3331

3432
class LoginWindow : public QDialog
@@ -37,9 +35,8 @@ Q_OBJECT
3735

3836
public:
3937
LoginWindow(const std::shared_ptr<spdlog::logger> &logger
38+
, const std::shared_ptr<BsClient> &bsClient
4039
, std::shared_ptr<ApplicationSettings> &settings
41-
, ZmqBipNewKeyCb *cbApprovePub
42-
, ZmqBipNewKeyCb *cbApproveProxy
4340
, QWidget* parent = nullptr);
4441
~LoginWindow() override;
4542

@@ -51,8 +48,6 @@ Q_OBJECT
5148

5249
QString email() const;
5350
BsClientLoginResult *result() const { return result_.get(); }
54-
std::unique_ptr<BsClient> getClient();
55-
const NetworkSettings &networkSettings() const;
5651

5752
private slots:
5853
void onStartLoginDone(AutheIDClient::ErrorType errorCode);
@@ -73,14 +68,11 @@ private slots:
7368
std::unique_ptr<Ui::LoginWindow> ui_;
7469
std::shared_ptr<spdlog::logger> logger_;
7570
std::shared_ptr<ApplicationSettings> settings_;
76-
ZmqBipNewKeyCb *cbApprovePub_{};
77-
ZmqBipNewKeyCb *cbApproveProxy_{};
7871

7972
State state_{State::Idle};
8073
QTimer timer_;
8174
float timeLeft_{};
82-
std::unique_ptr<BsClient> bsClient_;
83-
std::unique_ptr<NetworkSettingsLoader> networkSettingsLoader_;
75+
std::shared_ptr<BsClient> bsClient_;
8476
std::unique_ptr<BsClientLoginResult> result_;
8577
};
8678

BlockSettleUILib/Trading/RFQDealerReply.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ void RFQDealerReply::submitReply(const bs::network::QuoteReqNotification &qrn, d
703703
const auto &spendWallet = isSpendCC ? ccWallet : xbtWallet;
704704
const auto &recvWallet = isSpendCC ? xbtWallet : ccWallet;
705705

706+
preparingCCRequest_.insert(replyData->qn.quoteRequestId);
706707
auto recvAddrCb = [this, replyData, qrn, spendWallet, spendVal, isSpendCC, ccWallet, xbtWallets, price](const bs::Address &addr) {
707708
replyData->qn.receiptAddress = addr.display();
708709
replyData->qn.reqAuthKey = qrn.requestorRecvAddress;
@@ -733,6 +734,10 @@ void RFQDealerReply::submitReply(const bs::network::QuoteReqNotification &qrn, d
733734
signingContainer_->resolvePublicSpenders(txReq, [replyData, this, price, txReq]
734735
(bs::error::ErrorCode result, const Codec_SignerState::SignerState &state)
735736
{
737+
if (preparingCCRequest_.count(replyData->qn.quoteRequestId) == 0) {
738+
return;
739+
}
740+
736741
if (result == bs::error::ErrorCode::NoError) {
737742
replyData->qn.transactionData = BinaryData::fromString(state.SerializeAsString()).toHexStr();
738743
replyData->utxoRes = utxoReservationManager_->makeNewReservation(txReq.inputs, replyData->qn.quoteRequestId);
@@ -742,6 +747,7 @@ void RFQDealerReply::submitReply(const bs::network::QuoteReqNotification &qrn, d
742747
SPDLOG_LOGGER_ERROR(logger_, "error resolving public spenders: {}"
743748
, bs::error::ErrorCodeToString(result).toStdString());
744749
}
750+
preparingCCRequest_.erase(replyData->qn.quoteRequestId);
745751
});
746752
} catch (const std::exception &e) {
747753
SPDLOG_LOGGER_ERROR(logger_, "error creating own unsigned half: {}", e.what());
@@ -1089,6 +1095,11 @@ void RFQDealerReply::onAutoSignStateChanged()
10891095
ui_->comboBoxXbtWallet->setEnabled(autoSignQuoteProvider_->autoSignState() == bs::error::ErrorCode::AutoSignDisabled);
10901096
}
10911097

1098+
void bs::ui::RFQDealerReply::onQuoteCancelled(const std::string &quoteId)
1099+
{
1100+
preparingCCRequest_.erase(quoteId);
1101+
}
1102+
10921103
void bs::ui::RFQDealerReply::onUTXOReservationChanged(const std::string& walletId)
10931104
{
10941105
if (walletId.empty()) {

BlockSettleUILib/Trading/RFQDealerReply.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ namespace bs {
130130
void onCelerConnected();
131131
void onCelerDisconnected();
132132
void onAutoSignStateChanged();
133+
void onQuoteCancelled(const std::string &quoteId);
133134

134135
private slots:
135136
void initUi();
@@ -199,6 +200,8 @@ namespace bs {
199200
ResetCurrentReservationCb resetCurrentReservationCb_;
200201
GetLastUTXOReplyCb getLastUTXOReplyCb_;
201202

203+
std::set<std::string> preparingCCRequest_;
204+
202205
private:
203206
enum class ReplyType
204207
{

0 commit comments

Comments
 (0)