|
|
|
@ -47,15 +47,6 @@ class Wallet(object):
|
|
|
|
|
def height(self):
|
|
|
|
|
return self.make_wallet_rpc('get_height', {})
|
|
|
|
|
|
|
|
|
|
def spend_key(self):
|
|
|
|
|
return self.make_wallet_rpc('query_key', {'key_type': 'spend_key'})['key']
|
|
|
|
|
|
|
|
|
|
def view_key(self):
|
|
|
|
|
return self.make_wallet_rpc('query_key', {'key_type': 'view_key'})['key']
|
|
|
|
|
|
|
|
|
|
def seed(self):
|
|
|
|
|
return self.make_wallet_rpc('query_key', {'key_type': 'mnemonic'})['key']
|
|
|
|
|
|
|
|
|
|
def accounts(self):
|
|
|
|
|
_accounts = self.make_wallet_rpc('get_accounts')
|
|
|
|
|
return [i['account_index'] for i in _accounts['subaddress_accounts']]
|
|
|
|
@ -89,20 +80,23 @@ class Wallet(object):
|
|
|
|
|
_address = self.make_wallet_rpc('create_address', data)
|
|
|
|
|
return (_address['address_index'], _address['address'])
|
|
|
|
|
|
|
|
|
|
def transfers(self, account, address_indices=[]):
|
|
|
|
|
def transfers(self, address_indices=[], _in=True, _out=True):
|
|
|
|
|
data = {
|
|
|
|
|
'account_index': account,
|
|
|
|
|
'account_index': config.WALLET_ACCOUNT,
|
|
|
|
|
'subaddr_indices': address_indices,
|
|
|
|
|
'in': True,
|
|
|
|
|
'out': True
|
|
|
|
|
'in': _in,
|
|
|
|
|
'out': _out
|
|
|
|
|
}
|
|
|
|
|
_transfers = self.make_wallet_rpc('get_transfers', data)
|
|
|
|
|
return _transfers
|
|
|
|
|
|
|
|
|
|
def balances(self, account):
|
|
|
|
|
data = {'account_index': account}
|
|
|
|
|
def balances(self, address_indices=[]):
|
|
|
|
|
data = {
|
|
|
|
|
'account_index': config.WALLET_ACCOUNT,
|
|
|
|
|
'address_indices': address_indices
|
|
|
|
|
}
|
|
|
|
|
_balance = self.make_wallet_rpc('get_balance', data)
|
|
|
|
|
return (from_atomic(_balance['balance']), from_atomic(_balance['unlocked_balance']))
|
|
|
|
|
return (_balance['balance'], _balance['unlocked_balance'])
|
|
|
|
|
|
|
|
|
|
def transfer(self, dest_address, amount, priority, account):
|
|
|
|
|
data = {
|
|
|
|
@ -120,26 +114,15 @@ class Wallet(object):
|
|
|
|
|
self.store()
|
|
|
|
|
return transfer
|
|
|
|
|
|
|
|
|
|
def sweep_all(self, account, dest_address):
|
|
|
|
|
data = {
|
|
|
|
|
'address': dest_address,
|
|
|
|
|
'account_index': account,
|
|
|
|
|
}
|
|
|
|
|
sweep = self.make_wallet_rpc('sweep_all', data)
|
|
|
|
|
self.store()
|
|
|
|
|
return sweep
|
|
|
|
|
|
|
|
|
|
def incoming_transfers(self, account, transfer_type='all', verbose=True):
|
|
|
|
|
def incoming_transfers(self, transfer_type='all'):
|
|
|
|
|
data = {
|
|
|
|
|
'transfer_type': transfer_type,
|
|
|
|
|
'account_index': account,
|
|
|
|
|
'verbose': verbose
|
|
|
|
|
'account_index': config.WALLET_ACCOUNT
|
|
|
|
|
}
|
|
|
|
|
transfers = self.make_wallet_rpc('incoming_transfers', data)
|
|
|
|
|
return transfers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_atomic(amount):
|
|
|
|
|
if not isinstance(amount, (Decimal, float) + six.integer_types):
|
|
|
|
|
raise ValueError("Amount '{}' doesn't have numeric type. Only Decimal, int, long and "
|
|
|
|
|