Skip to content

Commit 640253f

Browse files
committed
Release 0.91.1
2 parents f590f28 + d995e45 commit 640253f

36 files changed

+494
-222
lines changed

BlockSettleSigner/SignerAdapter.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,8 @@ SignerAdapter::SignerAdapter(const std::shared_ptr<spdlog::logger> &logger
3636
, const std::shared_ptr<QmlBridge> &qmlBridge
3737
, const NetworkType netType
3838
, int signerPort, const BinaryData& inSrvIDKey)
39-
: QObject(nullptr)
40-
,logger_(logger)
41-
, netType_(netType)
42-
, qmlBridge_(qmlBridge)
39+
: SignerAdapter(logger, qmlBridge, netType, signerPort, SignerAdapter::instantiateAdapterConnection(logger, signerPort, inSrvIDKey))
4340
{
44-
auto adapterConn = instantiateAdapterConnection(logger, signerPort, inSrvIDKey);
45-
46-
listener_ = std::make_shared<SignerInterfaceListener>(logger, qmlBridge_, adapterConn, this);
47-
if (!adapterConn->openConnection(kLocalAddrV4, std::to_string(signerPort)
48-
, listener_.get())) {
49-
throw std::runtime_error("adapter connection failed");
50-
}
51-
signContainer_ = std::make_shared<SignAdapterContainer>(logger_, listener_);
5241
}
5342

