@@ -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
0 commit comments