From a86ab9e0ce7b3911e59ebd24d31764e2a5be2d36 Mon Sep 17 00:00:00 2001 From: Liquid Date: Tue, 2 May 2023 06:32:01 -0500 Subject: [PATCH] Fix GUI banning Fix whitespace --- src/qt/rpcconsole.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 7a031f350fdf3..ac6d94295e2f4 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -808,15 +808,24 @@ void RPCConsole::banSelectedNode(int bantime) if (!clientModel || !g_connman) return; + // No node selected exit out + if (cachedNodeid == -1) + return; + // Get currently selected peer address - QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString(); - // Find possible nodes, ban it and clear the selected node - std::string nStr = strNode.toStdString(); + int selectedNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid); + if (selectedNodeRow < 0) + return; + + // Get nodeStats and we will use the addrName string(ip address) + const CNodeCombinedStats* stats = clientModel->getPeerTableModel()->getNodeStats(selectedNodeRow); + + std::string nStr = stats->nodeStats.addrName; std::string addr; int port = 0; SplitHostPort(nStr, port, addr); - CNetAddr resolved; + if (!LookupHost(addr.c_str(), resolved, false)) return; g_connman->Ban(resolved, BanReasonManuallyAdded, bantime);