2017-11-26 22:22:48 +00:00
|
|
|
from . import address
|
|
|
|
from . import prio
|
|
|
|
|
|
|
|
|
|
|
|
class Account(object):
|
|
|
|
index = None
|
|
|
|
|
|
|
|
def __init__(self, backend, index):
|
|
|
|
self.index = index
|
|
|
|
self._backend = backend
|
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def balances(self):
|
|
|
|
return self._backend.balances(account=self.index)
|
2017-12-01 05:06:15 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def balance(self, unlocked=False):
|
|
|
|
return self._backend.balances(account=self.index)[1 if unlocked else 0]
|
2017-11-26 22:22:48 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def address(self):
|
2017-11-26 22:22:48 +00:00
|
|
|
"""
|
|
|
|
Return account's main address.
|
|
|
|
"""
|
2018-01-28 15:11:27 +00:00
|
|
|
return self._backend.addresses(account=self.index)[0]
|
2017-11-26 22:22:48 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def addresses(self):
|
|
|
|
return self._backend.addresses(account=self.index)
|
2017-11-26 22:22:48 +00:00
|
|
|
|
2018-01-11 22:17:34 +00:00
|
|
|
def new_address(self, label=None):
|
|
|
|
return self._backend.new_address(account=self.index, label=label)
|
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def payments(self, payment_id=None):
|
|
|
|
return self._backend.payments(account=self.index, payment_id=payment_id)
|
2017-11-26 22:22:48 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def transactions_in(self, confirmed=True, unconfirmed=False):
|
|
|
|
return self._backend.transactions_in(
|
2018-01-22 02:55:08 +00:00
|
|
|
account=self.index, confirmed=confirmed, unconfirmed=unconfirmed)
|
2017-12-27 00:49:59 +00:00
|
|
|
|
2018-01-28 15:11:27 +00:00
|
|
|
def transactions_out(self, confirmed=True, unconfirmed=True):
|
|
|
|
return self._backend.transactions_out(
|
2018-01-22 02:55:08 +00:00
|
|
|
account=self.index, confirmed=confirmed, unconfirmed=unconfirmed)
|
2017-11-26 22:22:48 +00:00
|
|
|
|
2018-01-14 02:40:46 +00:00
|
|
|
def transfer(self, address, amount,
|
|
|
|
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
|
|
|
|
relay=True):
|
2017-11-29 03:38:29 +00:00
|
|
|
return self._backend.transfer(
|
|
|
|
[(address, amount)],
|
|
|
|
priority,
|
2018-01-13 21:24:17 +00:00
|
|
|
ringsize,
|
2018-01-06 22:12:42 +00:00
|
|
|
payment_id,
|
2017-11-29 03:38:29 +00:00
|
|
|
unlock_time,
|
2018-01-14 02:40:46 +00:00
|
|
|
account=self.index,
|
|
|
|
relay=relay)
|
2017-11-29 03:38:29 +00:00
|
|
|
|
2018-01-14 02:40:46 +00:00
|
|
|
def transfer_multiple(self, destinations,
|
|
|
|
priority=prio.NORMAL, ringsize=5, payment_id=None, unlock_time=0,
|
|
|
|
relay=True):
|
2017-11-26 22:22:48 +00:00
|
|
|
"""
|
|
|
|
destinations = [(address, amount), ...]
|
|
|
|
"""
|
2017-11-29 03:38:29 +00:00
|
|
|
return self._backend.transfer(
|
|
|
|
destinations,
|
|
|
|
priority,
|
2018-01-13 21:24:17 +00:00
|
|
|
ringsize,
|
2018-01-06 22:12:42 +00:00
|
|
|
payment_id,
|
2017-11-29 03:38:29 +00:00
|
|
|
unlock_time,
|
2018-01-14 02:40:46 +00:00
|
|
|
account=self.index,
|
|
|
|
relay=relay)
|