From 6a8c4e8cd7dfee77711456eaba5813d74dc7d816 Mon Sep 17 00:00:00 2001 From: Philippe Dumonet Date: Sat, 6 Jun 2020 20:26:44 +0200 Subject: [PATCH 1/2] Add fee to txs returned from .transactions() previously the transaction fees were omitted from transactions loaded/found using .transactions methods, this simple change fixes it --- monero/backends/jsonrpc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monero/backends/jsonrpc.py b/monero/backends/jsonrpc.py index 4247a4d..11e9522 100644 --- a/monero/backends/jsonrpc.py +++ b/monero/backends/jsonrpc.py @@ -133,12 +133,16 @@ class JSONRPCDaemon(object): raise exceptions.BackendException(res['status']) txs = [] for tx in res.get('txs', []): + as_json = json.loads(tx['as_json']) + fee = as_json['rct_signatures'].get('txnFee') txs.append(Transaction( hash=tx['tx_hash'], + fee=from_atomic(fee) if fee else None, 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=binascii.unhexlify(tx['as_hex']), - json=json.loads(tx['as_json']))) + json=as_json)) return txs def raw_request(self, path, data): From ae32ca0f0e15a69d41a155b1cefa1eec18408853 Mon Sep 17 00:00:00 2001 From: Philippe Dumonet Date: Sat, 6 Jun 2020 22:10:11 +0200 Subject: [PATCH 2/2] Add compatibility to old transactions --- monero/backends/jsonrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monero/backends/jsonrpc.py b/monero/backends/jsonrpc.py index 11e9522..82ec4fb 100644 --- a/monero/backends/jsonrpc.py +++ b/monero/backends/jsonrpc.py @@ -134,7 +134,7 @@ class JSONRPCDaemon(object): txs = [] for tx in res.get('txs', []): as_json = json.loads(tx['as_json']) - fee = as_json['rct_signatures'].get('txnFee') + fee = as_json.get('rct_signatures', {}).get('txnFee') txs.append(Transaction( hash=tx['tx_hash'], fee=from_atomic(fee) if fee else None,