ADD: View Wallet xPub

This commit is contained in:
marcosrdz 2020-08-16 23:56:05 -04:00 committed by Overtorment
parent ec62a5a805
commit 47a7e19145
8 changed files with 99 additions and 18 deletions

View File

@ -163,6 +163,7 @@ export default class WatchConnectivity {
preferredBalanceUnit: wallet.getPreferredBalanceUnit(),
receiveAddress: receiveAddress,
transactions: watchTransactions,
xpub: wallet.getXpub(),
});
}
Watch.updateApplicationContext({ wallets, randomID: Math.floor(Math.random() * 11) });

View File

@ -26,7 +26,8 @@
32B5A32A2334450100F8D608 /* Bridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B5A3292334450100F8D608 /* Bridge.swift */; };
32F0A29A2311DBB20095C559 /* ComplicationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F0A2992311DBB20095C559 /* ComplicationController.swift */; };
6DF25A9F249DB97E001D06F5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6DF25A9E249DB97E001D06F5 /* LaunchScreen.storyboard */; };
6DFC807024EA0B6C007B8700 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = 6DFC806F24EA0B6C007B8700 /* SwiftPackageProductDependency */; };
6DFC807024EA0B6C007B8700 /* EFQRCode in Frameworks */ = {isa = PBXBuildFile; productRef = 6DFC806F24EA0B6C007B8700 /* EFQRCode */; };
6DFC807224EA2FA9007B8700 /* ViewQRCodefaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DFC807124EA2FA9007B8700 /* ViewQRCodefaceController.swift */; };
764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B468CC34D5B41F3950078EF /* libsqlite3.0.tbd */; };
782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B9D9B3A7B2CB4255876B67AF /* libz.tbd */; };
906451CAD44154C2950030EC /* libPods-BlueWallet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 731973BA0AC6EA78962CE5B6 /* libPods-BlueWallet.a */; };
@ -218,6 +219,7 @@
6D294A9D24D5127F0039E22B /* xh */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = xh; path = xh.lproj/Interface.strings; sourceTree = "<group>"; };
6D294A9E24D512800039E22B /* xh */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = xh; path = xh.lproj/MainInterface.strings; sourceTree = "<group>"; };
6DF25A9E249DB97E001D06F5 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
6DFC807124EA2FA9007B8700 /* ViewQRCodefaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewQRCodefaceController.swift; sourceTree = "<group>"; };
6EB3338E347F4AFAA8C85C04 /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; };
70C9C17A3F52430B99582AF4 /* libRNCamera.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCamera.a; sourceTree = "<group>"; };
731973BA0AC6EA78962CE5B6 /* libPods-BlueWallet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BlueWallet.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -337,7 +339,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
6DFC807024EA0B6C007B8700 /* BuildFile in Frameworks */,
6DFC807024EA0B6C007B8700 /* EFQRCode in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -506,6 +508,7 @@
B40D4E552258425400428FCC /* InterfaceController.swift */,
B40D4E562258425400428FCC /* NumericKeypadInterfaceController.swift */,
B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */,
6DFC807124EA2FA9007B8700 /* ViewQRCodefaceController.swift */,
B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */,
B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */,
B40D4E49225841ED00428FCC /* Info.plist */,
@ -691,7 +694,7 @@
);
name = "BlueWalletWatch Extension";
packageProductDependencies = (
6DFC806F24EA0B6C007B8700 /* SwiftPackageProductDependency */,
6DFC806F24EA0B6C007B8700 /* EFQRCode */,
);
productName = "BlueWalletWatch Extension";
productReference = B40D4E3C225841ED00428FCC /* BlueWalletWatch Extension.appex */;
@ -790,7 +793,7 @@
);
mainGroup = 83CBB9F61A601CBA00E9B192;
packageReferences = (
6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */,
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */,
);
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
@ -1005,6 +1008,7 @@
32F0A29A2311DBB20095C559 /* ComplicationController.swift in Sources */,
B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */,
B43D0379225847C500FBAA95 /* WatchDataSource.swift in Sources */,
6DFC807224EA2FA9007B8700 /* ViewQRCodefaceController.swift in Sources */,
B40D4E46225841ED00428FCC /* NotificationController.swift in Sources */,
B40D4E5D2258425500428FCC /* InterfaceController.swift in Sources */,
B43D037B225847C500FBAA95 /* TransactionTableRow.swift in Sources */,
@ -1921,7 +1925,7 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */ = {
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EFPrefix/EFQRCode.git";
requirement = {
@ -1932,9 +1936,9 @@
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
6DFC806F24EA0B6C007B8700 /* SwiftPackageProductDependency */ = {
6DFC806F24EA0B6C007B8700 /* EFQRCode */ = {
isa = XCSwiftPackageProductDependency;
package = 6DFC806E24EA0B6C007B8700 /* RemoteSwiftPackageReference */;
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */;
productName = EFQRCode;
};
/* End XCSwiftPackageProductDependency section */

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.io.bluewallet.bluewallet</string>
</array>
</dict>
</plist>

View File

@ -18,8 +18,9 @@ class Wallet: NSObject, NSCoding {
let preferredBalanceUnit: String
let receiveAddress: String
let transactions: [Transaction]
let xpub: String?
init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int) {
init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?) {
self.label = label
self.balance = balance
self.type = type
@ -27,6 +28,7 @@ class Wallet: NSObject, NSCoding {
self.receiveAddress = receiveAddress
self.transactions = transactions
self.identifier = identifier
self.xpub = xpub
}
func encode(with aCoder: NSCoder) {
@ -37,6 +39,7 @@ class Wallet: NSObject, NSCoding {
aCoder.encode(preferredBalanceUnit, forKey: "preferredBalanceUnit")
aCoder.encode(transactions, forKey: "transactions")
aCoder.encode(identifier, forKey: "identifier")
aCoder.encode(xpub, forKey: "xpub")
}
required init?(coder aDecoder: NSCoder) {
@ -46,6 +49,8 @@ class Wallet: NSObject, NSCoding {
preferredBalanceUnit = aDecoder.decodeObject(forKey: "preferredBalanceUnit") as! String
receiveAddress = aDecoder.decodeObject(forKey: "receiveAddress") as! String
transactions = aDecoder.decodeObject(forKey: "transactions") as? [Transaction] ?? [Transaction]()
xpub = aDecoder.decodeObject(forKey: "xpub") as? String
}
}

View File

@ -45,7 +45,8 @@ class WatchDataSource: NSObject, WCSessionDelegate {
transactionsProcessed.append(transaction)
}
let receiveAddress = entry["receiveAddress"] as? String ?? ""
let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index)
let xpub = entry["xpub"] as? String ?? ""
let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index, xpub: xpub)
wallets.append(wallet)
}
@ -78,10 +79,6 @@ class WatchDataSource: NSObject, WCSessionDelegate {
}
}
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
WatchDataSource.shared.processWalletsData(walletsInfo: applicationContext)
}
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) {
WatchDataSource.shared.processWalletsData(walletsInfo: applicationContext)
}

