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

Design for seed backup and move new wallet seed verification to after setup #502

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Decred Wallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@
DD3DF86722C42B3E00E168AB /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
DD41737C22B1B31E00580935 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
DD41737E22B1B32500580935 /* ru-RU */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "ru-RU"; path = "ru-RU.lproj/Localizable.strings"; sourceTree = "<group>"; };
DD452ED922CA93CB00A12378 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
DD443DD422C768A000EEAB95 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
DD452ED922CA93CB00A12378 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
DD4948EB22C0E400006A35F8 /* LocalizedStrings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedStrings.swift; sourceTree = "<group>"; };
DD75148922BA67B10070E4F6 /* TransactionHistoryViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TransactionHistoryViewController.xib; sourceTree = "<group>"; };
DD8F9D3B22BE7A5600FF8594 /* Security.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Security.storyboard; sourceTree = "<group>"; };
Expand Down
21 changes: 21 additions & 0 deletions Decred Wallet/Assets.xcassets/right-arrow.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "rightArrow.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 53 additions & 8 deletions Decred Wallet/Features/Overview/Overview.storyboard

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Decred Wallet/Features/Overview/OverviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class OverviewViewController: UIViewController {
@IBOutlet weak var fetchingBalanceIndicator: UIImageView!
@IBOutlet weak var totalBalanceLabel: UILabel!
@IBOutlet weak var recentActivityTableView: UITableView!
@IBOutlet weak var backupWallet: UIView!
macsleven marked this conversation as resolved.
Show resolved Hide resolved
@IBOutlet weak var backupViewSpacing: UIView!
Copy link
Contributor

Choose a reason for hiding this comment

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

  • I don't really see a need for this IBOutlet
  • The view referenced by this IBOutlet was added before this PR and it's purpose was certainly not to space the newly added backup view. This tells me that this variable is named wrongly. Which further leads me to question its usage.


var recentTransactions = [Transaction]()

Expand Down Expand Up @@ -49,6 +51,13 @@ class OverviewViewController: UIViewController {
AppDelegate.walletLoader.notification.registerListener(for: "\(self)", newTxistener: self)
AppDelegate.walletLoader.notification.registerListener(for: "\(self)", confirmedTxListener: self)

if !Settings.seedBackedUp {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(backupSeedAction))
self.backupWallet.addGestureRecognizer(tapGesture)
self.backupWallet.isHidden = false
self.backupViewSpacing.isHidden = true
Copy link
Contributor

Choose a reason for hiding this comment

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

As alluded to in the preceding comment, I don't see why it is necessary to hide this spacing.

}

self.fetchingBalanceIndicator.loadGif(name: "progress bar-1s-200px")
self.updateCurrentBalance()

Expand All @@ -65,6 +74,17 @@ class OverviewViewController: UIViewController {
self.overviewPageContentView.isHidden = false
}

// backup seed action
@objc func backupSeedAction() {
let confirmSeedVC = ConfirmNewWalletSeedViewController.instantiate()
confirmSeedVC.prepareSeedForVerification(seedToVerify: Settings.readValue(for: Settings.Keys.Seed))
confirmSeedVC.isSeedBackedUp = { seed in
self.backupViewSpacing.isHidden = false
self.backupWallet.isHidden = true
}
self.navigationController?.pushViewController(confirmSeedVC, animated: true)
}

func updateCurrentBalance() {
DispatchQueue.main.async {
self.totalBalanceLabel.isHidden = true
Expand Down Expand Up @@ -145,6 +165,7 @@ extension OverviewViewController: NewTransactionNotificationProtocol, ConfirmedT
_ = self.recentTransactions.popLast()
}

self.recentActivityTableView.backgroundView = .none
self.recentActivityTableView.reloadData()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ import UIKit
import Dcrlibwallet
import JGProgressHUD

class ConfirmNewWalletSeedViewController: WalletSetupBaseViewController {
class ConfirmNewWalletSeedViewController: UIViewController {
static func instantiate() -> Self {
return Storyboards.WalletSetup.instantiateViewController(for: self)
}

var seedWordsGroupedByThree: [[String]] = []
var selectedWords: [String] = []

@IBOutlet weak var btnConfirm: UIButton!
@IBOutlet var vActiveCellView: SeedCheckActiveCellView!

var isSeedBackedUp: ((String?)->())?

override func viewDidLoad() {
self.navigationController?.navigationBar.isHidden = true
}

func prepareSeedForVerification(seedToVerify: String) {
let allSeedWords = loadSeedWordsList()
let validSeedWords = seedToVerify.split{$0 == " "}.map(String.init)
Expand Down Expand Up @@ -54,28 +64,23 @@ class ConfirmNewWalletSeedViewController: WalletSetupBaseViewController {
}

@IBAction func backbtn(_ sender: Any) {
self.navigationController?.navigationBar.isHidden = false
self.navigationController?.popViewController(animated: true)
}

@IBAction func onConfirm(_ sender: Any) {
let seed = selectedWords.joined(separator: " ")
let seedIsValid = DcrlibwalletVerifySeed(seed)
if seedIsValid {
self.secureWallet()
Settings.setValue(true, for: Settings.Keys.SeedBackedUp)
Settings.clearValue(for: Settings.Keys.Seed)
isSeedBackedUp?(seed)
self.backbtn(sender)
} else {
self.showError(error: LocalizedStrings.seedDoesNotMatch)
}
}

func secureWallet() {
let seed = selectedWords.joined(separator: " ")
let securityVC = SecurityViewController.instantiate()
securityVC.onUserEnteredPinOrPassword = { (pinOrPassword, securityType) in
self.finalizeWalletSetup(seed, pinOrPassword, securityType)
}
self.navigationController?.pushViewController(securityVC, animated: true)
}

private func showError(error:String){
let alert = UIAlertController(title: LocalizedStrings.error, message: error, preferredStyle: .alert)
let okAction = UIAlertAction(title: LocalizedStrings.ok, style: .default) { (action) in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ class CreateNewWalletViewController: WalletSetupBaseViewController {
outerStackView.center.x = self.view.center.x
seedContainer.setNeedsLayout()
}

// MARK: - Navigation

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let confirmSeedVC = segue.destination as! ConfirmNewWalletSeedViewController
confirmSeedVC.prepareSeedForVerification(seedToVerify: self.seed)
@IBAction func secureWallet(_ sender: Any) {
let securityVC = SecurityViewController.instantiate()
securityVC.onUserEnteredPinOrPassword = { (pinOrPassword, securityType) in
self.finalizeWalletSetup(self.seed, pinOrPassword, securityType)
}
self.navigationController?.pushViewController(securityVC, animated: true)
}

@IBAction func backAction(_ sender: UIButton) {
Expand Down
4 changes: 2 additions & 2 deletions Decred Wallet/Features/Wallet Setup/WalletSetup.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="xibLocalizedStringKey" value="iCopiedTheSeedPhrase"/>
</userDefinedRuntimeAttributes>
<connections>
<segue destination="Ixd-Bq-Lpi" kind="show" id="nY0-Is-tDq"/>
<action selector="secureWallet:" destination="gFt-pD-kVi" eventType="touchUpInside" id="A10-fR-Cz6"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LQE-gP-yYb">
Expand Down Expand Up @@ -614,7 +614,7 @@
<!--Confirm New Wallet Seed View Controller-->
<scene sceneID="8cr-QT-J7B">
<objects>
<viewController id="Ixd-Bq-Lpi" customClass="ConfirmNewWalletSeedViewController" customModule="Decred_Wallet" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="ConfirmNewWalletSeedViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Ixd-Bq-Lpi" customClass="ConfirmNewWalletSeedViewController" customModule="Decred_Wallet" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="vHM-cF-NNR">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class WalletSetupBaseViewController: UIViewController {
DispatchQueue.main.async {
progressHud.dismiss()
Settings.setValue(securityType, for: Settings.Keys.SpendingPassphraseSecurityType)

if Settings.newWalletSetUp {
Settings.setValue(seed, for: Settings.Keys.Seed)
Settings.setValue(false, for: Settings.Keys.SeedBackedUp)
} else {
Settings.setValue(true, for: Settings.Keys.SeedBackedUp)
}

NavigationMenuViewController.setupMenuAndLaunchApp(isNewWallet: true)
}
} catch let error {
Expand Down
10 changes: 10 additions & 0 deletions Decred Wallet/Utils/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Foundation
class Settings {
struct Keys {
static let NewWalletSetUp = "new_wallet_set_up"
static let SeedBackedUp = "seed_backed_up"
static let Seed = "seed"
static let InitialSyncCompleted = "initial_sync_complete"
static let IsStartupSecuritySet = "startup_security_set"
static let StartupSecurityType = "startup_security_type"
Expand Down Expand Up @@ -57,6 +59,14 @@ class Settings {
}

/** Computed properties to access commonly used settings. */
static var newWalletSetUp: Bool {
return Settings.readValue(for: Settings.Keys.NewWalletSetUp)
}

