From 0585611f56279bdf7d23327992cfa3670304de63 Mon Sep 17 00:00:00 2001 From: Fonta1n3 Date: Wed, 4 Nov 2020 21:58:26 +0800 Subject: [PATCH] feat: add ability to parse a keystore via QR scan or text when creating a multisig wallet chore: minor UI updates fix: minor bug where a ) was not getting removed from single sig account extended key in the descriptor parser --- FullyNoded.xcodeproj/project.pbxproj | 8 +- FullyNoded/Base.lproj/Main.storyboard | 255 ++++++++++-------- FullyNoded/Helpers/DescriptorParser.swift | 4 +- .../Home Screen/MainMenuViewController.swift | 16 +- .../Wallets/ActiveWalletViewController.swift | 5 + .../CreateMultisigViewController.swift | 22 +- 6 files changed, 178 insertions(+), 132 deletions(-) diff --git a/FullyNoded.xcodeproj/project.pbxproj b/FullyNoded.xcodeproj/project.pbxproj index 622bb3baf..982aa5ee2 100644 --- a/FullyNoded.xcodeproj/project.pbxproj +++ b/FullyNoded.xcodeproj/project.pbxproj @@ -1409,7 +1409,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 269; + CURRENT_PROJECT_VERSION = 270; DEVELOPMENT_TEAM = 8JHDU5M9KD; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -1423,7 +1423,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.349; + MARKETING_VERSION = 1.350; PRODUCT_BUNDLE_IDENTIFIER = com.fontaine.FullyNoded; "PRODUCT_BUNDLE_IDENTIFIER[sdk=macosx*]" = com.fontaine.fullynodedmacos; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1448,7 +1448,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 269; + CURRENT_PROJECT_VERSION = 270; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 8JHDU5M9KD; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; @@ -1464,7 +1464,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.349; + MARKETING_VERSION = 1.350; PRODUCT_BUNDLE_IDENTIFIER = com.fontaine.FullyNoded; "PRODUCT_BUNDLE_IDENTIFIER[sdk=macosx*]" = com.fontaine.fullynodedmacos; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/FullyNoded/Base.lproj/Main.storyboard b/FullyNoded/Base.lproj/Main.storyboard index 99f84a1a5..728c25d9e 100644 --- a/FullyNoded/Base.lproj/Main.storyboard +++ b/FullyNoded/Base.lproj/Main.storyboard @@ -130,7 +130,7 @@ - + @@ -366,113 +366,130 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -480,12 +497,14 @@ + - + + - + - + @@ -516,6 +535,7 @@ + @@ -783,6 +803,7 @@ + @@ -4674,7 +4695,7 @@ If you add a fingerprint your extended key will derive addresses as if it is an - + @@ -4822,7 +4843,7 @@ If you add a fingerprint your extended key will derive addresses as if it is an - + @@ -7290,7 +7311,7 @@ COLD means no keys will be generated and no private keys can be imported. - + @@ -7313,7 +7334,7 @@ COLD means no keys will be generated and no private keys can be imported. - + @@ -7436,7 +7457,7 @@ COLD means no keys will be generated and no private keys can be imported. - + @@ -7449,7 +7470,7 @@ COLD means no keys will be generated and no private keys can be imported. - + diff --git a/FullyNoded/Helpers/DescriptorParser.swift b/FullyNoded/Helpers/DescriptorParser.swift index aa1f98b68..31d742ddf 100644 --- a/FullyNoded/Helpers/DescriptorParser.swift +++ b/FullyNoded/Helpers/DescriptorParser.swift @@ -256,9 +256,9 @@ class DescriptorParser { let arr4 = extendedKeyWithPath.split(separator: "/") let extendedKey = arr4[0] if extendedKey.contains("tpub") || extendedKey.contains("xpub") { - dict["accountXpub"] = "\(extendedKey)" + dict["accountXpub"] = "\(extendedKey.replacingOccurrences(of: ")", with: ""))" } else if extendedKey.contains("tprv") || extendedKey.contains("xprv") { - dict["accountXprv"] = "\(extendedKey)" + dict["accountXprv"] = "\(extendedKey.replacingOccurrences(of: ")", with: ""))" } let arr3 = derivation.split(separator: "/") diff --git a/FullyNoded/View Controllers/Home/Home Screen/MainMenuViewController.swift b/FullyNoded/View Controllers/Home/Home Screen/MainMenuViewController.swift index 95a0cbba3..b7e9acbaf 100644 --- a/FullyNoded/View Controllers/Home/Home Screen/MainMenuViewController.swift +++ b/FullyNoded/View Controllers/Home/Home Screen/MainMenuViewController.swift @@ -882,14 +882,14 @@ extension MainMenuViewController: OnionManagerDelegate { self?.blurView.isHidden = true } -// if KeyChain.getData("hasPaid") == nil { -// guard let data = KeyChain.getData("paymentAddress") else { -// goToPaywall() -// return -// } -// -// checkIfPaymentReceived(data.utf8) -// } + if KeyChain.getData("hasPaid") == nil { + guard let data = KeyChain.getData("paymentAddress") else { + goToPaywall() + return + } + + checkIfPaymentReceived(data.utf8) + } } func torConnDifficulties() { diff --git a/FullyNoded/View Controllers/Wallets/ActiveWalletViewController.swift b/FullyNoded/View Controllers/Wallets/ActiveWalletViewController.swift index 9eeabfd1f..29099b8d5 100644 --- a/FullyNoded/View Controllers/Wallets/ActiveWalletViewController.swift +++ b/FullyNoded/View Controllers/Wallets/ActiveWalletViewController.swift @@ -33,6 +33,7 @@ class ActiveWalletViewController: UIViewController { private let ud = UserDefaults.standard private let spinner = ConnectingView() + @IBOutlet weak private var backgroundView: UIVisualEffectView! @IBOutlet weak private var walletTable: UITableView! @IBOutlet weak private var sendView: UIView! @IBOutlet weak private var invoiceView: UIView! @@ -42,6 +43,7 @@ class ActiveWalletViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + walletTable.delegate = self walletTable.dataSource = self configureUi() @@ -86,6 +88,9 @@ class ActiveWalletViewController: UIViewController { fxRateLabel.text = "" + backgroundView.clipsToBounds = true + backgroundView.layer.cornerRadius = 8 + if (UIDevice.current.userInterfaceIdiom == .pad) { alertStyle = UIAlertController.Style.alert } diff --git a/FullyNoded/View Controllers/Wallets/CreateMultisigViewController.swift b/FullyNoded/View Controllers/Wallets/CreateMultisigViewController.swift index c4a3cb5de..dcac0663a 100644 --- a/FullyNoded/View Controllers/Wallets/CreateMultisigViewController.swift +++ b/FullyNoded/View Controllers/Wallets/CreateMultisigViewController.swift @@ -409,6 +409,25 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText updateXpubField("") showAlert(vc: self, title: "Error", message: "Invalid extended key. It must be either an xpub, tpub, Zpub or Vpub") } + } else if extendedKey.hasPrefix("[") { + let p = DescriptorParser() + let hack = "wpkh(\(extendedKey))" + let descriptor = p.descriptor(hack) + let key = descriptor.accountXpub + let fingerprint = descriptor.fingerprint + + guard key != "", fingerprint != "" else { + showAlert(vc: self, title: "Invalid format", message: "Sorry we do not recognize that format yet, please reach out on Twitter, Telegram or GitHub and let us know.") + return + } + + DispatchQueue.main.async { [weak self] in + guard let self = self else { return } + + self.addKeyStore(fingerprint, key) + } + } else { + showAlert(vc: self, title: "Invalid format", message: "Sorry we do not recognize that format yet, please reach out on Twitter, Telegram or GitHub and let us know.") } } @@ -449,10 +468,11 @@ class CreateMultisigViewController: UIViewController, UITextViewDelegate, UIText guard let vc = segue.destination as? QRScannerViewController else { fallthrough } vc.isScanningAddress = true + vc.onAddressDoneBlock = { [weak self] xpub in guard let self = self, let xpub = xpub else { return } - self.updateXpubField(xpub) + self.parseExtendedKey(xpub) } case "segueToChooseSignerToDeriveXpub":