mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Add retrieval of transaction from daemon
This commit is contained in:
parent
df9dd7152b
commit
44d87be2e6
6 changed files with 208 additions and 0 deletions
|
@ -71,6 +71,22 @@ class JSONRPCDaemon(object):
|
|||
return res['headers']
|
||||
raise exceptions.BackendException(res['status'])
|
||||
|
||||
def transactions(self, hashes):
|
||||
res = self.raw_request('/get_transactions', {
|
||||
'txs_hashes': hashes,
|
||||
'decode_as_json': True})
|
||||
if res['status'] != 'OK':
|
||||
raise exceptions.BackendException(res['status'])
|
||||
txs = []
|
||||
for tx in res.get('txs', []):
|
||||
txs.append(Transaction(
|
||||
hash=tx['tx_hash'],
|
||||
height=None if tx['in_pool'] else tx['block_height'],
|
||||
timestamp=datetime.fromtimestamp(tx['block_timestamp']) if 'block_timestamp' in tx else None,
|
||||
blob=tx['as_hex'],
|
||||
json=json.loads(tx['as_json'])))
|
||||
return txs
|
||||
|
||||
def raw_request(self, path, data):
|
||||
hdr = {'Content-Type': 'application/json'}
|
||||
_log.debug(u"Request: {path}\nData: {data}".format(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue