From f408cd63abb2f68350e827c12e19da569a4dcdaa Mon Sep 17 00:00:00 2001 From: Matt Gleason Date: Wed, 13 Sep 2023 11:59:28 -0400 Subject: [PATCH 1/2] SFT-2757: fixed account renaming --- .../Passport/modules/flows/rename_account_flow.py | 11 ++++++++--- .../Passport/modules/tasks/rename_account_task.py | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/flows/rename_account_flow.py b/ports/stm32/boards/Passport/modules/flows/rename_account_flow.py index a3710ab52..80f139792 100644 --- a/ports/stm32/boards/Passport/modules/flows/rename_account_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/rename_account_flow.py @@ -29,6 +29,8 @@ def __init__(self): super().__init__(initial_state=initial_state, name='RenameAccountFLow') async def ask_for_name(self): + from common import settings + name = self.account.get('name') if self.new_account_name is None else self.new_account_name result = await TextInputPage(initial_text=name, max_length=MAX_ACCOUNT_NAME_LEN, @@ -38,7 +40,7 @@ async def ask_for_name(self): self.new_account_name = result # Check for existing account with this name - existing_account = get_account_by_name(self.new_account_name) + existing_account = get_account_by_name(self.new_account_name, settings.get('xfp')) if existing_account is not None: await ErrorPage(text='Account #{} already exists with the name "{}".'.format( existing_account.get('acct_num'), self.new_account_name)).show() @@ -49,9 +51,12 @@ async def ask_for_name(self): self.set_result(False) async def do_rename(self): - from common import ui + from common import ui, settings + (error,) = await spinner_task('Renaming account', rename_account_task, - args=[self.account.get('acct_num'), self.new_account_name]) + args=[self.account.get('acct_num'), + self.new_account_name, + settings.get('xfp')]) if error is None: import common from utils import start_task diff --git a/ports/stm32/boards/Passport/modules/tasks/rename_account_task.py b/ports/stm32/boards/Passport/modules/tasks/rename_account_task.py index f84d43181..a38233bf6 100644 --- a/ports/stm32/boards/Passport/modules/tasks/rename_account_task.py +++ b/ports/stm32/boards/Passport/modules/tasks/rename_account_task.py @@ -6,12 +6,12 @@ from utils import get_accounts -async def rename_account_task(on_done, account_num, account_name): +async def rename_account_task(on_done, account_num, account_name, xfp): from common import settings accounts = get_accounts() for account in accounts: - if account.get('acct_num') == account_num: + if account.get('acct_num') == account_num and account.get('xfp') == xfp: account['name'] = account_name break From c9ea05be3999412c0b2c6a34c489851f7d931a0d Mon Sep 17 00:00:00 2001 From: Matt Gleason Date: Wed, 13 Sep 2023 13:10:37 -0400 Subject: [PATCH 2/2] SFT-2757: fixed account deletion with passphrases --- .../boards/Passport/modules/flows/delete_account_flow.py | 5 ++++- .../boards/Passport/modules/tasks/delete_account_task.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/stm32/boards/Passport/modules/flows/delete_account_flow.py b/ports/stm32/boards/Passport/modules/flows/delete_account_flow.py index cb20d0c1c..1e8f93c57 100644 --- a/ports/stm32/boards/Passport/modules/flows/delete_account_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/delete_account_flow.py @@ -42,8 +42,11 @@ async def confirm_delete(self): self.set_result(False) async def do_delete(self): + from common import settings + (error,) = await spinner_task('Deleting Account', delete_account_task, - args=[self.account.get('acct_num')]) + args=[self.account.get('acct_num'), + settings.get('xfp')]) if error is None: import common from utils import start_task diff --git a/ports/stm32/boards/Passport/modules/tasks/delete_account_task.py b/ports/stm32/boards/Passport/modules/tasks/delete_account_task.py index 8e7869598..a8d4c5a6a 100644 --- a/ports/stm32/boards/Passport/modules/tasks/delete_account_task.py +++ b/ports/stm32/boards/Passport/modules/tasks/delete_account_task.py @@ -6,11 +6,11 @@ from utils import get_accounts -async def delete_account_task(on_done, account_num): +async def delete_account_task(on_done, account_num, xfp): from common import settings accounts = get_accounts() - accounts = list(filter(lambda acct: acct.get('acct_num') != account_num, accounts)) + accounts = list(filter(lambda acct: (acct.get('acct_num') != account_num or acct.get('xfp') != xfp), accounts)) settings.set('accounts', accounts) settings.save()