Start with namecoin connection module.

Create a still mostly empty module to encapsulate the
namecoin address query, and use it from the UI.
This commit is contained in:
Daniel Kraft 2013-07-05 17:29:49 +02:00
parent 9a5d048691
commit 19331b641a
2 changed files with 28 additions and 1 deletions

View File

@ -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(

20
src/class_namecoin.py Normal file
View File

@ -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"