mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 08:21:27 +00:00
send_tx
This commit is contained in:
parent
94b4ad8be7
commit
55a6b1d1e8
1 changed files with 15 additions and 1 deletions
|
@ -195,6 +195,7 @@ class NativeInterface(Interface):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
class TCPInterface(Interface):
|
class TCPInterface(Interface):
|
||||||
"""json-rpc over persistent TCP connection"""
|
"""json-rpc over persistent TCP connection"""
|
||||||
|
@ -205,13 +206,19 @@ class TCPInterface(Interface):
|
||||||
self.port = 50001
|
self.port = 50001
|
||||||
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
self.s.connect(( self.host, self.port))
|
self.s.connect(( self.host, self.port))
|
||||||
|
self.tx_event = threading.Event()
|
||||||
|
|
||||||
def send(self, cmd, params = []):
|
def send(self, cmd, params = []):
|
||||||
request = json.dumps( { 'method':cmd, 'params':params } )
|
request = json.dumps( { 'method':cmd, 'params':params } )
|
||||||
self.s.send( request + '\n' )
|
self.s.send( request + '\n' )
|
||||||
|
|
||||||
def send_tx(self, data):
|
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
|
return out
|
||||||
|
|
||||||
def listen_thread(self, wallet):
|
def listen_thread(self, wallet):
|
||||||
|
@ -233,9 +240,15 @@ class TCPInterface(Interface):
|
||||||
cmd = c.get('method')
|
cmd = c.get('method')
|
||||||
if cmd == 'server.banner':
|
if cmd == 'server.banner':
|
||||||
self.message = c.get('result')
|
self.message = c.get('result')
|
||||||
|
|
||||||
|
elif cmd == 'transaction.broadcast':
|
||||||
|
self.tx_result = c.get('result')
|
||||||
|
self.tx_event.set()
|
||||||
|
|
||||||
elif cmd == 'numblocks.subscribe':
|
elif cmd == 'numblocks.subscribe':
|
||||||
self.blocks = c.get('result')
|
self.blocks = c.get('result')
|
||||||
print "num blocks",self.blocks
|
print "num blocks",self.blocks
|
||||||
|
|
||||||
elif cmd =='address.subscribe':
|
elif cmd =='address.subscribe':
|
||||||
addr = c.get('address')
|
addr = c.get('address')
|
||||||
status = c.get('status')
|
status = c.get('status')
|
||||||
|
@ -245,6 +258,7 @@ class TCPInterface(Interface):
|
||||||
self.is_up_to_date = False
|
self.is_up_to_date = False
|
||||||
else:
|
else:
|
||||||
self.is_up_to_date = True
|
self.is_up_to_date = True
|
||||||
|
|
||||||
elif cmd == 'address.get_history':
|
elif cmd == 'address.get_history':
|
||||||
addr = c.get('address')
|
addr = c.get('address')
|
||||||
print "updating history for", addr
|
print "updating history for", addr
|
||||||
|
|
Loading…
Add table
Reference in a new issue