Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redesign passphrase backup [NMA-1484] #1106

Merged
merged 8 commits into from Apr 3, 2023

Conversation

Syn-McJ
Copy link
Member

@Syn-McJ Syn-McJ commented Apr 2, 2023

We want to remove an extra info screen from the "backup passphrase" flow and add a "success" screen.
Some redesign is also required.

Issue being fixed or feature implemented

  • Redesigned Info screen and added Success screen.
  • Refactored VerifyActivity to use a navigation controller.
  • Moved SecurityActivity to a SecurityFragment.
  • Combined ViewSeedActivity and VerifyWriteDownFragment since they are the same.
  • Refactored DecryptSeedLiveData to move this logic into SecurityFunctions.
  • Removed some unused resources.

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

@Syn-McJ Syn-McJ self-assigned this Apr 2, 2023
Comment on lines -60 to -86
private fun decryptSeed(pin: String, password: String) {
if (deriveKeyTask == null) {
deriveKeyTask = object : DeriveKeyTask(backgroundHandler, scryptIterationsTarget) {

override fun onSuccess(encryptionKey: KeyParameter, changed: Boolean) {
deriveKeyTask = null
if (decryptSeedTask == null) {
decryptSeedTask = object : DecryptSeedTask(backgroundHandler) {

override fun onBadPassphrase() {
value = Resource.error("wrong password", Pair(wallet.keyChainSeed, pin))
decryptSeedTask = null
}

override fun onSuccess(seed : DeterministicSeed) {
value = Resource.success(Pair(seed, pin))
decryptSeedTask = null
}
}
value = Resource.loading(null)
decryptSeedTask!!.decryptSeed(wallet.keyChainSeed, wallet.keyCrypter, encryptionKey)
}
}
}
value = Resource.loading(null)
deriveKeyTask!!.deriveKey(wallet, password)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to have this logic as a couple of suspend calls in the SecurityFunctions class. That way, we can use it from anywhere - not just the UI thread.

if (showBackupWalletDialog) {
BackupWalletDialogFragment.show(getSupportFragmentManager());
showBackupWalletDialog = false;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we don't need this anymore. showBackupWalletDialog is never set to true.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.


wipePasswords();
super.onDismiss(dialog);
}

@Override
public void onCancel(final DialogInterface dialog) {
activity.finish();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we were finishing SecurityActivity on the dialog dismissal. Seems like just dismissing is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken from Bitcoin Wallet, where I think an activity was created that displays the backup wallet dialog.

However, we are not creating an activity to only display this dialog:

Reference:
https://github.com/bitcoin-wallet/bitcoin-wallet/blob/main/wallet/src/de/schildbach/wallet/ui/backup/BackupWalletActivity.java#L28-L40

Comment on lines 18 to +19
class DecryptSeedWithPinDialog(
private var onSuccessOrDismiss: ((DeterministicSeed?) -> Unit)?
private var onSuccessOrDismiss: ((Array<String>) -> Unit)?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting change. We must not need the DeterministicSeed object, only the phrase.

Copy link
Collaborator

@HashEngineering HashEngineering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@HashEngineering HashEngineering merged commit d88c9f9 into master Apr 3, 2023
1 check passed
@Syn-McJ Syn-McJ deleted the feature-redesign-backup branch April 10, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants