From badeac38eb352c544b45ba2842ae610ed9612fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sa=C5=82aban?= Date: Tue, 14 Jan 2020 10:49:30 +0100 Subject: [PATCH] Make Transaction.blob raw binary instead of hex --- monero/backends/jsonrpc.py | 8 +++++--- monero/transaction.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/monero/backends/jsonrpc.py b/monero/backends/jsonrpc.py index e5037f1..44a8e89 100644 --- a/monero/backends/jsonrpc.py +++ b/monero/backends/jsonrpc.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals +import binascii from datetime import datetime import operator import json @@ -45,7 +47,7 @@ class JSONRPCDaemon(object): def send_transaction(self, blob, relay=True): res = self.raw_request('/sendrawtransaction', { - 'tx_as_hex': blob, + 'tx_as_hex': binascii.hexlify(blob), 'do_not_relay': not relay}) if res['status'] == 'OK': return res @@ -85,7 +87,7 @@ class JSONRPCDaemon(object): 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'], + blob=binascii.unhexlify(tx['as_hex']), json=json.loads(tx['as_json']))) return txs @@ -319,7 +321,7 @@ class JSONRPCWallet(object): 'key': data.get('key'), 'height': data.get('height', data.get('block_height')) or 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) }) diff --git a/monero/transaction.py b/monero/transaction.py index f2ebb46..d5b6118 100644 --- a/monero/transaction.py +++ b/monero/transaction.py @@ -77,7 +77,7 @@ class Transaction(object): @property def size(self): - return len(self.blob)//2 + return len(self.blob) def __init__(self, **kwargs): self.hash = kwargs.get('hash', self.hash)