From 2d9843fec9496d3b4255be3f51fc7406745fe5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sa=C5=82aban?= Date: Thu, 18 Oct 2018 23:47:22 +0200 Subject: [PATCH] Make list of destinations a tuple, like argument to transfer_multiple(); Initialize destinations as empty list, make iterations straightforward --- monero/backends/jsonrpc.py | 2 +- monero/transaction.py | 2 +- utils/walletdump.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/monero/backends/jsonrpc.py b/monero/backends/jsonrpc.py index 4e732f8..6b6b061 100644 --- a/monero/backends/jsonrpc.py +++ b/monero/backends/jsonrpc.py @@ -247,7 +247,7 @@ class JSONRPCWallet(object): } if 'destinations' in data: result['destinations'] = [ - {'address': address(x['address']), 'amount': from_atomic(data['amount'])} + (address(x['address']), from_atomic(data['amount'])) for x in data.get('destinations') ] return result diff --git a/monero/transaction.py b/monero/transaction.py index 8f4f5fe..4457c8a 100644 --- a/monero/transaction.py +++ b/monero/transaction.py @@ -50,7 +50,7 @@ class OutgoingPayment(Payment): destinations = None def __init__(self, **kwargs): - self.destinations = kwargs.pop('destinations', self.destinations) + self.destinations = kwargs.pop('destinations', []) super(OutgoingPayment, self).__init__(**kwargs) _reprstr = "out: {} @ {} {:.12f} id={}" diff --git a/utils/walletdump.py b/utils/walletdump.py index bdf6b5f..80a0336 100755 --- a/utils/walletdump.py +++ b/utils/walletdump.py @@ -33,14 +33,20 @@ _TXHDR = "timestamp height id/hash " amount fee {dir:95s} payment_id" def pmt2str(pmt): - return "{time} {height:7d} {hash} {amount:17.12f} {fee:13.12f} {addr} {payment_id}".format( + res = ["{time} {height:7d} {hash} {amount:17.12f} {fee:13.12f} {addr} {payment_id}".format( time=pmt.timestamp.strftime("%d-%m-%y %H:%M:%S") if getattr(pmt, 'timestamp', None) else None, height=pmt.transaction.height or 0, hash=pmt.transaction.hash, amount=pmt.amount, fee=pmt.transaction.fee or 0, payment_id=pmt.payment_id, - addr=getattr(pmt, 'local_address', None) or '') + addr=getattr(pmt, 'local_address', None) or '')] + try: + for dest in pmt.destinations: + res.append(" {amount:17.12f} to {address}".format(address=dest[0], amount=dest[1])) + except AttributeError: + pass + return "\n".join(res) def a2str(a): return "{addr} {label}".format(