View File

@ -0,0 +1,37 @@
//
// ReceiveInterfaceController.swift
// BlueWalletWatch Extension
//
// Created by Marcos Rodriguez on 3/12/19.
// Copyright © 2019 Facebook. All rights reserved.
//
import WatchKit
import Foundation
import EFQRCode
class ViewQRCodefaceController: WKInterfaceController {
static let identifier = "ViewQRCodefaceController"
@IBOutlet weak var imageInterface: WKInterfaceImage!
var qrcodeData: String?
override func awake(withContext context: Any?) {
super.awake(withContext: context)
guard let passedContext = context as? String else {
pop()
return
}
DispatchQueue.main.async {
guard let cgImage = EFQRCode.generate(
content: passedContext) else {
return
}
let image = UIImage(cgImage: cgImage)
self.imageInterface.setImage(nil)
self.imageInterface.setImage(image)
}
}
}

View File

@ -36,6 +36,23 @@ class WalletDetailsInterfaceController: WKInterfaceController {
walletBasicsGroup.setBackgroundImageNamed(WalletGradient(rawValue: wallet.type)?.imageString)
createInvoiceButton.setHidden(wallet.type != "lightningCustodianWallet")
processWalletsTable()
addMenuItems()
}
func addMenuItems() {
guard let wallet = wallet else {
return
}
if wallet.type != "lightningCustodianWallet" && !(wallet.xpub ?? "").isEmpty {
addMenuItem(with: .share, title: "View XPub", action: #selector(viewXPubMenuItemTapped))
}
}
@objc func viewXPubMenuItemTapped() {
guard let xpub = wallet?.xpub else {
return
}
presentController(withName: ViewQRCodefaceController.identifier, context: xpub)
}
override func willActivate() {

View File

@ -54,10 +54,10 @@
</objects>
<point key="canvasLocation" x="220" y="345"/>
</scene>
<!--WalletDetailsInterfaceController-->
<!--Transactions-->
<scene sceneID="KqX-Cy-IJm">
<objects>
<controller identifier="WalletDetailsInterfaceController" id="XWa-4i-Abg" customClass="WalletDetailsInterfaceController" customModule="BlueWalletWatch_Extension">
<controller identifier="WalletDetailsInterfaceController" title="Transactions" id="XWa-4i-Abg" customClass="WalletDetailsInterfaceController" customModule="BlueWalletWatch_Extension">
<items>
<group width="1" height="66.5" alignment="left" backgroundImage="walletHD" radius="8" id="275-K7-Qhe" customClass="WalletInformation" customModule="BlueWalletWatch_Extension">
<items>
@ -167,10 +167,10 @@
</objects>
<point key="canvasLocation" x="468" y="643"/>
</scene>
<!--ReceiveInterfaceController-->
<!--Receive-->
<scene sceneID="tQ7-Qr-5i4">
<objects>
<controller identifier="ReceiveInterfaceController" fullBounds="YES" id="egq-Yw-qK5" customClass="ReceiveInterfaceController" customModule="BlueWalletWatch_Extension">
<controller identifier="ReceiveInterfaceController" title="Receive" fullBounds="YES" id="egq-Yw-qK5" customClass="ReceiveInterfaceController" customModule="BlueWalletWatch_Extension">
<items>
<imageView height="0.90000000000000002" alignment="left" id="Dnb-sM-wdN"/>
<group width="1" alignment="center" verticalAlignment="center" hidden="YES" layout="vertical" id="0If-FP-smM">
@ -198,6 +198,21 @@
</objects>
<point key="canvasLocation" x="716" y="345"/>
</scene>
<!--ViewQRCodefaceController-->
<scene sceneID="jZ8-sK-IyQ">
<objects>
<controller identifier="ViewQRCodefaceController" fullBounds="YES" id="ON9-Qg-65y" customClass="ViewQRCodefaceController" customModule="BlueWalletWatch_Extension">
<items>
<imageView height="0.90000000000000002" alignment="left" id="cp4-B3-gV6"/>
</items>
<edgeInsets key="margins" left="4" right="4" top="4" bottom="4"/>
<connections>
<outlet property="imageInterface" destination="cp4-B3-gV6" id="aOC-cT-eKL"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="715" y="66"/>
</scene>
<!--SpecifyInterfaceController-->
<scene sceneID="erR-Ld-VGW">
<objects>