mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-01 11:39:40 +01:00
Merge pull request #6705 from BlueWallet/watchpaymentcode
ADD: View Payment Code on Watch app
This commit is contained in:
commit
fc868c020f
16 changed files with 199 additions and 502 deletions
|
@ -232,6 +232,9 @@ function WatchConnectivity() {
|
||||||
if (wallet.chain === Chain.ONCHAIN && wallet.type !== MultisigHDWallet.type) {
|
if (wallet.chain === Chain.ONCHAIN && wallet.type !== MultisigHDWallet.type) {
|
||||||
walletInformation.xpub = wallet.getXpub() ? wallet.getXpub() : wallet.getSecret();
|
walletInformation.xpub = wallet.getXpub() ? wallet.getXpub() : wallet.getSecret();
|
||||||
}
|
}
|
||||||
|
if (wallet.allowBIP47() && wallet.isBIP47Enabled()) {
|
||||||
|
walletInformation.paymentCode = wallet.getBIP47PaymentCode();
|
||||||
|
}
|
||||||
walletsToProcess.push(walletInformation);
|
walletsToProcess.push(walletInformation);
|
||||||
}
|
}
|
||||||
return { wallets: walletsToProcess, randomID: Math.floor(Math.random() * 11) };
|
return { wallets: walletsToProcess, randomID: Math.floor(Math.random() * 11) };
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */; };
|
B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */; };
|
||||||
B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */; };
|
B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */; };
|
||||||
B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */; };
|
B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */; };
|
||||||
B40D4E682258426B00428FCC /* KeychainSwiftDistrib.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */; };
|
|
||||||
B40FC3FA29CCD1D00007EBAC /* SwiftTCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */; };
|
B40FC3FA29CCD1D00007EBAC /* SwiftTCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */; };
|
||||||
B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76842B66B2FF002C48D5 /* Bugsnag */; };
|
B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76842B66B2FF002C48D5 /* Bugsnag */; };
|
||||||
B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */; };
|
B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */; };
|
||||||
|
@ -146,6 +145,7 @@
|
||||||
B461B852299599F800E431AA /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B461B851299599F800E431AA /* AppDelegate.mm */; };
|
B461B852299599F800E431AA /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B461B851299599F800E431AA /* AppDelegate.mm */; };
|
||||||
B47462D02C1538D800100825 /* CustomSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B45010A52C1507DE00619044 /* CustomSegmentedControlManager.m */; };
|
B47462D02C1538D800100825 /* CustomSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B45010A52C1507DE00619044 /* CustomSegmentedControlManager.m */; };
|
||||||
B47B21EC2B2128B8001F6690 /* BlueWalletUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47B21EB2B2128B8001F6690 /* BlueWalletUITests.swift */; };
|
B47B21EC2B2128B8001F6690 /* BlueWalletUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47B21EB2B2128B8001F6690 /* BlueWalletUITests.swift */; };
|
||||||
|
B48A6A292C1DF01000030AB9 /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B48A6A282C1DF01000030AB9 /* KeychainSwift */; };
|
||||||
B49038D92B8FBAD300A8164A /* BlueWalletUITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49038D82B8FBAD300A8164A /* BlueWalletUITest.swift */; };
|
B49038D92B8FBAD300A8164A /* BlueWalletUITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49038D82B8FBAD300A8164A /* BlueWalletUITest.swift */; };
|
||||||
B4A29A2C2B55C990002A67DF /* EventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D32C5C52596CE3A008C077C /* EventEmitter.m */; };
|
B4A29A2C2B55C990002A67DF /* EventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D32C5C52596CE3A008C077C /* EventEmitter.m */; };
|
||||||
B4A29A2D2B55C990002A67DF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
B4A29A2D2B55C990002A67DF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||||
|
@ -163,9 +163,13 @@
|
||||||
B4B1A4622BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
B4B1A4622BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
||||||
B4B1A4642BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
B4B1A4642BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
||||||
B4B1A4652BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
B4B1A4652BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; };
|
||||||
|
B4D0B2622C1DEA11006B6B1B /* ReceivePageInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */; };
|
||||||
|
B4D0B2642C1DEA99006B6B1B /* ReceiveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */; };
|
||||||
|
B4D0B2662C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */; };
|
||||||
|
B4D0B2682C1DED67006B6B1B /* ReceiveMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */; };
|
||||||
B4EE583C226703320003363C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B40D4E35225841ED00428FCC /* Assets.xcassets */; };
|
B4EE583C226703320003363C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B40D4E35225841ED00428FCC /* Assets.xcassets */; };
|
||||||
C59F90CE0D04D3E4BB39BC5D /* libPods-BlueWalletUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F02C2F7CA3591E4E0B06EBA /* libPods-BlueWalletUITests.a */; };
|
C59F90CE0D04D3E4BB39BC5D /* libPods-BlueWalletUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F02C2F7CA3591E4E0B06EBA /* libPods-BlueWalletUITests.a */; };
|
||||||
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
|
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */ = {isa = PBXBuildFile; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
@ -422,7 +426,6 @@
|
||||||
B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpecifyInterfaceController.swift; sourceTree = "<group>"; };
|
B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpecifyInterfaceController.swift; sourceTree = "<group>"; };
|
||||||
B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiveInterfaceController.swift; sourceTree = "<group>"; };
|
B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiveInterfaceController.swift; sourceTree = "<group>"; };
|
||||||
B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletDetailsInterfaceController.swift; sourceTree = "<group>"; };
|
B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletDetailsInterfaceController.swift; sourceTree = "<group>"; };
|
||||||
B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainSwiftDistrib.swift; sourceTree = SOURCE_ROOT; };
|
|
||||||
B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTCPClient.swift; sourceTree = "<group>"; };
|
B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTCPClient.swift; sourceTree = "<group>"; };
|
||||||
B41C2E552BB3DCB8000FE097 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
|
B41C2E552BB3DCB8000FE097 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
|
||||||
B43B69BA225C46D800925B1E /* libRCTLinking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libRCTLinking.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
B43B69BA225C46D800925B1E /* libRCTLinking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libRCTLinking.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -458,6 +461,10 @@
|
||||||
B4A29A462B55C990002A67DF /* BlueWallet-NoLDK.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BlueWallet-NoLDK.plist"; sourceTree = "<absolute>"; };
|
B4A29A462B55C990002A67DF /* BlueWallet-NoLDK.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BlueWallet-NoLDK.plist"; sourceTree = "<absolute>"; };
|
||||||
B4AB225C2B02AD12001F4328 /* XMLParserDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLParserDelegate.swift; sourceTree = "<group>"; };
|
B4AB225C2B02AD12001F4328 /* XMLParserDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLParserDelegate.swift; sourceTree = "<group>"; };
|
||||||
B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetHelper.swift; sourceTree = "<group>"; };
|
B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetHelper.swift; sourceTree = "<group>"; };
|
||||||
|
B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceivePageInterfaceController.swift; sourceTree = "<group>"; };
|
||||||
|
B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveType.swift; sourceTree = "<group>"; };
|
||||||
|
B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveInterfaceMode.swift; sourceTree = "<group>"; };
|
||||||
|
B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveMethod.swift; sourceTree = "<group>"; };
|
||||||
B4D3235A177F4580BA52F2F9 /* libRNCSlider.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCSlider.a; sourceTree = "<group>"; };
|
B4D3235A177F4580BA52F2F9 /* libRNCSlider.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCSlider.a; sourceTree = "<group>"; };
|
||||||
B642AFB13483418CAB6FF25E /* libRCTQRCodeLocalImage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTQRCodeLocalImage.a; sourceTree = "<group>"; };
|
B642AFB13483418CAB6FF25E /* libRCTQRCodeLocalImage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTQRCodeLocalImage.a; sourceTree = "<group>"; };
|
||||||
B68F8552DD4428F64B11DCFB /* Pods-BlueWallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueWallet.debug.xcconfig"; path = "Target Support Files/Pods-BlueWallet/Pods-BlueWallet.debug.xcconfig"; sourceTree = "<group>"; };
|
B68F8552DD4428F64B11DCFB /* Pods-BlueWallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueWallet.debug.xcconfig"; path = "Target Support Files/Pods-BlueWallet/Pods-BlueWallet.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
@ -484,7 +491,7 @@
|
||||||
files = (
|
files = (
|
||||||
782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */,
|
782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */,
|
||||||
764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */,
|
764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */,
|
||||||
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */,
|
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */,
|
||||||
773E382FE62E836172AAB98B /* libPods-BlueWallet.a in Frameworks */,
|
773E382FE62E836172AAB98B /* libPods-BlueWallet.a in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -518,6 +525,7 @@
|
||||||
files = (
|
files = (
|
||||||
B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */,
|
B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */,
|
||||||
B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */,
|
B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */,
|
||||||
|
B48A6A292C1DF01000030AB9 /* KeychainSwift in Frameworks */,
|
||||||
6DFC807024EA0B6C007B8700 /* EFQRCode in Frameworks */,
|
6DFC807024EA0B6C007B8700 /* EFQRCode in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -771,7 +779,6 @@
|
||||||
children = (
|
children = (
|
||||||
32F0A24F2310B0700095C559 /* BlueWalletWatch Extension.entitlements */,
|
32F0A24F2310B0700095C559 /* BlueWalletWatch Extension.entitlements */,
|
||||||
B43D03242258474500FBAA95 /* Objects */,
|
B43D03242258474500FBAA95 /* Objects */,
|
||||||
B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */,
|
|
||||||
32F0A2992311DBB20095C559 /* ComplicationController.swift */,
|
32F0A2992311DBB20095C559 /* ComplicationController.swift */,
|
||||||
B40D4E43225841ED00428FCC /* ExtensionDelegate.swift */,
|
B40D4E43225841ED00428FCC /* ExtensionDelegate.swift */,
|
||||||
B40D4E45225841ED00428FCC /* NotificationController.swift */,
|
B40D4E45225841ED00428FCC /* NotificationController.swift */,
|
||||||
|
@ -783,6 +790,7 @@
|
||||||
B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */,
|
B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */,
|
||||||
B40D4E49225841ED00428FCC /* Info.plist */,
|
B40D4E49225841ED00428FCC /* Info.plist */,
|
||||||
B40D4E4A225841ED00428FCC /* PushNotificationPayload.apns */,
|
B40D4E4A225841ED00428FCC /* PushNotificationPayload.apns */,
|
||||||
|
B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */,
|
||||||
);
|
);
|
||||||
path = "BlueWalletWatch Extension";
|
path = "BlueWalletWatch Extension";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -828,6 +836,9 @@
|
||||||
B43D0377225847C500FBAA95 /* WalletInformation.swift */,
|
B43D0377225847C500FBAA95 /* WalletInformation.swift */,
|
||||||
B43D0373225847C500FBAA95 /* WatchDataSource.swift */,
|
B43D0373225847C500FBAA95 /* WatchDataSource.swift */,
|
||||||
849047C92702A32A008EE567 /* Handoff.swift */,
|
849047C92702A32A008EE567 /* Handoff.swift */,
|
||||||
|
B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */,
|
||||||
|
B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */,
|
||||||
|
B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */,
|
||||||
);
|
);
|
||||||
path = Objects;
|
path = Objects;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1021,6 +1032,7 @@
|
||||||
6DFC806F24EA0B6C007B8700 /* EFQRCode */,
|
6DFC806F24EA0B6C007B8700 /* EFQRCode */,
|
||||||
B41B76842B66B2FF002C48D5 /* Bugsnag */,
|
B41B76842B66B2FF002C48D5 /* Bugsnag */,
|
||||||
B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */,
|
B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */,
|
||||||
|
B48A6A282C1DF01000030AB9 /* KeychainSwift */,
|
||||||
);
|
);
|
||||||
productName = "BlueWalletWatch Extension";
|
productName = "BlueWalletWatch Extension";
|
||||||
productReference = B40D4E3C225841ED00428FCC /* BlueWalletWatch Extension.appex */;
|
productReference = B40D4E3C225841ED00428FCC /* BlueWalletWatch Extension.appex */;
|
||||||
|
@ -1152,8 +1164,9 @@
|
||||||
);
|
);
|
||||||
mainGroup = 83CBB9F61A601CBA00E9B192;
|
mainGroup = 83CBB9F61A601CBA00E9B192;
|
||||||
packageReferences = (
|
packageReferences = (
|
||||||
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */,
|
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */,
|
||||||
B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */,
|
B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */,
|
||||||
|
B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */,
|
||||||
);
|
);
|
||||||
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
|
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
@ -1611,10 +1624,12 @@
|
||||||
B43D037A225847C500FBAA95 /* Transaction.swift in Sources */,
|
B43D037A225847C500FBAA95 /* Transaction.swift in Sources */,
|
||||||
32F0A29A2311DBB20095C559 /* ComplicationController.swift in Sources */,
|
32F0A29A2311DBB20095C559 /* ComplicationController.swift in Sources */,
|
||||||
B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */,
|
B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */,
|
||||||
|
B4D0B2642C1DEA99006B6B1B /* ReceiveType.swift in Sources */,
|
||||||
B43D0379225847C500FBAA95 /* WatchDataSource.swift in Sources */,
|
B43D0379225847C500FBAA95 /* WatchDataSource.swift in Sources */,
|
||||||
B450109F2C0FCDA500619044 /* Utilities.swift in Sources */,
|
B450109F2C0FCDA500619044 /* Utilities.swift in Sources */,
|
||||||
B44033D42BCC368800162242 /* UserDefaultsGroupKey.swift in Sources */,
|
B44033D42BCC368800162242 /* UserDefaultsGroupKey.swift in Sources */,
|
||||||
B44034012BCC37F800162242 /* Bundle+decode.swift in Sources */,
|
B44034012BCC37F800162242 /* Bundle+decode.swift in Sources */,
|
||||||
|
B4D0B2682C1DED67006B6B1B /* ReceiveMethod.swift in Sources */,
|
||||||
849047CA2702A32A008EE567 /* Handoff.swift in Sources */,
|
849047CA2702A32A008EE567 /* Handoff.swift in Sources */,
|
||||||
B44033EA2BCC371A00162242 /* MarketData.swift in Sources */,
|
B44033EA2BCC371A00162242 /* MarketData.swift in Sources */,
|
||||||
B44033CB2BCC350A00162242 /* Currency.swift in Sources */,
|
B44033CB2BCC350A00162242 /* Currency.swift in Sources */,
|
||||||
|
@ -1623,12 +1638,12 @@
|
||||||
B40D4E5D2258425500428FCC /* InterfaceController.swift in Sources */,
|
B40D4E5D2258425500428FCC /* InterfaceController.swift in Sources */,
|
||||||
B44033FA2BCC379200162242 /* WidgetDataStore.swift in Sources */,
|
B44033FA2BCC379200162242 /* WidgetDataStore.swift in Sources */,
|
||||||
B44033DE2BCC36C300162242 /* LatestTransaction.swift in Sources */,
|
B44033DE2BCC36C300162242 /* LatestTransaction.swift in Sources */,
|
||||||
|
B4D0B2662C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift in Sources */,
|
||||||
B43D037B225847C500FBAA95 /* TransactionTableRow.swift in Sources */,
|
B43D037B225847C500FBAA95 /* TransactionTableRow.swift in Sources */,
|
||||||
B43D037D225847C500FBAA95 /* WalletInformation.swift in Sources */,
|
B43D037D225847C500FBAA95 /* WalletInformation.swift in Sources */,
|
||||||
6D4AF15925D21172009DD853 /* MarketAPI.swift in Sources */,
|
6D4AF15925D21172009DD853 /* MarketAPI.swift in Sources */,
|
||||||
B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */,
|
B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */,
|
||||||
B40D4E44225841ED00428FCC /* ExtensionDelegate.swift in Sources */,
|
B40D4E44225841ED00428FCC /* ExtensionDelegate.swift in Sources */,
|
||||||
B40D4E682258426B00428FCC /* KeychainSwiftDistrib.swift in Sources */,
|
|
||||||
6D4AF16D25D21192009DD853 /* Placeholders.swift in Sources */,
|
6D4AF16D25D21192009DD853 /* Placeholders.swift in Sources */,
|
||||||
B44033DB2BCC369B00162242 /* Colors.swift in Sources */,
|
B44033DB2BCC369B00162242 /* Colors.swift in Sources */,
|
||||||
B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */,
|
B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */,
|
||||||
|
@ -1636,6 +1651,7 @@
|
||||||
B44033C02BCC32F800162242 /* BitcoinUnit.swift in Sources */,
|
B44033C02BCC32F800162242 /* BitcoinUnit.swift in Sources */,
|
||||||
B44033E52BCC36FF00162242 /* WalletData.swift in Sources */,
|
B44033E52BCC36FF00162242 /* WalletData.swift in Sources */,
|
||||||
B44033EF2BCC374500162242 /* Numeric+abbreviated.swift in Sources */,
|
B44033EF2BCC374500162242 /* Numeric+abbreviated.swift in Sources */,
|
||||||
|
B4D0B2622C1DEA11006B6B1B /* ReceivePageInterfaceController.swift in Sources */,
|
||||||
B44033D02BCC352F00162242 /* UserDefaultsGroup.swift in Sources */,
|
B44033D02BCC352F00162242 /* UserDefaultsGroup.swift in Sources */,
|
||||||
B44033C52BCC332400162242 /* Balance.swift in Sources */,
|
B44033C52BCC332400162242 /* Balance.swift in Sources */,
|
||||||
6D4AF18425D215D1009DD853 /* UserDefaultsExtension.swift in Sources */,
|
6D4AF18425D215D1009DD853 /* UserDefaultsExtension.swift in Sources */,
|
||||||
|
@ -2250,7 +2266,7 @@
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = 4;
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 6.0;
|
WATCHOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -2299,7 +2315,7 @@
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = 4;
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 6.0;
|
WATCHOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
@ -2346,7 +2362,7 @@
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 4.2;
|
SWIFT_VERSION = 4.2;
|
||||||
TARGETED_DEVICE_FAMILY = 4;
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 6.0;
|
WATCHOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
@ -2393,7 +2409,7 @@
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
SWIFT_VERSION = 4.2;
|
SWIFT_VERSION = 4.2;
|
||||||
TARGETED_DEVICE_FAMILY = 4;
|
TARGETED_DEVICE_FAMILY = 4;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 6.0;
|
WATCHOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
@ -2671,7 +2687,7 @@
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
/* Begin XCRemoteSwiftPackageReference section */
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */ = {
|
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = {
|
||||||
isa = XCRemoteSwiftPackageReference;
|
isa = XCRemoteSwiftPackageReference;
|
||||||
repositoryURL = "https://github.com/EFPrefix/EFQRCode.git";
|
repositoryURL = "https://github.com/EFPrefix/EFQRCode.git";
|
||||||
requirement = {
|
requirement = {
|
||||||
|
@ -2687,12 +2703,20 @@
|
||||||
version = 6.28.1;
|
version = 6.28.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/evgenyneu/keychain-swift.git";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 24.0.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
/* End XCRemoteSwiftPackageReference section */
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
/* Begin XCSwiftPackageProductDependency section */
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
6DFC806F24EA0B6C007B8700 /* EFQRCode */ = {
|
6DFC806F24EA0B6C007B8700 /* EFQRCode */ = {
|
||||||
isa = XCSwiftPackageProductDependency;
|
isa = XCSwiftPackageProductDependency;
|
||||||
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */;
|
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */;
|
||||||
productName = EFQRCode;
|
productName = EFQRCode;
|
||||||
};
|
};
|
||||||
B41B76842B66B2FF002C48D5 /* Bugsnag */ = {
|
B41B76842B66B2FF002C48D5 /* Bugsnag */ = {
|
||||||
|
@ -2705,6 +2729,11 @@
|
||||||
package = B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */;
|
package = B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */;
|
||||||
productName = BugsnagNetworkRequestPlugin;
|
productName = BugsnagNetworkRequestPlugin;
|
||||||
};
|
};
|
||||||
|
B48A6A282C1DF01000030AB9 /* KeychainSwift */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */;
|
||||||
|
productName = KeychainSwift;
|
||||||
|
};
|
||||||
/* End XCSwiftPackageProductDependency section */
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
|
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"originHash" : "52530e6b1e3a85c8854952ef703a6d1bbe1acd82713be2b3166476b9b277db23",
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "bugsnag-cocoa",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/bugsnag/bugsnag-cocoa",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "16b9145fc66e5296f16e733f6feb5d0e450574e8",
|
||||||
|
"version" : "6.28.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "efqrcode",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/EFPrefix/EFQRCode.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "2991c2f318ad9529d93b2a73a382a3f9c72c64ce",
|
||||||
|
"version" : "6.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "keychain-swift",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/evgenyneu/keychain-swift.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "5e1b02b6a9dac2a759a1d5dbc175c86bd192a608",
|
||||||
|
"version" : "24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift_qrcodejs",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/ApolloZhu/swift_qrcodejs.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "374dc7f7b9e76c6aeb393f6a84590c6d387e1ecb",
|
||||||
|
"version" : "2.2.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
|
}
|
|
@ -15,9 +15,7 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate {
|
||||||
@IBOutlet weak var noWalletsAvailableLabel: WKInterfaceLabel!
|
@IBOutlet weak var noWalletsAvailableLabel: WKInterfaceLabel!
|
||||||
|
|
||||||
override func awake(withContext context: Any?) {
|
override func awake(withContext context: Any?) {
|
||||||
super.awake(withContext: context)
|
|
||||||
setupSession()
|
setupSession()
|
||||||
processContextData(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func willActivate() {
|
override func willActivate() {
|
||||||
|
@ -64,13 +62,15 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate {
|
||||||
WatchDataSource.shared.processData(data: applicationContext)
|
WatchDataSource.shared.processData(data: applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any] = [:]) {
|
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any] = [:]) {
|
||||||
WatchDataSource.shared.processData(data: userInfo)
|
WatchDataSource.shared.processData(data: userInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
|
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
|
||||||
if activationState == .activated {
|
if activationState == .activated {
|
||||||
WatchDataSource.shared.processWalletsData(walletsInfo: WCSession.default.applicationContext)
|
WatchDataSource.shared.loadKeychainData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,4 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate {
|
||||||
WatchDataSource.shared.processData(data: message)
|
WatchDataSource.shared.processData(data: message)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didDeactivate() {
|
|
||||||
WCSession.default.activate()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// ReceiveInterfaceMode.swift
|
||||||
|
// BlueWalletWatch Extension
|
||||||
|
//
|
||||||
|
// Created by Marcos Rodriguez on 6/15/24.
|
||||||
|
// Copyright © 2024 BlueWallet. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum ReceiveInterfaceMode {
|
||||||
|
case Address, QRCode
|
||||||
|
}
|
13
ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift
Normal file
13
ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// ReceiveMethod.swift
|
||||||
|
// BlueWalletWatch Extension
|
||||||
|
//
|
||||||
|
// Created by Marcos Rodriguez on 6/15/24.
|
||||||
|
// Copyright © 2024 BlueWallet. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum ReceiveMethod {
|
||||||
|
case Onchain, CreateInvoice
|
||||||
|
}
|
13
ios/BlueWalletWatch Extension/Objects/ReceiveType.swift
Normal file
13
ios/BlueWalletWatch Extension/Objects/ReceiveType.swift
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// ReceiveType.swift
|
||||||
|
// BlueWalletWatch Extension
|
||||||
|
//
|
||||||
|
// Created by Marcos Rodriguez on 6/15/24.
|
||||||
|
// Copyright © 2024 BlueWallet. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum ReceiveType {
|
||||||
|
case Address, PaymentCode
|
||||||
|
}
|
|
@ -8,7 +8,9 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class Transaction: NSObject, NSCoding {
|
class Transaction: NSObject, NSSecureCoding {
|
||||||
|
static var supportsSecureCoding: Bool = true
|
||||||
|
|
||||||
static let identifier: String = "Transaction"
|
static let identifier: String = "Transaction"
|
||||||
|
|
||||||
let time: String
|
let time: String
|
||||||
|
|
|
@ -8,11 +8,10 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum InterfaceMode {
|
class Wallet: NSObject, NSSecureCoding {
|
||||||
case Address, QRCode
|
|
||||||
}
|
static var supportsSecureCoding: Bool = true
|
||||||
|
|
||||||
class Wallet: NSObject, NSCoding {
|
|
||||||
static let identifier: String = "Wallet"
|
static let identifier: String = "Wallet"
|
||||||
|
|
||||||
var identifier: Int?
|
var identifier: Int?
|
||||||
|
@ -24,8 +23,9 @@ class Wallet: NSObject, NSCoding {
|
||||||
let transactions: [Transaction]
|
let transactions: [Transaction]
|
||||||
let xpub: String?
|
let xpub: String?
|
||||||
let hideBalance: Bool
|
let hideBalance: Bool
|
||||||
|
let paymentCode: String?
|
||||||
|
|
||||||
init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?, hideBalance: Bool = false) {
|
init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?, hideBalance: Bool = false, paymentCode: String?) {
|
||||||
self.label = label
|
self.label = label
|
||||||
self.balance = balance
|
self.balance = balance
|
||||||
self.type = type
|
self.type = type
|
||||||
|
@ -35,6 +35,7 @@ class Wallet: NSObject, NSCoding {
|
||||||
self.identifier = identifier
|
self.identifier = identifier
|
||||||
self.xpub = xpub
|
self.xpub = xpub
|
||||||
self.hideBalance = hideBalance
|
self.hideBalance = hideBalance
|
||||||
|
self.paymentCode = paymentCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func encode(with aCoder: NSCoder) {
|
func encode(with aCoder: NSCoder) {
|
||||||
|
@ -47,6 +48,7 @@ class Wallet: NSObject, NSCoding {
|
||||||
aCoder.encode(identifier, forKey: "identifier")
|
aCoder.encode(identifier, forKey: "identifier")
|
||||||
aCoder.encode(xpub, forKey: "xpub")
|
aCoder.encode(xpub, forKey: "xpub")
|
||||||
aCoder.encode(hideBalance, forKey: "hideBalance")
|
aCoder.encode(hideBalance, forKey: "hideBalance")
|
||||||
|
aCoder.encode(paymentCode, forKey: "paymentCode")
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
@ -58,6 +60,7 @@ class Wallet: NSObject, NSCoding {
|
||||||
transactions = aDecoder.decodeObject(forKey: "transactions") as? [Transaction] ?? [Transaction]()
|
transactions = aDecoder.decodeObject(forKey: "transactions") as? [Transaction] ?? [Transaction]()
|
||||||
xpub = aDecoder.decodeObject(forKey: "xpub") as? String
|
xpub = aDecoder.decodeObject(forKey: "xpub") as? String
|
||||||
hideBalance = aDecoder.decodeObject(forKey: "hideBalance") as? Bool ?? false
|
hideBalance = aDecoder.decodeObject(forKey: "hideBalance") as? Bool ?? false
|
||||||
|
paymentCode = aDecoder.decodeObject(forKey: "paymentCode") as? String
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import WatchConnectivity
|
import WatchConnectivity
|
||||||
|
import KeychainSwift
|
||||||
|
|
||||||
class WatchDataSource: NSObject {
|
class WatchDataSource: NSObject {
|
||||||
struct NotificationName {
|
struct NotificationName {
|
||||||
|
@ -27,8 +28,12 @@ class WatchDataSource: NSObject {
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
if let existingData = keychain.getData(Wallet.identifier), let walletData = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(existingData) as? [Wallet]) as [Wallet]??) {
|
loadKeychainData()
|
||||||
guard let walletData = walletData, walletData != self.wallets else { return }
|
}
|
||||||
|
|
||||||
|
func loadKeychainData() {
|
||||||
|
if let existingData = keychain.getData(Wallet.identifier), let walletData = try? NSKeyedUnarchiver.unarchivedArrayOfObjects(ofClass: Wallet.self, from: existingData) {
|
||||||
|
guard walletData != self.wallets else { return }
|
||||||
wallets = walletData
|
wallets = walletData
|
||||||
WatchDataSource.postDataUpdatedNotification()
|
WatchDataSource.postDataUpdatedNotification()
|
||||||
}
|
}
|
||||||
|
@ -38,7 +43,7 @@ class WatchDataSource: NSObject {
|
||||||
if let walletsToProcess = walletsInfo["wallets"] as? [[String: Any]] {
|
if let walletsToProcess = walletsInfo["wallets"] as? [[String: Any]] {
|
||||||
wallets.removeAll();
|
wallets.removeAll();
|
||||||
for (index, entry) in walletsToProcess.enumerated() {
|
for (index, entry) in walletsToProcess.enumerated() {
|
||||||
guard let label = entry["label"] as? String, let balance = entry["balance"] as? String, let type = entry["type"] as? String, let preferredBalanceUnit = entry["preferredBalanceUnit"] as? String, let transactions = entry["transactions"] as? [[String: Any]] else {
|
guard let label = entry["label"] as? String, let balance = entry["balance"] as? String, let type = entry["type"] as? String, let preferredBalanceUnit = entry["preferredBalanceUnit"] as? String, let transactions = entry["transactions"] as? [[String: Any]], let paymentCode = entry["paymentCode"] as? String else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +56,7 @@ class WatchDataSource: NSObject {
|
||||||
let receiveAddress = entry["receiveAddress"] as? String ?? ""
|
let receiveAddress = entry["receiveAddress"] as? String ?? ""
|
||||||
let xpub = entry["xpub"] as? String ?? ""
|
let xpub = entry["xpub"] as? String ?? ""
|
||||||
let hideBalance = entry["hideBalance"] as? Bool ?? false
|
let hideBalance = entry["hideBalance"] as? Bool ?? false
|
||||||
let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index, xpub: xpub, hideBalance: hideBalance)
|
let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index, xpub: xpub, hideBalance: hideBalance, paymentCode: paymentCode)
|
||||||
wallets.append(wallet)
|
wallets.append(wallet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,13 @@ import WatchConnectivity
|
||||||
import Foundation
|
import Foundation
|
||||||
import EFQRCode
|
import EFQRCode
|
||||||
|
|
||||||
import WatchKit
|
|
||||||
import WatchConnectivity
|
|
||||||
import Foundation
|
|
||||||
import EFQRCode
|
|
||||||
|
|
||||||
class ReceiveInterfaceController: WKInterfaceController {
|
class ReceiveInterfaceController: WKInterfaceController {
|
||||||
|
|
||||||
static let identifier = "ReceiveInterfaceController"
|
static let identifier = "ReceiveInterfaceController"
|
||||||
private var wallet: Wallet?
|
private var wallet: Wallet?
|
||||||
private var receiveMethod: String = "receive"
|
private var receiveMethod: ReceiveMethod = .Onchain
|
||||||
private var interfaceMode: InterfaceMode = .Address
|
private var interfaceMode: ReceiveInterfaceMode = .Address
|
||||||
|
var receiveType: ReceiveType = .Address
|
||||||
@IBOutlet weak var addressLabel: WKInterfaceLabel!
|
@IBOutlet weak var addressLabel: WKInterfaceLabel!
|
||||||
@IBOutlet weak var loadingIndicator: WKInterfaceGroup!
|
@IBOutlet weak var loadingIndicator: WKInterfaceGroup!
|
||||||
@IBOutlet weak var imageInterface: WKInterfaceImage!
|
@IBOutlet weak var imageInterface: WKInterfaceImage!
|
||||||
|
@ -35,18 +31,19 @@ class ReceiveInterfaceController: WKInterfaceController {
|
||||||
|
|
||||||
override func awake(withContext context: Any?) {
|
override func awake(withContext context: Any?) {
|
||||||
super.awake(withContext: context)
|
super.awake(withContext: context)
|
||||||
guard let passedContext = context as? (Int, String) else {
|
guard let passedContext = context as? (Int, ReceiveMethod, ReceiveType) else {
|
||||||
pop()
|
pop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let wallet = WatchDataSource.shared.wallets[passedContext.0]
|
let wallet = WatchDataSource.shared.wallets[passedContext.0]
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
receiveMethod = passedContext.1
|
receiveMethod = passedContext.1
|
||||||
|
receiveType = passedContext.2
|
||||||
setupView()
|
setupView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupView() {
|
private func setupView() {
|
||||||
if receiveMethod == "createInvoice" && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) {
|
if receiveMethod == .CreateInvoice && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) {
|
||||||
presentController(withName: SpecifyInterfaceController.identifier, context: wallet?.identifier)
|
presentController(withName: SpecifyInterfaceController.identifier, context: wallet?.identifier)
|
||||||
} else {
|
} else {
|
||||||
setupQRCode()
|
setupQRCode()
|
||||||
|
@ -55,7 +52,7 @@ class ReceiveInterfaceController: WKInterfaceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupQRCode() {
|
private func setupQRCode() {
|
||||||
guard let address = wallet?.receiveAddress else { return }
|
guard let address = receiveType == .Address ? wallet?.receiveAddress : wallet?.paymentCode else { return }
|
||||||
addressLabel.setText(address)
|
addressLabel.setText(address)
|
||||||
generateQRCode(from: address)
|
generateQRCode(from: address)
|
||||||
}
|
}
|
||||||
|
@ -95,7 +92,7 @@ class ReceiveInterfaceController: WKInterfaceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func isCreatingInvoice() -> Bool {
|
private func isCreatingInvoice() -> Bool {
|
||||||
return receiveMethod == "createInvoice" && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue)
|
return receiveMethod == .CreateInvoice && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didDeactivate() {
|
override func didDeactivate() {
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ReceivePageViewController.swift
|
||||||
|
// BlueWalletWatch Extension
|
||||||
|
//
|
||||||
|
// Created by Marcos Rodriguez on 6/15/24.
|
||||||
|
// Copyright © 2024 BlueWallet. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import WatchKit
|
||||||
|
|
||||||
|
class ReceivePageInterfaceController: WKInterfaceController {
|
||||||
|
static let identifier = "ReceivePageInterfaceController"
|
||||||
|
var pageNames = ["Address", "Payment Code"]
|
||||||
|
var pageControllers = ["ReceiveInterfaceController", "ReceiveInterfaceController"]
|
||||||
|
|
||||||
|
override func awake(withContext context: Any?) {
|
||||||
|
super.awake(withContext: context)
|
||||||
|
|
||||||
|
let wallet = context as? Wallet
|
||||||
|
|
||||||
|
WKInterfaceController.reloadRootPageControllers(
|
||||||
|
withNames: pageControllers,
|
||||||
|
contexts: [(wallet,ReceiveMethod.Onchain , ReceiveType.Address), (wallet, ReceiveMethod.Onchain, ReceiveType.PaymentCode)],
|
||||||
|
orientation: .horizontal,
|
||||||
|
pageIndex: 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ class ViewQRCodefaceController: WKInterfaceController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var interfaceMode = InterfaceMode.Address
|
private var interfaceMode = ReceiveInterfaceMode.Address
|
||||||
private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.Xpub.rawValue)
|
private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.Xpub.rawValue)
|
||||||
|
|
||||||
override func awake(withContext context: Any?) {
|
override func awake(withContext context: Any?) {
|
||||||
|
|
|
@ -111,13 +111,13 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
||||||
|
|
||||||
@IBAction func receiveMenuItemTapped() {
|
@IBAction func receiveMenuItemTapped() {
|
||||||
guard let wallet = wallet else { return }
|
guard let wallet = wallet else { return }
|
||||||
presentController(withName: ReceiveInterfaceController.identifier, context: (wallet, "receive"))
|
presentController(withName: ReceivePageInterfaceController.identifier, context: (wallet, ReceiveMethod.Onchain))
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func createInvoiceTapped() {
|
@IBAction func createInvoiceTapped() {
|
||||||
if WatchDataSource.shared.companionWalletsInitialized {
|
if WatchDataSource.shared.companionWalletsInitialized {
|
||||||
guard let wallet = wallet else { return }
|
guard let wallet = wallet else { return }
|
||||||
pushController(withName: ReceiveInterfaceController.identifier, context: (wallet.identifier, "createInvoice"))
|
pushController(withName: ReceiveInterfaceController.identifier, context: (wallet.identifier, ReceiveMethod.CreateInvoice))
|
||||||
} else {
|
} else {
|
||||||
WKInterfaceDevice.current().play(.failure)
|
WKInterfaceDevice.current().play(.failure)
|
||||||
presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in
|
presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in
|
||||||
|
@ -128,7 +128,7 @@ class WalletDetailsInterfaceController: WKInterfaceController {
|
||||||
|
|
||||||
override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
|
override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
|
||||||
guard let wallet = wallet else { return nil }
|
guard let wallet = wallet else { return nil }
|
||||||
return (wallet.identifier, "receive")
|
return (wallet.identifier, ReceiveMethod.Onchain)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="19162" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
|
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="32700.99.1234" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
|
||||||
<device id="watch44"/>
|
<device id="watch44"/>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="watchOS"/>
|
<deployment identifier="watchOS"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="22609"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="19044"/>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
<!--BlueWallet-->
|
<!--BlueWallet-->
|
||||||
|
@ -227,6 +226,13 @@
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="715" y="66"/>
|
<point key="canvasLocation" x="715" y="66"/>
|
||||||
</scene>
|
</scene>
|
||||||
|
<!--Receive Page Interface Controller-->
|
||||||
|
<scene sceneID="6fh-b2-HCf">
|
||||||
|
<objects>
|
||||||
|
<controller id="v6m-dc-zp4" customClass="ReceivePageInterfaceController" customModule="BlueWalletWatch_Extension"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="954" y="64"/>
|
||||||
|
</scene>
|
||||||
<!--SpecifyInterfaceController-->
|
<!--SpecifyInterfaceController-->
|
||||||
<scene sceneID="erR-Ld-VGW">
|
<scene sceneID="erR-Ld-VGW">
|
||||||
<objects>
|
<objects>
|
||||||
|
|
|
@ -1,454 +0,0 @@
|
||||||
//
|
|
||||||
// Keychain helper for iOS/Swift.
|
|
||||||
//
|
|
||||||
// https://github.com/evgenyneu/keychain-swift
|
|
||||||
//
|
|
||||||
// This file was automatically generated by combining multiple Swift source files.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------
|
|
||||||
//
|
|
||||||
// KeychainSwift.swift
|
|
||||||
//
|
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
import Security
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
A collection of helper functions for saving text and data in the keychain.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open class KeychainSwift {
|
|
||||||
|
|
||||||
var lastQueryParameters: [String: Any]? // Used by the unit tests
|
|
||||||
|
|
||||||
/// Contains result code from the last operation. Value is noErr (0) for a successful result.
|
|
||||||
open var lastResultCode: OSStatus = noErr
|
|
||||||
|
|
||||||
var keyPrefix = "" // Can be useful in test.
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Specify an access group that will be used to access keychain items. Access groups can be used to share keychain items between applications. When access group value is nil all application access groups are being accessed. Access group name is used by all functions: set, get, delete and clear.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open var accessGroup: String?
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Specifies whether the items can be synchronized with other devices through iCloud. Setting this property to true will
|
|
||||||
add the item to other devices with the `set` method and obtain synchronizable items with the `get` command. Deleting synchronizable items will remove them from all devices. In order for keychain synchronization to work the user must enable "Keychain" in iCloud settings.
|
|
||||||
|
|
||||||
Does not work on macOS.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open var synchronizable: Bool = false
|
|
||||||
|
|
||||||
private let readLock = NSLock()
|
|
||||||
|
|
||||||
/// Instantiate a KeychainSwift object
|
|
||||||
public init() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
- parameter keyPrefix: a prefix that is added before the key in get/set methods. Note that `clear` method still clears everything from the Keychain.
|
|
||||||
|
|
||||||
*/
|
|
||||||
public init(keyPrefix: String) {
|
|
||||||
self.keyPrefix = keyPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Stores the text value in the keychain item under the given key.
|
|
||||||
|
|
||||||
- parameter key: Key under which the text value is stored in the keychain.
|
|
||||||
- parameter value: Text string to be written to the keychain.
|
|
||||||
- parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
|
|
||||||
|
|
||||||
- returns: True if the text was successfully written to the keychain.
|
|
||||||
|
|
||||||
*/
|
|
||||||
@discardableResult
|
|
||||||
open func set(_ value: String, forKey key: String,
|
|
||||||
withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool {
|
|
||||||
|
|
||||||
if let value = value.data(using: String.Encoding.utf8) {
|
|
||||||
return set(value, forKey: key, withAccess: access)
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Stores the data in the keychain item under the given key.
|
|
||||||
|
|
||||||
- parameter key: Key under which the data is stored in the keychain.
|
|
||||||
- parameter value: Data to be written to the keychain.
|
|
||||||
- parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
|
|
||||||
|
|
||||||
- returns: True if the text was successfully written to the keychain.
|
|
||||||
|
|
||||||
*/
|
|
||||||
@discardableResult
|
|
||||||
open func set(_ value: Data, forKey key: String,
|
|
||||||
withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool {
|
|
||||||
|
|
||||||
delete(key) // Delete any existing key before saving it
|
|
||||||
|
|
||||||
let accessible = access?.value ?? KeychainSwiftAccessOptions.defaultOption.value
|
|
||||||
|
|
||||||
let prefixedKey = keyWithPrefix(key)
|
|
||||||
|
|
||||||
var query: [String : Any] = [
|
|
||||||
KeychainSwiftConstants.klass : kSecClassGenericPassword,
|
|
||||||
KeychainSwiftConstants.attrAccount : prefixedKey,
|
|
||||||
KeychainSwiftConstants.valueData : value,
|
|
||||||
KeychainSwiftConstants.accessible : accessible
|
|
||||||
]
|
|
||||||
|
|
||||||
query = addAccessGroupWhenPresent(query)
|
|
||||||
query = addSynchronizableIfRequired(query, addingItems: true)
|
|
||||||
lastQueryParameters = query
|
|
||||||
|
|
||||||
lastResultCode = SecItemAdd(query as CFDictionary, nil)
|
|
||||||
|
|
||||||
return lastResultCode == noErr
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Stores the boolean value in the keychain item under the given key.
|
|
||||||
|
|
||||||
- parameter key: Key under which the value is stored in the keychain.
|
|
||||||
- parameter value: Boolean to be written to the keychain.
|
|
||||||
- parameter withAccess: Value that indicates when your app needs access to the value in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
|
|
||||||
|
|
||||||
- returns: True if the value was successfully written to the keychain.
|
|
||||||
|
|
||||||
*/
|
|
||||||
@discardableResult
|
|
||||||
open func set(_ value: Bool, forKey key: String,
|
|
||||||
withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool {
|
|
||||||
|
|
||||||
let bytes: [UInt8] = value ? [1] : [0]
|
|
||||||
let data = Data(bytes)
|
|
||||||
|
|
||||||
return set(data, forKey: key, withAccess: access)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Retrieves the text value from the keychain that corresponds to the given key.
|
|
||||||
|
|
||||||
- parameter key: The key that is used to read the keychain item.
|
|
||||||
- returns: The text value from the keychain. Returns nil if unable to read the item.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open func get(_ key: String) -> String? {
|
|
||||||
if let data = getData(key) {
|
|
||||||
|
|
||||||
if let currentString = String(data: data, encoding: .utf8) {
|
|
||||||
return currentString
|
|
||||||
}
|
|
||||||
|
|
||||||
lastResultCode = -67853 // errSecInvalidEncoding
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Retrieves the data from the keychain that corresponds to the given key.
|
|
||||||
|
|
||||||
- parameter key: The key that is used to read the keychain item.
|
|
||||||
- returns: The text value from the keychain. Returns nil if unable to read the item.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open func getData(_ key: String) -> Data? {
|
|
||||||
// The lock prevents the code to be run simlultaneously
|
|
||||||
// from multiple threads which may result in crashing
|
|
||||||
readLock.lock()
|
|
||||||
defer { readLock.unlock() }
|
|
||||||
|
|
||||||
let prefixedKey = keyWithPrefix(key)
|
|
||||||
|
|
||||||
var query: [String: Any] = [
|
|
||||||
KeychainSwiftConstants.klass : kSecClassGenericPassword,
|
|
||||||
KeychainSwiftConstants.attrAccount : prefixedKey,
|
|
||||||
KeychainSwiftConstants.returnData : kCFBooleanTrue!,
|
|
||||||
KeychainSwiftConstants.matchLimit : kSecMatchLimitOne
|
|
||||||
]
|
|
||||||
|
|
||||||
query = addAccessGroupWhenPresent(query)
|
|
||||||
query = addSynchronizableIfRequired(query, addingItems: false)
|
|
||||||
lastQueryParameters = query
|
|
||||||
|
|
||||||
var result: AnyObject?
|
|
||||||
|
|
||||||
lastResultCode = withUnsafeMutablePointer(to: &result) {
|
|
||||||
SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0))
|
|
||||||
}
|
|
||||||
|
|
||||||
if lastResultCode == noErr { return result as? Data }
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Retrieves the boolean value from the keychain that corresponds to the given key.
|
|
||||||
|
|
||||||
- parameter key: The key that is used to read the keychain item.
|
|
||||||
- returns: The boolean value from the keychain. Returns nil if unable to read the item.
|
|
||||||
|
|
||||||
*/
|
|
||||||
open func getBool(_ key: String) -> Bool? {
|
|
||||||
guard let data = getData(key) else { return nil }
|
|
||||||
guard let firstBit = data.first else { return nil }
|
|
||||||
return firstBit == 1
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Deletes the single keychain item specified by the key.
|
|
||||||
|
|
||||||
- parameter key: The key that is used to delete the keychain item.
|
|
||||||
- returns: True if the item was successfully deleted.
|
|
||||||
|
|
||||||
*/
|
|
||||||
@discardableResult
|
|
||||||
open func delete(_ key: String) -> Bool {
|
|
||||||
let prefixedKey = keyWithPrefix(key)
|
|
||||||
|
|
||||||
var query: [String: Any] = [
|
|
||||||
KeychainSwiftConstants.klass : kSecClassGenericPassword,
|
|
||||||
KeychainSwiftConstants.attrAccount : prefixedKey
|
|
||||||
]
|
|
||||||
|
|
||||||
query = addAccessGroupWhenPresent(query)
|
|
||||||
query = addSynchronizableIfRequired(query, addingItems: false)
|
|
||||||
lastQueryParameters = query
|
|
||||||
|
|
||||||
lastResultCode = SecItemDelete(query as CFDictionary)
|
|
||||||
|
|
||||||
return lastResultCode == noErr
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Deletes all Keychain items used by the app. Note that this method deletes all items regardless of the prefix settings used for initializing the class.
|
|
||||||
|
|
||||||
- returns: True if the keychain items were successfully deleted.
|
|
||||||
|
|
||||||
*/
|
|
||||||
@discardableResult
|
|
||||||
open func clear() -> Bool {
|
|
||||||
var query: [String: Any] = [ kSecClass as String : kSecClassGenericPassword ]
|
|
||||||
query = addAccessGroupWhenPresent(query)
|
|
||||||
query = addSynchronizableIfRequired(query, addingItems: false)
|
|
||||||
lastQueryParameters = query
|
|
||||||
|
|
||||||
lastResultCode = SecItemDelete(query as CFDictionary)
|
|
||||||
|
|
||||||
return lastResultCode == noErr
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the key with currently set prefix.
|
|
||||||
func keyWithPrefix(_ key: String) -> String {
|
|
||||||
return "\(keyPrefix)\(key)"
|
|
||||||
}
|
|
||||||
|
|
||||||
func addAccessGroupWhenPresent(_ items: [String: Any]) -> [String: Any] {
|
|
||||||
guard let accessGroup = accessGroup else { return items }
|
|
||||||
|
|
||||||
var result: [String: Any] = items
|
|
||||||
result[KeychainSwiftConstants.accessGroup] = accessGroup
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Adds kSecAttrSynchronizable: kSecAttrSynchronizableAny` item to the dictionary when the `synchronizable` property is true.
|
|
||||||
|
|
||||||
- parameter items: The dictionary where the kSecAttrSynchronizable items will be added when requested.
|
|
||||||
- parameter addingItems: Use `true` when the dictionary will be used with `SecItemAdd` method (adding a keychain item). For getting and deleting items, use `false`.
|
|
||||||
|
|
||||||
- returns: the dictionary with kSecAttrSynchronizable item added if it was requested. Otherwise, it returns the original dictionary.
|
|
||||||
|
|
||||||
*/
|
|
||||||
func addSynchronizableIfRequired(_ items: [String: Any], addingItems: Bool) -> [String: Any] {
|
|
||||||
if !synchronizable { return items }
|
|
||||||
var result: [String: Any] = items
|
|
||||||
result[KeychainSwiftConstants.attrSynchronizable] = addingItems == true ? true : kSecAttrSynchronizableAny
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------
|
|
||||||
//
|
|
||||||
// TegKeychainConstants.swift
|
|
||||||
//
|
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import Security
|
|
||||||
|
|
||||||
/// Constants used by the library
|
|
||||||
public struct KeychainSwiftConstants {
|
|
||||||
/// Specifies a Keychain access group. Used for sharing Keychain items between apps.
|
|
||||||
public static var accessGroup: String { return toString(kSecAttrAccessGroup) }
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
A value that indicates when your app needs access to the data in a keychain item. The default value is AccessibleWhenUnlocked. For a list of possible values, see KeychainSwiftAccessOptions.
|
|
||||||
|
|
||||||
*/
|
|
||||||
public static var accessible: String { return toString(kSecAttrAccessible) }
|
|
||||||
|
|
||||||
/// Used for specifying a String key when setting/getting a Keychain value.
|
|
||||||
public static var attrAccount: String { return toString(kSecAttrAccount) }
|
|
||||||
|
|
||||||
/// Used for specifying synchronization of keychain items between devices.
|
|
||||||
public static var attrSynchronizable: String { return toString(kSecAttrSynchronizable) }
|
|
||||||
|
|
||||||
/// An item class key used to construct a Keychain search dictionary.
|
|
||||||
public static var klass: String { return toString(kSecClass) }
|
|
||||||
|
|
||||||
/// Specifies the number of values returned from the keychain. The library only supports single values.
|
|
||||||
public static var matchLimit: String { return toString(kSecMatchLimit) }
|
|
||||||
|
|
||||||
/// A return data type used to get the data from the Keychain.
|
|
||||||
public static var returnData: String { return toString(kSecReturnData) }
|
|
||||||
|
|
||||||
/// Used for specifying a value when setting a Keychain value.
|
|
||||||
public static var valueData: String { return toString(kSecValueData) }
|
|
||||||
|
|
||||||
static func toString(_ value: CFString) -> String {
|
|
||||||
return value as String
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------
|
|
||||||
//
|
|
||||||
// KeychainSwiftAccessOptions.swift
|
|
||||||
//
|
|
||||||
// ----------------------------
|
|
||||||
|
|
||||||
import Security
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
These options are used to determine when a keychain item should be readable. The default value is AccessibleWhenUnlocked.
|
|
||||||
|
|
||||||
*/
|
|
||||||
public enum KeychainSwiftAccessOptions {
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item can be accessed only while the device is unlocked by the user.
|
|
||||||
|
|
||||||
This is recommended for items that need to be accessible only while the application is in the foreground. Items with this attribute migrate to a new device when using encrypted backups.
|
|
||||||
|
|
||||||
This is the default value for keychain items added without explicitly setting an accessibility constant.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleWhenUnlocked
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item can be accessed only while the device is unlocked by the user.
|
|
||||||
|
|
||||||
This is recommended for items that need to be accessible only while the application is in the foreground. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleWhenUnlockedThisDeviceOnly
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user.
|
|
||||||
|
|
||||||
After the first unlock, the data remains accessible until the next restart. This is recommended for items that need to be accessed by background applications. Items with this attribute migrate to a new device when using encrypted backups.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleAfterFirstUnlock
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user.
|
|
||||||
|
|
||||||
After the first unlock, the data remains accessible until the next restart. This is recommended for items that need to be accessed by background applications. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleAfterFirstUnlockThisDeviceOnly
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item can always be accessed regardless of whether the device is locked.
|
|
||||||
|
|
||||||
This is not recommended for application use. Items with this attribute migrate to a new device when using encrypted backups.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleAlways
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain can only be accessed when the device is unlocked. Only available if a passcode is set on the device.
|
|
||||||
|
|
||||||
This is recommended for items that only need to be accessible while the application is in the foreground. Items with this attribute never migrate to a new device. After a backup is restored to a new device, these items are missing. No items can be stored in this class on devices without a passcode. Disabling the device passcode causes all items in this class to be deleted.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleWhenPasscodeSetThisDeviceOnly
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
The data in the keychain item can always be accessed regardless of whether the device is locked.
|
|
||||||
|
|
||||||
This is not recommended for application use. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present.
|
|
||||||
|
|
||||||
*/
|
|
||||||
case accessibleAlwaysThisDeviceOnly
|
|
||||||
|
|
||||||
static var defaultOption: KeychainSwiftAccessOptions {
|
|
||||||
return .accessibleWhenUnlocked
|
|
||||||
}
|
|
||||||
|
|
||||||
var value: String {
|
|
||||||
switch self {
|
|
||||||
case .accessibleWhenUnlocked:
|
|
||||||
return toString(kSecAttrAccessibleWhenUnlocked)
|
|
||||||
|
|
||||||
case .accessibleWhenUnlockedThisDeviceOnly:
|
|
||||||
return toString(kSecAttrAccessibleWhenUnlockedThisDeviceOnly)
|
|
||||||
|
|
||||||
case .accessibleAfterFirstUnlock:
|
|
||||||
return toString(kSecAttrAccessibleAfterFirstUnlock)
|
|
||||||
|
|
||||||
case .accessibleAfterFirstUnlockThisDeviceOnly:
|
|
||||||
return toString(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly)
|
|
||||||
|
|
||||||
case .accessibleAlways:
|
|
||||||
return toString(kSecAttrAccessibleAlways)
|
|
||||||
|
|
||||||
case .accessibleWhenPasscodeSetThisDeviceOnly:
|
|
||||||
return toString(kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly)
|
|
||||||
|
|
||||||
case .accessibleAlwaysThisDeviceOnly:
|
|
||||||
return toString(kSecAttrAccessibleAlwaysThisDeviceOnly)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func toString(_ value: CFString) -> String {
|
|
||||||
return KeychainSwiftConstants.toString(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue