Skip to content

Commit

Permalink
SFT-4094: improved multisig import flow
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Aug 22, 2024
1 parent 51fbca2 commit aaee128
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,50 @@ async def show_overview(self):
msg, is_dup = self.ms.format_overview()

if is_dup:
await ErrorPage(text="Duplicate wallet will not be imported.").show()
await ErrorPage(text="Duplicate multisig wallet will not be imported.").show()
self.set_result(False)
return
else:
result = await LongTextPage(card_header={'title': 'Confirm Import'}, text=msg, centered=True).show()
if not result:
self.set_result(False)
return

await LongTextPage(card_header={'title': 'Confirm Import'}, text=msg, centered=True, left_micron=None).show()

self.goto(self.show_details)

async def show_details(self):
from errors import Error
from utils import spinner_task, escape_text
from tasks import save_multisig_wallet_task
from utils import escape_text

msg = self.ms.format_details()

result = await LongTextPage(card_header={'title': escape_text(self.ms.name)}, text=msg, centered=True).show()

if not result:
self.back()
return

self.goto(self.confirm_import)

async def confirm_import(self):
from pages import QuestionPage

result = await QuestionPage('Create new multisig wallet?').show()

if not result:
self.set_result(False)
return

self.goto(self.import_wallet)

async def import_wallet(self):
from utils import spinner_task
from errors import Error
from tasks import save_multisig_wallet_task

# User confirmed the import, so save
(error,) = await spinner_task('Saving multisig', save_multisig_wallet_task, args=[self.ms])
if not error:
self.set_result(True)
elif error is Error.USER_SETTINGS_FULL:
await ErrorPage(text='Out of space in user settings. Too many multisig configs?').show()
self.set_result(False)
else:
# User confirmed the import, so save
(error,) = await spinner_task('Saving multisig', save_multisig_wallet_task, args=[self.ms])
if not error:
self.set_result(True)
elif error is Error.USER_SETTINGS_FULL:
await ErrorPage(text='Out of space in user settings. Too many multisig configs?').show()
self.set_result(False)
else:
await ErrorPage(text='Unable to save multisig config.').show()
self.set_result(False)
await ErrorPage(text='Unable to save multisig config.').show()
self.set_result(False)
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ async def check_multisig_import(self):
if self.psbt.multisig_import_needs_approval:
result = await ImportMultisigWalletFlow(self.psbt.active_multisig).run()
if not result:
await ErrorPage(
'The transaction can still be signed, but this multisig config will not be saved.').show()
text = 'The transaction can still be signed, but this multisig config will not be saved.'
result2 = await ErrorPage(text=text, left_micron=microns.Back).show()
if not result2:
return

self.goto(self.show_transaction_details)

Expand Down
9 changes: 2 additions & 7 deletions ports/stm32/boards/Passport/modules/multisig_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,18 +976,13 @@ def format_overview(self, importing=True):
wallet first. Differences: '''.format(recolor(COPPER_HEX, 'WARNING:')) + ', '.join(diff_items)
is_dup = True
elif importing and num_dups:
msg = 'Duplicate wallet. All details are the same as an existing wallet, so it will not be added.'
msg = 'Duplicate wallet. All details are the same as an existing wallet, so it will not be added.\n\n'
is_dup = True
elif not importing:
msg = ''
else:
msg = 'Create new multisig wallet?'
msg = ''

derivs, dsum = self.get_deriv_paths()

if importing:
msg += '\n\n'

msg += '''{name_title}
{name}
Expand Down
4 changes: 2 additions & 2 deletions ports/stm32/boards/Passport/modules/pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def detach(self):

def left_action(self, is_pressed):
# print('Page.right_action()')
if not is_pressed:
if not is_pressed and self.left_micron:
self.set_result(False)

def right_action(self, is_pressed):
# print('Page.right_action()')
if not is_pressed:
if not is_pressed and self.right_micron:
self.set_result(True)

# By default, returns None so caller can differentiate between user pressing a button to back out
Expand Down

0 comments on commit aaee128

Please sign in to comment.