send_tx
This commit is contained in:
parent
c24776ea5d
commit
70ef684718
|
@ -37,7 +37,6 @@ class Interface:
|
||||||
#only asynchrnous
|
#only asynchrnous
|
||||||
self.addresses_waiting_for_status = []
|
self.addresses_waiting_for_status = []
|
||||||
self.addresses_waiting_for_history = []
|
self.addresses_waiting_for_history = []
|
||||||
self.tx_event = threading.Event()
|
|
||||||
|
|
||||||
#json
|
#json
|
||||||
self.message_id = 0
|
self.message_id = 0
|
||||||
|
@ -49,13 +48,6 @@ class Interface:
|
||||||
return self.responses.empty() and not ( self.addresses_waiting_for_status or self.addresses_waiting_for_history )
|
return self.responses.empty() and not ( self.addresses_waiting_for_status or self.addresses_waiting_for_history )
|
||||||
|
|
||||||
|
|
||||||
def send_tx(self, data):
|
|
||||||
self.tx_event.clear()
|
|
||||||
self.send([('transaction.broadcast', [data])])
|
|
||||||
self.tx_event.wait()
|
|
||||||
return self.tx_result
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def queue_json_response(self, c):
|
def queue_json_response(self, c):
|
||||||
#print repr(c)
|
#print repr(c)
|
||||||
|
|
|
@ -276,6 +276,7 @@ class Wallet:
|
||||||
self.up_to_date_event = threading.Event()
|
self.up_to_date_event = threading.Event()
|
||||||
self.up_to_date_event.clear()
|
self.up_to_date_event.clear()
|
||||||
self.interface_lock = threading.Lock()
|
self.interface_lock = threading.Lock()
|
||||||
|
self.tx_event = threading.Event()
|
||||||
|
|
||||||
|
|
||||||
def set_server(self, host, port):
|
def set_server(self, host, port):
|
||||||
|
@ -760,7 +761,10 @@ class Wallet:
|
||||||
|
|
||||||
def sendtx(self, tx):
|
def sendtx(self, tx):
|
||||||
tx_hash = Hash(tx.decode('hex') )[::-1].encode('hex')
|
tx_hash = Hash(tx.decode('hex') )[::-1].encode('hex')
|
||||||
out = self.interface.send_tx(tx)
|
self.tx_event.clear()
|
||||||
|
self.interface.send([('transaction.broadcast', [tx])])
|
||||||
|
self.tx_event.wait()
|
||||||
|
out = self.tx_result
|
||||||
if out != tx_hash:
|
if out != tx_hash:
|
||||||
return False, "error: " + out
|
return False, "error: " + out
|
||||||
if self.receipt:
|
if self.receipt:
|
||||||
|
|
Loading…
Reference in New Issue