static var seedBackedUp: Bool {
return Settings.readValue(for: Settings.Keys.SeedBackedUp)
}

static var syncOnCellular: Bool {
return Settings.readValue(for: Settings.Keys.SyncOnCellular)
}
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "Setting Up Decred Wallet";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will be asked to enter it on the next screen and if you ever need to restore your wallet.";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "Failure to keep this seed safe can result in theft of your entire wallet or inability to recover your wallet.";
"iCopiedTheSeedPhrase" = "I COPIED THE SEED PHRASE";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "Current Total Balance";
"recentActivity" = "Recent Activity";
"showAllTransactions" = "Show All Transactions";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "Pending";
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "Configurando Cartera Decred";
"seedHeaderInfo" = "Escriba esta frase semilla que aparece abajo y guárdela en un lugar seguro. Se le pedirá que lo ingrese en la siguiente pantalla y si alguna vez necesita restaurar su billetara.";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "El no mantener esta semilla segura puede resultar en el robo de su billetera completa o la incapacidad de recuperarla.";
"iCopiedTheSeedPhrase" = "He copiado la frase semilla";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "Saldo total actual";
"recentActivity" = "Actividad reciente";
"showAllTransactions" = "Mostrar todas las transacciones";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "Pendiente";
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "Preparando Carteira Decred";
"seedHeaderInfo" = "Escreva abaixo a semente (seed phrase) e guarde-a em um local seguro. Voce será perguntado para inseri-la na próxima tela e também para recuperar sua carteira.";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "Falha em manter essa semente segura, poderá resultar em extravio da sua carteira ou inviabilidadede para recuperar sua carteira.";
"iCopiedTheSeedPhrase" = "Eu copiei a semente (seed phrase)";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "Saldo Total Atual";
"recentActivity" = "Atividades Recentes";
"showAllTransactions" = "Mostrar Todas As Transações";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "Pendente";
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/ru-RU.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "НАСТРОЙКА КОШЕЛЬКА DECRED";
"seedHeaderInfo" = "Запишите себе эту сид-фразу и храните её в надёжном месте. Вас попросят ввести эту фразу, в случае если у вас когда-либо возникнет необходимость восстановить ваш кошелёк.";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "Небрежное отношение к хранению сида может привести к краже всего вашего кошелька или к невозможности его восстановить.";
"iCopiedTheSeedPhrase" = "Я скопировал/а сид-фразы.";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "Текущий общий баланс";
"recentActivity" = "Последние действия";
"showAllTransactions" = "Показать все транзакции";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "В ожидании";
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "Thiết lập Ví Decred";
"seedHeaderInfo" = "Hãy ghi lại từ khóa seed này, và lưu nó trong một vị trí bảo mật. Bạn sẽ được yêu cầu đăng nhập nó trên màn hình tiếp và nếu bạn cần phục hồi tên ví.";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "Việc không giữ seed này an toàn có thể dẫn đến việc đánh cắp toàn bộ ví của bạn hoặc không thể khôi phục ví của bạn.";
"iCopiedTheSeedPhrase" = "Tôi đã sao chép cụm từ seed";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "Tổng số dư hiện tại";
"recentActivity" = "Hoạt động gần đây";
"showAllTransactions" = "Hiển thị tất cả các giao dịch";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "Đang chờ xử lý";
Expand Down
3 changes: 2 additions & 1 deletion Decred Wallet/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Create New Wallet(Seed display view) */
"settingUpYourWallet" = "设置Decred钱包";
"seedHeaderInfo" = "请将种子写下并安全保存。在下个页面及以后需要恢复钱包时都需要输入种子。";
"seedHeaderInfo" = "Write down this seed phrase and save it in a secure location. You will require this seed if you ever need to restore your wallet.";
"seedWarningInfo" = "如果不能保证种子单词的安全可能会导致钱包被盗或无法恢复。";
"iCopiedTheSeedPhrase" = "我已复制种子单词";

Expand Down Expand Up @@ -159,6 +159,7 @@
"currentTotalBalance" = "总余额";
"recentActivity" = "近期活动";
"showAllTransactions" = "显示所有交易";
"backUpYourWallet" = "Back up your wallet";

/* Transaction List/ History */
"pending" = "等待";
Expand Down