From 19331b641a596a0351919c9e1705a42a01e65b75 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Fri, 5 Jul 2013 17:29:49 +0200 Subject: [PATCH] Start with namecoin connection module. Create a still mostly empty module to encapsulate the namecoin address query, and use it from the UI. --- src/bitmessageqt/__init__.py | 9 ++++++++- src/class_namecoin.py | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/class_namecoin.py diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 4c9fd2c0..b04320d2 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -14,6 +14,7 @@ except ImportError: from addresses import * import shared from bitmessageui import * +from class_namecoin import * from newaddressdialog import * from newsubscriptiondialog import * from regenerateaddresses import * @@ -1457,7 +1458,13 @@ class MyForm(QtGui.QMainWindow): "MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'.")) def click_pushButtonFetchNamecoinID(self): - self.ui.lineEditTo.setText ("BM-Foobar") + nc = namecoinConnection() + err, addr = nc.query("") + if err is not None: + self.statusBar().showMessage(_translate( + "MainWindow", "Error: " + err)) + else: + self.ui.lineEditTo.setText(addr) def redrawLabelFrom(self, index): self.ui.labelFrom.setText( diff --git a/src/class_namecoin.py b/src/class_namecoin.py new file mode 100644 index 00000000..6239cd78 --- /dev/null +++ b/src/class_namecoin.py @@ -0,0 +1,20 @@ +from jsonrpc import ServiceProxy, JSONRPCException + +# This class handles the Namecoin identity integration. + +class namecoinConnection(object): + + def __init__(self): + user = "daniel" + password = "password" + host = "localhost" + port = "8336" + self.s = ServiceProxy ("http://" + user + ":" + password + + "@" + host + ":" + port) + + # Query for the bitmessage address corresponding to the given identity + # string. If it doesn't contain a slash, id/ is prepended. We return + # the result as (Error, Address) pair, where the Error is an error + # message to display or None in case of success. + def query(self,string): + return None, "BM-Foobar2"