diff --git a/electrumpersonalserver/server/common.py b/electrumpersonalserver/server/common.py
index 3a7b7e7..a645f0f 100644
--- a/electrumpersonalserver/server/common.py
+++ b/electrumpersonalserver/server/common.py
@@ -15,7 +15,6 @@
 import electrumpersonalserver.server.hashes as hashes
 import electrumpersonalserver.server.deterministicwallet as deterministicwallet
 import electrumpersonalserver.server.transactionmonitor as transactionmonitor
-import electrumpersonalserver.server.peertopeer as peertopeer
 from electrumpersonalserver.server.electrumprotocol import (
     SERVER_VERSION_NUMBER,
     ElectrumProtocol,
@@ -28,24 +27,6 @@
 ## global variables are actually mutable lists
 bestblockhash = [None]
 
-def get_tor_hostport():
-    # Probable ports for Tor to listen at
-    host = "127.0.0.1"
-    ports = [9050, 9150]
-    for port in ports:
-        try:
-            s = (socket._socketobject if hasattr(socket, "_socketobject")
-                 else socket.socket)(socket.AF_INET, socket.SOCK_STREAM)
-            s.settimeout(0.1)
-            s.connect((host, port))
-            # Tor responds uniquely to HTTP-like requests
-            s.send(b"GET\n")
-            if b"Tor is not an HTTP Proxy" in s.recv(1024):
-                return (host, port)
-        except socket.error:
-            pass
-    return None
-
 def on_heartbeat_listening(txmonitor):
     logger = logging.getLogger('ELECTRUMPERSONALSERVER')
     logger.debug("on heartbeat listening")
diff --git a/electrumpersonalserver/server/electrumprotocol.py b/electrumpersonalserver/server/electrumprotocol.py
index f1fac08..9dfdea1 100644
--- a/electrumpersonalserver/server/electrumprotocol.py
+++ b/electrumpersonalserver/server/electrumprotocol.py
@@ -5,6 +5,7 @@
 import os
 import struct
 import tempfile
+import socket
 from collections import defaultdict
 
 from electrumpersonalserver.server.hashes import (
@@ -13,6 +14,7 @@
     bytes_fmt
 )
 from .jsonrpc import JsonRpc, JsonRpcError
+import electrumpersonalserver.server.peertopeer as peertopeer
 from electrumpersonalserver.server.merkleproof import (
     convert_core_to_electrum_merkle_proof
 )
@@ -48,6 +50,25 @@
 
 """
 
+def get_tor_hostport():
+    # Probable ports for Tor to listen at
+    host = "127.0.0.1"
+    ports = [9050, 9150]
+    for port in ports:
+        try:
+            s = (socket._socketobject if hasattr(socket, "_socketobject")
+                 else socket.socket)(socket.AF_INET, socket.SOCK_STREAM)
+            s.settimeout(0.1)
+            s.connect((host, port))
+            # Tor responds uniquely to HTTP-like requests
+            s.send(b"GET\n")
+            if b"Tor is not an HTTP Proxy" in s.recv(1024):
+                return (host, port)
+        except socket.error:
+            pass
+    return None
+
+
 def get_block_header(rpc, blockhash, raw=False):
     rpc_head = rpc.call("getblockheader", [blockhash])
     if "previousblockhash" in rpc_head: