account_add fix

This commit is contained in:
Lex Berezhny 2020-10-16 14:28:39 -04:00
parent 5cdfbcc88e
commit cc2837c021

View file

@ -989,21 +989,15 @@ class API:
""" """
wallet = self.wallets.get_or_default(wallet_id) wallet = self.wallets.get_or_default(wallet_id)
account = await Account.from_dict( return await wallet.accounts.add_from_dict({
self.ledger, wallet, { 'name': account_name,
'name': account_name, 'seed': seed,
'seed': seed, 'private_key': private_key,
'private_key': private_key, 'public_key': public_key,
'public_key': public_key, 'address_generator': {
'address_generator': { 'name': SingleKey.name if single_key else HierarchicalDeterministic.name
'name': SingleKey.name if single_key else HierarchicalDeterministic.name
}
} }
) })
wallet.save()
if self.ledger.sync.network.is_connected:
await self.ledger.subscribe_account(account)
return account
async def account_create( async def account_create(
self, self,
@ -1046,10 +1040,7 @@ class API:
""" """
wallet = self.wallets.get_or_default(wallet_id) wallet = self.wallets.get_or_default(wallet_id)
account = wallet.accounts.get_account_or_error(account_id) return await wallet.accounts.remove(account_id)
wallet.accounts.remove(account)
await wallet.save()
return account
async def account_set( async def account_set(
self, self,