Make Transaction.blob raw binary instead of hex
This commit is contained in:
parent
337e84704f
commit
badeac38eb
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import binascii
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import operator
|
import operator
|
||||||
import json
|
import json
|
||||||
|
@ -45,7 +47,7 @@ class JSONRPCDaemon(object):
|
||||||
|
|
||||||
def send_transaction(self, blob, relay=True):
|
def send_transaction(self, blob, relay=True):
|
||||||
res = self.raw_request('/sendrawtransaction', {
|
res = self.raw_request('/sendrawtransaction', {
|
||||||
'tx_as_hex': blob,
|
'tx_as_hex': binascii.hexlify(blob),
|
||||||
'do_not_relay': not relay})
|
'do_not_relay': not relay})
|
||||||
if res['status'] == 'OK':
|
if res['status'] == 'OK':
|
||||||
return res
|
return res
|
||||||
|
@ -85,7 +87,7 @@ class JSONRPCDaemon(object):
|
||||||
hash=tx['tx_hash'],
|
hash=tx['tx_hash'],
|
||||||
height=None if tx['in_pool'] else tx['block_height'],
|
height=None if tx['in_pool'] else tx['block_height'],
|
||||||
timestamp=datetime.fromtimestamp(tx['block_timestamp']) if 'block_timestamp' in tx else None,
|
timestamp=datetime.fromtimestamp(tx['block_timestamp']) if 'block_timestamp' in tx else None,
|
||||||
blob=tx['as_hex'],
|
blob=binascii.unhexlify(tx['as_hex']),
|
||||||
json=json.loads(tx['as_json'])))
|
json=json.loads(tx['as_json'])))
|
||||||
return txs
|
return txs
|
||||||
|
|
||||||
|
@ -319,7 +321,7 @@ class JSONRPCWallet(object):
|
||||||
'key': data.get('key'),
|
'key': data.get('key'),
|
||||||
'height': data.get('height', data.get('block_height')) or None,
|
'height': data.get('height', data.get('block_height')) or None,
|
||||||
'timestamp': datetime.fromtimestamp(data['timestamp']) if 'timestamp' in data else None,
|
'timestamp': datetime.fromtimestamp(data['timestamp']) if 'timestamp' in data else None,
|
||||||
'blob': data.get('blob', None),
|
'blob': binascii.unhexlify(data.get('blob', '')),
|
||||||
'confirmations': data.get('confirmations', None)
|
'confirmations': data.get('confirmations', None)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Transaction(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
return len(self.blob)//2
|
return len(self.blob)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.hash = kwargs.get('hash', self.hash)
|
self.hash = kwargs.get('hash', self.hash)
|
||||||
|
|
Loading…
Reference in New Issue