From 5edea3c436fee1273054f658e31f15ea438dd2d4 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Mon, 24 May 2021 00:30:47 +0200 Subject: [PATCH] TxImportDialog: change daemon rpc network if connected to local node --- src/dialog/tximportdialog.cpp | 12 ++++++++---- src/utils/daemonrpc.cpp | 4 ++++ src/utils/daemonrpc.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dialog/tximportdialog.cpp b/src/dialog/tximportdialog.cpp index 771dd92..a256248 100644 --- a/src/dialog/tximportdialog.cpp +++ b/src/dialog/tximportdialog.cpp @@ -34,12 +34,16 @@ TxImportDialog::TxImportDialog(QWidget *parent, QSharedPointer ctx) void TxImportDialog::loadTx() { QString txid = ui->line_txid->text(); - QString node = m_ctx->nodes->connection().toAddress(); + FeatherNode node = m_ctx->nodes->connection(); - if (!node.startsWith("http://")) - node = QString("http://%1").arg(node); + if (node.isLocal()) { + m_rpc->setNetwork(getNetworkClearnet()); + } else { + m_rpc->setNetwork(getNetworkTor()); + } - m_rpc->setDaemonAddress(node); + qDebug() << node.toURL(); + m_rpc->setDaemonAddress(node.toURL()); m_rpc->getTransactions(QStringList() << txid, false, true); ui->label_loading->setText("Loading transaction"); diff --git a/src/utils/daemonrpc.cpp b/src/utils/daemonrpc.cpp index 58c57d9..48faafd 100644 --- a/src/utils/daemonrpc.cpp +++ b/src/utils/daemonrpc.cpp @@ -93,3 +93,7 @@ QString DaemonRpc::onSendRawTransactionFailed(const QJsonObject &obj) { void DaemonRpc::setDaemonAddress(const QString &daemonAddress) { m_daemonAddress = daemonAddress; } + +void DaemonRpc::setNetwork(QNetworkAccessManager *network) { + m_network = new UtilsNetworking(network, this); +} \ No newline at end of file diff --git a/src/utils/daemonrpc.h b/src/utils/daemonrpc.h index 403e893..0bd1af8 100644 --- a/src/utils/daemonrpc.h +++ b/src/utils/daemonrpc.h @@ -33,6 +33,7 @@ public: void getTransactions(const QStringList &txs_hashes, bool decode_as_json = false, bool prune = false); void setDaemonAddress(const QString &daemonAddress); + void setNetwork(QNetworkAccessManager *network); signals: void ApiResponse(DaemonResponse resp);