Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BlockSettleApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ 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}
Expand Down
38 changes: 32 additions & 6 deletions BlockSettleApp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
#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"
Expand All @@ -55,6 +56,23 @@ Q_IMPORT_PLUGIN(QCupsPrinterSupportPlugin)
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)
Expand Down Expand Up @@ -158,13 +176,22 @@ int main(int argc, char** argv)
+ 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"));
const auto &guiAdapter = std::make_shared<QtGuiAdapter>(logMgr->logger("ui"));
//const auto& guiAdapter = std::make_shared<QtQuickAdapter>(logMgr->logger("ui"));
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);
Expand All @@ -174,18 +201,17 @@ int main(int argc, char** argv)

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.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");
, userBlockchain), /*"blkchain_conn"*/"signer");

if (!inprocBus.run(argc, argv)) {
logMgr->logger()->error("No runnable adapter found on main inproc bus");
Expand Down
25 changes: 0 additions & 25 deletions BlockSettleUILib/AddressListModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,6 @@ bool AddressListModel::AddressRow::operator==(const AddressRow& other) const
isExternal == other.isExternal;
}

AddressListModel::AddressListModel(const std::shared_ptr<bs::sync::WalletsManager> &walletsMgr
, QObject* parent, AddressType addrType)
: QAbstractTableModel(parent)
, walletsMgr_(walletsMgr)
, addrType_(addrType)
, processing_(false)
{
if (walletsMgr_) {
connect(walletsMgr_.get(), &bs::sync::WalletsManager::walletsReady, this
, &AddressListModel::updateWallets);
connect(walletsMgr_.get(), &bs::sync::WalletsManager::walletChanged, this
, &AddressListModel::updateWallets);
connect(walletsMgr_.get(), &bs::sync::WalletsManager::blockchainEvent, this
, &AddressListModel::updateWallets);
connect(walletsMgr_.get(), &bs::sync::WalletsManager::walletBalanceUpdated
, this, &AddressListModel::updateWallets);
}
}

AddressListModel::AddressListModel(QObject* parent, AddressType addrType)
: QAbstractTableModel(parent)
, addrType_(addrType)
Expand Down Expand Up @@ -282,9 +263,6 @@ void AddressListModel::onAddressComments(const std::string &
void AddressListModel::onAddressBalances(const std::string &walletId
, const std::vector<bs::sync::WalletBalanceData::AddressBalance> &balances)
{
if (balances.empty()) {
return;
}
const auto &lbdSaveBalToPool = [this, walletId, balances]
{
auto &walletBal = pooledBalances_[walletId];
Expand Down Expand Up @@ -318,9 +296,6 @@ void AddressListModel::onAddressBalances(const std::string &walletId
addressRows_[itAddr->second].balance = bal.balTotal;
addressRows_[itAddr->second].transactionCount = bal.txn;
}
if (!nbFound) {
return;
}
for (auto &addrRow : addressRows_) {
if ((addrRow.balance > 0) || (addrRow.transactionCount > 0)) {
continue;
Expand Down
2 changes: 0 additions & 2 deletions BlockSettleUILib/AddressListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class AddressListModel : public QAbstractTableModel

typedef std::vector<bs::sync::WalletInfo> Wallets;

[[deprecated]] AddressListModel(const std::shared_ptr<bs::sync::WalletsManager> &, QObject* parent
, AddressType addrType = AddressType::All);
AddressListModel(QObject* parent, AddressType addrType = AddressType::All);
~AddressListModel() noexcept = default;

Expand Down
59 changes: 33 additions & 26 deletions BlockSettleUILib/CreateTransactionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void CreateTransactionDialog::init()
xbtValidator_ = new XbtAmountValidator(this);
lineEditAmount()->setValidator(xbtValidator_);

populateWalletsList();
emit needWalletsList(UiUtils::WalletsTypes::All_AllowHwLegacy, "CreateTX");
if (loadFeeSuggestions_) {
populateFeeList();
}
Expand Down Expand Up @@ -170,42 +170,29 @@ int CreateTransactionDialog::SelectWallet(const std::string& walletId, UiUtils::

void CreateTransactionDialog::populateWalletsList()
{
emit needWalletsList(UiUtils::WalletsTypes::All_AllowHwLegacy, "CreateTX");
}

void CreateTransactionDialog::onWalletsList(const std::string &id
, const std::vector<bs::sync::HDWalletData>& hdWallets)
{
if (id != "CreateTX") {
return;
}
int selected = 0;
auto comboBox = comboBoxWallets();
comboBox->clear();

const auto &addRow = [comboBox, this]
(const std::string& label, const std::string& walletId, UiUtils::WalletsTypes type)
const auto& addRow = [comboBox, this]
(const std::string& label, const std::string& walletId, UiUtils::WalletsTypes type)
{
bool blocked = comboBox->blockSignals(true);
int i = comboBox->count();
logger_->debug("[CreateTransactionDialog::onWalletsList::addRow] #{}: {}", i, walletId);
comboBox->addItem(QString::fromStdString(label));
comboBox->setItemData(i, QString::fromStdString(walletId), UiUtils::WalletIdRole);
comboBox->setItemData(i, QVariant::fromValue(static_cast<int>(type)), UiUtils::WalletType);
logger_->debug("[CreateTransactionDialog::onWalletsList::addRow] {} #{} get: {}", i, (void*)comboBox, comboBox->itemData(i, UiUtils::WalletIdRole).toString().toStdString());
comboBox->blockSignals(blocked);
};

hdWallets_.clear();
for (const auto& hdWallet : hdWallets) {
hdWallets_[hdWallet.id] = hdWallet;
if (hdWallet.primary) {
for (const auto& hdWallet : hdWallets_) {
if (hdWallet.second.primary) {
selected = comboBox->count();
}
UiUtils::WalletsTypes type = UiUtils::WalletsTypes::None;
if ((hdWallet.groups.size() == 1) && (hdWallet.groups[0].leaves.size() == 1)) {
const auto& leaf = hdWallet.groups[0].leaves.at(0);
std::string label = hdWallet.name;
if ((hdWallet.second.groups.size() == 1) && (hdWallet.second.groups[0].leaves.size() == 1)) {
const auto& leaf = hdWallet.second.groups[0].leaves.at(0);
std::string label = hdWallet.second.name;
const auto purpose = static_cast<bs::hd::Purpose>(leaf.path.get(0) & ~bs::hd::hardFlag);
if (purpose == bs::hd::Purpose::Native) {
label += " Native";
Expand All @@ -217,21 +204,41 @@ void CreateTransactionDialog::onWalletsList(const std::string &id
label += " Legacy";
type = UiUtils::WalletsTypes::HardwareLegacy;
}
addRow(label, hdWallet.id, type);
}
else {
if (hdWallet.offline) {
addRow(label, hdWallet.second.id, type);
} else {
if (hdWallet.second.offline) {
type = UiUtils::WalletsTypes::WatchOnly;
} else {
type = UiUtils::WalletsTypes::Full;
}
addRow(hdWallet.name, hdWallet.id, type);
addRow(hdWallet.second.name, hdWallet.second.id, type);
}
}
comboBox->setCurrentIndex(selected);
selectedWalletChanged(selected, true);
}

void CreateTransactionDialog::onWalletsList(const std::string &id
, const std::vector<bs::sync::HDWalletData>& hdWallets)
{
if (id != "CreateTX") {
return;
}

hdWallets_.clear();
for (const auto& hdWallet : hdWallets) {
hdWallets_[hdWallet.id] = hdWallet;
}
populateWalletsList();
}

void CreateTransactionDialog::onWalletDeleted(const bs::sync::WalletInfo& wi)
{
const auto& rootId = *wi.ids.cbegin();
hdWallets_.erase(rootId);
populateWalletsList();
}

void CreateTransactionDialog::onFeeLevels(const std::map<unsigned int, float>& feeLevels)
{
comboBoxFeeSuggestions()->clear();
Expand Down
3 changes: 2 additions & 1 deletion BlockSettleUILib/CreateTransactionDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Q_OBJECT
virtual void onChangeAddress(const std::string& walletId, const bs::Address&);

virtual void onWalletsList(const std::string &id, const std::vector<bs::sync::HDWalletData>&);
virtual void onWalletDeleted(const bs::sync::WalletInfo&);
void onFeeLevels(const std::map<unsigned int, float>&);
void onUTXOs(const std::string& id, const std::string& walletId, const std::vector<UTXO>&);
void onSignedTX(const std::string& id, BinaryData signedTX, bs::error::ErrorCode result);
Expand Down Expand Up @@ -152,13 +153,13 @@ protected slots:

protected:
void populateFeeList();
void populateWalletsList();

bool createTransactionImpl();

static bool canUseSimpleMode(const Bip21::PaymentRequestInfo& paymentInfo);

private:
void populateWalletsList();
void startBroadcasting();
void stopBroadcasting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ static inline QString encTypeToString(bs::wallet::EncryptionType enc)
case bs::wallet::EncryptionType::Hardware :
return QObject::tr("Hardware Security Module");
};

//no default entry in switch statment nor default return value
return QObject::tr("Unknown");
}

void RootWalletPropertiesDialog::onHDWalletInfo(unsigned int id, const bs::hd::WalletInfo &walletInfo)
Expand Down
24 changes: 2 additions & 22 deletions BlockSettleUILib/SelectAddressDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@
#include "Wallets/SyncWalletsManager.h"


SelectAddressDialog::SelectAddressDialog(const std::shared_ptr<bs::sync::WalletsManager> &walletsManager
, const std::shared_ptr<bs::sync::Wallet>& wallet
, QWidget* parent, AddressListModel::AddressType addrType)
: QDialog(parent)
, ui_(new Ui::SelectAddressDialog)
, wallets_({ wallet })
, walletsMgr_(walletsManager)
, addrType_(addrType)
{
init();
}

SelectAddressDialog::SelectAddressDialog(const std::shared_ptr<bs::sync::hd::Group> &group
, QWidget* parent, AddressListModel::AddressType addrType)
: QDialog(parent)
, ui_(new Ui::SelectAddressDialog)
, wallets_(group->getAllLeaves())
, addrType_(addrType)
{
init();
}

SelectAddressDialog::SelectAddressDialog(QWidget* parent
, AddressListModel::AddressType addrType)
: QDialog(parent)
Expand Down Expand Up @@ -89,6 +67,7 @@ void SelectAddressDialog::onAddressBalances(const std::string& walletId
model_->onAddressBalances(walletId, addrBal);
}

#if 0
void SelectAddressDialog::init()
{
ui_->setupUi(this);
Expand All @@ -112,6 +91,7 @@ void SelectAddressDialog::init()

onSelectionChanged();
}
#endif //0

bs::Address SelectAddressDialog::getAddress(const QModelIndex& index) const
{
Expand Down
6 changes: 0 additions & 6 deletions BlockSettleUILib/SelectAddressDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class SelectAddressDialog : public QDialog
Q_OBJECT

public:
[[deprecated]] SelectAddressDialog(const std::shared_ptr<bs::sync::WalletsManager> &
, const std::shared_ptr<bs::sync::Wallet> &, QWidget* parent = nullptr
, AddressListModel::AddressType addrType = AddressListModel::AddressType::All);
[[deprecated]] SelectAddressDialog(const std::shared_ptr<bs::sync::hd::Group> &, QWidget* parent = nullptr
, AddressListModel::AddressType addrType = AddressListModel::AddressType::All);
SelectAddressDialog(QWidget* parent
, AddressListModel::AddressType addrType = AddressListModel::AddressType::All);
~SelectAddressDialog() override;
Expand All @@ -64,7 +59,6 @@ public slots:
void onDoubleClicked(const QModelIndex& index);

private:
[[deprecated]] void init();
bs::Address getAddress(const QModelIndex& index) const;

private:
Expand Down
Loading