5443
SignerAdapter::SignerAdapter(const std::shared_ptr<spdlog::logger> &logger

BlockSettleSigner/SignerAdapter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#ifndef SIGNER_ADAPTER_H
1212
#define SIGNER_ADAPTER_H
1313

14-
#include <memory>
15-
#include <QObject>
1614

1715
#include "BSErrorCode.h"
1816
#include "CoreWallet.h"
@@ -23,6 +21,9 @@
2321

2422
#include "bs_signer.pb.h"
2523

24+
#include <QObject>
25+
26+
#include <memory>
2627

2728
namespace bs {
2829
namespace sync {
@@ -160,7 +161,6 @@ class SignerAdapter : public QObject
160161
bool closeHeadless_{true};
161162

162163
QString headlessPubKey_;
163-
164164
};
165165

166166

BlockSettleSigner/SignerAdapterContainer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ class SignAdapterContainer : public WalletSignerContainer
7777
, const std::vector<bs::wallet::PasswordData>& = {}
7878
, bs::sync::PasswordDialogData = {}, const CreateHDLeafCb & = nullptr) override { return false; }
7979

80-
bool promoteHDWallet(const std::string &, const BinaryData &
81-
, bs::sync::PasswordDialogData = {}, const PromoteHDWalletCb& = nullptr) override { return false; }
80+
bool enableTradingInHDWallet(const std::string &, const BinaryData &
81+
, bs::sync::PasswordDialogData = {}, const UpdateWalletStructureCB& = nullptr) override { return false; }
82+
83+
bool promoteWalletToPrimary(const std::string& rootWalletId
84+
, bs::sync::PasswordDialogData dialogData = {}, const UpdateWalletStructureCB& cb = nullptr) override { return false; }
8285

8386
bs::signer::RequestId DeleteHDRoot(const std::string &rootWalletId) override;
8487
bs::signer::RequestId DeleteHDLeaf(const std::string &) override { return 0; }

BlockSettleSigner/SignerAdapterListener.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ bool SignerAdapterListener::onSyncHDWallet(const std::string &data, bs::signer::
399399
auto groupEntry = response.add_groups();
400400
groupEntry->set_type(static_cast<bs::hd::CoinType>(group->index()));
401401

402-
for (const auto &leaf : group->getLeaves()) {
402+
for (const auto &leaf : group->getAllLeaves()) {
403403
auto leafEntry = groupEntry->add_leaves();
404404
leafEntry->set_id(leaf->walletId());
405405
leafEntry->set_path(leaf->path().toString());
@@ -472,7 +472,7 @@ bool SignerAdapterListener::sendWoWallet(const std::shared_ptr<bs::core::hd::Wal
472472
for (const auto &group : wallet->getGroups()) {
473473
auto groupEntry = response.add_groups();
474474
groupEntry->set_type(group->index());
475-
for (const auto &leaf : group->getLeaves()) {
475+
for (const auto &leaf : group->getAllLeaves()) {
476476
auto leafEntry = groupEntry->add_leaves();
477477
leafEntry->set_id(leaf->walletId());
478478
leafEntry->set_path(leaf->path().toString());
@@ -1036,8 +1036,8 @@ bs::error::ErrorCode SignerAdapterListener::verifyOfflineSignRequest(const bs::c
10361036
size_t foundInputCount = 0;
10371037
auto checkAddress = [](const bs::core::WalletsManager::WalletPtr& wallet,
10381038
bs::Address addr) {
1039-
return wallet->addressType() == addr.getType() ||
1040-
(addr.getType() == AddressEntryType_P2SH && (wallet->addressType() & addr.getType()));
1039+
return wallet->defaultAddressType() == addr.getType() ||
1040+
(addr.getType() == AddressEntryType_P2SH && (wallet->defaultAddressType() & addr.getType()));
10411041
};
10421042

10431043
for (const auto &walletId : txSignReq.walletIds) { // sync new addresses in all wallets

BlockSettleSigner/SignerInterfaceListener.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void SignerInterfaceListener::processData(const std::string &data)
8484
{
8585
signer::Packet packet;
8686
if (!packet.ParseFromString(data)) {
87-
logger_->error("[SignerInterfaceListener::{}] failed to parse packet", __func__);
87+
logger_->error("[SignerInterfaceListener::processData] failed to parse packet");
8888
return;
8989
}
9090
/* if (packet.data().empty()) {
@@ -101,7 +101,7 @@ void SignerInterfaceListener::processData(const std::string &data)
101101
onPeerConnected(packet.data());
102102
break;
103103
case signer::PeerDisconnectedType:
104-
onPeerConnected(packet.data());
104+
onPeerDisconnected(packet.data());
105105
break;
106106
case signer::DecryptWalletRequestType:
107107
onDecryptWalletRequested(packet.data());
@@ -177,7 +177,7 @@ void SignerInterfaceListener::processData(const std::string &data)
177177
onVerifyOfflineTxRequest(packet.data(), packet.id());
178178
break;
179179
default:
180-
logger_->warn("[SignerInterfaceListener::{}] unknown response type {}", __func__, packet.type());
180+
logger_->warn("[SignerInterfaceListener::processData] unknown response type {}", packet.type());
181181
break;
182182
}
183183
}
@@ -192,7 +192,7 @@ void SignerInterfaceListener::onPeerConnected(const std::string &data)
192192
{
193193
signer::ClientConnected evt;
194194
if (!evt.ParseFromString(data)) {
195-
logger_->error("[SignerInterfaceListener::{}] failed to parse", __func__);
195+
logger_->error("[SignerInterfaceListener::onPeerConnected] failed to parse");
196196
return;
197197
}
198198
emit parent_->peerConnected(evt.client_id(), evt.ip_address(), evt.public_key());
@@ -202,7 +202,7 @@ void SignerInterfaceListener::onPeerDisconnected(const std::string &data)
202202
{
203203
signer::ClientDisconnected evt;
204204
if (!evt.ParseFromString(data)) {
205-
logger_->error("[SignerInterfaceListener::{}] failed to parse", __func__);
205+
logger_->error("[SignerInterfaceListener::onPeerDisconnected] failed to parse");
206206
return;
207207
}
208208
emit parent_->peerDisconnected(evt.client_id());
@@ -219,7 +219,7 @@ void SignerInterfaceListener::onDecryptWalletRequested(const std::string &data)
219219

220220
signer::DecryptWalletRequest request;
221221
if (!request.ParseFromString(data)) {
222-
logger_->error("[SignerInterfaceListener::{}] failed to parse", __func__);
222+
logger_->error("[SignerInterfaceListener::onDecryptWalletRequested] failed to parse");
223223
return;
224224
}
225225

@@ -277,8 +277,11 @@ void SignerInterfaceListener::onDecryptWalletRequested(const std::string &data)
277277
dialogData->setValue(PasswordDialogData::Title, tr("Revoke Authentication Address"));
278278
requestPasswordForDialogType(ui::PasswordInputDialogType::RequestPasswordForRevokeAuthAddress, dialogData, walletInfo);
279279
break;
280-
case signer::PromoteHDWallet:
281-
requestPasswordForDialogType(ui::PasswordInputDialogType::RequestPasswordForPromoteHDWallet, dialogData, walletInfo);
280+
case signer::EnableTrading:
281+
requestPasswordForDialogType(ui::PasswordInputDialogType::RequestPasswordForEnableTrading, dialogData, walletInfo);
282+
break;
283+
case signer::PromoteToPrimary:
284+
requestPasswordForDialogType(ui::PasswordInputDialogType::RequestPasswordForPromoteWallet, dialogData, walletInfo);
282285
break;
283286
default:
284287
break;

BlockSettleSigner/main.cpp

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,49 @@
88
**********************************************************************************
99
1010
*/
11-
#include <QApplication>
12-
#include <QIcon>
13-
#include <QStyleFactory>
14-
#include <QtPlugin>
15-
#include <QtGui/QGuiApplication>
16-
#include <QtQml/QQmlApplicationEngine>
17-
#include <QtQuickControls2/QQuickStyle>
18-
#include <QSplashScreen>
19-
#include <QTimer>
20-
#include <QFileInfo>
21-
#include <QStandardPaths>
22-
#include <QDir>
23-
#include <QFontDatabase>
24-
#include <QQmlContext>
25-
#include <QQuickWindow>
26-
#include <QtPlatformHeaders/QWindowsWindowFunctions>
27-
28-
#include <btc/ecc.h>
29-
#include <iostream>
30-
#include <thread>
31-
#include <spdlog/spdlog.h>
32-
#include <spdlog/sinks/basic_file_sink.h>
33-
#include <spdlog/sinks/stdout_sinks.h>
34-
35-
#include "BIP150_151.h"
11+
#include "AppNap.h"
3612
#include "AuthorizedPeers.h"
13+
#include "BIP150_151.h"
14+
#include "Bip15xDataConnection.h"
15+
#include "BIP15xHelpers.h"
3716
#include "DispatchQueue.h"
3817
#include "HeadlessApp.h"
39-
#include "Settings/HeadlessSettings.h"
4018
#include "LogManager.h"
19+
#include "QMLApp.h"
20+
#include "QmlBridge.h"
21+
#include "Settings/HeadlessSettings.h"
22+
#include "Settings/SignerSettings.h"
4123
#include "SignalsHandler.h"
4224
#include "SignerAdapter.h"
43-
#include "Settings/SignerSettings.h"
4425
#include "SystemFileUtils.h"
45-
#include "BIP15xHelpers.h"
46-
#include "Bip15xDataConnection.h"
4726
#include "TransportBIP15x.h"
4827
#include "TransportBIP15xServer.h"
4928

50-
#include "QMLApp.h"
51-
#include "QmlBridge.h"
29+
#include <QApplication>
30+
#include <QDir>
31+
#include <QFileInfo>
32+
#include <QFontDatabase>
33+
#include <QIcon>
34+
#include <QQmlContext>
35+
#include <QQuickWindow>
36+
#include <QSplashScreen>
37+
#include <QStandardPaths>
38+
#include <QStyleFactory>
39+
#include <QtGui/QGuiApplication>
40+
#include <QTimer>
41+
#include <QtPlatformHeaders/QWindowsWindowFunctions>
42+
#include <QtPlugin>
43+
#include <QtQml/QQmlApplicationEngine>
44+
#include <QtQuickControls2/QQuickStyle>
5245

53-
#include "AppNap.h"
46+
#include <iostream>
47+
#include <thread>
48+
49+
#include <btc/ecc.h>
50+
51+
#include <spdlog/sinks/basic_file_sink.h>
52+
#include <spdlog/sinks/stdout_sinks.h>
53+
#include <spdlog/spdlog.h>
5454

5555
Q_DECLARE_METATYPE(std::string)
5656
Q_DECLARE_METATYPE(std::vector<BinaryData>)
@@ -290,6 +290,10 @@ static int QMLApp(int argc, char **argv
290290
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
291291
engine.rootContext()->setContextProperty(QStringLiteral("fixedFont"), fixedFont);
292292

293+
QTimer terminalConnectionTimer;
294+
bool terminalConnected = false;
295+
bool timerStarted = false;
296+
293297
try {
294298
//setup signer's own GUI connection
295299
auto guiSrvParams = queue.getGuiServerParams();
@@ -306,7 +310,7 @@ static int QMLApp(int argc, char **argv
306310
{
307311
std::string clientID = "127.0.0.1:" + std::to_string(guiPort);
308312

309-
auto adapterBip15x =
313+
auto adapterBip15x =
310314
std::dynamic_pointer_cast<Bip15xDataConnection>(adapterConn);
311315
if (adapterBip15x == nullptr) {
312316
throw std::runtime_error("unexpected adapter connection type");
@@ -322,14 +326,39 @@ static int QMLApp(int argc, char **argv
322326
adapter.setCloseHeadless(settings->closeHeadless());
323327

324328
QMLAppObj qmlAppObj(&adapter, logger, settings, splashScreen, engine.rootContext());
325-
QTimer::singleShot(0, &qmlAppObj, &QMLAppObj::Start);
326329

327330
switch (settings->runMode()) {
328331
case bs::signer::ui::RunMode::fullgui:
329332
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
330333
break;
331334
case bs::signer::ui::RunMode::litegui:
332335
engine.load(QUrl(QStringLiteral("qrc:/qml/mainLite.qml")));
336+
337+
terminalConnectionTimer.setSingleShot(true);
338+
//BST-2786
339+
terminalConnectionTimer.setInterval(std::chrono::milliseconds{ 5000 });
340+
341+
QObject::connect(&adapter, &SignerAdapter::ready, [&timerStarted, &terminalConnectionTimer]()
342+
{
343+
if (!timerStarted) {
344+
terminalConnectionTimer.start();
345+
timerStarted = true;
346+
}
347+
});
348+
349+
350+
QObject::connect(&adapter, &SignerAdapter::peerConnected, [&terminalConnected] {
351+
terminalConnected = true;
352+
});
353+
QObject::connect(&adapter, &SignerAdapter::peerDisconnected, [&terminalConnected] {
354+
terminalConnected = false;
355+
});
356+
QObject::connect(&terminalConnectionTimer, &QTimer::timeout, [&terminalConnected] {
357+
if (!terminalConnected) {
358+
QCoreApplication::quit();
359+
}
360+
});
361+
333362
break;
334363
default:
335364
return EXIT_FAILURE;
@@ -343,6 +372,8 @@ static int QMLApp(int argc, char **argv
343372

344373
bs::disableAppNap();
345374

375+
QTimer::singleShot(0, &qmlAppObj, &QMLAppObj::Start);
376+
346377
QObject::connect(&qmlAppObj, &QMLAppObj::qmlAppStarted, [&queue](){
347378
queue.start();
348379
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
3+
***********************************************************************************
4+
* Copyright (C) 2018 - 2020, BlockSettle AB
5+
* Distributed under the GNU Affero General Public License (AGPL v3)
6+
* See LICENSE or http://www.gnu.org/licenses/agpl.html
7+
*
8+
**********************************************************************************
9+
10+
*/
11+
import QtQuick 2.12
12+
import QtQuick.Controls 2.5
13+
import QtQuick.Layouts 1.12
14+
15+
import com.blocksettle.AutheIDClient 1.0
16+
import com.blocksettle.PasswordDialogData 1.0
17+
import com.blocksettle.WalletInfo 1.0
18+
19+
import "../StyledControls"
20+
import "../BsStyles"
21+
22+
BSPasswordInput {
23+
id: root
24+
25+
property WalletInfo walletInfo: WalletInfo{}
26+
property PasswordDialogData passwordDialogData: PasswordDialogData {}
27+
28+
title: passwordDialogData.Title
29+
autheIDSignType: AutheIDClient.EnableTrading
30+
31+
CustomHeader {
32+
text: qsTr("Wallet Details")
33+
Layout.fillWidth: true
34+
Layout.preferredHeight: 25
35+
Layout.topMargin: 5
36+
Layout.leftMargin: 10
37+
Layout.rightMargin: 10
38+
}
39+
40+
RowLayout {
41+
spacing: 5
42+
Layout.topMargin: 5
43+
Layout.fillWidth: true
44+
Layout.leftMargin: 10
45+
Layout.rightMargin: 10
46+
47+
CustomLabel {
48+
Layout.minimumWidth: 110
49+
Layout.preferredWidth: 110
50+
Layout.maximumWidth: 110
51+
Layout.fillWidth: true
52+
text: qsTr("Wallet name")
53+
}
54+
CustomLabel {
55+
Layout.fillWidth: true
56+
Layout.preferredWidth: 110
57+
text: walletInfo.name
58+
}
59+
}
60+
61+
RowLayout {
62+
spacing: 5
63+
Layout.fillWidth: true
64+
Layout.leftMargin: 10
65+
Layout.rightMargin: 10
66+
67+
CustomLabel {
68+
Layout.minimumWidth: 110
69+
Layout.preferredWidth: 110
70+
Layout.maximumWidth: 110
71+
Layout.fillWidth: true
72+
text: qsTr("Wallet ID")
73+
}
74+
CustomLabel {
75+
Layout.fillWidth: true
76+
text: walletInfo.walletId
77+
}
78+
}
79+
}
80+

BlockSettleSigner/qml/BsControls/qmldir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ BSConfirmedPasswordInput 1.0 BSConfirmedPasswordInput.qml
1212
BSPasswordInputToken 1.0 BSPasswordInputToken.qml
1313
BSPasswordInputAuthLeaf 1.0 BSPasswordInputAuthLeaf.qml
1414
BSPasswordInputSettlementLeaf 1.0 BSPasswordInputSettlementLeaf.qml
15+
BSPasswordInputEnableTrading 1.0 BSPasswordInputEnableTrading.qml
1516
BSPasswordInputPromoteWallet 1.0 BSPasswordInputPromoteWallet.qml
1617
BSPasswordInputAutoSignDialog 1.0 BSPasswordInputAutoSignDialog.qml
1718
BSPasswordInputRevokeAuthAddress 1.0 BSPasswordInputRevokeAuthAddress.qml

0 commit comments

Comments
 (0)