TxImportDialog: change daemon rpc network if connected to local node

This commit is contained in:
tobtoht 2021-05-24 00:30:47 +02:00
parent b2217c974b
commit 5edea3c436
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
3 changed files with 13 additions and 4 deletions

View file

@ -34,12 +34,16 @@ TxImportDialog::TxImportDialog(QWidget *parent, QSharedPointer<AppContext> 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");

View file

@ -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);
}

View file

@ -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);