diff --git a/OpenSSL/ios/include/openssl/ecdsa.h b/OpenSSL/ios/include/openssl/ecdsa.h index a6f0930..361a009 100755 --- a/OpenSSL/ios/include/openssl/ecdsa.h +++ b/OpenSSL/ios/include/openssl/ecdsa.h @@ -288,20 +288,21 @@ void ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method, const ECDSA_SIG *sig, EC_KEY *eckey)); -void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags); - /** Set the flags field in the ECDSA_METHOD * \param ecdsa_method pointer to existing ECDSA_METHOD * \param flags flags value to set */ -void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name); +void ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags); /** Set the name field in the ECDSA_METHOD * \param ecdsa_method pointer to existing ECDSA_METHOD * \param name name to set */ +void ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name); + + /* BEGIN ERROR CODES */ /* * The following lines are auto generated by the script mkerr.pl. Any changes diff --git a/transactId-library-ios/transactId-library-ios.xcodeproj/project.pbxproj b/transactId-library-ios/transactId-library-ios.xcodeproj/project.pbxproj index b853ba4..39b8c13 100644 --- a/transactId-library-ios/transactId-library-ios.xcodeproj/project.pbxproj +++ b/transactId-library-ios/transactId-library-ios.xcodeproj/project.pbxproj @@ -10,6 +10,9 @@ 39F581BA249890FCFE356855 /* Pods_transactId_library_ios_tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA608D1A49C134C66850E0DE /* Pods_transactId_library_ios_tests.framework */; }; 64C7EE10077813EDA34B2AA9 /* Pods_transactId_demo_app.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89A2F49221D2BD1F4605E148 /* Pods_transactId_demo_app.framework */; }; 86AAE378AF7573791DA7E5E3 /* Pods_transactId_library_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DD5C9EA943F8C0323878031 /* Pods_transactId_library_ios.framework */; }; + 8B0A466F265BD09C00B87E0E /* MerkleAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B0A466E265BD09C00B87E0E /* MerkleAddress.swift */; }; + 8B0A4672265BD76700B87E0E /* MerkleTags.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B0A4671265BD76700B87E0E /* MerkleTags.swift */; }; + 8B0A4675265BD7B000B87E0E /* MerkleTagInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B0A4674265BD7B000B87E0E /* MerkleTagInformation.swift */; }; 8B0A46D025FF4CDF00B879F4 /* OpenSSLSigningHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B0A46CE25FF4CDF00B879F4 /* OpenSSLSigningHelper.cpp */; }; 8B0A46D125FF4CDF00B879F4 /* OpenSSLSigningHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B0A46CF25FF4CDF00B879F4 /* OpenSSLSigningHelper.h */; }; 8B0A46D625FF4D0100B879F4 /* OpenSSLEncryptionHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B0A46D425FF4D0100B879F4 /* OpenSSLEncryptionHelper.cpp */; }; @@ -73,7 +76,7 @@ 8BA437EC262F00B5003634FE /* TransactIdPaymentACKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA437EB262F00B5003634FE /* TransactIdPaymentACKTests.swift */; }; 8BA437EF262F00D8003634FE /* TransactIdPaymentRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BA437EE262F00D8003634FE /* TransactIdPaymentRequestTests.swift */; }; 8BAAE2D9260B2B3000187722 /* AddressInformationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BAAE2D8260B2B3000187722 /* AddressInformationService.swift */; }; - 8BAAE2DE260B2B6500187722 /* AddressInformaionServiceNetki.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BAAE2DD260B2B6500187722 /* AddressInformaionServiceNetki.swift */; }; + 8BAAE2DE260B2B6500187722 /* AddressInformationServiceNetki.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BAAE2DD260B2B6500187722 /* AddressInformationServiceNetki.swift */; }; 8BAAE2E1260B326E00187722 /* AddressInformationRepo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BAAE2E0260B326E00187722 /* AddressInformationRepo.swift */; }; 8BBD13A7261CA40000E62F6D /* PaymentRequestParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BBD13A6261CA40000E62F6D /* PaymentRequestParameters.swift */; }; 8BBD13AA261CA82500E62F6D /* MessagePaymentDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BBD13A9261CA82500E62F6D /* MessagePaymentDetails.swift */; }; @@ -111,6 +114,13 @@ 8BE9171825E7EDA000426912 /* MessageAttestationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BE9171725E7EDA000426912 /* MessageAttestationType.swift */; }; 8BE9171B25E7FB4A00426912 /* MessageOriginator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BE9171A25E7FB4A00426912 /* MessageOriginator.swift */; }; 8BE9172125E7FCA300426912 /* OriginatorParameters+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BE9172025E7FCA300426912 /* OriginatorParameters+Extension.swift */; }; + 8BF21ED82652739C00180605 /* AddressInformationFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21ED72652739C00180605 /* AddressInformationFactory.swift */; }; + 8BF21EDB2652743D00180605 /* AddressInformationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EDA2652743D00180605 /* AddressInformationProvider.swift */; }; + 8BF21EDE265274C400180605 /* AddressInformationNetkiProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EDD265274C400180605 /* AddressInformationNetkiProvider.swift */; }; + 8BF21EE3265276EA00180605 /* MerkleRepo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EE2265276EA00180605 /* MerkleRepo.swift */; }; + 8BF21EE626528BCD00180605 /* Dictionary+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EE526528BCD00180605 /* Dictionary+Extension.swift */; }; + 8BF21EE926528C3000180605 /* CharacterSet+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EE826528C3000180605 /* CharacterSet+Extension.swift */; }; + 8BF21EEC2655174800180605 /* TransactIdMerkleRepoUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF21EEB2655174800180605 /* TransactIdMerkleRepoUnitTests.swift */; }; 8BF24C3025D1CB3900C922A3 /* TrustStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF24C2F25D1CB3900C922A3 /* TrustStore.swift */; }; 8BF24C3625D29E0600C922A3 /* Bip75.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF24C3525D29E0600C922A3 /* Bip75.swift */; }; 8BF24C3925D29F4E00C922A3 /* InvoiceRequestParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BF24C3825D29F4E00C922A3 /* InvoiceRequestParameters.swift */; }; @@ -174,6 +184,9 @@ 52A6C2E563E68D47ABA8BE1F /* Pods-transactId-demo-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-transactId-demo-app.release.xcconfig"; path = "Target Support Files/Pods-transactId-demo-app/Pods-transactId-demo-app.release.xcconfig"; sourceTree = ""; }; 5B0FC61304BCAD777F627973 /* Pods-transactId-library-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-transactId-library-ios.release.xcconfig"; path = "Target Support Files/Pods-transactId-library-ios/Pods-transactId-library-ios.release.xcconfig"; sourceTree = ""; }; 89A2F49221D2BD1F4605E148 /* Pods_transactId_demo_app.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_transactId_demo_app.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8B0A466E265BD09C00B87E0E /* MerkleAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerkleAddress.swift; sourceTree = ""; }; + 8B0A4671265BD76700B87E0E /* MerkleTags.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerkleTags.swift; sourceTree = ""; }; + 8B0A4674265BD7B000B87E0E /* MerkleTagInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerkleTagInformation.swift; sourceTree = ""; }; 8B0A46CE25FF4CDF00B879F4 /* OpenSSLSigningHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OpenSSLSigningHelper.cpp; sourceTree = ""; }; 8B0A46CF25FF4CDF00B879F4 /* OpenSSLSigningHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenSSLSigningHelper.h; sourceTree = ""; }; 8B0A46D425FF4D0100B879F4 /* OpenSSLEncryptionHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OpenSSLEncryptionHelper.cpp; sourceTree = ""; }; @@ -239,7 +252,7 @@ 8BA437EB262F00B5003634FE /* TransactIdPaymentACKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactIdPaymentACKTests.swift; sourceTree = ""; }; 8BA437EE262F00D8003634FE /* TransactIdPaymentRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactIdPaymentRequestTests.swift; sourceTree = ""; }; 8BAAE2D8260B2B3000187722 /* AddressInformationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationService.swift; sourceTree = ""; }; - 8BAAE2DD260B2B6500187722 /* AddressInformaionServiceNetki.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformaionServiceNetki.swift; sourceTree = ""; }; + 8BAAE2DD260B2B6500187722 /* AddressInformationServiceNetki.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationServiceNetki.swift; sourceTree = ""; }; 8BAAE2E0260B326E00187722 /* AddressInformationRepo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationRepo.swift; sourceTree = ""; }; 8BBD13A6261CA40000E62F6D /* PaymentRequestParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentRequestParameters.swift; sourceTree = ""; }; 8BBD13A9261CA82500E62F6D /* MessagePaymentDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagePaymentDetails.swift; sourceTree = ""; }; @@ -277,6 +290,13 @@ 8BE9171725E7EDA000426912 /* MessageAttestationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageAttestationType.swift; sourceTree = ""; }; 8BE9171A25E7FB4A00426912 /* MessageOriginator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageOriginator.swift; sourceTree = ""; }; 8BE9172025E7FCA300426912 /* OriginatorParameters+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OriginatorParameters+Extension.swift"; sourceTree = ""; }; + 8BF21ED72652739C00180605 /* AddressInformationFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationFactory.swift; sourceTree = ""; }; + 8BF21EDA2652743D00180605 /* AddressInformationProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationProvider.swift; sourceTree = ""; }; + 8BF21EDD265274C400180605 /* AddressInformationNetkiProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressInformationNetkiProvider.swift; sourceTree = ""; }; + 8BF21EE2265276EA00180605 /* MerkleRepo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerkleRepo.swift; sourceTree = ""; }; + 8BF21EE526528BCD00180605 /* Dictionary+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Dictionary+Extension.swift"; sourceTree = ""; }; + 8BF21EE826528C3000180605 /* CharacterSet+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CharacterSet+Extension.swift"; sourceTree = ""; }; + 8BF21EEB2655174800180605 /* TransactIdMerkleRepoUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactIdMerkleRepoUnitTests.swift; sourceTree = ""; }; 8BF24C2F25D1CB3900C922A3 /* TrustStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustStore.swift; sourceTree = ""; }; 8BF24C3525D29E0600C922A3 /* Bip75.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bip75.swift; sourceTree = ""; }; 8BF24C3825D29F4E00C922A3 /* InvoiceRequestParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvoiceRequestParameters.swift; sourceTree = ""; }; @@ -326,6 +346,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 8B0A466D265BD08C00B87E0E /* Data */ = { + isa = PBXGroup; + children = ( + 8B0A466E265BD09C00B87E0E /* MerkleAddress.swift */, + 8B0A4671265BD76700B87E0E /* MerkleTags.swift */, + 8B0A4674265BD7B000B87E0E /* MerkleTagInformation.swift */, + ); + path = Data; + sourceTree = ""; + }; 8B290B9625CC3C75006B96B3 /* transactId-demo-app */ = { isa = PBXGroup; children = ( @@ -469,6 +499,7 @@ 8BA437EB262F00B5003634FE /* TransactIdPaymentACKTests.swift */, 8BA437EE262F00D8003634FE /* TransactIdPaymentRequestTests.swift */, 8BA437E8262F00A2003634FE /* TransactIdPaymentTests.swift */, + 8BF21EEB2655174800180605 /* TransactIdMerkleRepoUnitTests.swift */, ); path = "transactId_library_ios-tests"; sourceTree = ""; @@ -524,6 +555,8 @@ 8BBD1C252628336B0029738A /* Payment+Extension.swift */, 8BBD1C2B2628368A0029738A /* Beneficiary+Extension.swift */, 8BBD1C2E26283B5E0029738A /* Originator+Extension.swift */, + 8BF21EE526528BCD00180605 /* Dictionary+Extension.swift */, + 8BF21EE826528C3000180605 /* CharacterSet+Extension.swift */, ); path = Extensions; sourceTree = ""; @@ -540,9 +573,13 @@ 8BAAE2D5260B2A6D00187722 /* AddressInformation */ = { isa = PBXGroup; children = ( - 8BAAE2D8260B2B3000187722 /* AddressInformationService.swift */, - 8BAAE2DD260B2B6500187722 /* AddressInformaionServiceNetki.swift */, + 8BF21ED72652739C00180605 /* AddressInformationFactory.swift */, + 8BF21EDD265274C400180605 /* AddressInformationNetkiProvider.swift */, + 8BF21EDA2652743D00180605 /* AddressInformationProvider.swift */, 8BAAE2E0260B326E00187722 /* AddressInformationRepo.swift */, + 8BAAE2D8260B2B3000187722 /* AddressInformationService.swift */, + 8BAAE2DD260B2B6500187722 /* AddressInformationServiceNetki.swift */, + 8BF21EE1265276D600180605 /* Merkle */, ); path = AddressInformation; sourceTree = ""; @@ -583,6 +620,15 @@ path = Enums; sourceTree = ""; }; + 8BF21EE1265276D600180605 /* Merkle */ = { + isa = PBXGroup; + children = ( + 8B0A466D265BD08C00B87E0E /* Data */, + 8BF21EE2265276EA00180605 /* MerkleRepo.swift */, + ); + path = Merkle; + sourceTree = ""; + }; 8BF24C2E25D1CB0F00C922A3 /* TrustStore */ = { isa = PBXGroup; children = ( @@ -917,16 +963,20 @@ 8B47535025D2B9DD00383451 /* BeneficiaryParameters.swift in Sources */, 8BDEFBB525ED082300577BAF /* MessageType.swift in Sources */, 8BBD13A7261CA40000E62F6D /* PaymentRequestParameters.swift in Sources */, + 8B0A466F265BD09C00B87E0E /* MerkleAddress.swift in Sources */, 8BF24C3C25D29F6800C922A3 /* InvoiceRequest.swift in Sources */, 8B290AE325CBE369006B96B3 /* KeyChainProvider.swift in Sources */, 8BDEFBB225ED061700577BAF /* Data+Extension.swift in Sources */, 8B47534225D2B7F300383451 /* AddressCurrency.swift in Sources */, 8B47536125D2BE1A00383451 /* Array+Extension.swift in Sources */, 8BE9170325E7A83E00426912 /* MessageInvoiceRequest.swift in Sources */, + 8BF21EE3265276EA00180605 /* MerkleRepo.swift in Sources */, 8B8E210826090EC200139EC0 /* ProtocolMessageMetadata.swift in Sources */, 8B8E21172609BE9F00139EC0 /* Originator.swift in Sources */, 8BC29F79262487D400071401 /* PaymentParameters.swift in Sources */, 8BE3FDC925D1778B00D78B62 /* Request.swift in Sources */, + 8BF21EE926528C3000180605 /* CharacterSet+Extension.swift in Sources */, + 8BF21EDE265274C400180605 /* AddressInformationNetkiProvider.swift in Sources */, 8BBD1C2C2628368A0029738A /* Beneficiary+Extension.swift in Sources */, 8BE9170A25E7AAAD00426912 /* MessageAttestation.swift in Sources */, 8B47533825D2B58300383451 /* SenderParameters.swift in Sources */, @@ -954,6 +1004,7 @@ 8BBD13AA261CA82500E62F6D /* MessagePaymentDetails.swift in Sources */, 8BBD1C262628336B0029738A /* Payment+Extension.swift in Sources */, 8BE9170625E7A8D500426912 /* MessageBeneficiary.swift in Sources */, + 8BF21EDB2652743D00180605 /* AddressInformationProvider.swift in Sources */, 8BE3FDBA25D1736000D78B62 /* PearlApiService.swift in Sources */, 8BF24C3625D29E0600C922A3 /* Bip75.swift in Sources */, 8BAAE2D9260B2B3000187722 /* AddressInformationService.swift in Sources */, @@ -963,20 +1014,24 @@ 8B36B2DF25C99AAE00CE14E9 /* OpenSSLCSRHelper.cpp in Sources */, 8BE3FDD025D1780000D78B62 /* TokenRequest.swift in Sources */, 8B47533C25D2B5D000383451 /* EncryptionParameters.swift in Sources */, + 8B0A4672265BD76700B87E0E /* MerkleTags.swift in Sources */, 8BDEFBAC25ECFBF300577BAF /* ProtocolMessage.swift in Sources */, 8BBD13B0261CB88100E62F6D /* MessagePaymentRequest.swift in Sources */, 8BBD1C2F26283B5E0029738A /* Originator+Extension.swift in Sources */, 8B47534925D2B96200383451 /* AddressTagInformation.swift in Sources */, 8B8E20FF2604AC6B00139EC0 /* String+Extension.swift in Sources */, + 8BF21ED82652739C00180605 /* AddressInformationFactory.swift in Sources */, 8B0A46D025FF4CDF00B879F4 /* OpenSSLSigningHelper.cpp in Sources */, 8BE9171225E7E39600426912 /* MessageOutput.swift in Sources */, 8BBD1C29262833CB0029738A /* MessagePaymentACK.swift in Sources */, 8BF24C5025D2A4EC00C922A3 /* Bip75ServiceNetki.swift in Sources */, + 8B0A4675265BD7B000B87E0E /* MerkleTagInformation.swift in Sources */, 8B47535625D2BA8400383451 /* StatusCode.swift in Sources */, - 8BAAE2DE260B2B6500187722 /* AddressInformaionServiceNetki.swift in Sources */, + 8BAAE2DE260B2B6500187722 /* AddressInformationServiceNetki.swift in Sources */, 8B5BF57A25D3015D0086E7AF /* ExceptionMessages.swift in Sources */, 8BDEFBAF25ECFCA700577BAF /* ProtocolMessageType.swift in Sources */, 8BE9171525E7E58B00426912 /* Output+Extension.swift in Sources */, + 8BF21EE626528BCD00180605 /* Dictionary+Extension.swift in Sources */, 8BE3FDC625D1776600D78B62 /* Response.swift in Sources */, 8BBD13B3261EEDE900E62F6D /* PaymentRequest.swift in Sources */, 8BF24C3F25D29F8200C922A3 /* RecipientParameters.swift in Sources */, @@ -1009,6 +1064,7 @@ 8B92870A25DC0C5E005AB4B0 /* TrustStore.swift in Sources */, 8BA437E9262F00A2003634FE /* TransactIdPaymentTests.swift in Sources */, 8B43C77C25E66E4000ED9D56 /* TestData.swift in Sources */, + 8BF21EEC2655174800180605 /* TransactIdMerkleRepoUnitTests.swift in Sources */, 8BA437EF262F00D8003634FE /* TransactIdPaymentRequestTests.swift in Sources */, 8BA437EC262F00B5003634FE /* TransactIdPaymentACKTests.swift in Sources */, ); diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationFactory.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationFactory.swift new file mode 100644 index 0000000..247474b --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationFactory.swift @@ -0,0 +1,31 @@ +// +// AddressInformationFactory.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +/** + * Factory to generate AddressInformation instance. + */ + +class AddressInformationFactory { + + private static var sharedAddressInformationFactory = AddressInformationFactory() + + private init () {} + + class func shared() -> AddressInformationFactory { + return sharedAddressInformationFactory + } + + func getInstance(authorizationKey: String) -> AddressInformationProvider { + + let addressInformationRepo = MerkleRepo(authorizationKey: authorizationKey) + let addressInformationServiceNetki = AddressInformationServiceNetki(addressInformationRepo: addressInformationRepo) + return AddressInformationProviderNetki(addressInformationService: addressInformationServiceNetki) + } + +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationNetkiProvider.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationNetkiProvider.swift new file mode 100644 index 0000000..f189e95 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationNetkiProvider.swift @@ -0,0 +1,22 @@ +// +// AddressInformationProviderNetki.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +class AddressInformationProviderNetki: AddressInformationProvider { + + private let addressInformationService: AddressInformationService + + init(addressInformationService: AddressInformationService) { + self.addressInformationService = addressInformationService + } + + func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? { + return try self.addressInformationService.getAddressInformation(currency: currency, address: address) + } + +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationProvider.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationProvider.swift new file mode 100644 index 0000000..4a61c04 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationProvider.swift @@ -0,0 +1,27 @@ +// +// AddressInformationProvider.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +/** + * Fetch the detailed information about an address. + */ +protocol AddressInformationProvider { + + /** + * Fetch the information of a given address. + * + * @param currency of the address. + * @param address to fetch the information. + * @throws AddressProviderErrorException if there is an error fetching the information from the provider. + * @throws AddressProviderUnauthorizedException if there is an error with the authorization to connect to the provider. + * @return information of the address. + */ + + func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? + +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationRepo.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationRepo.swift index 059079b..3581dba 100644 --- a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationRepo.swift +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationRepo.swift @@ -19,7 +19,7 @@ protocol AddressInformationRepo { * @return information of the address. */ - func getAddressInformation(currency: AddressCurrency, address: String) -> AddressInformation + func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? } diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationService.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationService.swift index 4f89d08..19f6711 100644 --- a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationService.swift +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationService.swift @@ -8,8 +8,7 @@ import Foundation protocol AddressInformationService { - - + /** * Fetch the information of a given address. * @@ -20,6 +19,6 @@ protocol AddressInformationService { * @return information of the address. */ - func getAddressInformation(currency: AddressCurrency, address: String) -> AddressInformation + func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? } diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformaionServiceNetki.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationServiceNetki.swift similarity index 59% rename from transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformaionServiceNetki.swift rename to transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationServiceNetki.swift index c9f2c63..eaa15d5 100644 --- a/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformaionServiceNetki.swift +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/AddressInformationServiceNetki.swift @@ -1,5 +1,5 @@ // -// AddressInformaionServiceNetki.swift +// AddressInformationServiceNetki.swift // transactId-library-ios // // Created by Developer on 24.03.2021. @@ -7,7 +7,7 @@ import Foundation -class AddressInformaionServiceNetki: AddressInformationService { +class AddressInformationServiceNetki: AddressInformationService { private let addressInformationRepo: AddressInformationRepo @@ -15,8 +15,8 @@ class AddressInformaionServiceNetki: AddressInformationService { self.addressInformationRepo = addressInformationRepo } - func getAddressInformation(currency: AddressCurrency, address: String) -> AddressInformation { - return self.addressInformationRepo.getAddressInformation(currency: currency, address: address) + func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? { + return try self.addressInformationRepo.getAddressInformation(currency: currency, address: address) } diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleAddress.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleAddress.swift new file mode 100644 index 0000000..d609856 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleAddress.swift @@ -0,0 +1,145 @@ +// +// MerkleAddress.swift +// transactId-library-ios +// +// Created by Developer on 24.05.2021. +// + +import Foundation + +class MerkleAddress { + + var identifier: String? + var balance: Double? + var beneficiary: Array = [] + var caseStatus: Int? + var caseStatusVerbose: String? + var currency: Int? + var currencyVerbose: String? + var earliestTransactionTime: String? + var latestTransactionTime: String? + var originator: Array = [] + var riskLevel: Int? + var riskLevelVerbose: String? + var merkleTags: MerkleTags? + var totalIncomingValue: String? + var totalIncomingValueUsd: String? + var totalOutgoingValue: String? + var totalOutgoingValueUsd: String? + var createdAt: String? + var updatedAt: String? + + init (json: [String: Any]) { + if let identifier = json["identifier"] as? String { + self.identifier = identifier + } + + if let balance = json["balance"] as? Double { + self.balance = balance + } + + if let beneficiaryJson = json["beneficiary"] as? Array<[String: Any]> { + beneficiaryJson.forEach { (merkleTagInformationJson) in + self.beneficiary.append(MerkleTagInformation(json: merkleTagInformationJson)) + } + } + + if let caseStatus = json["case_status"] as? Int { + self.caseStatus = caseStatus + } + + if let caseStatusVerbose = json["case_status_verbose"] as? String { + self.caseStatusVerbose = caseStatusVerbose + } + + if let currency = json["currency"] as? Int { + self.currency = currency + } + + if let currencyVerbose = json["currency_verbose"] as? String { + self.currencyVerbose = currencyVerbose + } + + if let earliestTransactionTime = json["earliest_transaction_time"] as? String { + self.earliestTransactionTime = earliestTransactionTime + } + + if let latestTransactionTime = json["latest_transaction_time"] as? String { + self.latestTransactionTime = latestTransactionTime + } + + if let originatorJson = json["originator"] as? Array<[String: Any]> { + originatorJson.forEach { (merkleTagInformationJson) in + self.originator.append(MerkleTagInformation(json: merkleTagInformationJson)) + } + } + + if let riskLevel = json["risk_level"] as? Int { + self.riskLevel = riskLevel + } + + if let riskLevelVerbose = json["risk_level_verbose"] as? String { + self.riskLevelVerbose = riskLevelVerbose + } + + if let merkleTagsJson = json["tags"] as? [String: Any] { + self.merkleTags = MerkleTags(json: merkleTagsJson) + } + + if let totalIncomingValue = json["total_incoming_value"] as? String { + self.totalIncomingValue = totalIncomingValue + } + + if let totalIncomingValueUsd = json["total_incoming_value_usd"] as? String { + self.totalIncomingValueUsd = totalIncomingValueUsd + } + + if let totalOutgoingValue = json["total_outgoing_value"] as? String { + self.totalOutgoingValue = totalOutgoingValue + } + + if let totalOutgoingValueUsd = json["total_outgoing_value_usd"] as? String { + self.totalOutgoingValueUsd = totalOutgoingValueUsd + } + + if let createdAt = json["created_at"] as? String { + self.createdAt = createdAt + } + + if let updatedAt = json["updated_at"] as? String { + self.updatedAt = updatedAt + } + + } +} + +extension MerkleAddress { + + func toAddressInformation() -> AddressInformation { + let addressInformation = AddressInformation() + addressInformation.identifier = self.identifier + addressInformation.balance = self.balance + self.beneficiary.forEach { (merkleTagInformation) in + addressInformation.beneficiary.append(merkleTagInformation.toAddressTagInformation()) + } + addressInformation.caseStatus = self.caseStatus + addressInformation.caseStatusVerbose = self.caseStatusVerbose + addressInformation.currency = self.currency + addressInformation.currencyVerbose = self.currencyVerbose + addressInformation.earliestTransactionTime = self.earliestTransactionTime + addressInformation.latestTransactionTime = self.latestTransactionTime + self.originator.forEach { (merkleTagInformation) in + addressInformation.originator.append(merkleTagInformation.toAddressTagInformation()) + } + addressInformation.riskLevel = self.riskLevel + addressInformation.riskLevelVerbose = self.riskLevelVerbose + addressInformation.tags = self.merkleTags?.toAddressTags() + addressInformation.totalIncomingValue = self.totalIncomingValue + addressInformation.totalIncomingValueUsd = self.totalIncomingValueUsd + addressInformation.totalOutgoingValue = self.totalOutgoingValue + addressInformation.totalOutgoingValueUsd = self.totalOutgoingValueUsd + addressInformation.createdAt = self.createdAt + addressInformation.updatedAt = self.updatedAt + return addressInformation + } +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTagInformation.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTagInformation.swift new file mode 100644 index 0000000..29fc881 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTagInformation.swift @@ -0,0 +1,48 @@ +// +// MerkleTagInformation.swift +// transactId-library-ios +// +// Created by Developer on 24.05.2021. +// + +import Foundation + +class MerkleTagInformation { + + var tagNameVerbose: String? + var tagSubtypeVerbose: String? + var tagTypeVerbose: String? + var tagTotalValueUsd: String? + + + init(json: [String: Any]) { + if let tagNameVerbose = json["tag_name_verbose"] as? String { + self.tagNameVerbose = tagNameVerbose + } + + if let tagSubtypeVerbose = json["tag_subtype_verbose"] as? String { + self.tagSubtypeVerbose = tagSubtypeVerbose + } + + if let tagTypeVerbose = json["tag_type_verbose"] as? String { + self.tagTypeVerbose = tagTypeVerbose + } + + if let tagTotalValueUsd = json["total_value_usd"] as? String { + self.tagTotalValueUsd = tagTotalValueUsd + } + } +} + +extension MerkleTagInformation { + + func toAddressTagInformation() -> AddressTagInformation { + let addressTagInformation = AddressTagInformation() + addressTagInformation.tagNameVerbose = self.tagNameVerbose + addressTagInformation.tagSubtypeVerbose = self.tagSubtypeVerbose + addressTagInformation.tagTypeVerbose = self.tagTypeVerbose + addressTagInformation.totalValueUsd = self.tagTotalValueUsd + return addressTagInformation + + } +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTags.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTags.swift new file mode 100644 index 0000000..f4e25a0 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/Data/MerkleTags.swift @@ -0,0 +1,32 @@ +// +// MerkleTags.swift +// transactId-library-ios +// +// Created by Developer on 24.05.2021. +// + +import Foundation + +class MerkleTags { + var owner: MerkleTagInformation? + var user: MerkleTagInformation? + + init(json: [String: Any]) { + if let ownerJson = json["owner"] as? [String: Any] { + self.owner = MerkleTagInformation(json: ownerJson) + } + + if let userJson = json["user"] as? [String: Any] { + self.user = MerkleTagInformation(json: userJson) + } + } +} + +extension MerkleTags { + func toAddressTags() -> AddressTags { + let addressTags = AddressTags() + addressTags.owner = self.owner?.toAddressTagInformation() + addressTags.user = self.user?.toAddressTagInformation() + return addressTags + } +} diff --git a/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/MerkleRepo.swift b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/MerkleRepo.swift new file mode 100644 index 0000000..92e34f8 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/AddressInformation/Merkle/MerkleRepo.swift @@ -0,0 +1,63 @@ +// +// MerkleRepo.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +/** + * Implementation to fetch the address information from Merkle provider. + */ + +private let xApiKeyHeader = "X-API-KEY" +private let identifierParameter = "identifier" +private let currencyParameter = "currency" +private let merkleBaseUrl = "https://api.merklescience.com/" +private let addressInfoPath = "api/v3/addresses/" + +public class MerkleRepo : AddressInformationRepo { + + private let authorizationKey: String + + public init(authorizationKey: String) { + self.authorizationKey = authorizationKey + } + + public func getAddressInformation(currency: AddressCurrency, address: String) throws -> AddressInformation? { + + var addressInformation: AddressInformation? = nil + + if let url = URL(string: "\(merkleBaseUrl)\(addressInfoPath)") { + let semaphore = DispatchSemaphore(value: 0) + + var request = URLRequest(url: url) + request.setValue(authorizationKey, forHTTPHeaderField: xApiKeyHeader) + request.httpMethod = "POST" + + let parameters = [identifierParameter: address, + currencyParameter: currency.rawValue] as [String : Any] + + request.httpBody = parameters.percentEncoded() + + let task = URLSession.shared.dataTask(with: request) { data, response, error in + guard let data = data else { + semaphore.signal() + return + } + + let responseJSON = try? JSONSerialization.jsonObject(with: data, options: []) + if let responseJSON = responseJSON as? [String: Any] { + addressInformation = MerkleAddress(json: responseJSON).toAddressInformation() + } + semaphore.signal() + } + + task.resume() + _ = semaphore.wait(timeout: DispatchTime.distantFuture) + + } + return addressInformation + } +} diff --git a/transactId-library-ios/transactId-library-ios/Bip75/Bip75.swift b/transactId-library-ios/transactId-library-ios/Bip75/Bip75.swift index f4796f4..a8fa93a 100644 --- a/transactId-library-ios/transactId-library-ios/Bip75/Bip75.swift +++ b/transactId-library-ios/transactId-library-ios/Bip75/Bip75.swift @@ -47,6 +47,20 @@ protocol Bip75 { */ func parseInvoiceRequest(invoiceRequestBinary: Data, recipientParameters: RecipientParameters?)throws -> InvoiceRequest? + /** + * Parse binary PaymentRequest and also get the detailed information of the addresses. + * + * @param paymentRequestBinary binary data with the message to parse. + * @param recipientParameters information of the recipient of the message, the RecipientParameters.EncryptionParameters is mandatory to handle encrypted messages. + * @return PaymentRequest parsed with the detailed information for each address. + * @exception InvalidObjectException if the binary is malformed. + * @exception AddressProviderErrorException if there is an error fetching the information from the provider. + * @exception AddressProviderUnauthorizedException if there is an error with the authorization to connect to the provider. + * @exception EncryptionException if there is an error decrypting or validating the encryption. + */ + + func parseInvoiceRequestWithAddressInfo(invoiceRequestBinary: Data, recipientParameters: RecipientParameters?) throws -> InvoiceRequest? + /** * Create binary PaymentRequest. * diff --git a/transactId-library-ios/transactId-library-ios/Bip75/Bip75Factory.swift b/transactId-library-ios/transactId-library-ios/Bip75/Bip75Factory.swift index 6d64e4a..5f63d91 100644 --- a/transactId-library-ios/transactId-library-ios/Bip75/Bip75Factory.swift +++ b/transactId-library-ios/transactId-library-ios/Bip75/Bip75Factory.swift @@ -30,8 +30,13 @@ class Bip75Factory { func getInstance(trustStore: TrustStore? = nil, autorizationKey: String? = nil, developmentMode: Bool = false) -> Bip75 { let certificateValidator: CertificateValidator = CertificateValidator(trustStore: trustStore, developmentMode: developmentMode) - let bip75Service: Bip75Service = Bip75ServiceNetki(certificateValidator: certificateValidator) + let addressInformationRepo = MerkleRepo(authorizationKey: autorizationKey ?? "") + + let addressInformationService = AddressInformationServiceNetki(addressInformationRepo: addressInformationRepo) + + let bip75Service: Bip75Service = Bip75ServiceNetki(certificateValidator: certificateValidator, addressInformationService: addressInformationService) + return Bip75Netki(bip75Service: bip75Service) } } diff --git a/transactId-library-ios/transactId-library-ios/Bip75/Bip75ServiceNetki.swift b/transactId-library-ios/transactId-library-ios/Bip75/Bip75ServiceNetki.swift index 8670599..4ee4739 100644 --- a/transactId-library-ios/transactId-library-ios/Bip75/Bip75ServiceNetki.swift +++ b/transactId-library-ios/transactId-library-ios/Bip75/Bip75ServiceNetki.swift @@ -132,14 +132,12 @@ class Bip75ServiceNetki: Bip75Service { func parseInvoiceRequest(invoiceRequestBinary: Data, recipientParameters: RecipientParameters?) throws -> InvoiceRequest? { return try self.parseInvoiceRequestBinary(invoiceRequestBinary: invoiceRequestBinary, recipientParameters: recipientParameters) } - - //MARK: TODO parseInvoiceRequestWithAddressInfo - + func parseInvoiceRequestWithAddressInfo(invoiceRequestBinary: Data, recipientParameters: RecipientParameters?) throws -> InvoiceRequest? { if let invoiceRequest = try self.parseInvoiceRequestBinary(invoiceRequestBinary: invoiceRequestBinary, recipientParameters: recipientParameters) { - invoiceRequest.originatorsAddresses.forEach { (output) in + try invoiceRequest.originatorsAddresses.forEach { (output) in if let addressInformationService = self.addressInformationService, let script = output.script { - let addressInfo = addressInformationService.getAddressInformation(currency: output.currency, address: script) + let addressInfo = try addressInformationService.getAddressInformation(currency: output.currency, address: script) output.addressInformation = addressInfo } } diff --git a/transactId-library-ios/transactId-library-ios/Extensions/CharacterSet+Extension.swift b/transactId-library-ios/transactId-library-ios/Extensions/CharacterSet+Extension.swift new file mode 100644 index 0000000..b1331e4 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/Extensions/CharacterSet+Extension.swift @@ -0,0 +1,19 @@ +// +// CharacterSet+Extension.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +extension CharacterSet { + static let urlQueryValueAllowed: CharacterSet = { + let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4 + let subDelimitersToEncode = "!$&'()*+,;=" + + var allowed = CharacterSet.urlQueryAllowed + allowed.remove(charactersIn: "\(generalDelimitersToEncode)\(subDelimitersToEncode)") + return allowed + }() +} diff --git a/transactId-library-ios/transactId-library-ios/Extensions/Dictionary+Extension.swift b/transactId-library-ios/transactId-library-ios/Extensions/Dictionary+Extension.swift new file mode 100644 index 0000000..6b26222 --- /dev/null +++ b/transactId-library-ios/transactId-library-ios/Extensions/Dictionary+Extension.swift @@ -0,0 +1,20 @@ +// +// Dictionary+Extension.swift +// transactId-library-ios +// +// Created by Developer on 17.05.2021. +// + +import Foundation + +extension Dictionary { + func percentEncoded() -> Data? { + return map { key, value in + let escapedKey = "\(key)".addingPercentEncoding(withAllowedCharacters: .urlQueryValueAllowed) ?? "" + let escapedValue = "\(value)".addingPercentEncoding(withAllowedCharacters: .urlQueryValueAllowed) ?? "" + return escapedKey + "=" + escapedValue + } + .joined(separator: "&") + .data(using: .utf8) + } +} diff --git a/transactId-library-ios/transactId-library-ios/Models/AddressInformation.swift b/transactId-library-ios/transactId-library-ios/Models/AddressInformation.swift index 3d9d9b1..97167aa 100644 --- a/transactId-library-ios/transactId-library-ios/Models/AddressInformation.swift +++ b/transactId-library-ios/transactId-library-ios/Models/AddressInformation.swift @@ -16,95 +16,95 @@ public class AddressInformation { * Address. * If blank or empty, not information was found for this address. */ - var identifier: String? = nil + public var identifier: String? = nil /** * Total amount in cryptocurrency available with address. */ - var balance: Double? = 0.0 + public var balance: Double? = 0.0 /** * A list of entities who were beneficiaries in a transaction. */ - var beneficiary: Array? = nil + public var beneficiary: Array = [] /** * Case status for transaction. */ - var caseStatus: Int? = nil + public var caseStatus: Int? = nil /** * Case status for transaction. */ - var caseStatusVerbose: String? = nil + public var caseStatusVerbose: String? = nil /** * The currency code for the blockchain this address was searched on, [-1] if could not get the currency of the address. */ - var currency: Int? = -1 + public var currency: Int? = -1 /** * The currency name for the blockchain this address was searched on. */ - var currencyVerbose: String? = nil + public var currencyVerbose: String? = nil /** * Date on which address has made its first transaction. */ - var earliestTransactionTime: String? = nil + public var earliestTransactionTime: String? = nil /** * Date on which address has made its last transaction. */ - var latestTransactionTime: String? = nil + public var latestTransactionTime: String? = nil /** * A list of entities who were originators in a transaction. */ - var originator: Array? = nil + public var originator: Array = [] /** * An integer indicating if this address is Low Risk [1], Medium Risk [2] or High Risk [3] address or if no risks were detected [0], [-1] if could not fetch the risk level. */ - var riskLevel: Int? = -1 + public var riskLevel: Int? = -1 /** * Indicates if this address is Low Risk, Medium Risk , High Risk or if no risks were detected. */ - var riskLevelVerbose: String? = nil + public var riskLevelVerbose: String? = nil /** * Information about the owner and user. */ - var tags: AddressTags? = nil + public var tags: AddressTags? = nil /** * Total amount received by the address in cryptocurrency. */ - var totalIncomingValue: String? = nil + public var totalIncomingValue: String? = nil /** * Total amount received by the address in USD. */ - var totalIncomingValueUsd: String? = nil + public var totalIncomingValueUsd: String? = nil /** * Total amount sent by the address in cryptocurrency. */ - var totalOutgoingValue: String? = nil + public var totalOutgoingValue: String? = nil /** * Total amount sent by the address in USD. */ - var totalOutgoingValueUsd: String? = nil + public var totalOutgoingValueUsd: String? = nil /** * UTC Timestamp for when this resource was created by you. */ - var createdAt: String? = nil + public var createdAt: String? = nil /** * UTC Timestamp for most recent lookup of this resource. */ - var updatedAt: String? = nil + public var updatedAt: String? = nil } diff --git a/transactId-library-ios/transactId-library-ios/Models/AddressTagInformation.swift b/transactId-library-ios/transactId-library-ios/Models/AddressTagInformation.swift index b8a9be4..69229a3 100644 --- a/transactId-library-ios/transactId-library-ios/Models/AddressTagInformation.swift +++ b/transactId-library-ios/transactId-library-ios/Models/AddressTagInformation.swift @@ -7,25 +7,25 @@ import Foundation -class AddressTagInformation { +public class AddressTagInformation { /** * Entity type. */ - var tagNameVerbose: String? = nil + public var tagNameVerbose: String? = nil /** * Entity subtype. */ - var tagSubtypeVerbose: String? = nil + public var tagSubtypeVerbose: String? = nil /** * Entity name. */ - var tagTypeVerbose: String? = nil + public var tagTypeVerbose: String? = nil /** * Value sent by entity in this transaction. */ - var totalValueUsd: String? = nil + public var totalValueUsd: String? = nil } diff --git a/transactId-library-ios/transactId-library-ios/Models/AddressTags.swift b/transactId-library-ios/transactId-library-ios/Models/AddressTags.swift index 5800215..e8e87df 100644 --- a/transactId-library-ios/transactId-library-ios/Models/AddressTags.swift +++ b/transactId-library-ios/transactId-library-ios/Models/AddressTags.swift @@ -7,9 +7,9 @@ import Foundation -class AddressTags { +public class AddressTags { - var owner: AddressTagInformation? = nil + public var owner: AddressTagInformation? = nil - var user: AddressTagInformation? = nil + public var user: AddressTagInformation? = nil } diff --git a/transactId-library-ios/transactId-library-ios/Services/PearlApiService/PearlApiRouter.swift b/transactId-library-ios/transactId-library-ios/Services/PearlApiService/PearlApiRouter.swift index 801dc42..b0e19f8 100644 --- a/transactId-library-ios/transactId-library-ios/Services/PearlApiService/PearlApiRouter.swift +++ b/transactId-library-ios/transactId-library-ios/Services/PearlApiService/PearlApiRouter.swift @@ -56,10 +56,10 @@ enum PearlApiRouter: URLRequestConvertible { case .getToken(let parameters): urlRequest.setValue("application/json", forHTTPHeaderField: "Accept") urlRequest = try JSONEncoding.default.encode(urlRequest, with: parameters) - case .createUser(let parameters): + case .createUser(let parameters, let token): urlRequest.setValue("application/json", forHTTPHeaderField: "Accept") - urlRequest.setValue("Token 4a4adfbbb3f9782af60d03eefb9d351e3eca9f4a", forHTTPHeaderField: "Authorization") - urlRequest = try JSONEncoding.default.encode(urlRequest, with: parameters.parameters) + urlRequest.setValue("Token \(token)", forHTTPHeaderField: "Authorization") + urlRequest = try JSONEncoding.default.encode(urlRequest, with: parameters) case .getTransactions( _, let token): urlRequest.setValue(token, forHTTPHeaderField: "Authorization") case .generateCertificate( _, let token, let parameters): diff --git a/transactId-library-ios/transactId-library-ios/TransactId.swift b/transactId-library-ios/transactId-library-ios/TransactId.swift index 772e712..c638540 100644 --- a/transactId-library-ios/transactId-library-ios/TransactId.swift +++ b/transactId-library-ios/transactId-library-ios/TransactId.swift @@ -29,6 +29,10 @@ public class TransactId { recipientParameters: RecipientParameters? = nil) throws -> InvoiceRequest? { return try self.bip75.parseInvoiceRequest(invoiceRequestBinary: invoiceRequestBinary, recipientParameters: recipientParameters) } + + public func parseInvoiceRequestWithAddressInfo(invoiceRequestBinary: Data, recipientParameters: RecipientParameters?) throws -> InvoiceRequest? { + return try self.bip75.parseInvoiceRequestWithAddressInfo(invoiceRequestBinary: invoiceRequestBinary, recipientParameters: recipientParameters) + } public func createPaymentRequest(paymentRequestParameters: PaymentRequestParameters) throws -> Data? { return try self.bip75.createPaymentRequest(paymentRequestParameters: paymentRequestParameters) @@ -65,6 +69,4 @@ public class TransactId { public func parsePaymentACK(paymentAckBinary: Data, recipientParameters: RecipientParameters? = nil) throws -> PaymentACK? { return try self.bip75.parsePaymentACK(paymentAckBinary: paymentAckBinary, recipientParameters: recipientParameters) } - - } diff --git a/transactId-library-ios/transactId_library_ios-tests/TransactIdMerkleRepoUnitTests.swift b/transactId-library-ios/transactId_library_ios-tests/TransactIdMerkleRepoUnitTests.swift new file mode 100644 index 0000000..ba87d86 --- /dev/null +++ b/transactId-library-ios/transactId_library_ios-tests/TransactIdMerkleRepoUnitTests.swift @@ -0,0 +1,48 @@ +// +// TransactIdMerkleRepoUnitTests.swift +// transactId_library_ios-tests +// +// Created by Developer on 19.05.2021. +// + +import Foundation + +import XCTest +import transactId_library_ios + +class TransactIdMerkleRepoUnitTests: XCTestCase { + + //MARK: Create and validate PaymentAckBinary + + func testCreateAndValidatePaymentAckBinary() throws { + + let merkleRepo = MerkleRepo(authorizationKey: "7WJNVNED7FZVZ09LXH4NGZV2ZPTKFLVNI9Y4CZOLWS") + + if let addressInformation = try merkleRepo.getAddressInformation(currency: AddressCurrency.bitcoin, address: "367f4YWz1VCFaqBqwbTrzwi2b1h2U3w1AF") { + + XCTAssert(addressInformation.identifier == "367f4YWz1VCFaqBqwbTrzwi2b1h2U3w1AF") + XCTAssert(addressInformation.balance == 589.00293000001693) + XCTAssert(addressInformation.currency == AddressCurrency.bitcoin.rawValue) + XCTAssert(addressInformation.currencyVerbose == "Bitcoin") + XCTAssert(addressInformation.riskLevel == 5) + XCTAssert(addressInformation.riskLevelVerbose == "Critical") + XCTAssert(addressInformation.totalIncomingValue == "396513.9406") + XCTAssert(addressInformation.totalIncomingValueUsd == "5959999379.62") + XCTAssert(addressInformation.totalOutgoingValue == "395924.9377") + XCTAssert(addressInformation.totalOutgoingValueUsd == "5979830112.47") + XCTAssert(addressInformation.tags?.user?.tagNameVerbose == nil) + XCTAssert(addressInformation.tags?.user?.tagSubtypeVerbose == nil) + XCTAssert(addressInformation.tags?.user?.tagTypeVerbose == nil) + XCTAssert(addressInformation.tags?.user?.totalValueUsd == nil) + XCTAssert(addressInformation.tags?.owner?.tagNameVerbose == "Gopax") + XCTAssert(addressInformation.tags?.owner?.tagSubtypeVerbose == "Optional KYC and AML") + XCTAssert(addressInformation.tags?.owner?.tagTypeVerbose == "Exchange") + XCTAssert(addressInformation.tags?.owner?.totalValueUsd == nil) + + } else { + XCTFail("Failed to Get Address Information") + } + + } + +}