commit 55a6b1d1e898a35fedfaf71db350c8c6a2da5bee
parent 94b4ad8be77f8470e90274871d4a99f9c9074487
Author: ThomasV <thomasv@gitorious>
Date: Tue, 13 Mar 2012 23:06:06 +0100
send_tx
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/client/interface.py b/client/interface.py
@@ -195,6 +195,7 @@ class NativeInterface(Interface):
+import threading
class TCPInterface(Interface):
"""json-rpc over persistent TCP connection"""
@@ -205,13 +206,19 @@ class TCPInterface(Interface):
self.port = 50001
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.s.connect(( self.host, self.port))
+ self.tx_event = threading.Event()
def send(self, cmd, params = []):
request = json.dumps( { 'method':cmd, 'params':params } )
self.s.send( request + '\n' )
def send_tx(self, data):
- out = self.send('transaction.broadcast', data )
+ self.tx_event.clear()
+ self.send('transaction.broadcast', data )
+ print "waiting for event.."
+ self.tx_event.wait()
+ out = self.tx_result
+ print "result:", out
return out
def listen_thread(self, wallet):
@@ -233,9 +240,15 @@ class TCPInterface(Interface):
cmd = c.get('method')
if cmd == 'server.banner':
self.message = c.get('result')
+
+ elif cmd == 'transaction.broadcast':
+ self.tx_result = c.get('result')
+ self.tx_event.set()
+
elif cmd == 'numblocks.subscribe':
self.blocks = c.get('result')
print "num blocks",self.blocks
+
elif cmd =='address.subscribe':
addr = c.get('address')
status = c.get('status')
@@ -245,6 +258,7 @@ class TCPInterface(Interface):
self.is_up_to_date = False
else:
self.is_up_to_date = True
+
elif cmd == 'address.get_history':
addr = c.get('address')
print "updating history for", addr