Make list of destinations a tuple, like argument to transfer_multiple();

Initialize destinations as empty list, make iterations straightforward
This commit is contained in:
Michał Sałaban 2018-10-18 23:47:22 +02:00
parent 55ce01f555
commit 2d9843fec9
3 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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={}"

View File

@ -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(