From 810387df3eb652d7db688d337369503ff437ce30 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Wed, 17 Jul 2013 18:33:26 +0200 Subject: [PATCH] Read also rpcport from namecoin.conf. Read also the rpcport setting from namecoin.conf when it is available and use that as default when switching the setting in the UI dialog. --- src/bitmessageqt/__init__.py | 2 +- src/namecoin.py | 55 ++++++++++++++++++------------------ src/shared.py | 7 ++++- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 748f6954..1a7dbc42 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2936,7 +2936,7 @@ class settingsDialog(QtGui.QDialog): self.ui.labelNamecoinPassword.setEnabled(isNamecoind) if isNamecoind: - self.ui.lineEditNamecoinPort.setText("8336") + self.ui.lineEditNamecoinPort.setText(shared.namecoinDefaultRpcPort) else: self.ui.lineEditNamecoinPort.setText("9000") diff --git a/src/namecoin.py b/src/namecoin.py index 17cd74ea..5ad1c049 100644 --- a/src/namecoin.py +++ b/src/namecoin.py @@ -247,33 +247,34 @@ def ensureNamecoinOptions (): hasPass = shared.config.has_option (configSection, "namecoinrpcpassword") # Try to read user/password from .namecoin configuration file. - if (not hasUser) or (not hasPass): - try: - nmcFolder = lookupNamecoinFolder () - nmcConfig = nmcFolder + "namecoin.conf" - nmc = open (nmcConfig, "r") + try: + nmcFolder = lookupNamecoinFolder () + nmcConfig = nmcFolder + "namecoin.conf" + nmc = open (nmcConfig, "r") - while True: - line = nmc.readline () - if line == "": - break - parts = line.split ("=") - if len (parts) == 2: - key = parts[0] - val = parts[1].rstrip () + while True: + line = nmc.readline () + if line == "": + break + parts = line.split ("=") + if len (parts) == 2: + key = parts[0] + val = parts[1].rstrip () - if key == "rpcuser" and not hasUser: - shared.config.set (configSection, - "namecoinrpcuser", val) - if key == "rpcpassword" and not hasPass: - shared.config.set (configSection, - "namecoinrpcpassword", val) - - nmc.close () + if key == "rpcuser" and not hasUser: + shared.config.set (configSection, + "namecoinrpcuser", val) + if key == "rpcpassword" and not hasPass: + shared.config.set (configSection, + "namecoinrpcpassword", val) + if key == "rpcport": + shared.namecoinDefaultRpcPort = val + + nmc.close () - except Exception as exc: - print "Failure reading namecoin config file: %s" % str (exc) - if (not hasUser): - shared.config.set (configSection, "namecoinrpcuser", "") - if (not hasPass): - shared.config.set (configSection, "namecoinrpcpassword", "") + except Exception as exc: + print "Failure reading namecoin config file: %s" % str (exc) + if (not hasUser): + shared.config.set (configSection, "namecoinrpcuser", "") + if (not hasPass): + shared.config.set (configSection, "namecoinrpcpassword", "") diff --git a/src/shared.py b/src/shared.py index 557b332d..98e540d7 100644 --- a/src/shared.py +++ b/src/shared.py @@ -68,6 +68,11 @@ ackdataForWhichImWatching = {} networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work. networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target. +# Remember here the RPC port read from namecoin.conf so we can restore to +# it as default whenever the user changes the "method" selection for +# namecoin integration to "namecoind". +namecoinDefaultRpcPort = "8336" + def isInSqlInventory(hash): t = (hash,) shared.sqlLock.acquire() @@ -371,4 +376,4 @@ def fixSensitiveFilePermissions(filename, hasEnabledKeys): raise helper_startup.loadConfig() -from debug import logger \ No newline at end of file +from debug import logger