Skip to content

Commit 7a6e4a8

Browse files
committed
Release 0.89.5
2 parents e07fd64 + 6fce6eb commit 7a6e4a8

File tree

16 files changed

+328
-113
lines changed

16 files changed

+328
-113
lines changed

BlockSettleSigner/SignerAdapterListener.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ bool SignerAdapterListener::onImportWoWallet(const std::string &data, bs::signer
838838
}
839839
}
840840

841+
const std::string filePath = settings_->getWalletsDir() + "/" + request.filename();
841842
{
842-
const std::string filePath = settings_->getWalletsDir() + "/" + request.filename();
843843
std::ofstream ofs(filePath, std::ios::out | std::ios::binary | std::ios::trunc);
844844
if (!ofs.good()) {
845845
logger_->error("[{}] failed to write to {}", __func__, filePath);
@@ -851,6 +851,7 @@ bool SignerAdapterListener::onImportWoWallet(const std::string &data, bs::signer
851851
const auto woWallet = walletsMgr_->loadWoWallet(settings_->netType()
852852
, settings_->getWalletsDir(), request.filename(), app_->controlPassword());
853853
if (!woWallet) {
854+
SystemFileUtils::rmFile(filePath);
854855
return false;
855856
}
856857
walletsListUpdated();

BlockSettleSigner/TXInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool TXInfo::loadSignedTx(const QString &fileName)
128128
SPDLOG_LOGGER_ERROR(logger_, "loading signed offline request failed from '{}'", fileName.toStdString());
129129
return false;
130130
}
131-
if (loadedTxs.size() != 1 || loadedTxs.front().prevStates.size() != 1) {
131+
if (loadedTxs.size() != 1) {
132132
SPDLOG_LOGGER_ERROR(logger_, "invalid signed offline request in '{}'", fileName.toStdString());
133133
return false;
134134
}

BlockSettleSigner/WalletsProxy.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void WalletsProxy::exportWatchingOnly(const QString &walletId, const QString &fi
242242

243243
if (isHw) {
244244
try {
245-
bs::core::hd::Wallet wallet(filePath.toStdString(), NetworkType::TestNet);
245+
bs::core::hd::Wallet wallet(filePath.toStdString(), adapter_->netType());
246246
wallet.convertHardwareToWo();
247247
} catch (const std::exception &e) {
248248
SPDLOG_LOGGER_ERROR(logger_, "converting HW to WO wallet failed: {}", e.what());
@@ -766,6 +766,27 @@ void WalletsProxy::importWoWallet(const QString &walletPath, const QJSValue &jsC
766766

767767
QFileInfo fi(walletPath);
768768

769+
try {
770+
const auto wallet = std::make_shared<bs::core::hd::Wallet>(fi.fileName().toStdString()
771+
, adapter_->netType(), fi.path().toStdString(), SecureBinaryData(), logger_);
772+
if (wallet->networkType() != adapter_->netType()) {
773+
SPDLOG_LOGGER_ERROR(logger_, "invalid net type in WO file: {}, expected: {}"
774+
, static_cast<int>(wallet->networkType()), static_cast<int>(adapter_->netType()));
775+
if (adapter_->netType() == NetworkType::MainNet) {
776+
errWallet.description = "Can not import testnet WO wallet";
777+
} else {
778+
errWallet.description = "Can not import mainnet WO wallet";
779+
}
780+
cb(errWallet);
781+
return;
782+
}
783+
} catch (const std::exception &e) {
784+
SPDLOG_LOGGER_ERROR(logger_, "loading WO wallet failed: {}", e.what());
785+
errWallet.description = fmt::format("Loading WO wallet failed: {}", e.what());
786+
cb(errWallet);
787+
return;
788+
}
789+
769790
adapter_->importWoWallet(fi.fileName().toStdString(), content, cb);
770791
}
771792

BlockSettleSigner/qml/BsDialogs/TxSignSettlementBaseDialog.qml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ CustomTitleDialogWindowWithExpander {
6161
property alias txDetailsItem: txDetailsContainer.data
6262

6363
readonly property bool acceptable: {
64-
if (walletInfo.encType === QPasswordData.Password) return tfPassword.text.length > 0
65-
else if (walletInfo.encType === QPasswordData.Unencrypted) return txInfo.isOfflineTxSigned
66-
else return true
64+
if (walletInfo.encType === QPasswordData.Password) {
65+
return tfPassword.text.length > 0
66+
}
67+
if (walletInfo.encType === QPasswordData.Unencrypted) {
68+
return txInfo.isOfflineTxSigned
69+
}
70+
return true
6771
}
6872

6973
readonly property int addressRowHeight: 24
@@ -619,7 +623,7 @@ CustomTitleDialogWindowWithExpander {
619623
JsHelper.messageBox(BSMessageBox.Type.Warning
620624
, qsTr("Signed Transacton Import")
621625
, qsTr("Error importing signed transaction")
622-
, qsTr("Error while importing signed transaction file.\nComparsion between signed and unsigned transaction failed."))
626+
, qsTr("Error while importing signed transaction file.\nComparison between signed and unsigned transaction failed."))
623627
}
624628
}
625629
}

BlockSettleSigner/qml/BsDialogs/WalletImportDialog.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ CustomTitleDialogWindow {
735735
}
736736
else {
737737
JsHelper.messageBox(BSMessageBox.Type.Critical
738-
, qsTr("Import Failed"), qsTr("Import WO-wallet failed:\n") + msg)
738+
, qsTr("Import Failed"), qsTr("Import WO-wallet failed:\n") + desc)
739739
}
740740
}
741741

BlockSettleUILib/CreateTransactionDialog.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void CreateTransactionDialog::updateCreateButtonText()
144144
const auto walletId = UiUtils::getSelectedWalletId(comboBoxWallets());
145145

146146
auto walletPtr = walletsManager_->getHDWalletById(walletId);
147-
if (!walletPtr->isHardwareWallet() && (signContainer_->isOffline() || signContainer_->isWalletOffline(walletId))) {
147+
if (walletPtr && !walletPtr->isHardwareWallet() && (signContainer_->isOffline()
148+
|| signContainer_->isWalletOffline(walletId))) {
148149
pushButtonCreate()->setText(tr("Export"));
149150
} else {
150151
selectedWalletChanged(-1);
@@ -692,15 +693,16 @@ std::vector<bs::core::wallet::TXSignRequest> CreateTransactionDialog::ImportTran
692693
return {};
693694
}
694695

695-
#ifdef PRODUCTION_BUILD
696-
if (!transactions.at(0).allowBroadcasts) {
696+
const auto envConf = static_cast<ApplicationSettings::EnvConfiguration>(applicationSettings_->get<int>(ApplicationSettings::envConfiguration));
697+
const bool isProd = (envConf == ApplicationSettings::EnvConfiguration::Production);
698+
const bool isTest = (envConf == ApplicationSettings::EnvConfiguration::Test);
699+
if ((isProd || isTest) && !transactions.at(0).allowBroadcasts) {
697700
BSMessageBox errorMessage(BSMessageBox::warning, tr("Warning"), tr("Import failure")
698701
, tr("You are trying to import a settlement transaction into a BlockSettle Terminal. "
699702
"Settlement transactions must be imported into a BlockSettle Signer if signed offline."), this);
700703
errorMessage.exec();
701704
return {};
702705
}
703-
#endif
704706

705707
clear();
706708
return transactions;

0 commit comments

Comments
 (0)