Basic implementation.
Implement very rough first query implementation, with still hardcoded connection details.
This commit is contained in:
parent
19331b641a
commit
9aa82db81f
|
@ -1459,7 +1459,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
def click_pushButtonFetchNamecoinID(self):
|
def click_pushButtonFetchNamecoinID(self):
|
||||||
nc = namecoinConnection()
|
nc = namecoinConnection()
|
||||||
err, addr = nc.query("")
|
err, addr = nc.query(str(self.ui.lineEditTo.text()))
|
||||||
if err is not None:
|
if err is not None:
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Error: " + err))
|
"MainWindow", "Error: " + err))
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import json
|
||||||
from jsonrpc import ServiceProxy, JSONRPCException
|
from jsonrpc import ServiceProxy, JSONRPCException
|
||||||
|
|
||||||
# This class handles the Namecoin identity integration.
|
# This class handles the Namecoin identity integration.
|
||||||
|
@ -9,7 +10,7 @@ class namecoinConnection(object):
|
||||||
password = "password"
|
password = "password"
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
port = "8336"
|
port = "8336"
|
||||||
self.s = ServiceProxy ("http://" + user + ":" + password
|
self.s = ServiceProxy("http://" + user + ":" + password
|
||||||
+ "@" + host + ":" + port)
|
+ "@" + host + ":" + port)
|
||||||
|
|
||||||
# Query for the bitmessage address corresponding to the given identity
|
# Query for the bitmessage address corresponding to the given identity
|
||||||
|
@ -17,4 +18,29 @@ class namecoinConnection(object):
|
||||||
# the result as (Error, Address) pair, where the Error is an error
|
# the result as (Error, Address) pair, where the Error is an error
|
||||||
# message to display or None in case of success.
|
# message to display or None in case of success.
|
||||||
def query(self,string):
|
def query(self,string):
|
||||||
return None, "BM-Foobar2"
|
slashPos = string.find("/")
|
||||||
|
if slashPos < 0:
|
||||||
|
string = "id/" + string
|
||||||
|
|
||||||
|
try:
|
||||||
|
res = self.s.name_show(string)
|
||||||
|
except JSONRPCException as err:
|
||||||
|
if err.error["code"] == -4:
|
||||||
|
return ("The name '" + string + "' was not found.", None)
|
||||||
|
else:
|
||||||
|
return ("The namecoin query failed ("
|
||||||
|
+ err.error["message"] + ")", None)
|
||||||
|
except:
|
||||||
|
return ("The namecoin query failed.", None)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print res["value"]
|
||||||
|
val = json.loads(res["value"])
|
||||||
|
except:
|
||||||
|
return ("The name '" + string + "' has no valid JSON data.", None)
|
||||||
|
|
||||||
|
if "bitmessage" in val:
|
||||||
|
return (None, val["bitmessage"])
|
||||||
|
|
||||||
|
return ("The name '" + string
|
||||||
|
+ "' has no associated Bitmessage address.", None)
|
||||||
|
|
Reference in New Issue
Block a user