├── 755 ├── .gitignore ├── AirbitzCore.podspec ├── AirbitzCore.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── AirbitzCore.xcworkspace └── contents.xcworkspacedata ├── Classes ├── Private │ ├── ABCAccount+Internal.h │ ├── ABCAccount.m │ ├── ABCCategories+Internal.h │ ├── ABCCategories.m │ ├── ABCContext+Internal.h │ ├── ABCContext.m │ ├── ABCCurrency+Internal.h │ ├── ABCCurrency.m │ ├── ABCDataStore+Internal.h │ ├── ABCDataStore.m │ ├── ABCDenomination.m │ ├── ABCError+Internal.h │ ├── ABCError.m │ ├── ABCExchangeCache+Internal.h │ ├── ABCExchangeCache.m │ ├── ABCKeychain+Internal.h │ ├── ABCKeychain.m │ ├── ABCLocalSettings.h │ ├── ABCLocalSettings.m │ ├── ABCMetaData+Internal.h │ ├── ABCMetaData.m │ ├── ABCParsedURI+Internal.h │ ├── ABCParsedURI.m │ ├── ABCReceiveAddress+Internal.h │ ├── ABCReceiveAddress.m │ ├── ABCSettings+Internal.h │ ├── ABCSettings.m │ ├── ABCSpend+Internal.h │ ├── ABCSpend.m │ ├── ABCTransaction+Internal.h │ ├── ABCTransaction.m │ ├── ABCTxInOut.m │ ├── ABCUtil.m │ ├── ABCWallet+Internal.h │ ├── ABCWallet.m │ ├── NSMutableData+Secure.h │ └── NSMutableData+Secure.m └── Public │ ├── ABCAccount.h │ ├── ABCCategories.h │ ├── ABCConditionCode.h │ ├── ABCContext.h │ ├── ABCCurrency.h │ ├── ABCDataStore.h │ ├── ABCDenomination.h │ ├── ABCError.h │ ├── ABCExchangeCache.h │ ├── ABCKeychain.h │ ├── ABCMetadata.h │ ├── ABCParsedURI.h │ ├── ABCReceiveAddress.h │ ├── ABCSettings.h │ ├── ABCSpend.h │ ├── ABCStrings.h │ ├── ABCTransaction.h │ ├── ABCTxInOut.h │ ├── ABCUtil.h │ └── ABCWallet.h ├── LICENSE ├── Podfile ├── Podfile.lock ├── README.md ├── ReactBridge ├── ABCReact.h ├── ABCReact.m └── abc-react.js ├── Resources ├── api.cer └── ca-certificates.crt ├── help └── html │ ├── Classes │ ├── ABCAccount.html │ ├── ABCBitIDSignature.html │ ├── ABCDataStore.html │ ├── ABCDenomination.html │ ├── ABCExchangeCache.html │ ├── ABCMetaData.html │ ├── ABCPasswordRuleResult.html │ ├── ABCReceiveAddress.html │ ├── ABCSettings.html │ ├── ABCSpend.html │ ├── ABCTransaction.html │ ├── ABCUtil.html │ ├── ABCWallet.html │ └── AirbitzCore.html │ ├── Constants │ ├── ABCDenominationMultiplier.html │ └── ABCImportDataModel.html │ ├── Protocols │ └── ABCAccountDelegate.html │ ├── css │ ├── scss │ │ ├── _index.scss │ │ ├── _layout.scss │ │ ├── _normalize.scss │ │ ├── _object.scss │ │ ├── _print.scss │ │ ├── _variables.scss │ │ ├── _xcode.scss │ │ └── style.scss │ └── style.css │ ├── hierarchy.html │ ├── img │ ├── button_bar_background.png │ ├── disclosure.png │ ├── disclosure_open.png │ ├── library_background.png │ └── title_background.png │ ├── index.html │ └── js │ └── script.js ├── main-help.m ├── mkabc ├── mkabcallclean ├── mkabcclean ├── mkabcosx └── mkdocs /755: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/755 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | AirBitz.xcodeproj/xcshareddata 2 | xcuserdata 3 | project.xcworkspace 4 | Pods/ 5 | Classes/Private/ABC.h 6 | Libraries/ 7 | LibrariesOSX/ 8 | .idea/ 9 | -------------------------------------------------------------------------------- /AirbitzCore.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint AirbitzCore.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "AirbitzCore" 19 | s.version = "1.2.1" 20 | s.summary = "Bitcoin and Edge Security Library" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | AirbitzCore is an SDK providing Bitcoin transaction functionality with simple handling of HD wallets. AirbitzCore also allows 29 | developers to secure arbitrary data which provides automatic client-side encryption, auto backup, and auto device-to-device synchronization. 30 | DESC 31 | 32 | s.homepage = "https://airbitz.co" 33 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 34 | 35 | 36 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 37 | # 38 | # Licensing your code is important. See http://choosealicense.com for more info. 39 | # CocoaPods will detect a license file if there is a named LICENSE* 40 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 41 | # 42 | 43 | s.license = "BSD modified" 44 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 45 | 46 | 47 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 48 | # 49 | # Specify the authors of the library, with email addresses. Email addresses 50 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 51 | # accepts just a name if you'd rather not provide an email address. 52 | # 53 | # Specify a social_media_url where others can refer to, for example a twitter 54 | # profile URL. 55 | # 56 | 57 | s.author = { "Paul Puey" => "paul@airbitz.co" } 58 | # Or just: s.author = "Paul Puey" 59 | # s.authors = { "Paul Puey" => "paul@airbitz.co" } 60 | s.social_media_url = "http://twitter.com/Airbitz" 61 | 62 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 63 | # 64 | # If this Pod runs only on iOS or OS X, then specify the platform and 65 | # the deployment target. You can optionally include the target after the platform. 66 | # 67 | 68 | # s.platform = :ios 69 | # s.platform = :ios, "8.0" 70 | 71 | # When using multiple platforms 72 | s.ios.deployment_target = "7.0" 73 | s.osx.deployment_target = "10.9" 74 | # s.watchos.deployment_target = "2.0" 75 | # s.tvos.deployment_target = "9.0" 76 | 77 | 78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 79 | # 80 | # Specify the location from where the source should be retrieved. 81 | # Supports git, hg, bzr, svn and HTTP. 82 | # 83 | #s.source = { :git => 'https://github.com/Airbitz/airbitz-core-objc.git', :tag => '0.10.3' } 84 | s.source = { :http => "https://developer.airbitz.co/download/airbitz-core-objc-1.2.1.tgz" } 85 | 86 | 87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 88 | # 89 | # CocoaPods is smart about how it includes source code. For source files 90 | # giving a folder will include any swift, h, m, mm, c & cpp files. 91 | # For header files it will include any header in the folder. 92 | # Not including the public_header_files will make all headers public. 93 | # 94 | 95 | s.source_files = "Classes", "Classes/**/*.{h,m}" 96 | s.exclude_files = "Classes/Exclude" 97 | 98 | s.public_header_files = "Classes/Public/*.{h,m}" 99 | 100 | 101 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 102 | # 103 | # A list of resources included with the Pod. These are copied into the 104 | # target bundle with a build phase script. Anything else will be cleaned. 105 | # You can preserve files from being cleaned, please don't preserve 106 | # non-essential files like tests, examples and documentation. 107 | # 108 | 109 | # s.resource = "icon.png" 110 | s.resources = "Resources/api.cer", "Resources/ca-certificates.crt" 111 | 112 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 113 | 114 | 115 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 116 | # 117 | # Link your library with frameworks, or libraries. Libraries do not include 118 | # the lib prefix of their name. 119 | # 120 | 121 | # s.framework = "SomeFramework" 122 | # s.frameworks = "SomeFramework", "AnotherFramework" 123 | 124 | # s.library = "AirbitzCore" 125 | s.libraries = "iconv", "c++" 126 | 127 | s.osx.vendored_libraries = 128 | "LibrariesOSX/libabc.a", 129 | "LibrariesOSX/libbitcoin.a", 130 | "LibrariesOSX/libboost_atomic.a", 131 | "LibrariesOSX/libboost_chrono.a", 132 | "LibrariesOSX/libboost_date_time.a", 133 | "LibrariesOSX/libboost_filesystem.a", 134 | "LibrariesOSX/libboost_program_options.a", 135 | "LibrariesOSX/libboost_regex.a", 136 | "LibrariesOSX/libboost_system.a", 137 | "LibrariesOSX/libboost_thread.a", 138 | "LibrariesOSX/libcrypto.a", 139 | "LibrariesOSX/libcsv.a", 140 | "LibrariesOSX/libcurl.a", 141 | "LibrariesOSX/libgit2.a", 142 | "LibrariesOSX/libjansson.a", 143 | "LibrariesOSX/libprotobuf-lite.a", 144 | "LibrariesOSX/libqrencode.a", 145 | "LibrariesOSX/libsecp256k1.a", 146 | "LibrariesOSX/libsodium.a", 147 | "LibrariesOSX/libssl.a", 148 | "LibrariesOSX/libz.a", 149 | "LibrariesOSX/libzmq.a" 150 | 151 | s.ios.vendored_libraries = 152 | "Libraries/libabc.a", 153 | "Libraries/libbitcoin.a", 154 | "Libraries/libboost_atomic.a", 155 | "Libraries/libboost_chrono.a", 156 | "Libraries/libboost_date_time.a", 157 | "Libraries/libboost_filesystem.a", 158 | "Libraries/libboost_program_options.a", 159 | "Libraries/libboost_regex.a", 160 | "Libraries/libboost_system.a", 161 | "Libraries/libboost_thread.a", 162 | "Libraries/libcrypto.a", 163 | "Libraries/libcsv.a", 164 | "Libraries/libcurl.a", 165 | "Libraries/libgit2.a", 166 | "Libraries/libjansson.a", 167 | "Libraries/libprotobuf-lite.a", 168 | "Libraries/libqrencode.a", 169 | "Libraries/libsecp256k1.a", 170 | "Libraries/libsodium.a", 171 | "Libraries/libssl.a", 172 | "Libraries/libz.a", 173 | "Libraries/libzmq.a" 174 | 175 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 176 | # 177 | # If your library depends on compiler flags you can set them in the xcconfig hash 178 | # where they will only apply to your library. If you depend on other Podspecs 179 | # you can include multiple dependencies to ensure it works. 180 | 181 | s.requires_arc = true 182 | 183 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 184 | # s.dependency "JSONKit", "~> 1.4" 185 | 186 | end 187 | -------------------------------------------------------------------------------- /AirbitzCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AirbitzCore.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Classes/Private/ABCAccount+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCAccount+Internal.h 3 | // Airbitz 4 | // 5 | 6 | #import "ABCAccount.h" 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCAccount (Internal) 10 | 11 | @property (atomic, strong) ABCContext *abc; 12 | @property BOOL bNewDeviceLogin; 13 | @property (atomic, copy) NSString *password; 14 | @property (atomic, copy) NSString *loginKey; 15 | 16 | - (void)login; 17 | - (void)startSuspend; 18 | - (void)enterBackground; 19 | - (void)enterForeground; 20 | - (BOOL)didLoginExpire; 21 | - (void)postToGenQRQueue:(void(^)(void))cb; 22 | - (void)postToMiscQueue:(void(^)(void))cb; 23 | - (void)postToWatcherQueue:(void(^)(void))cb; 24 | - (void)postToDataQueue:(void(^)(void))cb; 25 | - (ABCError *)setDefaultCurrency:(NSString *)currencyCode; 26 | - (void)setConnectivity:(BOOL)hasConnectivity; 27 | - (void)setupLoginPIN; 28 | - (void)refreshWallets; 29 | - (void)connectWatcher:(NSString *)uuid; 30 | - (void)clearDataQueue; 31 | - (BOOL)watcherExists:(NSString *)uuid; 32 | - (id)initWithCore:(ABCContext *)airbitzCore; 33 | - (void)free; 34 | - (void)startQueues; 35 | - (void)stopQueues; 36 | - (int)dataOperationCount; 37 | - (long) saveLogoutDate; 38 | - (void)requestExchangeRateUpdate; 39 | - (void)dataSyncAccount; 40 | - (void)logoutAllowRelogin; 41 | - (NSString *)getLoginKey:(ABCError **)error; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Classes/Private/ABCCategories+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCCategories+Internal.h 3 | // 4 | // Created by Paul Puey on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCCategories.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCCategories(Internal) 12 | 13 | - (id) initWithAccount:(ABCAccount *)account; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/Private/ABCCategories.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCCategories.m 3 | // Airbitz 4 | // 5 | 6 | #import "ABCCategories+Internal.h" 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCCategories () 10 | { 11 | ABCAccount *_account; 12 | NSArray *_categoryList; 13 | BOOL _categoriesUpdated; 14 | } 15 | 16 | @end 17 | 18 | @implementation ABCCategories 19 | 20 | - (id) initWithAccount:(ABCAccount *)account; 21 | { 22 | _account = account; 23 | return self; 24 | } 25 | 26 | - (NSArray *)listCategories 27 | { 28 | if (_categoryList && !_categoriesUpdated) 29 | return _categoryList; 30 | 31 | _categoriesUpdated = NO; 32 | char **aszCategories = NULL; 33 | unsigned int countCategories = 0; 34 | NSMutableArray *mutableArrayCategories = [[NSMutableArray alloc] init]; 35 | 36 | // get the categories from the core 37 | tABC_Error error; 38 | ABC_GetCategories([_account.name UTF8String], 39 | [_account.password UTF8String], 40 | &aszCategories, 41 | &countCategories, 42 | &error); 43 | 44 | { 45 | // store them in our own array 46 | 47 | if (aszCategories && countCategories > 0) 48 | { 49 | for (int i = 0; i < countCategories; i++) 50 | { 51 | [mutableArrayCategories addObject:[NSString stringWithUTF8String:aszCategories[i]]]; 52 | } 53 | } 54 | 55 | } 56 | 57 | // free the core categories 58 | if (aszCategories != NULL) 59 | { 60 | [ABCUtil freeStringArray:aszCategories count:countCategories]; 61 | } 62 | 63 | NSArray *tempArray = [mutableArrayCategories sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; 64 | 65 | // store the final as storted 66 | _categoryList = tempArray; 67 | 68 | return _categoryList; 69 | } 70 | 71 | - (ABCError *)addCategory:(NSString *)category; 72 | { 73 | ABCError *nserror = nil; 74 | // check and see that it doesn't already exist 75 | if ([_categoryList indexOfObject:category] == NSNotFound) 76 | { 77 | // add the category to the core 78 | tABC_Error error; 79 | ABC_AddCategory([_account.name UTF8String], 80 | [_account.password UTF8String], 81 | (char *)[category UTF8String], &error); 82 | nserror = [ABCError makeNSError:error]; 83 | _categoriesUpdated = YES; 84 | } 85 | return nserror; 86 | } 87 | 88 | - (ABCError *)removeCategory:(NSString *)category; 89 | { 90 | tABC_Error error; 91 | ABCError *nserror = nil; 92 | ABC_RemoveCategory([_account.name UTF8String], 93 | [_account.password UTF8String], 94 | (char *)[category UTF8String], &error); 95 | nserror = [ABCError makeNSError:error]; 96 | _categoriesUpdated = YES; 97 | return nserror; 98 | } 99 | 100 | // saves the categories to the core 101 | - (ABCError *)saveCategories:(NSArray *)arrayCategories; 102 | { 103 | ABCError *nserror = nil; 104 | ABCError *nserrorRet = nil; 105 | NSMutableArray *saveArrayCategories = [NSMutableArray arrayWithArray:arrayCategories]; 106 | 107 | // got through the existing categories 108 | for (NSString *strCategory in _categoryList) 109 | { 110 | // if this category is in our new list 111 | if ([saveArrayCategories containsObject:strCategory]) 112 | { 113 | // remove it from our new list since it is already there 114 | [saveArrayCategories removeObject:strCategory]; 115 | } 116 | else 117 | { 118 | // it doesn't exist in our new list so delete it from the core 119 | nserror = [self removeCategory:strCategory]; 120 | if (nserror) nserrorRet = nserror; 121 | } 122 | } 123 | 124 | // add any categories from our new list that didn't exist in the core list 125 | for (NSString *strCategory in saveArrayCategories) 126 | { 127 | nserror = [self addCategory:strCategory]; 128 | if (nserror) nserrorRet = nserror; 129 | } 130 | 131 | return nserrorRet; 132 | } 133 | 134 | 135 | 136 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCContext+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCContext+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABC.h" 9 | #import "ABCContext.h" 10 | #import "ABCAccount+Internal.h" 11 | #import "ABCCategories+Internal.h" 12 | #import "ABCCurrency+Internal.h" 13 | #import "ABCDataStore+Internal.h" 14 | #import "ABCError+Internal.h" 15 | #import "ABCExchangeCache+Internal.h" 16 | #import "ABCKeychain+Internal.h" 17 | #import "ABCLocalSettings.h" 18 | #import "ABCMetaData+Internal.h" 19 | #import "ABCParsedURI+Internal.h" 20 | #import "ABCReceiveAddress+Internal.h" 21 | #import "ABCSettings+Internal.h" 22 | #import "ABCSpend+Internal.h" 23 | #import "ABCStrings.h" 24 | #import "ABCTransaction+Internal.h" 25 | #import "ABCAccount+Internal.h" 26 | #import "ABCWallet+Internal.h" 27 | 28 | @interface ABCContext (Internal) 29 | 30 | @property (atomic, strong) ABCLocalSettings *localSettings; 31 | @property (atomic, strong) ABCKeychain *keyChain; 32 | @property (atomic, strong) NSMutableArray *loggedInUsers; 33 | @property (atomic, strong) ABCExchangeCache *exchangeCache; 34 | @property (atomic, strong) NSOperationQueue *exchangeQueue; 35 | 36 | - (NSDate *)dateFromTimestamp:(int64_t) intDate; 37 | - (ABCError *)setupOTPKey:(NSString *)username 38 | key:(NSString *)key; 39 | 40 | @end 41 | 42 | -------------------------------------------------------------------------------- /Classes/Private/ABCCurrency+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCCurrency+Internal.h 3 | // 4 | // Created by Paul Puey on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCCurrency.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCCurrency(Internal) 12 | 13 | + (NSArray *) listCurrencyNums; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/Private/ABCCurrency.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCCurrency.m 3 | // Airbitz 4 | // 5 | 6 | #import "ABCContext+Internal.h" 7 | 8 | @interface ABCCurrency () 9 | { 10 | } 11 | 12 | @end 13 | 14 | static ABCCurrency *staticNoCurrency = nil; 15 | static ABCCurrency *staticDefaultCurrency = nil; 16 | static NSMutableDictionary *currencyCodesCache = nil; 17 | static NSMutableDictionary *currencySymbolCache = nil; 18 | static NSArray *arrayCurrency = nil; 19 | static NSArray *arrayCurrencyNums = nil; 20 | static NSArray *arrayCurrencyCodes = nil; 21 | static NSArray *arrayCurrencyStrings = nil; 22 | static NSNumberFormatter *numberFormatter = nil; 23 | 24 | @implementation ABCCurrency 25 | 26 | + (ABCCurrency *)noCurrency; 27 | { 28 | if (!staticNoCurrency) 29 | { 30 | staticNoCurrency = [ABCCurrency alloc]; 31 | staticNoCurrency.code = @""; 32 | staticNoCurrency.textDescription = @""; 33 | staticNoCurrency.symbol = @""; 34 | staticNoCurrency.currencyNum = 0; 35 | } 36 | return staticNoCurrency; 37 | } 38 | + (ABCCurrency *)defaultCurrency; 39 | { 40 | if (!staticDefaultCurrency) 41 | { 42 | staticDefaultCurrency = [ABCCurrency alloc]; 43 | staticDefaultCurrency.code = @"USD"; 44 | staticDefaultCurrency.textDescription = @"USD - US Dollar"; 45 | staticDefaultCurrency.symbol = @"$"; 46 | staticDefaultCurrency.currencyNum = 840; 47 | } 48 | return staticDefaultCurrency; 49 | } 50 | 51 | + (NSArray *) listCurrencies; 52 | { 53 | if (!arrayCurrency) 54 | [ABCCurrency initializeCurrencyArrays]; 55 | 56 | return arrayCurrency; 57 | } 58 | 59 | + (NSArray *) listCurrencyCodes; 60 | { 61 | if (!arrayCurrencyCodes) 62 | [ABCCurrency initializeCurrencyArrays]; 63 | return arrayCurrencyCodes; 64 | } 65 | 66 | + (NSArray *) listCurrencyStrings; 67 | { 68 | if (!arrayCurrencyStrings) 69 | [ABCCurrency initializeCurrencyArrays]; 70 | return arrayCurrencyStrings; 71 | } 72 | 73 | + (NSArray *) listCurrencyNums; 74 | { 75 | if (!arrayCurrencyNums) 76 | [ABCCurrency initializeCurrencyArrays]; 77 | 78 | return arrayCurrencyNums; 79 | } 80 | 81 | - (NSString *)symbol 82 | { 83 | if (!_symbol) 84 | { 85 | NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; 86 | for (NSString *l in NSLocale.availableLocaleIdentifiers) { 87 | f.locale = [NSLocale localeWithLocaleIdentifier:l]; 88 | if ([f.currencyCode isEqualToString:_code]) { 89 | _symbol = f.currencySymbol; 90 | break; 91 | } 92 | } 93 | } 94 | return _symbol; 95 | } 96 | 97 | const NSString *syncToken = @"ABCCurrencySyncToken"; 98 | #define DEFAULT_CURRENCY @"USD" 99 | 100 | + (NSString *)getCurrencyCodeOfLocale; 101 | { 102 | NSLocale *locale = [NSLocale autoupdatingCurrentLocale]; 103 | NSString *code = [locale objectForKey:NSLocaleCurrencyCode]; 104 | 105 | if (code) 106 | return code; 107 | else 108 | return DEFAULT_CURRENCY; 109 | } 110 | 111 | + (void) initializeCurrencyArrays 112 | { 113 | @synchronized(syncToken) 114 | { 115 | tABC_Error error; 116 | tABC_Currency *aCurrencies = nil; 117 | int currencyCount; 118 | 119 | ABC_GetCurrencies(&aCurrencies, ¤cyCount, &error); 120 | if ([ABCError makeNSError:error]) return; 121 | 122 | // set up our internal currency arrays 123 | NSMutableArray *lArrayCurrency = [[NSMutableArray alloc] initWithCapacity:currencyCount]; 124 | NSMutableArray *lArrayCurrencyNums = [[NSMutableArray alloc] initWithCapacity:currencyCount]; 125 | NSMutableArray *lArrayCurrencyCodes = [[NSMutableArray alloc] initWithCapacity:currencyCount]; 126 | NSMutableArray *lArrayCurrencyStrings = [[NSMutableArray alloc] initWithCapacity:currencyCount]; 127 | 128 | for (int i = 0; i < currencyCount; i++) 129 | { 130 | ABCCurrency *currency = [ABCCurrency alloc]; 131 | 132 | currency.textDescription = [NSString stringWithFormat:@"%s - %@", 133 | aCurrencies[i].szCode, 134 | [NSString stringWithUTF8String:aCurrencies[i].szDescription]]; 135 | currency.code = [NSString stringWithUTF8String:aCurrencies[i].szCode]; 136 | currency.currencyNum = aCurrencies[i].num; 137 | 138 | [lArrayCurrency addObject:currency]; 139 | [lArrayCurrencyCodes addObject:currency.code]; 140 | [lArrayCurrencyNums addObject:[NSNumber numberWithInt:aCurrencies[i].num]]; 141 | [lArrayCurrencyStrings addObject:currency.textDescription]; 142 | } 143 | arrayCurrency = lArrayCurrency; 144 | arrayCurrencyNums = lArrayCurrencyNums; 145 | arrayCurrencyStrings = lArrayCurrencyStrings; 146 | arrayCurrencyCodes = lArrayCurrencyCodes; 147 | } 148 | } 149 | 150 | - (NSString *)doubleToPrettyCurrencyString:(double) fCurrency; 151 | { 152 | return [self doubleToPrettyCurrencyString:fCurrency withSymbol:true]; 153 | } 154 | 155 | - (NSString *)doubleToPrettyCurrencyString:(double) fCurrency withSymbol:(bool)symbol 156 | { 157 | NSNumberFormatter *f = [ABCCurrency generateNumberFormatter]; 158 | [f setNumberStyle: NSNumberFormatterCurrencyStyle]; 159 | if (symbol) { 160 | NSString *symbol = self.symbol; 161 | [f setNegativePrefix:[NSString stringWithFormat:@"-%@ ",symbol]]; 162 | [f setNegativeSuffix:@""]; 163 | [f setCurrencySymbol:[NSString stringWithFormat:@"%@ ", symbol]]; 164 | } else { 165 | [f setCurrencySymbol:@""]; 166 | } 167 | return [f stringFromNumber:[NSNumber numberWithFloat:fCurrency]]; 168 | } 169 | 170 | + (NSNumberFormatter *)generateNumberFormatter; 171 | { 172 | if (!numberFormatter) 173 | { 174 | NSLocale *locale = [NSLocale autoupdatingCurrentLocale]; 175 | numberFormatter = [[NSNumberFormatter alloc] init]; 176 | [numberFormatter setMinimumFractionDigits:2]; 177 | [numberFormatter setMaximumFractionDigits:2]; 178 | [numberFormatter setLocale:locale]; 179 | } 180 | return numberFormatter; 181 | } 182 | 183 | 184 | //+ (NSString *)currencyAbbrevLookup:(int)currencyNum 185 | //{ 186 | // ABCLog(2,@"ENTER currencyAbbrevLookup: %@", [NSThread currentThread].name); 187 | //// NSNumber *c = [NSNumber numberWithInt:currencyNum]; 188 | //// NSString *cached = [currencyCodesCache objectForKey:c]; 189 | //// if (cached != nil) { 190 | //// ABCLog(2,@"EXIT currencyAbbrevLookup CACHED code:%@ thread:%@", cached, [NSThread currentThread].name); 191 | //// return cached; 192 | //// } 193 | // tABC_Error error; 194 | // int currencyCount; 195 | // tABC_Currency *currencies = NULL; 196 | // ABC_GetCurrencies(¤cies, ¤cyCount, &error); 197 | // ABCLog(2,@"CALLED ABC_GetCurrencies: %@ currencyCount:%d", [NSThread currentThread].name, currencyCount); 198 | // if (error.code == ABC_CC_Ok) { 199 | // for (int i = 0; i < currencyCount; ++i) { 200 | // if (currencyNum == currencies[i].num) { 201 | // NSString *code = [NSString stringWithUTF8String:currencies[i].szCode]; 202 | // [currencyCodesCache setObject:code forKey:c]; 203 | // ABCLog(2,@"EXIT currencyAbbrevLookup code:%@ thread:%@", code, [NSThread currentThread].name); 204 | // return code; 205 | // } 206 | // } 207 | // } 208 | // ABCLog(2,@"EXIT currencyAbbrevLookup code:NULL thread:%@", [NSThread currentThread].name); 209 | // return @""; 210 | //} 211 | // 212 | //- (NSString *)currencySymbolLookup:(int)currencyNum 213 | //{ 214 | // NSNumber *c = [NSNumber numberWithInt:currencyNum]; 215 | // NSString *cached = [currencySymbolCache objectForKey:c]; 216 | // if (cached != nil) { 217 | // return cached; 218 | // } 219 | // NSNumberFormatter *formatter = nil; 220 | // NSString *code = [ABCCurrency currencyAbbrevLookup:currencyNum]; 221 | // for (NSString *l in NSLocale.availableLocaleIdentifiers) { 222 | // NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; 223 | // f.locale = [NSLocale localeWithLocaleIdentifier:l]; 224 | // if ([f.currencyCode isEqualToString:code]) { 225 | // formatter = f; 226 | // break; 227 | // } 228 | // } 229 | // if (formatter != nil) { 230 | // [currencySymbolCache setObject:formatter.currencySymbol forKey:c]; 231 | // return formatter.currencySymbol; 232 | // } else { 233 | // return @""; 234 | // } 235 | //} 236 | // 237 | // 238 | // 239 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCDataStore+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCDataStore+Internal.h 3 | // 4 | // Created by Paul Puey on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCDataStore.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCDataStore (Internal) 12 | 13 | @property ABCAccount *account; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/Private/ABCDataStore.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCDataStore.m 3 | // 4 | // Created by Paul Puey on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext+Internal.h" 9 | 10 | @interface ABCDataStore () 11 | { 12 | } 13 | 14 | @property ABCAccount *account; 15 | 16 | @end 17 | 18 | @implementation ABCDataStore 19 | 20 | #pragma Data Methods 21 | 22 | - (ABCError *)dataRead:(NSString *)folder withKey:(NSString *)key data:(NSMutableString *)data; 23 | { 24 | [data setString:@""]; 25 | tABC_Error error; 26 | char *szData = NULL; 27 | ABC_PluginDataGet([self.account.name UTF8String], 28 | [self.account.password UTF8String], 29 | [folder UTF8String], [key UTF8String], 30 | &szData, &error); 31 | ABCError *nserror = [ABCError makeNSError:error]; 32 | if (!nserror) { 33 | [data setString:[NSString stringWithUTF8String:szData]]; 34 | } 35 | if (szData != NULL) { 36 | free(szData); 37 | } 38 | return nserror; 39 | } 40 | 41 | - (ABCError *)dataWrite:(NSString *)folder withKey:(NSString *)key withValue:(NSString *)value; 42 | { 43 | tABC_Error error; 44 | ABC_PluginDataSet([self.account.name UTF8String], 45 | [self.account.password UTF8String], 46 | [folder UTF8String], 47 | [key UTF8String], 48 | [value UTF8String], 49 | &error); 50 | 51 | ABCError *nserror = [ABCError makeNSError:error]; 52 | if (!nserror) 53 | { 54 | [self.account dataSyncAccount]; 55 | } 56 | return nserror; 57 | } 58 | 59 | - (ABCError *)dataListKeys:(NSString *)folder keys:(NSMutableArray *)keys; 60 | { 61 | tABC_Error error; 62 | char **szKeys = NULL; 63 | unsigned int count; 64 | ABC_PluginDataKeys([self.account.name UTF8String], 65 | [self.account.password UTF8String], 66 | [folder UTF8String], 67 | &szKeys, &count, &error); 68 | ABCError *nserror = [ABCError makeNSError:error]; 69 | if (!nserror) 70 | { 71 | for (unsigned int i = 0; i < count; i++) 72 | { 73 | [keys addObject:[NSString stringWithUTF8String:szKeys[i]]]; 74 | } 75 | } 76 | if (szKeys != NULL) { 77 | free(szKeys); 78 | } 79 | return nserror; 80 | } 81 | 82 | 83 | 84 | - (ABCError *)dataRemoveKey:(NSString *)folder withKey:(NSString *)key; 85 | { 86 | tABC_Error error; 87 | ABC_PluginDataRemove([self.account.name UTF8String], 88 | [self.account.password UTF8String], 89 | [folder UTF8String], [key UTF8String], &error); 90 | ABCError *nserror = [ABCError makeNSError:error]; 91 | if (!nserror) 92 | { 93 | [self.account dataSyncAccount]; 94 | } 95 | return nserror; 96 | } 97 | 98 | - (ABCError *)dataRemoveFolder:(NSString *)folder; 99 | { 100 | tABC_Error error; 101 | ABC_PluginDataClear([self.account.name UTF8String], 102 | [self.account.password UTF8String], 103 | [folder UTF8String], &error); 104 | ABCError *nserror = [ABCError makeNSError:error]; 105 | if (!nserror) 106 | { 107 | [self.account dataSyncAccount]; 108 | } 109 | return nserror; 110 | } 111 | 112 | 113 | 114 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCDenomination.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCDenomination.m 3 | // Airbitz 4 | // 5 | 6 | #import "ABCDenomination.h" 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCDenomination () 10 | 11 | @end 12 | 13 | static ABCDenomination *BTC = nil; 14 | static ABCDenomination *mBTC = nil; 15 | static ABCDenomination *uBTC = nil; 16 | static NSString *decimalSymbol = nil; 17 | static NSNumberFormatter *numberFormatter = nil; 18 | static NSLocale *locale = nil; 19 | static NSLocale *usLocale = nil; 20 | 21 | @implementation ABCDenomination 22 | 23 | + (void)initDenominations; 24 | { 25 | BTC = [ABCDenomination alloc]; 26 | mBTC = [ABCDenomination alloc]; 27 | uBTC = [ABCDenomination alloc]; 28 | 29 | BTC.symbol = @"Ƀ"; 30 | BTC.label = @"BTC"; 31 | BTC.multiplier = ABCDenominationMultiplierBTC; 32 | BTC.index = 0; 33 | 34 | mBTC.symbol = @"mɃ"; 35 | mBTC.label = @"mBTC"; 36 | mBTC.multiplier = ABCDenominationMultiplierMBTC; 37 | mBTC.index = 1; 38 | 39 | uBTC.symbol = @"ƀ"; 40 | uBTC.label = @"bits"; 41 | uBTC.multiplier = ABCDenominationMultiplierUBTC; 42 | uBTC.index = 2; 43 | 44 | NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; 45 | decimalSymbol = [formatter decimalSeparator]; 46 | } 47 | 48 | + (ABCDenomination *) getDenominationForMultiplier:(ABCDenominationMultiplier)multiplier; 49 | { 50 | if (!BTC) 51 | { 52 | [ABCDenomination initDenominations]; 53 | } 54 | 55 | if (ABCDenominationMultiplierBTC == multiplier) 56 | { 57 | return BTC; 58 | } 59 | else if (ABCDenominationMultiplierMBTC == multiplier) 60 | { 61 | return mBTC; 62 | } 63 | else 64 | { 65 | return uBTC; 66 | } 67 | } 68 | 69 | + (ABCDenomination *) getDenominationForIndex:(int)index; 70 | { 71 | if (!BTC) 72 | { 73 | [ABCDenomination initDenominations]; 74 | } 75 | 76 | if (0 == index) 77 | { 78 | return BTC; 79 | } 80 | else if (1 == index) 81 | { 82 | return mBTC; 83 | } 84 | else 85 | { 86 | return uBTC; 87 | } 88 | } 89 | 90 | - (int) prettyBitcoinDecimalPlaces; 91 | { 92 | return [self maxBitcoinDecimalPlaces] - 2; 93 | } 94 | 95 | - (int) maxBitcoinDecimalPlaces 96 | { 97 | return log10((double) self.multiplier); 98 | } 99 | 100 | - (int64_t) btcStringToSatoshi:(NSString *) amount; 101 | { 102 | uint64_t parsedAmount = 0; 103 | int decimalPlaces = [self maxBitcoinDecimalPlaces]; 104 | 105 | NSNumberFormatter *nf = [ABCDenomination generateNumberFormatter]; 106 | [nf setLocale:locale]; 107 | [nf setMinimumFractionDigits:0]; 108 | [nf setMaximumFractionDigits:decimalPlaces]; 109 | 110 | [nf setNumberStyle:NSNumberFormatterDecimalStyle]; 111 | 112 | NSNumber *num = [nf numberFromString:amount]; 113 | 114 | if (num) 115 | { 116 | NSString *cleanAmount = [num stringValue]; 117 | if (cleanAmount) 118 | { 119 | if (ABC_ParseAmount([cleanAmount UTF8String], &parsedAmount, decimalPlaces) != ABC_CC_Ok) { 120 | } 121 | } 122 | } 123 | return (int64_t) parsedAmount; 124 | } 125 | 126 | - (NSString *)satoshiToBTCString:(int64_t)amount; 127 | { 128 | return [self satoshiToBTCString:amount withSymbol:true]; 129 | } 130 | 131 | - (NSString *)satoshiToBTCString: (int64_t) amount withSymbol:(bool)symbol 132 | { 133 | return [self satoshiToBTCString:amount withSymbol:symbol cropDecimals:NO]; 134 | } 135 | 136 | - (NSString *)satoshiToBTCString:(int64_t)amount 137 | withSymbol:(bool)symbol 138 | cropDecimals:(BOOL)cropDecimals 139 | { 140 | tABC_Error error; 141 | char *pFormatted = NULL; 142 | int decimalPlaces, prettyDecimalPlaces; 143 | 144 | decimalPlaces = [self maxBitcoinDecimalPlaces]; 145 | 146 | if (cropDecimals) 147 | { 148 | prettyDecimalPlaces = [self prettyBitcoinDecimalPlaces]; 149 | } 150 | else 151 | { 152 | prettyDecimalPlaces = decimalPlaces; 153 | } 154 | 155 | 156 | bool negative = amount < 0; 157 | amount = llabs(amount); 158 | if (ABC_FormatAmount(amount, &pFormatted, decimalPlaces, false, &error) != ABC_CC_Ok) 159 | { 160 | return nil; 161 | } 162 | else 163 | { 164 | NSMutableString *formatted = [[NSMutableString alloc] init]; 165 | if (negative) 166 | [formatted appendString: @"-"]; 167 | if (symbol && self.symbol) 168 | { 169 | [formatted appendString: self.symbol]; 170 | [formatted appendString: @" "]; 171 | } 172 | 173 | NSNumberFormatter *f = [ABCDenomination generateNumberFormatter]; 174 | [f setMinimumFractionDigits:0]; 175 | [f setMaximumFractionDigits:prettyDecimalPlaces]; 176 | 177 | // Use NSNumberFormatter in US locale to convert ABC formatted string 178 | // to NSNumber 179 | [f setLocale:usLocale]; 180 | NSString *str1 = [NSString stringWithUTF8String:pFormatted]; 181 | NSNumber *nsnum = [f numberFromString:str1]; 182 | 183 | // Use NSNumberFormatter to output an NSString in localized number format 184 | [f setLocale:locale]; 185 | NSString *str2 = [f stringFromNumber:nsnum]; 186 | if (str2) 187 | [formatted appendString:str2]; 188 | 189 | free(pFormatted); 190 | return formatted; 191 | } 192 | } 193 | 194 | + (NSString *) getDecimalSymbol; 195 | { 196 | return decimalSymbol; 197 | } 198 | 199 | + (NSNumberFormatter *)generateNumberFormatter; 200 | { 201 | if (!numberFormatter) 202 | { 203 | locale = [NSLocale autoupdatingCurrentLocale]; 204 | usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 205 | 206 | [numberFormatter setLocale:locale]; 207 | numberFormatter = [[NSNumberFormatter alloc] init]; 208 | [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; 209 | } 210 | return numberFormatter; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCError+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCError+Internal.h 3 | // 4 | // Created by Paul P on 1/30/16. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCError.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCError (Internal) 12 | 13 | /* 14 | * errorMap 15 | * @param ABCConditionCode: error code to look up 16 | * @return NSString* : text description of error 17 | */ 18 | + (NSString *)conditionCodeMap:(const ABCConditionCode) code; 19 | 20 | + (ABCError *)makeNSError:(tABC_Error)error; 21 | + (ABCError *)makeNSError:(tABC_Error)error description:(NSString *)description; 22 | 23 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCError.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCError.m 3 | // Airbitz 4 | // 5 | 6 | #import 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCError () 10 | 11 | @end 12 | 13 | @implementation ABCError 14 | 15 | + (ABCError *)makeNSError:(tABC_Error)error; 16 | { 17 | return [ABCError makeNSError:error description:[ABCError errorMap:error]]; 18 | } 19 | 20 | + (ABCError *)makeNSError:(tABC_Error)error description:(NSString *)description; 21 | { 22 | if (ABCConditionCodeOk == error.code) 23 | { 24 | return nil; 25 | } 26 | else 27 | { 28 | NSString *failureReason = @""; 29 | NSString *failureDetail = @""; 30 | if (ABCConditionCodeNULLPtr != error.code) 31 | { 32 | failureReason = [NSString stringWithUTF8String:error.szDescription]; 33 | failureDetail = [NSString stringWithFormat:@"%@: %@:%d", 34 | [NSString stringWithUTF8String:error.szSourceFunc], 35 | [NSString stringWithUTF8String:error.szSourceFile], 36 | error.nSourceLine]; 37 | } 38 | 39 | if (!description) 40 | description = @""; 41 | if (!failureReason) 42 | failureReason = @""; 43 | if (!failureDetail) 44 | failureDetail = @""; 45 | 46 | ABCError *abcError = [ABCError errorWithDomain:ABCErrorDomain 47 | code:error.code 48 | userInfo:@{ NSLocalizedDescriptionKey:description, 49 | NSLocalizedFailureReasonErrorKey:failureReason, 50 | NSLocalizedRecoverySuggestionErrorKey:failureDetail }]; 51 | return abcError; 52 | } 53 | } 54 | 55 | +(ABCError *) errorWithDomain:(NSInteger) code 56 | userInfo:(NSDictionary *)userInfo; 57 | { 58 | ABCError *error = [ABCError alloc]; 59 | error.code = code; 60 | error.userInfo = userInfo; 61 | 62 | return error; 63 | } 64 | 65 | 66 | + (NSString *)errorMap:(tABC_Error)error; 67 | { 68 | if (ABCConditionCodeInvalidPinWait == error.code) 69 | { 70 | NSString *description = [NSString stringWithUTF8String:error.szDescription]; 71 | if ([@"0" isEqualToString:description]) { 72 | return NSLocalizedString(@"Invalid PIN/Password", nil); 73 | } else { 74 | return [NSString stringWithFormat: 75 | NSLocalizedString(@"Too many failed login attempts. Please try again in %@ seconds.", nil), 76 | description]; 77 | } 78 | } 79 | else 80 | { 81 | return [ABCError conditionCodeMap:(ABCConditionCode) error.code]; 82 | } 83 | 84 | } 85 | 86 | + (NSString *)conditionCodeMap:(ABCConditionCode) cc; 87 | { 88 | NSString *str; 89 | 90 | switch (cc) 91 | { 92 | case ABCConditionCodeAccountAlreadyExists: 93 | return NSLocalizedString(@"This account already exists.", nil); 94 | case ABCConditionCodeAccountDoesNotExist: 95 | return NSLocalizedString(@"We were unable to find your account. Be sure your username is correct.", nil); 96 | case ABCConditionCodeBadPassword: 97 | return NSLocalizedString(@"Invalid username, PIN, or password", nil); 98 | case ABCConditionCodeWalletAlreadyExists: 99 | return NSLocalizedString(@"Wallet already exists.", nil); 100 | case ABCConditionCodeInvalidWalletID: 101 | return NSLocalizedString(@"Wallet does not exist.", nil); 102 | case ABCConditionCodeURLError: 103 | case ABCConditionCodeServerError: 104 | return NSLocalizedString(@"Unable to connect to Airbitz server. Please try again later.", nil); 105 | case ABCConditionCodeNoRecoveryQuestions: 106 | return NSLocalizedString(@"No recovery questions are available for this user", nil); 107 | case ABCConditionCodeNotSupported: 108 | return NSLocalizedString(@"This operation is not supported.", nil); 109 | case ABCConditionCodeInsufficientFunds: 110 | return NSLocalizedString(@"Insufficient funds", nil); 111 | case ABCConditionCodeSpendDust: 112 | return NSLocalizedString(@"Amount is too small", nil); 113 | case ABCConditionCodeSynchronizing: 114 | return NSLocalizedString(@"Synchronizing with the network.", nil); 115 | case ABCConditionCodeNonNumericPin: 116 | return NSLocalizedString(@"PIN must be a numeric value.", nil); 117 | case ABCConditionCodeNULLPtr: 118 | return NSLocalizedString(@"Invalid NULL Ptr passed to ABC", nil); 119 | case ABCConditionCodeNoAvailAccountSpace: 120 | return NSLocalizedString(@"No Available Account Space", nil); 121 | case ABCConditionCodeDirReadError: 122 | return NSLocalizedString(@"Directory Read Error", nil); 123 | case ABCConditionCodeFileOpenError: 124 | return NSLocalizedString(@"File Open Error", nil); 125 | case ABCConditionCodeFileReadError: 126 | return NSLocalizedString(@"File Read Error", nil); 127 | case ABCConditionCodeFileWriteError: 128 | return NSLocalizedString(@"File Write Error", nil); 129 | case ABCConditionCodeFileDoesNotExist: 130 | return NSLocalizedString(@"File Does Not Exist Error", nil); 131 | case ABCConditionCodeUnknownCryptoType: 132 | case ABCConditionCodeInvalidCryptoType: 133 | case ABCConditionCodeDecryptError: 134 | case ABCConditionCodeDecryptFailure: 135 | case ABCConditionCodeEncryptError: 136 | case ABCConditionCodeScryptError: 137 | return NSLocalizedString(@"Encryption/Decryption Error", nil); 138 | case ABCConditionCodeMutexError: 139 | return NSLocalizedString(@"Mutex Error", nil); 140 | case ABCConditionCodeJSONError: 141 | return NSLocalizedString(@"JSON Error", nil); 142 | case ABCConditionCodeNoTransaction: 143 | return NSLocalizedString(@"No Transactions in Wallet", nil); 144 | case ABCConditionCodeSysError: 145 | return NSLocalizedString(@"Trouble accessing network. Please check network connection", nil); 146 | case ABCConditionCodeNotInitialized: 147 | case ABCConditionCodeReinitialization: 148 | case ABCConditionCodeParseError: 149 | case ABCConditionCodeNoRequest: 150 | case ABCConditionCodeNoAvailableAddress: 151 | case ABCConditionCodeError: 152 | default: 153 | str = [NSString stringWithFormat:@"%@ %d", NSLocalizedString(@"An error has occurred:", nil), cc]; 154 | return str; 155 | } 156 | } 157 | 158 | 159 | @end 160 | -------------------------------------------------------------------------------- /Classes/Private/ABCExchangeCache+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCExchangeCache+Internal.h 3 | // 4 | // Created by Paul Puey on 2016/02/27 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | #import "ABCExchangeCache.h" 8 | #import "ABCContext+Internal.h" 9 | 10 | @interface ABCExchangeCache (Internal) 11 | 12 | @property (atomic, strong) ABCContext *abc; 13 | @property (atomic, strong) ABCAccount *account; 14 | 15 | - (id)init:(ABCContext *)abc; 16 | - (ABCCurrency *) getCurrencyFromCode:(NSString *)code; 17 | - (int) getCurrencyNumFromCode:(NSString *)code; 18 | - (NSString *) getCurrencyCodeFromNum:(int) num; 19 | - (ABCCurrency *) getCurrencyFromNum:(int) num; 20 | - (void)updateExchangeCache; 21 | - (void)addCurrencyToCheck:(ABCCurrency *)currency; 22 | - (void)addCurrenciesToCheck:(NSMutableArray *)currencies; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/Private/ABCExchangeCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCExchangeCache.m 3 | // 4 | // Created by Paul Puey on 2016/02/27 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCExchangeCache+Internal.h" 9 | 10 | @interface ABCExchangeCache () 11 | { 12 | // ABCError *abcError; 13 | 14 | } 15 | 16 | @property (atomic, strong) ABCContext *abc; 17 | @property (atomic, strong) ABCAccount *account; 18 | @property (atomic, strong) NSMutableArray *currenciesToCheck; 19 | 20 | @end 21 | 22 | @implementation ABCExchangeCache 23 | 24 | - (id)init:(ABCContext *)abc; 25 | { 26 | // get the currencies 27 | self.abc = abc; 28 | 29 | self.currenciesToCheck = [[NSMutableArray alloc] init]; 30 | 31 | return self; 32 | } 33 | 34 | - (int) getCurrencyNumFromCode:(NSString *)code; 35 | { 36 | int index = (int) [[ABCCurrency listCurrencyCodes] indexOfObject:code]; 37 | if (index < 0) 38 | return [ABCCurrency noCurrency].currencyNum; 39 | if (index >= [[ABCCurrency listCurrencyNums] count]) 40 | return [ABCCurrency noCurrency].currencyNum; 41 | 42 | NSNumber *currencyNum = [ABCCurrency listCurrencyNums][index]; 43 | 44 | return (int)[currencyNum integerValue]; 45 | } 46 | 47 | - (ABCCurrency *) getCurrencyFromCode:(NSString *)code; 48 | { 49 | int index = (int) [[ABCCurrency listCurrencyCodes] indexOfObject:code]; 50 | if (index < 0) 51 | return [ABCCurrency noCurrency]; 52 | if (index >= [[ABCCurrency listCurrencies] count]) 53 | return [ABCCurrency noCurrency]; 54 | 55 | return [ABCCurrency listCurrencies][index]; 56 | } 57 | 58 | - (NSString *) getCurrencyCodeFromNum:(int) num; 59 | { 60 | int index = (int) [[ABCCurrency listCurrencyNums] indexOfObject:[NSNumber numberWithInt:num]]; 61 | if (index < 0) 62 | return [ABCCurrency noCurrency].code; 63 | if (index >= [[ABCCurrency listCurrencyCodes] count]) 64 | return [ABCCurrency noCurrency].code; 65 | 66 | return [ABCCurrency listCurrencyCodes][index]; 67 | } 68 | 69 | - (ABCCurrency *) getCurrencyFromNum:(int) num; 70 | { 71 | int index = (int) [[ABCCurrency listCurrencyNums] indexOfObject:[NSNumber numberWithInt:num]]; 72 | if (index < 0) 73 | return [ABCCurrency noCurrency]; 74 | if (index >= [[ABCCurrency listCurrencies] count]) 75 | return [ABCCurrency noCurrency]; 76 | 77 | return [ABCCurrency listCurrencies][index]; 78 | } 79 | 80 | - (double) satoshiToCurrency:(uint64_t) satoshi 81 | currencyCode:(NSString *)currencyCode 82 | error:(ABCError **)nserror; 83 | { 84 | tABC_Error error; 85 | ABCError *nserror2 = nil; 86 | double currency = 0.0; 87 | 88 | int currencyNum = [self getCurrencyNumFromCode:currencyCode]; 89 | 90 | ABC_SatoshiToCurrency(nil, nil, 91 | satoshi, ¤cy, currencyNum, &error); 92 | nserror2 = [ABCError makeNSError:error]; 93 | if (nserror2) 94 | { 95 | ABCCurrency *c = [self getCurrencyFromCode:currencyCode]; 96 | [self addCurrencyToCheck:c]; 97 | 98 | if (self.abc.loggedInUsers && [self.abc.loggedInUsers count]) 99 | { 100 | ABCAccount *account = self.abc.loggedInUsers[0]; 101 | if (account) 102 | [account requestExchangeRateUpdate]; 103 | } 104 | } 105 | 106 | if (nserror) *nserror = nserror2; 107 | 108 | return currency; 109 | } 110 | 111 | - (uint64_t) currencyToSatoshi:(double)currency 112 | currencyCode:(NSString *)currencyCode 113 | error:(ABCError **)nserror; 114 | { 115 | tABC_Error error; 116 | ABCError *nserror2 = nil; 117 | int64_t satoshi = 0; 118 | 119 | int currencyNum = [self getCurrencyNumFromCode:currencyCode]; 120 | 121 | ABC_CurrencyToSatoshi(nil, nil, currency, currencyNum, &satoshi, &error); 122 | nserror2 = [ABCError makeNSError:error]; 123 | if (nserror2) 124 | { 125 | ABCCurrency *c = [self getCurrencyFromCode:currencyCode]; 126 | [self addCurrencyToCheck:c]; 127 | 128 | ABCAccount *account = self.abc.loggedInUsers[0]; 129 | if (account) 130 | [account requestExchangeRateUpdate]; 131 | } 132 | 133 | if (nserror) *nserror = nserror2; 134 | 135 | return (uint64_t) satoshi; 136 | } 137 | 138 | - (void)addCurrencyToCheck:(ABCCurrency *)currency; 139 | { 140 | [self.abc.exchangeQueue addOperationWithBlock:^{ 141 | if ([self.currenciesToCheck indexOfObject:currency] == NSNotFound) 142 | { 143 | [self.currenciesToCheck addObject:currency]; 144 | } 145 | }]; 146 | } 147 | 148 | - (void)addCurrenciesToCheck:(NSMutableArray *)currencies; 149 | { 150 | [self.abc.exchangeQueue addOperationWithBlock:^{ 151 | for (ABCCurrency *c in currencies) 152 | { 153 | if ([self.currenciesToCheck indexOfObject:c] == NSNotFound) 154 | { 155 | [self.currenciesToCheck addObject:c]; 156 | } 157 | } 158 | }]; 159 | } 160 | 161 | - (void)updateExchangeCache; 162 | { 163 | tABC_Error error; 164 | 165 | [self.abc.exchangeQueue addOperationWithBlock:^{ 166 | for (ABCCurrency *c in self.currenciesToCheck) 167 | { 168 | // We pass no callback so this call is blocking 169 | ABC_RequestExchangeRateUpdate(nil, 170 | nil, 171 | c.currencyNum, &error); 172 | 173 | } 174 | [[NSThread currentThread] setName:@"Exchange Rate Update"]; 175 | }]; 176 | } 177 | 178 | 179 | 180 | @end 181 | 182 | -------------------------------------------------------------------------------- /Classes/Private/ABCKeychain+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCKeychain+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCKeychain.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | #define PASSWORD_KEY @"key_password" 12 | #define LOGINKEY_KEY @"key_loginkey" 13 | #define RELOGIN_KEY @"key_relogin" 14 | #define USE_TOUCHID_KEY @"key_use_touchid" 15 | #define LOGOUT_TIME_KEY @"key_logout_time" 16 | #define RECOVERY2_KEY @"key_recovery2" 17 | #define SEC_ATTR_SERVICE @"co.airbitz.airbitz" 18 | 19 | @class ABCSettings; 20 | @class ABCLocalSettings; 21 | 22 | @interface ABCKeychain(Internal) 23 | 24 | @property (nonatomic) ABCLocalSettings *localSettings; 25 | 26 | - (id) init:(ABCContext *)abc; 27 | - (BOOL) setKeychainData:(NSData *)data key:(NSString *)key authenticated:(BOOL) authenticated; 28 | - (NSData *) getKeychainData:(NSString *)key error:(ABCError **)error; 29 | - (BOOL) setKeychainString:(NSString *)s key:(NSString *)key authenticated:(BOOL) authenticated; 30 | - (BOOL) setKeychainInt:(int64_t) i key:(NSString *)key authenticated:(BOOL) authenticated; 31 | - (int64_t) getKeychainInt:(NSString *)key error:(ABCError **)error; 32 | - (NSString *) getKeychainString:(NSString *)key error:(ABCError **)error; 33 | - (NSString *) createKeyWithUsername:(NSString *)username key:(NSString *)key; 34 | - (BOOL) bHasSecureEnclave; 35 | - (void)authenticateTouchID:(NSString *)promptString fallbackString:(NSString *)fallbackString 36 | complete:(void (^)(BOOL didAuthenticate)) completionHandler; 37 | - (void) disableRelogin:(NSString *)username; 38 | - (void) disableTouchID:(NSString *)username; 39 | - (BOOL) disableKeychainBasedOnSettings:(NSString *)username; 40 | - (void) clearKeychainInfo:(NSString *)username; 41 | - (void) updateLoginKeychainInfo:(NSString *)username 42 | loginKey:(NSString *)key 43 | useTouchID:(BOOL) bUseTouchID; 44 | @end 45 | -------------------------------------------------------------------------------- /Classes/Private/ABCLocalSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCLocalSettings.h 3 | // 4 | // Created by Paul P on 1/31/16. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "ABCContext.h" 10 | 11 | @class ABCContext; 12 | 13 | @interface ABCLocalSettings : NSObject 14 | 15 | @property (retain) NSString *lastLoggedInAccount; 16 | @property (retain) NSMutableArray *touchIDUsersEnabled; 17 | @property (retain) NSMutableArray *touchIDUsersDisabled; 18 | 19 | - (id)init:(ABCContext *)abc; 20 | - (void)loadAll; 21 | - (void)saveAll; 22 | 23 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCLocalSettings.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/31/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import "ABCContext+Internal.h" 7 | 8 | #define KEY_LOCAL_SETTINGS_TOUCHID_USERS_ENABLED @"touchIDUsersEnabled" 9 | #define KEY_LOCAL_SETTINGS_TOUCHID_USERS_DISABLED @"touchIDUsersDisabled" 10 | #define KEY_LOCAL_SETTINGS_CACHED_USERNAME @"cachedUsername" 11 | 12 | static BOOL bInitialized = NO; 13 | 14 | __strong static ABCLocalSettings *singleton = nil; // this will be the one and only object this static singleton class has 15 | 16 | 17 | @interface ABCLocalSettings () 18 | 19 | @property (nonatomic) ABCContext *abc; 20 | 21 | @end 22 | 23 | @implementation ABCLocalSettings 24 | { 25 | 26 | } 27 | 28 | 29 | - (id)init:(ABCContext *)abc 30 | { 31 | self = [super init]; 32 | if (self) 33 | { 34 | if (!bInitialized) 35 | { 36 | self.touchIDUsersDisabled = nil; 37 | self.touchIDUsersEnabled = nil; 38 | self.abc = abc; 39 | 40 | // load the settings 41 | [self loadAll]; 42 | 43 | bInitialized = YES; 44 | } 45 | } 46 | return self; 47 | } 48 | 49 | - (void)dealloc 50 | { 51 | if (bInitialized) 52 | { 53 | bInitialized = NO; 54 | } 55 | 56 | } 57 | 58 | // loads all the settings from persistant memory 59 | - (void)loadAll 60 | { 61 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 62 | 63 | [defaults synchronize]; 64 | 65 | self.lastLoggedInAccount = [defaults stringForKey:KEY_LOCAL_SETTINGS_CACHED_USERNAME]; 66 | 67 | NSData *touchIDUsersEnabledData = [defaults objectForKey:KEY_LOCAL_SETTINGS_TOUCHID_USERS_ENABLED]; 68 | if (touchIDUsersEnabledData) { 69 | self.touchIDUsersEnabled = [NSKeyedUnarchiver unarchiveObjectWithData:touchIDUsersEnabledData]; 70 | } else { 71 | self.touchIDUsersEnabled = [[NSMutableArray alloc] init]; 72 | } 73 | 74 | NSData *touchIDUsersDisabledData = [defaults objectForKey:KEY_LOCAL_SETTINGS_TOUCHID_USERS_DISABLED]; 75 | if (touchIDUsersDisabledData) { 76 | self.touchIDUsersDisabled = [NSKeyedUnarchiver unarchiveObjectWithData:touchIDUsersDisabledData]; 77 | } else { 78 | self.touchIDUsersDisabled = [[NSMutableArray alloc] init]; 79 | } 80 | } 81 | 82 | // saves all the settings to persistant memory 83 | - (void)saveAll 84 | { 85 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 86 | 87 | [defaults setValue:self.lastLoggedInAccount forKey:KEY_LOCAL_SETTINGS_CACHED_USERNAME]; 88 | 89 | NSData *touchIDUsersEnabledData = [NSKeyedArchiver archivedDataWithRootObject:self.touchIDUsersEnabled]; 90 | [defaults setObject:touchIDUsersEnabledData forKey:KEY_LOCAL_SETTINGS_TOUCHID_USERS_ENABLED]; 91 | 92 | NSData *touchIDUsersDisabledData = [NSKeyedArchiver archivedDataWithRootObject:self.touchIDUsersDisabled]; 93 | [defaults setObject:touchIDUsersDisabledData forKey:KEY_LOCAL_SETTINGS_TOUCHID_USERS_DISABLED]; 94 | 95 | // flush the buffer 96 | [defaults synchronize]; 97 | } 98 | 99 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCMetaData+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCMetaData+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCMetaData.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | ///---------------------------------------------------------- 12 | /// @name ABCAccount Delegate callbacks 13 | ///---------------------------------------------------------- 14 | 15 | @protocol ABCMetaDataDelegate 16 | 17 | @optional 18 | 19 | - (void) abcMetaDataChanged; 20 | 21 | @end 22 | 23 | 24 | @interface ABCMetaData (Internal) 25 | 26 | /// Delegate object to handle delegate callbacks 27 | @property (assign) id delegate; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Classes/Private/ABCMetaData.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCKeychain.m 3 | // Airbitz 4 | // 5 | // Created by Paul Puey on 2016-03-01. 6 | // Copyright (c) 2016 Airbitz. All rights reserved. 7 | // 8 | 9 | #import "ABCMetaData+Internal.h" 10 | #import "ABCContext.h" 11 | 12 | @interface ABCMetaData () 13 | 14 | /// Delegate object to handle delegate callbacks 15 | @property (assign) id delegate; 16 | 17 | @end 18 | 19 | @implementation ABCMetaData 20 | { 21 | 22 | } 23 | 24 | - (void)setPayeeName:(NSString *)payeeName 25 | { 26 | _payeeName = payeeName; 27 | [self sendDataChanged]; 28 | } 29 | 30 | - (void)setCategory:(NSString *)category 31 | { 32 | _category = category; 33 | [self sendDataChanged]; 34 | } 35 | 36 | - (void)setAmountFiat:(double)amountFiat 37 | { 38 | _amountFiat = amountFiat; 39 | [self sendDataChanged]; 40 | } 41 | 42 | - (void)setNotes:(NSString *)notes 43 | { 44 | _notes = notes; 45 | [self sendDataChanged]; 46 | } 47 | 48 | - (void)setBizId:(unsigned int)bizId 49 | { 50 | _bizId = bizId; 51 | [self sendDataChanged]; 52 | } 53 | 54 | - (void)sendDataChanged 55 | { 56 | if (self.delegate) { 57 | if ([self.delegate respondsToSelector:@selector(abcMetaDataChanged)]) { 58 | [self.delegate abcMetaDataChanged]; 59 | } 60 | } 61 | } 62 | 63 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCParsedURI+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCParsedURI+Internal.h 3 | // 4 | // Created by Paul Puey on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCParsedURI.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCParsedURI(Internal) 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Classes/Private/ABCParsedURI.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCParsedURI.m 3 | // Airbitz 4 | // 5 | 6 | #import "ABCContext+Internal.h" 7 | 8 | @interface ABCParsedURI () 9 | { 10 | } 11 | 12 | @end 13 | 14 | @implementation ABCParsedURI 15 | 16 | - (ABCPaymentRequest *) getPaymentRequest:(ABCError **)nserror; 17 | { 18 | ABCPaymentRequest *paymentRequest = nil; 19 | tABC_PaymentRequest *pPaymentRequest = NULL; 20 | ABCError *lnserror = nil; 21 | tABC_Error error; 22 | 23 | if (self.paymentRequestURL) 24 | { 25 | ABC_FetchPaymentRequest((char *)[self.paymentRequestURL UTF8String], &pPaymentRequest, &error); 26 | lnserror = [ABCError makeNSError:error]; 27 | 28 | if (!lnserror) 29 | { 30 | paymentRequest = [ABCPaymentRequest alloc]; 31 | 32 | paymentRequest.pPaymentRequest = pPaymentRequest; 33 | paymentRequest.amountSatoshi = pPaymentRequest->amountSatoshi; 34 | if (pPaymentRequest->szDomain) 35 | paymentRequest.domain = [NSString stringWithUTF8String:pPaymentRequest->szDomain]; 36 | if (pPaymentRequest->szMemo) 37 | paymentRequest.memo = [NSString stringWithUTF8String:pPaymentRequest->szMemo]; 38 | if (pPaymentRequest->szMerchant) 39 | paymentRequest.merchant = [NSString stringWithUTF8String:pPaymentRequest->szMerchant]; 40 | } 41 | } 42 | 43 | if (nserror) *nserror = lnserror; 44 | 45 | return paymentRequest; 46 | } 47 | 48 | @end -------------------------------------------------------------------------------- /Classes/Private/ABCReceiveAddress+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCReceiveAddress+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCReceiveAddress.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCReceiveAddress (Internal) 12 | 13 | @property (atomic, strong) ABCWallet *wallet; 14 | 15 | - (ABCError *)createAddress; 16 | - (id)initWithWallet:(ABCWallet *)wallet; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Classes/Private/ABCReceiveAddress.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import "ABCReceiveAddress+Internal.h" 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCReceiveAddress () 10 | { 11 | 12 | } 13 | @property (nonatomic, strong) ABCWallet *wallet; 14 | @property BOOL requestChanged; 15 | 16 | @end 17 | 18 | @implementation ABCReceiveAddress 19 | - (id)initWithWallet:(ABCWallet *)wallet; 20 | { 21 | self = [super init]; 22 | self.metaData = [ABCMetaData alloc]; 23 | self.metaData.delegate = self; 24 | self.wallet = wallet; 25 | 26 | return self; 27 | } 28 | 29 | - (ABCError *)createAddress; 30 | { 31 | tABC_Error error; 32 | ABCError *lnserror = nil; 33 | 34 | char *pRequestID = nil; 35 | 36 | // create the request 37 | ABC_CreateReceiveRequest([self.wallet.account.name UTF8String], 38 | [self.wallet.account.password UTF8String], 39 | [self.wallet.uuid UTF8String], 40 | &pRequestID, 41 | &error); 42 | lnserror = [ABCError makeNSError:error]; 43 | if (lnserror) goto exitnow; 44 | self.address = [NSString stringWithUTF8String:pRequestID]; 45 | 46 | exitnow: 47 | 48 | if (pRequestID) free(pRequestID); 49 | 50 | return lnserror; 51 | 52 | } 53 | 54 | - (NSString *)address; 55 | { 56 | if (_requestChanged) 57 | [self modifyReceiveAddress]; 58 | return _address; 59 | } 60 | 61 | #if TARGET_OS_IPHONE 62 | - (UIImage *)qrCode 63 | #else 64 | - (NSImage *)qrCode 65 | #endif 66 | { 67 | if (_requestChanged || !_qrCode) 68 | [self modifyReceiveAddress]; 69 | return _qrCode; 70 | } 71 | 72 | - (NSString *)uri; 73 | { 74 | if (_requestChanged || !_uri) 75 | [self modifyReceiveAddress]; 76 | return _uri; 77 | } 78 | 79 | - (void)abcMetaDataChanged 80 | { 81 | _requestChanged = YES; 82 | } 83 | 84 | - (void)setAmountSatoshi:(int64_t)amountSatoshi 85 | { 86 | _amountSatoshi = amountSatoshi; 87 | _requestChanged = YES; 88 | } 89 | 90 | - (void)modifyReceiveAddress; 91 | { 92 | tABC_Error error; 93 | tABC_TxDetails details; 94 | ABCError *lnserror = nil; 95 | unsigned char *pData = NULL; 96 | char *pszURI = NULL; 97 | unsigned int width = 0; 98 | char *label = NULL; 99 | 100 | //first need to create a transaction details struct 101 | memset(&details, 0, sizeof(tABC_TxDetails)); 102 | 103 | details.amountSatoshi = _amountSatoshi; 104 | details.szName = (char *) [_metaData.payeeName UTF8String]; 105 | details.szCategory = (char *) [_metaData.category UTF8String]; 106 | details.szNotes = (char *) [_metaData.notes UTF8String]; 107 | details.bizId = _metaData.bizId; 108 | 109 | //the true fee values will be set by the core 110 | details.amountFeesAirbitzSatoshi = 0; 111 | details.amountFeesMinersSatoshi = 0; 112 | details.amountCurrency = 0; 113 | 114 | ABC_ModifyReceiveRequest([self.wallet.account.name UTF8String], 115 | [_wallet.account.password UTF8String], 116 | [_wallet.uuid UTF8String], 117 | [_address UTF8String], 118 | &details, 119 | &error); 120 | lnserror = [ABCError makeNSError:error]; 121 | if (lnserror) goto exitnow; 122 | 123 | if (self.wallet.account.settings.bNameOnPayments && self.wallet.account.settings.fullName) 124 | { 125 | label = [self.wallet.account.settings.fullName UTF8String]; 126 | } 127 | 128 | ABC_AddressUriEncode([_address UTF8String], _amountSatoshi, label, NULL, NULL, NULL, &pszURI, &error); 129 | lnserror = [ABCError makeNSError:error]; 130 | if (lnserror) goto exitnow; 131 | 132 | ABC_QrEncode(pszURI, &pData, &width, &error); 133 | lnserror = [ABCError makeNSError:error]; 134 | if (lnserror) goto exitnow; 135 | 136 | _qrCode = [ABCUtil dataToImage:pData withWidth:width andHeight:width]; 137 | _uri = [NSString stringWithUTF8String:pszURI]; 138 | 139 | exitnow: 140 | if (pData) free(pData); 141 | if (pszURI) free(pszURI); 142 | 143 | if (lnserror) 144 | { 145 | _qrCode = nil; 146 | _uri = nil; 147 | } 148 | 149 | _requestChanged = NO; 150 | 151 | } 152 | 153 | 154 | - (ABCError *)finalizeRequest 155 | { 156 | tABC_Error error; 157 | 158 | if (!self.wallet || !self.wallet.account || !self.address) 159 | { 160 | error.code = ABC_CC_NULLPtr; 161 | return [ABCError makeNSError:error]; 162 | } 163 | // Finalize this request so it isn't used elsewhere 164 | ABC_FinalizeReceiveRequest([self.wallet.account.name UTF8String], 165 | [self.wallet.account.password UTF8String], [self.wallet.uuid UTF8String], 166 | [self.address UTF8String], &error); 167 | return [ABCError makeNSError:error]; 168 | } 169 | 170 | - (void)prioritizeAddress:(BOOL)enable; 171 | { 172 | NSString *address = nil; 173 | 174 | if (enable) 175 | address = self.address; 176 | 177 | [self.wallet.account postToWatcherQueue:^{ 178 | tABC_Error error; 179 | ABC_PrioritizeAddress([self.wallet.account.name UTF8String], 180 | [self.wallet.account.password UTF8String], 181 | [self.wallet.uuid UTF8String], 182 | [address UTF8String], 183 | &error); 184 | }]; 185 | } 186 | 187 | - (ABCError *)modifyRequestWithDetails; 188 | { 189 | tABC_Error error; 190 | tABC_TxDetails details; 191 | unsigned char *pData = NULL; 192 | char *szRequestAddress = NULL; 193 | char *pszURI = NULL; 194 | ABCError *nserror = nil; 195 | char *label = NULL; 196 | 197 | //first need to create a transaction details struct 198 | memset(&details, 0, sizeof(tABC_TxDetails)); 199 | 200 | details.amountSatoshi = self.amountSatoshi; 201 | details.szName = (char *) [self.metaData.payeeName UTF8String]; 202 | details.szCategory = (char *) [self.metaData.category UTF8String]; 203 | details.szNotes = (char *) [self.metaData.notes UTF8String]; 204 | details.bizId = (unsigned int) self.metaData.bizId; 205 | 206 | //the true fee values will be set by the core 207 | details.amountFeesAirbitzSatoshi = 0; 208 | details.amountFeesMinersSatoshi = 0; 209 | details.amountCurrency = 0; 210 | 211 | char *pRequestID = (char *)[self.address UTF8String]; 212 | 213 | ABC_ModifyReceiveRequest([self.wallet.account.name UTF8String], 214 | [self.wallet.account.password UTF8String], 215 | [self.wallet.uuid UTF8String], 216 | pRequestID, 217 | &details, 218 | &error); 219 | nserror = [ABCError makeNSError:error]; 220 | if (nserror) goto exitnow; 221 | 222 | unsigned int width = 0; 223 | if (self.wallet.account.settings.bNameOnPayments && self.wallet.account.settings.fullName) 224 | { 225 | label = [self.wallet.account.settings.fullName UTF8String]; 226 | } 227 | 228 | ABC_AddressUriEncode([_address UTF8String], _amountSatoshi, label, NULL, NULL, NULL, &pszURI, &error); 229 | nserror = [ABCError makeNSError:error]; 230 | if (nserror) goto exitnow; 231 | 232 | ABC_QrEncode(pszURI, &pData, &width, &error); 233 | nserror = [ABCError makeNSError:error]; 234 | if (nserror) goto exitnow; 235 | 236 | self.qrCode = [ABCUtil dataToImage:pData withWidth:width andHeight:width]; 237 | self.uri = [NSString stringWithUTF8String:pszURI]; 238 | 239 | exitnow: 240 | 241 | if (szRequestAddress) free(szRequestAddress); 242 | if (pData) free(pData); 243 | if (pszURI) free(pszURI); 244 | 245 | return nserror; 246 | } 247 | 248 | 249 | @end 250 | 251 | -------------------------------------------------------------------------------- /Classes/Private/ABCSettings+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCSettings+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCSettings.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCSettings (Internal) 12 | 13 | @property (nonatomic, copy) NSString *strPIN; 14 | @property (nonatomic) bool bDisablePINLogin; 15 | 16 | 17 | - (id)init:(ABCAccount *)user localSettings:(id)local keyChain:(id)keyChain; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Classes/Private/ABCSpend+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCSpend+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCSpend.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCPaymentRequest (Internal) 12 | @property tABC_PaymentRequest *pPaymentRequest; 13 | @end 14 | 15 | @interface ABCSpend (Internal) 16 | 17 | @property (nonatomic) void *pSpend; 18 | 19 | - (id)init:(id)abc; 20 | - (void)spendObjectSet:(void *)o; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/Private/ABCSpend.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCSpend.m 3 | // AirBitz 4 | // 5 | 6 | #import "ABCSpend+Internal.h" 7 | #import "ABCContext+Internal.h" 8 | 9 | @interface ABCPaymentRequest () 10 | @property tABC_PaymentRequest *pPaymentRequest; 11 | @end 12 | 13 | @interface ABCSpend () 14 | { 15 | ABCMetaData *_metaData; 16 | ABCSpendFeeLevel _feeLevel; 17 | uint64_t _customFeeSatoshis; 18 | } 19 | 20 | @property (nonatomic) void *pSpend; 21 | @property (nonatomic, strong) ABCWallet *wallet; 22 | @end 23 | 24 | @interface ABCUnsentTx () 25 | @property ABCSpend *spend; 26 | @end 27 | 28 | 29 | @implementation ABCPaymentRequest 30 | - (void)dealloc; 31 | { 32 | if (self.pPaymentRequest) 33 | ABC_FreePaymentRequest(self.pPaymentRequest); 34 | } 35 | @end 36 | 37 | @implementation ABCUnsentTx 38 | 39 | - (ABCError *)broadcastTx; 40 | { 41 | tABC_Error error; 42 | ABC_SpendBroadcastTx(self.spend.pSpend, (char *)[self.base16 UTF8String], &error); 43 | 44 | ABCError *lnserror = [ABCError makeNSError:error]; 45 | if (lnserror) 46 | { 47 | ABCLog(1, @"*** ERROR broadcastTx: %@ // %@", lnserror.userInfo[NSLocalizedDescriptionKey], lnserror.userInfo[NSLocalizedFailureReasonErrorKey]); 48 | } 49 | 50 | return lnserror; 51 | } 52 | 53 | - (ABCTransaction *)saveTx:(ABCError **)nserror; 54 | { 55 | tABC_Error error; 56 | char *szTxId = NULL; 57 | ABCError *lnserror = nil; 58 | ABCTransaction *transaction = nil; 59 | 60 | ABC_SpendSaveTx(self.spend.pSpend, (char *)[self.base16 UTF8String], &szTxId, &error); 61 | lnserror = [ABCError makeNSError:error]; 62 | if (!lnserror) 63 | { 64 | transaction = [self.spend.wallet getTransaction:[NSString stringWithUTF8String:szTxId]]; 65 | } 66 | else 67 | { 68 | ABCLog(1, @"*** ERROR saveTx: %@ // %@", lnserror.userInfo[NSLocalizedDescriptionKey], lnserror.userInfo[NSLocalizedFailureReasonErrorKey]); 69 | } 70 | if (nserror) *nserror = lnserror; 71 | return transaction; 72 | } 73 | 74 | @end 75 | 76 | 77 | @implementation ABCSpend 78 | 79 | - (id)init:(id)wallet; 80 | { 81 | self = [super init]; 82 | if (self) { 83 | self.pSpend = NULL; 84 | self.metaData = [ABCMetaData alloc]; 85 | self.metaData.bizId = 0; 86 | self.wallet = wallet; 87 | } 88 | return self; 89 | } 90 | 91 | - (void)dealloc 92 | { 93 | if (self.pSpend != NULL) { 94 | ABC_SpendFree(self.pSpend); 95 | self.pSpend = NULL; 96 | } 97 | } 98 | 99 | - (ABCError *)addPaymentRequest:(ABCPaymentRequest *)paymentRequest; 100 | { 101 | tABC_Error error; 102 | 103 | if (!paymentRequest || !paymentRequest.pPaymentRequest) 104 | { 105 | error.code = ABC_CC_NULLPtr; 106 | return [ABCError makeNSError:error]; 107 | } 108 | ABC_SpendAddPaymentRequest(self.pSpend, paymentRequest.pPaymentRequest, &error); 109 | return [ABCError makeNSError:error]; 110 | } 111 | 112 | - (ABCError *)addTransfer:(ABCWallet *)destWallet amount:(uint64_t)amountSatoshi destMeta:(ABCMetaData *)destMeta; 113 | { 114 | tABC_Error error; 115 | tABC_TxDetails txDetails; 116 | 117 | if (!destWallet || !destWallet.uuid) 118 | { 119 | error.code = ABC_CC_NULLPtr; 120 | return [ABCError makeNSError:error]; 121 | } 122 | 123 | if (destMeta) 124 | { 125 | txDetails.szName = (char *) [destMeta.payeeName UTF8String]; 126 | txDetails.szCategory = (char *) [destMeta.category UTF8String]; 127 | txDetails.szNotes = (char *) [destMeta.notes UTF8String]; 128 | txDetails.amountCurrency = destMeta.amountFiat; 129 | txDetails.bizId = destMeta.bizId; 130 | } 131 | ABC_SpendAddTransfer(self.pSpend, [destWallet.uuid UTF8String], amountSatoshi, &txDetails, &error); 132 | return [ABCError makeNSError:error]; 133 | } 134 | 135 | - (ABCError *)addAddress:(NSString *)address amount:(uint64_t)amount; 136 | { 137 | tABC_Error error; 138 | if (!address) 139 | { 140 | error.code = ABC_CC_NULLPtr; 141 | return [ABCError makeNSError:error]; 142 | } 143 | 144 | ABC_SpendAddAddress(self.pSpend, [address UTF8String], amount, &error); 145 | return [ABCError makeNSError:error]; 146 | } 147 | 148 | - (ABCMetaData *)metaData 149 | { 150 | return _metaData; 151 | } 152 | 153 | - (void)setMetaData:(ABCMetaData *)metaData; 154 | { 155 | if (metaData) 156 | { 157 | _metaData = metaData; 158 | tABC_Error error; 159 | tABC_TxDetails details; 160 | 161 | details.amountCurrency = metaData.amountFiat; 162 | details.szName = (char *)[metaData.payeeName UTF8String]; 163 | details.szCategory = (char *)[metaData.category UTF8String]; 164 | details.szNotes = (char *)[metaData.notes UTF8String]; 165 | details.bizId = metaData.bizId; 166 | ABC_SpendSetMetadata(self.pSpend, &details, &error); 167 | } 168 | } 169 | 170 | - (uint64_t)getFees; 171 | { 172 | return [self getFees:nil]; 173 | } 174 | 175 | - (uint64_t)getFees:(ABCError **)nserror; 176 | { 177 | tABC_Error error; 178 | ABCError *lnserror = nil; 179 | 180 | uint64_t fee = 0; 181 | ABC_SpendGetFee(self.pSpend, &fee, &error); 182 | lnserror = [ABCError makeNSError:error]; 183 | if (nserror) *nserror = lnserror; 184 | 185 | return fee; 186 | } 187 | 188 | - (void)getFees:(void(^)(uint64_t fees))completionHandler 189 | error:(void(^)(ABCError *error)) errorHandler; 190 | { 191 | [self.wallet.account postToMiscQueue:^{ 192 | uint64_t fees; 193 | ABCError *error; 194 | 195 | fees = [self getFees:&error]; 196 | 197 | dispatch_async(dispatch_get_main_queue(),^{ 198 | if (!error) { 199 | if (completionHandler) completionHandler(fees); 200 | } else { 201 | if (errorHandler) errorHandler(error); 202 | } 203 | }); 204 | }]; 205 | 206 | } 207 | 208 | - (uint64_t)getMaxSpendable:(ABCError **)nserror; 209 | { 210 | tABC_Error error; 211 | ABCError *lnserror = nil; 212 | uint64_t max = 0; 213 | 214 | ABC_SpendGetMax(self.pSpend, &max, &error); 215 | lnserror = [ABCError makeNSError:error]; 216 | 217 | if (nserror) *nserror = lnserror; 218 | 219 | return max; 220 | } 221 | - (uint64_t)getMaxSpendable; 222 | { 223 | return [self getMaxSpendable:nil]; 224 | } 225 | 226 | - (void)getMaxSpendable:(void(^)(uint64_t amountSpendable))completionHandler 227 | error:(void(^)(ABCError *error)) errorHandler; 228 | { 229 | [self.wallet.account postToMiscQueue:^{ 230 | uint64_t max; 231 | ABCError *error; 232 | 233 | max = [self getMaxSpendable:&error]; 234 | 235 | dispatch_async(dispatch_get_main_queue(),^{ 236 | if (!error) { 237 | if (completionHandler) completionHandler(max); 238 | } else { 239 | if (errorHandler) errorHandler(error); 240 | } 241 | }); 242 | }]; 243 | 244 | } 245 | 246 | - (void) setFeeLevel:(ABCSpendFeeLevel)feeLevel; 247 | { 248 | tABC_Error error; 249 | 250 | _feeLevel = feeLevel; 251 | ABC_SpendSetFee(self.pSpend, (tABC_SpendFeeLevel) feeLevel, self.customFeeSatoshis, &error); 252 | } 253 | 254 | - (ABCSpendFeeLevel) feeLevel; 255 | { 256 | return _feeLevel; 257 | } 258 | 259 | - (ABCUnsentTx *)signTx:(ABCError **)nserror; 260 | { 261 | tABC_Error error; 262 | ABCError *lnserror = nil; 263 | char *pszRawTx = NULL; 264 | ABCUnsentTx *unsentTx = nil; 265 | 266 | ABC_SpendSignTx(self.pSpend, &pszRawTx, &error); 267 | lnserror = [ABCError makeNSError:error]; 268 | if (!lnserror) 269 | { 270 | unsentTx = [ABCUnsentTx alloc]; 271 | unsentTx.spend = self; 272 | unsentTx.base16 = [NSString stringWithUTF8String:pszRawTx]; 273 | } 274 | if (nserror) *nserror = lnserror; 275 | if (pszRawTx) free(pszRawTx); 276 | return unsentTx; 277 | } 278 | 279 | - (void)signTx:(void(^)(ABCUnsentTx *unsentTx))completionHandler 280 | error:(void(^)(ABCError *error)) errorHandler; 281 | { 282 | [self.wallet.account postToMiscQueue:^{ 283 | ABCError *error; 284 | 285 | ABCUnsentTx *unsentTx = [self signTx:&error]; 286 | 287 | dispatch_async(dispatch_get_main_queue(),^{ 288 | if (!error) { 289 | if (completionHandler) completionHandler(unsentTx); 290 | } else { 291 | if (errorHandler) errorHandler(error); 292 | } 293 | }); 294 | }]; 295 | 296 | } 297 | 298 | 299 | 300 | - (void)signBroadcastAndSave:(void(^)(ABCTransaction *transaction))completionHandler 301 | error:(void(^)(ABCError *error)) errorHandler; 302 | { 303 | [self.wallet.account postToMiscQueue:^{ 304 | ABCTransaction *transaction; 305 | ABCError *error; 306 | 307 | transaction = [self signBroadcastAndSave:&error]; 308 | 309 | dispatch_async(dispatch_get_main_queue(),^{ 310 | if (!error) { 311 | if (completionHandler) completionHandler(transaction); 312 | } else { 313 | if (errorHandler) errorHandler(error); 314 | } 315 | }); 316 | }]; 317 | } 318 | 319 | - (ABCTransaction *)signBroadcastAndSave:(ABCError **)nserror; 320 | { 321 | ABCError *lnserror = nil; 322 | ABCTransaction *transaction = nil; 323 | 324 | ABCUnsentTx *unsentTx = [self signTx:&lnserror]; 325 | if (!lnserror && unsentTx) 326 | { 327 | lnserror = [unsentTx broadcastTx]; 328 | if (!lnserror) 329 | { 330 | transaction = [unsentTx saveTx:&lnserror]; 331 | } 332 | } 333 | if (nserror) *nserror = lnserror; 334 | return transaction; 335 | } 336 | 337 | 338 | 339 | 340 | @end 341 | -------------------------------------------------------------------------------- /Classes/Private/ABCTransaction+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCTransaction+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCTransaction.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @interface ABCTransaction (Internal) 12 | 13 | - (id)initWithWallet:(ABCWallet *)wallet; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/Private/ABCTransaction.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCTransaction.m 3 | // AirBitz 4 | // 5 | // Created by Adam Harris on 3/3/14. 6 | // Copyright (c) 2014 AirBitz. All rights reserved. 7 | // 8 | 9 | #import "ABCTransaction.h" 10 | #import "ABCContext+Internal.h" 11 | 12 | @interface ABCTransaction () 13 | { 14 | long _height; 15 | } 16 | 17 | @end 18 | 19 | @implementation ABCTransaction 20 | 21 | #pragma mark - NSObject overrides 22 | 23 | - (id)initWithWallet:(ABCWallet *)wallet; 24 | { 25 | self = [super init]; 26 | if (self) 27 | { 28 | self.metaData = [ABCMetaData alloc]; 29 | self.txid = @""; 30 | self.date = [NSDate date]; 31 | self.inputOutputList = [[NSArray alloc] init]; 32 | self.metaData.payeeName = @""; 33 | self.metaData.category = @""; 34 | self.metaData.notes = @""; 35 | self.metaData.bizId = 0; 36 | self.wallet = wallet; 37 | } 38 | return self; 39 | } 40 | 41 | - (void)dealloc 42 | { 43 | 44 | } 45 | 46 | - (unsigned long)height; 47 | { 48 | if (_height == 0) 49 | { 50 | _height = [self.wallet getTxHeight:self.txid]; 51 | } 52 | return _height; 53 | } 54 | 55 | - (void)setHeight:(long)height; 56 | { 57 | _height = height; 58 | } 59 | 60 | - (void)saveTransactionDetails; 61 | { 62 | [self.wallet.account postToMiscQueue:^{ 63 | 64 | tABC_Error Error; 65 | tABC_TxDetails *pDetails; 66 | tABC_CC result = ABC_GetTransactionDetails([self.wallet.account.name UTF8String], 67 | [self.wallet.account.password UTF8String], 68 | [self.wallet.uuid UTF8String], 69 | [self.txid UTF8String], 70 | &pDetails, &Error); 71 | if (ABC_CC_Ok != result) { 72 | return; 73 | } 74 | 75 | pDetails->szName = (char *) [self.metaData.payeeName UTF8String]; 76 | pDetails->szCategory = (char *) [self.metaData.category UTF8String]; 77 | pDetails->szNotes = (char *) [self.metaData.notes UTF8String]; 78 | pDetails->amountCurrency = self.metaData.amountFiat; 79 | pDetails->bizId = self.metaData.bizId; 80 | 81 | result = ABC_SetTransactionDetails([self.wallet.account.name UTF8String], 82 | [self.wallet.account.password UTF8String], 83 | [self.wallet.uuid UTF8String], 84 | [self.txid UTF8String], 85 | pDetails, &Error); 86 | 87 | if (ABC_CC_Ok != result) { 88 | return; 89 | } 90 | 91 | [self.wallet.account refreshWallets]; 92 | return; 93 | }]; 94 | } 95 | 96 | 97 | 98 | // overriding the NSObject isEqual 99 | // allows us to call things like removeObject in array's of these 100 | - (BOOL)isEqual:(id)object 101 | { 102 | if ([object isKindOfClass:[ABCTransaction class]]) 103 | { 104 | ABCTransaction *transactionOther = object; 105 | 106 | if ([self.txid isEqualToString:transactionOther.txid]) 107 | { 108 | return YES; 109 | } 110 | } 111 | 112 | // if we got this far then they are not equal 113 | return NO; 114 | } 115 | 116 | // overriding the NSObject hash 117 | // since we are overriding isEqual, we have to override hash to make sure they agree 118 | - (NSUInteger)hash 119 | { 120 | return([self.txid hash]); 121 | } 122 | 123 | // overriding the description - used in debugging 124 | - (NSString *)description 125 | { 126 | return([NSString stringWithFormat:@"ABCTransaction - ID: %@, WalletUUID: %@, PayeeName: %@, Date: %@, AmountSatoshi: %lli, AmountFiat: %lf, Balance: %lli, Category: %@, Notes: %@", 127 | self.txid, 128 | self.wallet.uuid, 129 | self.metaData.payeeName, 130 | [self.date descriptionWithLocale:[NSLocale currentLocale]], 131 | self.amountSatoshi, 132 | self.metaData.amountFiat, 133 | self.balance, 134 | self.metaData.category, 135 | self.metaData.notes 136 | ]); 137 | } 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /Classes/Private/ABCTxInOut.m: -------------------------------------------------------------------------------- 1 | // 2 | // ABCTxInOut.m 3 | // AirBitz 4 | // 5 | // Created by Timbo on 6/17/14. 6 | // Copyright (c) 2014 AirBitz. All rights reserved. 7 | // 8 | 9 | #import "ABCTxInOut.h" 10 | #import "ABCContext+Internal.h" 11 | 12 | @interface ABCTxInOut () 13 | @end 14 | 15 | @implementation ABCTxInOut 16 | 17 | #pragma mark - NSObject overrides 18 | 19 | - (id)init 20 | { 21 | self = [super init]; 22 | if (self) 23 | { 24 | self.address = @""; 25 | self.isInput = false; 26 | self.amountSatoshi = 0; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)dealloc 32 | { 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/Private/ABCWallet+Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCWallet+Internal.h 3 | // 4 | // Created by Paul P on 2016/02/09. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCWallet.h" 9 | #import "ABCContext+Internal.h" 10 | 11 | @class ABCAccount; 12 | 13 | @interface ABCWallet (Internal) 14 | 15 | @property BOOL bBlockHeightChanged; 16 | 17 | - (id)initWithUser:(ABCAccount *) user; 18 | - (void)handleSweepCallback:(ABCTransaction *)transaction amount:(uint64_t)amount error:(ABCError *)error; 19 | - (void)loadTransactions; 20 | - (void)loadWalletFromCore:(NSString *)uuid; 21 | - (int)getBlockHeight:(ABCError **)nserror; 22 | - (int)getTxHeight:(NSString *)txid; 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Classes/Private/NSMutableData+Secure.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableData+Secure.h 3 | // Airbitz 4 | // 5 | // Created by Paul Puey on 2015-08-31. 6 | // Copyright (c) 2015 Airbitz. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | CF_IMPLICIT_BRIDGING_ENABLED 13 | CFAllocatorRef SecureAllocator(); 14 | CF_IMPLICIT_BRIDGING_DISABLED 15 | 16 | @interface NSMutableData (Secure) 17 | 18 | + (NSMutableData *)secureData; 19 | + (NSMutableData *)secureDataWithLength:(NSUInteger)length; 20 | + (NSMutableData *)secureDataWithCapacity:(NSUInteger)capacity; 21 | + (NSMutableData *)secureDataWithData:(NSData *)data; 22 | @end 23 | -------------------------------------------------------------------------------- /Classes/Private/NSMutableData+Secure.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableData+Secure.m 3 | // Airbitz 4 | // 5 | // Created by Paul Puey on 2015-08-31. 6 | // Copyright (c) 2015 Airbitz. All rights reserved. 7 | // 8 | 9 | 10 | #import "NSMutableData+Secure.h" 11 | 12 | static void *secureAllocate(CFIndex allocSize, CFOptionFlags hint, void *info) 13 | { 14 | void *ptr = malloc(sizeof(CFIndex) + allocSize); 15 | 16 | if (ptr) { 17 | *(CFIndex *)ptr = allocSize; 18 | return (CFIndex *)ptr + 1; 19 | } 20 | else return NULL; 21 | } 22 | 23 | static void secureDeallocate(void *ptr, void *info) 24 | { 25 | CFIndex size = *((CFIndex *)ptr - 1); 26 | 27 | if (size) { 28 | memset(ptr, 0, size); 29 | free((CFIndex *)ptr - 1); 30 | } 31 | } 32 | 33 | static void *secureReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) 34 | { 35 | void *newptr = secureAllocate(newsize, hint, info); 36 | CFIndex size = *((CFIndex *)ptr - 1); 37 | 38 | if (newptr && size) { 39 | memcpy(newptr, ptr, (size < newsize) ? size : newsize); 40 | secureDeallocate(ptr, info); 41 | } 42 | 43 | return newptr; 44 | } 45 | 46 | CFAllocatorRef SecureAllocator() 47 | { 48 | static CFAllocatorRef alloc = NULL; 49 | static dispatch_once_t onceToken = 0; 50 | 51 | dispatch_once(&onceToken, ^{ 52 | CFAllocatorContext context; 53 | 54 | context.version = 0; 55 | CFAllocatorGetContext(kCFAllocatorDefault, &context); 56 | context.allocate = secureAllocate; 57 | context.reallocate = secureReallocate; 58 | context.deallocate = secureDeallocate; 59 | 60 | alloc = CFAllocatorCreate(kCFAllocatorDefault, &context); 61 | }); 62 | 63 | return alloc; 64 | } 65 | 66 | @implementation NSMutableData (Secure) 67 | 68 | + (NSMutableData *)secureData 69 | { 70 | return [self secureDataWithCapacity:0]; 71 | } 72 | 73 | + (NSMutableData *)secureDataWithCapacity:(NSUInteger)aNumItems 74 | { 75 | return CFBridgingRelease(CFDataCreateMutable(SecureAllocator(), aNumItems)); 76 | } 77 | 78 | + (NSMutableData *)secureDataWithLength:(NSUInteger)length 79 | { 80 | NSMutableData *d = [self secureDataWithCapacity:length]; 81 | 82 | d.length = length; 83 | return d; 84 | } 85 | 86 | + (NSMutableData *)secureDataWithData:(NSData *)data 87 | { 88 | return CFBridgingRelease(CFDataCreateMutableCopy(SecureAllocator(), 0, (__bridge CFDataRef)data)); 89 | } 90 | @end 91 | -------------------------------------------------------------------------------- /Classes/Public/ABCCategories.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import "ABCContext.h" 7 | 8 | @class ABCError; 9 | 10 | @interface ABCCategories : NSObject 11 | 12 | @property (readonly, atomic, assign) NSArray *listCategories; 13 | 14 | - (ABCError *)addCategory:(NSString *)category; 15 | - (ABCError *)removeCategory:(NSString *)category; 16 | - (ABCError *)saveCategories:(NSArray *)arrayCategories; 17 | 18 | 19 | 20 | @end -------------------------------------------------------------------------------- /Classes/Public/ABCConditionCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCConditionCode.h 3 | // Airbitz 4 | // 5 | // This needs to get generated from ABC.h error codes 6 | 7 | typedef enum eABCConditionCode 8 | { 9 | /** The function completed without an error */ 10 | ABCConditionCodeOk = 0, 11 | /** An error occured */ 12 | ABCConditionCodeError = 1, 13 | /** Unexpected NULL pointer */ 14 | ABCConditionCodeNULLPtr = 2, 15 | /** Max number of accounts have been created */ 16 | ABCConditionCodeNoAvailAccountSpace = 3, 17 | /** Could not read directory */ 18 | ABCConditionCodeDirReadError = 4, 19 | /** Could not open file */ 20 | ABCConditionCodeFileOpenError = 5, 21 | /** Could not read from file */ 22 | ABCConditionCodeFileReadError = 6, 23 | /** Could not write to file */ 24 | ABCConditionCodeFileWriteError = 7, 25 | /** No such file */ 26 | ABCConditionCodeFileDoesNotExist = 8, 27 | /** Unknown crypto type */ 28 | ABCConditionCodeUnknownCryptoType = 9, 29 | /** Invalid crypto type */ 30 | ABCConditionCodeInvalidCryptoType = 10, 31 | /** Decryption error */ 32 | ABCConditionCodeDecryptError = 11, 33 | /** Decryption failure due to incorrect key */ 34 | ABCConditionCodeDecryptFailure = 12, 35 | /** Encryption error */ 36 | ABCConditionCodeEncryptError = 13, 37 | /** Scrypt error */ 38 | ABCConditionCodeScryptError = 14, 39 | /** Account already exists */ 40 | ABCConditionCodeAccountAlreadyExists = 15, 41 | /** Account does not exist */ 42 | ABCConditionCodeAccountDoesNotExist = 16, 43 | /** JSON parsing error */ 44 | ABCConditionCodeJSONError = 17, 45 | /** Incorrect password */ 46 | ABCConditionCodeBadPassword = 18, 47 | /** Wallet already exists */ 48 | ABCConditionCodeWalletAlreadyExists = 19, 49 | /** URL call failure */ 50 | ABCConditionCodeURLError = 20, 51 | /** An call to an external API failed */ 52 | ABCConditionCodeSysError = 21, 53 | /** No required initialization made */ 54 | ABCConditionCodeNotInitialized = 22, 55 | /** Initialization after already initializing */ 56 | ABCConditionCodeReinitialization = 23, 57 | /** Server error */ 58 | ABCConditionCodeServerError = 24, 59 | /** The user has not set recovery questions */ 60 | ABCConditionCodeNoRecoveryQuestions = 25, 61 | /** Functionality not supported */ 62 | ABCConditionCodeNotSupported = 26, 63 | /** Mutex error if some type */ 64 | ABCConditionCodeMutexError = 27, 65 | /** Transaction not found */ 66 | ABCConditionCodeNoTransaction = 28, 67 | ABCConditionCodeEmpty_Wallet = 28, /* Deprecated */ 68 | /** Failed to parse input text */ 69 | ABCConditionCodeParseError = 29, 70 | /** Invalid wallet ID */ 71 | ABCConditionCodeInvalidWalletID = 30, 72 | /** Request (address) not found */ 73 | ABCConditionCodeNoRequest = 31, 74 | /** Not enough money to send transaction */ 75 | ABCConditionCodeInsufficientFunds = 32, 76 | /** We are still sync-ing */ 77 | ABCConditionCodeSynchronizing = 33, 78 | /** Problem with the PIN */ 79 | ABCConditionCodeNonNumericPin = 34, 80 | /** Unable to find an address */ 81 | ABCConditionCodeNoAvailableAddress = 35, 82 | /** The user has entered a bad PIN, and must wait. */ 83 | ABCConditionCodeInvalidPinWait = 36, ABCConditionCodePinExpired = 36, 84 | /** Two Factor required */ 85 | ABCConditionCodeInvalidOTP = 37, 86 | /** Trying to send too little money. */ 87 | ABCConditionCodeSpendDust = 38, 88 | /** The server says app is obsolete and needs to be upgraded. */ 89 | ABCConditionCodeObsolete = 1000 90 | } ABCConditionCode; 91 | -------------------------------------------------------------------------------- /Classes/Public/ABCCurrency.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCCurrency.h 3 | // 4 | // Created by Paul P on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext.h" 9 | 10 | @interface ABCCurrency : NSObject 11 | @property (nonatomic) int currencyNum; 12 | @property (nonatomic, strong) NSString *textDescription; 13 | @property (nonatomic, strong) NSString *code; 14 | @property (nonatomic, strong) NSString *symbol; 15 | 16 | + (ABCCurrency *) noCurrency; 17 | + (ABCCurrency *) defaultCurrency; 18 | 19 | + (NSString *) getCurrencyCodeOfLocale; 20 | + (NSArray *) listCurrencies; 21 | + (NSArray *) listCurrencyCodes; 22 | + (NSArray *) listCurrencyStrings; 23 | 24 | + (NSNumberFormatter *)generateNumberFormatter; 25 | - (NSString *)doubleToPrettyCurrencyString:(double) fCurrency; 26 | - (NSString *)doubleToPrettyCurrencyString:(double) fCurrency withSymbol:(bool)symbol; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Classes/Public/ABCDataStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCDataStore.h 3 | // 4 | // Created by Paul P on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext.h" 9 | 10 | /** 11 | * The ABCDataStore object implements the Airbitz auto-encrypted, auto-backed up, and auto 12 | * synchronized Edge Security data storage. ABCDataStore is end-to-end encrypted with no access to the 13 | * data by Airbitz, other users, or developers. Data is encrypted
14 | *
15 | * Data is saved as key/value pairs in named folders. Usage is as simple as calling 16 | * dataWrite to write data to this ABCDataStore using a unique folderID. Then calling 17 | * dataRead to read back the data.
18 | *
19 | * Note: Data written using the same folderID and same key may generate conflicts when multiple devices 20 | * write to the same DataStore. In such a case, automatic 21 | * conflict resolution will chose the most likely newer update to the data. Writing 22 | * to different folderIDs or keys will not cause conflicts.
23 | *
24 | * ABCDataStore will automatically 25 | * backup all data and synchronize between all user's devices as long as the devices are 26 | * online. If devices are offline, the data will sync as soon as the device comes back online 27 | */ 28 | 29 | @interface ABCDataStore : NSObject 30 | 31 | /** 32 | * Writes a key value pair into the data store. 33 | * @param folder NSString* folder name to write data 34 | * @param key NSString* key of data 35 | * @param value NSString* value of data to write 36 | * @return NSError* Error object. Nil if success 37 | */ 38 | - (ABCError *)dataWrite:(NSString *)folder withKey:(NSString *)key withValue:(NSString *)value; 39 | 40 | /** 41 | * Reads a key value pair from the data store. 42 | * @param folder NSString* folder name to read data 43 | * @param key NSString* key of data 44 | * @param data Initialized & allocated NSMutableString* to receive data 45 | * @return NSError* Error object. Nil if success 46 | */ 47 | - (ABCError *)dataRead:(NSString *)folder withKey:(NSString *)key data:(NSMutableString *)data; 48 | 49 | /** 50 | * Removes key value pair from the data store. 51 | * @param folder NSString* folder name to read data 52 | * @param key NSString* key of data 53 | * @return NSError* Error object. Nil if success 54 | */ 55 | - (ABCError *)dataRemoveKey:(NSString *)folder withKey:(NSString *)key; 56 | 57 | /** 58 | * Lists all the keys in a folder of the dataStore. 59 | * @param folder NSString* folder name to read data 60 | * @param keys NSMutableArray* Array of NSString keys 61 | * @return NSError* Error object. Nil if success 62 | */ 63 | - (ABCError *)dataListKeys:(NSString *)folder keys:(NSMutableArray *)keys; 64 | 65 | /** 66 | * Removes all key value pairs from the specified folder in the data store. 67 | * @param folder NSString* folder name to read data 68 | * @return NSError* Error object. Nil if success 69 | */ 70 | - (ABCError *)dataRemoveFolder:(NSString *)folder; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Classes/Public/ABCDenomination.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import "ABCContext.h" 7 | 8 | typedef NS_ENUM(NSUInteger, ABCDenominationMultiplier) { 9 | ABCDenominationMultiplierBTC = 100000000, 10 | ABCDenominationMultiplierMBTC = 100000, 11 | ABCDenominationMultiplierUBTC = 100, 12 | }; 13 | 14 | /** 15 | * ABCDenomination represents a specific bitcoin denomination such as BTC, mBTC, or bits (uBTC). 16 | * The class also includes several utility methods to convert to/from 64 bit satoshi amounts and 17 | * user viewable strings in the current denomination. 18 | */ 19 | @interface ABCDenomination : NSObject 20 | 21 | /// Index of this denomination in the list of denominations.
22 | /// 0 = BTC, 1 = mBTC, 2 = bits 23 | @property (nonatomic) int index; 24 | 25 | /// Number of satoshis to equal one unit of this denomination
26 | /// ie. 1 BTC -> multiplier = 100,000,000
27 | /// 1 mBTC -> multipliers = 100,000 28 | @property (nonatomic) int multiplier; 29 | 30 | /// Denomination symbol such as "Ƀ" 31 | @property (nonatomic) NSString *symbol; 32 | 33 | /// Denomination label such as "BTC" or "bits" 34 | @property (nonatomic) NSString *label; 35 | 36 | 37 | /** 38 | * Returns the maximum number of decimal places represented by this denomination 39 | * @return int Maximum decimal places. BTC=8, mBTC=5, bits=2 40 | */ 41 | - (int) maxBitcoinDecimalPlaces; 42 | 43 | /** 44 | * Returns the 'pretty' number of decimal places represented by this denomination. 45 | * Due to the large number of subunits of bitcoin, several decimal places represent 46 | * units of value considered to be uninteresting to users. This returns the number of 47 | * decimal places to represent no less than .001 USD. 48 | * @return int Maximum decimal places 49 | */ 50 | - (int) prettyBitcoinDecimalPlaces; 51 | 52 | /** 53 | * Convert a 64 bit satoshi value to a string using the current denomination. Routine will automatically 54 | * apply the correct conversion to BTC/mBTC/bits based on this objects denomination 55 | * @param satoshi int64_t Signed satoshi amount to convert 56 | * @param symbol (optional) bool YES if routine should add a denomination symbol such as "Ƀ" before the amount 57 | * @param cropDecimals (optional) bool YES if routine should only show the number of decimal places specified by 58 | * prettyBitcoinDecimalPlaces 59 | * @return NSString String representation of bitcoin amount 60 | */ 61 | - (NSString *)satoshiToBTCString:(int64_t) satoshi withSymbol:(bool) symbol cropDecimals:(bool) cropDecimals; 62 | - (NSString *)satoshiToBTCString:(int64_t) satoshi withSymbol:(bool) symbol; 63 | - (NSString *)satoshiToBTCString:(int64_t) satoshi; 64 | 65 | /** 66 | * Parse an NSString to satoshi amount. Factors in the current denomination in the conversion. 67 | * @param amount NSString String value to parse 68 | * @return int64_t Signed 64 bit satoshi amount 69 | */ 70 | - (int64_t) btcStringToSatoshi:(NSString *) amount; 71 | 72 | /** 73 | * Returns an ABCDenomination object for the given multipier enum 74 | * @param multiplier ABCDenominationMultiplier enum 75 | * @return ABCDenomination Corresponding ABCDenomination for the multiplier 76 | */ 77 | + (ABCDenomination *) getDenominationForMultiplier:(ABCDenominationMultiplier)multiplier; 78 | 79 | /** 80 | * Returns an ABCDenomination object for the given index into the enum list. 81 | * @param index int 82 | * @return ABCDenomination Corresponding ABCDenomination for the index
83 | * 0 -> ABCDenominationMultiplierBTC 84 | * 1 -> ABCDenominationMultiplierMBTC 85 | * 2 -> ABCDenominationMultiplierUBTC 86 | */ 87 | + (ABCDenomination *) getDenominationForIndex:(int)index; 88 | 89 | /** 90 | * Returns the current decimal symbol for the device locale settings 91 | * @param void 92 | * @return NSString decimal symbol 93 | */ 94 | + (NSString *) getDecimalSymbol; 95 | 96 | 97 | 98 | 99 | @end -------------------------------------------------------------------------------- /Classes/Public/ABCError.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import 7 | #import "ABCContext.h" 8 | 9 | @interface ABCError : NSError 10 | 11 | @property NSInteger code; 12 | @property (nonatomic, strong) NSDictionary *userInfo; 13 | @property (nonatomic, strong) NSDate *otpResetDate; 14 | @property (nonatomic, strong) NSString *otpResetToken; 15 | 16 | +(ABCError *) errorWithDomain:(NSInteger) code 17 | userInfo:(NSDictionary *)userInfo; 18 | @end -------------------------------------------------------------------------------- /Classes/Public/ABCExchangeCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCExchangeCache.h 3 | // 4 | // Created by Paul Puey on 2016/02/27 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext.h" 9 | 10 | @class ABCContext; 11 | @class ABCSpend; 12 | @class ABCSettings; 13 | @class ABCReceiveAddress; 14 | @class ABCTransaction; 15 | 16 | #define ABCArrayExchanges @[@"Bitstamp", @"Bitfinex", @"BitcoinAverage", @"BraveNewCoin", @"Coinbase"] 17 | 18 | /** 19 | * ABCExchangeCache provides conversion routines to convert from any fiat currency 20 | * to BTC in satoshis or vice version. This object uses the exchange rate source 21 | * set it ABCSettings. Exchange values are cached globally and shared between all 22 | * incoming requests. 23 | */ 24 | 25 | @interface ABCExchangeCache : NSObject 26 | 27 | /** 28 | * Convert bitcoin amount in satoshis to a fiat currency amount 29 | * @param satoshi uint_64t amount to convert in satoshis 30 | * @param currencyCode NSSTring* ISO currency code of fiat currency to convert to. 31 | * ie "USD, CAD, EUR" 32 | * @param error NSError** pointer to ABCError object 33 | * @return double resulting fiat currency value 34 | */ 35 | - (double) satoshiToCurrency:(uint64_t) satoshi 36 | currencyCode:(NSString *)currencyCode 37 | error:(ABCError **)error; 38 | 39 | /** 40 | * Convert fiat currency amount to a bitcoin amount in satoshis 41 | * @param currency (double) Amount in fiat value to convert 42 | * @param currencyCode NSString* ISO currency code of fiat currency to convert to. 43 | * ie "USD, CAD, EUR" 44 | * @param error NSError** pointer to ABCError object 45 | * @return uint_64t Resulting value in satoshis 46 | */ 47 | - (uint64_t) currencyToSatoshi:(double)currency 48 | currencyCode:(NSString *)currencyCode 49 | error:(ABCError **)error; 50 | 51 | 52 | @end 53 | 54 | 55 | -------------------------------------------------------------------------------- /Classes/Public/ABCKeychain.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCKeychain.h 3 | // Airbitz 4 | // 5 | // Created by Paul Puey on 2015-08-31. 6 | // Copyright (c) 2015 Airbitz. All rights reserved. 7 | // 8 | 9 | #import "ABCContext.h" 10 | 11 | @interface ABCKeychain : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Classes/Public/ABCMetadata.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCMetaData.h 3 | // 4 | // Created by Paul P on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext.h" 9 | 10 | @interface ABCMetaData : NSObject 11 | 12 | /// Payee name to specify in the request. This should be the name of the entity intended to 13 | /// pay the request. This is auto tagged to transaction meta data for all incoming 14 | /// transactions to the address from this request 15 | @property (nonatomic, copy) NSString *payeeName; 16 | 17 | /// The category to tag all transactions incoming to this request's address 18 | @property (nonatomic, copy) NSString *category; 19 | 20 | /// Misc notes to tag all transactions incoming to this request's address 21 | @property (nonatomic, copy) NSString *notes; 22 | 23 | /// An Airbitz Directory bizid to tag all transactions incoming to this request's address 24 | @property (nonatomic) unsigned int bizId; 25 | 26 | /// Amount of transaction in fiat (USD, EUR, CAD) value. 27 | @property (nonatomic) double amountFiat; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Classes/Public/ABCParsedURI.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCParsedURI.h 3 | // 4 | // Created by Paul P on 2016/02/27. 5 | // Copyright (c) 2016 Airbitz. All rights reserved. 6 | // 7 | 8 | #import "ABCContext.h" 9 | 10 | @class ABCPaymentRequest; 11 | 12 | @interface ABCParsedURI : NSObject 13 | 14 | @property NSString *address; 15 | @property NSString *privateKey; 16 | @property NSString *bitIDURI; 17 | @property NSString *bitIDDomain; 18 | @property NSString *bitIDCallbackURI; 19 | @property NSString *paymentRequestURL; 20 | @property uint64_t amountSatoshi; 21 | @property ABCMetaData *metadata; 22 | @property NSString *returnURI; 23 | @property BOOL bitidPaymentAddress; 24 | @property BOOL bitidKYCProvider; 25 | @property BOOL bitidKYCRequest; 26 | 27 | - (ABCPaymentRequest *) getPaymentRequest:(ABCError **)error; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Classes/Public/ABCReceiveAddress.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #if TARGET_OS_IPHONE 7 | #import 8 | #endif 9 | #import "ABCContext.h" 10 | 11 | @class ABCContext; 12 | @class ABCAccount; 13 | @class ABCMetaData; 14 | @class ABCWallet; 15 | 16 | /** 17 | * ABCReceiveAddress is returned by ABCWallet routine createNewReceiveAddress and 18 | * getReceiveAddress. The properties amountSatoshi and metaData can be modified by 19 | * the caller.
20 | *
21 | * Subsequent reads of the properties uri, address, and qrCode will 22 | * automatically encompass the changes written to amountSatoshi and metaData. The 23 | * values written to metaData will be written to the ABCTransaction for funds received 24 | * on this address. 25 | */ 26 | @interface ABCReceiveAddress : NSObject 27 | 28 | ///-------------------------------------------------------------------- 29 | /// @name The following properties are passed into ABCReceiveAddress as details for the request 30 | ///-------------------------------------------------------------------- 31 | 32 | /// Amount of satoshis to request. Optional. Set to zero if not needed 33 | @property (nonatomic) int64_t amountSatoshi; 34 | 35 | /// Optional meta to add to this request. Once money is received into this request 36 | /// address, the transaction will be tagged with this metadata such as payeeName 37 | /// category, and notes 38 | @property (nonatomic, strong) ABCMetaData *metaData; 39 | 40 | /// ------------------------------------------------------ 41 | /// @name The following properties are returned by ABC 42 | /// ------------------------------------------------------ 43 | 44 | /// Full request URI ie. "bitcoin:12kjhg9834gkjh4tjr1jhgSADG4GASf?amount=.2123&label=Airbitz¬es=Hello" 45 | @property (nonatomic, copy) NSString *uri; 46 | 47 | /// Bitcoin public address for request 48 | @property (nonatomic, copy) NSString *address; 49 | 50 | #if TARGET_OS_IPHONE 51 | 52 | /// QRCode of request in UIImage format for iOS and NSImage format for OSX 53 | @property (nonatomic, copy) UIImage *qrCode; 54 | #else 55 | 56 | /// QRCode of request in NSImage format (OSX Only) 57 | @property (nonatomic, copy) NSImage *qrCode; 58 | #endif 59 | 60 | 61 | /// ------------------------------------------------------ 62 | /// @name Instance Methods 63 | /// ------------------------------------------------------ 64 | 65 | /** 66 | * Finalizes the request so the address cannot be used by future requests. Forces address 67 | * rotation so the next request gets a different address 68 | * @return NSError 69 | */ 70 | - (ABCError *)finalizeRequest; 71 | 72 | /** 73 | * Modify a request based on the values in the ABCReceiveAddress structure. Normally the 74 | * request would require that one of the parameters address, qrCode, or uri are readback 75 | * before the metaData is saved with the address in ABC. 76 | * @return NSError 77 | */ 78 | - (ABCError *)modifyRequestWithDetails; 79 | 80 | 81 | /** 82 | * Tell ABC to constantly query this address to help ensure timely detection of 83 | * funds on this address. Great to use when there is a QR code showing on screen. 84 | * @param enable BOOL Set to YES to prioritize this address. Set to NO to disable 85 | * priority 86 | */ 87 | - (void)prioritizeAddress:(BOOL)enable; 88 | 89 | 90 | @end 91 | 92 | -------------------------------------------------------------------------------- /Classes/Public/ABCSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import "ABCContext.h" 7 | 8 | @class ABCContext; 9 | @class ABCKeychain; 10 | @class ABCAccount; 11 | @class ABCDenomination; 12 | 13 | /** 14 | * ABCSettings represent settings for the associated ABCAccount. Like all other account info, 15 | * these settings are locally encrypted and synchronized between devices. 16 | * Must call [ABCSettings loadSettings] before reading and 17 | * [ABCSettings saveSettings] after writing 18 | */ 19 | 20 | @interface ABCSettings : NSObject 21 | 22 | /// How many seconds after the app is backgrounded before the user should be auto logged out 23 | @property (nonatomic) int secondsAutoLogout; 24 | 25 | /// Default currency code for new wallets and for the account total on Wallets screen 26 | @property (nonatomic) ABCCurrency *defaultCurrency; 27 | 28 | /// Current denomination for account (BTC, mBTC, or bits) 29 | @property (nonatomic, strong) ABCDenomination *denomination; 30 | 31 | /// Users first name (optional) 32 | @property (nonatomic, copy) NSString* firstName; 33 | 34 | /// Users last name (optional) 35 | @property (nonatomic, copy) NSString* lastName; 36 | 37 | /// Users nick name (optional) 38 | @property (nonatomic, copy) NSString* nickName; 39 | 40 | /// Users full name (read only) set by ABC as a combination of first, last, and nickname 41 | @property (nonatomic, copy) NSString* fullName; 42 | 43 | /// Preferred exchange rate source. Set to one of the values in ABCArrayExchanges 44 | @property (nonatomic, copy) NSString* exchangeRateSource; 45 | 46 | /// List of user override Bitcoin servers. Must be Electrum servers, one per line separated by '\n'. Must be of the format 47 | /// stratum://[servername]:[port] 48 | /// ie. stratum://electrum.mydomain.com:50001 49 | /// User may have multiple servers each seperated by a newline '\n' 50 | @property (nonatomic, copy) NSString* overrideBitcoinServerList; 51 | 52 | /// If YES, payment request QR Codes and URIs should have the user's firstName, lastName, and nickName on the request 53 | @property (nonatomic) bool bNameOnPayments; 54 | 55 | /// Require a PIN on spend. This is not enforced by ABC but a reference for the GUI to verify 56 | @property (nonatomic) bool bSpendRequirePin; 57 | 58 | /// Use the bitcoin server override list 59 | @property (nonatomic) bool bOverrideBitcoinServers; 60 | 61 | /// Require a PIN if spending greater than spendRequirePinSatoshis. This is not enforced by ABC but a reference for the GUI to verify 62 | @property (nonatomic) int64_t spendRequirePinSatoshis; 63 | 64 | /** 65 | * Loads all settings into ABCSettings from encrypted storage 66 | * @return NSSError object 67 | */ 68 | - (ABCError *)loadSettings; 69 | 70 | /** 71 | * Saves all settings from ABCSettings to encrypted storage 72 | * @return NSSError object 73 | */ 74 | - (ABCError *)saveSettings; 75 | 76 | /** 77 | * Returns YES if touchID is allowed on this account and device 78 | * @return YES if allowed 79 | */ 80 | - (BOOL) touchIDEnabled; 81 | 82 | /** 83 | * Enable touchID on this account and device. This may require the optional 84 | * password parameter if this account was logged into with out a password (ie. with PIN) 85 | * @param password (optional) 86 | * @return YES if successfully enabled 87 | */ 88 | - (BOOL) enableTouchID:(NSString *)password; 89 | - (BOOL) enableTouchID; 90 | 91 | /** 92 | * Disables TouchID for this account & device 93 | */ 94 | - (void) disableTouchID; 95 | @end 96 | 97 | -------------------------------------------------------------------------------- /Classes/Public/ABCSpend.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCSpend.h 3 | // AirBitz 4 | // 5 | 6 | #import "ABCContext.h" 7 | 8 | @class ABCWallet; 9 | @class ABCPaymentRequest; 10 | @class ABCUnsentTx; 11 | 12 | /** 13 | * ABCSpend is used to build a Spend from the ABCWallet that generated this ABCSpend object. 14 | * Caller can add multiple spend targets by calling either of addAddress, addTransfer, or 15 | * addPaymentRequest repeated times. Use signBroadcastAndSave to send the transaction to the 16 | * blockchain. This spend may also be signed without broadcast by calling signTx. 17 | */ 18 | 19 | typedef enum eABCSpendFeeLevel 20 | { 21 | ABCSpendFeeLevelLow = 0, 22 | ABCSpendFeeLevelStandard, 23 | ABCSpendFeeLevelHigh, 24 | ABCSpendFeeLevelCustom, 25 | } ABCSpendFeeLevel; 26 | 27 | @interface ABCSpend : NSObject 28 | 29 | @property ABCMetaData *metaData; 30 | @property ABCSpendFeeLevel feeLevel; 31 | @property uint64_t customFeeSatoshis; 32 | 33 | /** 34 | * Adds an address and amount to this spend request 35 | * @param address NSString Bitcoin public address to send funds to 36 | * @param amount uint64_t Amount of bitcoin to send in satoshis 37 | * @return NSError 38 | */ 39 | - (ABCError *)addAddress:(NSString *)address amount:(uint64_t)amount; 40 | 41 | /** 42 | * Adds a transfer of funds between ABCWallets in an account. The source 43 | * wallet is the wallet that created this ABCSpend and once the transaction 44 | * is sent, the source wallet is tagged with the metaData from this ABCSpend object. 45 | * The destWallet is tagged with metadata supplied in detaMeta 46 | * @param destWallet ABCWallet Destination wallet for transfer 47 | * @param amountSatoshi uint64_t Amount of transfer 48 | * @param destMeta ABCMetaData Metadata to tag the destination transaction with 49 | * @return ABCError Error object. Nil if success 50 | */ 51 | - (ABCError *)addTransfer:(ABCWallet *)destWallet amount:(uint64_t)amountSatoshi destMeta:(ABCMetaData *)destMeta; 52 | 53 | /** 54 | * Adds a BIP70 payment request to this ABCSpend transaction. No amount parameter is 55 | * provided as the payment request always has the amount included. Generate an 56 | * ABCPaymentRequest object by calling parseURI then getPaymentRequest 57 | * @param paymentRequest ABCPaymentRequest object to add 58 | * @return ABCError Error object. Nil if success 59 | */ 60 | - (ABCError *)addPaymentRequest:(ABCPaymentRequest *)paymentRequest; 61 | 62 | /** 63 | * Signs this send request and broadcasts it to the blockchain 64 | * @param error ABCError object 65 | * @return ABCTransaction Transaction object 66 | */ 67 | - (ABCTransaction *)signBroadcastAndSave:(ABCError **)error; 68 | 69 | /** 70 | * Signs this send request and broadcasts it to the blockchain. Uses completion handlers 71 | * @param completionHandler Completion handler code block
72 | * - *param* ABCTransaction Transaction object 73 | * @param errorHandler Error handler code block which is called with the following args
74 | * - *param* ABCError error object 75 | * @return void 76 | */ 77 | - (void)signBroadcastAndSave:(void(^)(ABCTransaction *))completionHandler 78 | error:(void(^)(ABCError *error)) errorHandler; 79 | 80 | 81 | /** 82 | * Calculate the amount of fees needed to send this transaction 83 | * @param error ABCError (optional) 84 | * @return uint64_t Total fees required for this transaction 85 | */ 86 | - (uint64_t)getFees:(ABCError **)error; 87 | - (uint64_t)getFees; 88 | 89 | /** 90 | * Calculate the amount of fees needed to send this transaction 91 | * @param completionHandler Completion handler code block which is called with uint64_t totalFees
92 | * - *param* uint64_t Amount of fees in satoshis 93 | * @param errorHandler Error handler code block which is called with the following args
94 | * - *param* ABCError error object 95 | */ 96 | - (void)getFees:(void(^)(uint64_t fees))completionHandler 97 | error:(void(^)(ABCError *error)) errorHandler; 98 | 99 | /** 100 | * Get the maximum amount spendable from this wallet using the currenct ABCSpend object 101 | * @param error ABCError (optional) 102 | * @return uint64_t Maximum spendable from this wallet in satoshis 103 | */ 104 | - (uint64_t)getMaxSpendable:(ABCError **)error; 105 | - (uint64_t)getMaxSpendable; 106 | 107 | /** 108 | * Get the maximum amount spendable from this wallet using completion handlers 109 | * @param completionHandler Completion handler code block which is called with uint64_t totalFees
110 | * - *param* uint64_t amountSpendable Total amount spendablein satoshis 111 | * @param errorHandler Error handler code block which is called with the following args
112 | * - *param* ABCError error object 113 | */ 114 | - (void)getMaxSpendable:(void(^)(uint64_t amountSpendable))completionHandler 115 | error:(void(^)(ABCError *error)) errorHandler; 116 | 117 | 118 | - (ABCUnsentTx *)signTx:(ABCError **)error; 119 | - (void)signTx:(void(^)(ABCUnsentTx *unsentTx))completionHandler 120 | error:(void(^)(ABCError *error)) errorHandler; 121 | 122 | 123 | @end 124 | 125 | 126 | 127 | @interface ABCPaymentRequest : NSObject 128 | @property NSString *domain; 129 | @property uint64_t amountSatoshi; 130 | @property NSString *memo; 131 | @property NSString *merchant; 132 | @end 133 | 134 | @interface ABCUnsentTx : NSObject 135 | @property NSString *base16; 136 | 137 | - (ABCError *)broadcastTx; 138 | - (ABCTransaction *)saveTx:(ABCError **)error; 139 | @end 140 | 141 | 142 | -------------------------------------------------------------------------------- /Classes/Public/ABCStrings.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 2/1/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | #define abcStringLoadingText NSLocalizedString(@"Loading", @"Loading...") 9 | #define abcStringUsePasswordText NSLocalizedString(@"Use Password", @"Touch ID [Use Password] button") 10 | #define abcStringDefaultWalletName NSLocalizedString(@"My Wallet", @"Default wallet name for new accounts") 11 | #define abcStringTouchIDPromptText NSLocalizedString(@"Touch to login user", @"Touch ID prompt text") 12 | #define abcStringInvalidPINWaitSecondsText NSLocalizedString(@"Too many failed login attempts. Please try again in %d seconds.", nil) 13 | #define abcStringExpenseCategory @"Expense" // ,@"Income, Expense, Transfer, or Exchange categories") 14 | #define abcStringIncomeCategory @"Income" //, @"Income, Expense, Transfer, or Exchange categories") 15 | #define abcStringTransferCategory @"Transfer" //,@"Income, Expense, Transfer, or Exchange categories") 16 | #define abcStringExchangeCategory @"Exchange" //,@"Income, Expense, Transfer, or Exchange categories") 17 | -------------------------------------------------------------------------------- /Classes/Public/ABCTransaction.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCTransaction.h 3 | // AirBitz 4 | // 5 | // Created by Adam Harris on 3/3/14. 6 | // Copyright (c) 2014 AirBitz. All rights reserved. 7 | // 8 | 9 | #import "ABCContext.h" 10 | 11 | @class ABCWallet; 12 | @class ABCMetaData; 13 | 14 | @interface ABCTransaction : NSObject 15 | 16 | /// ABCWallet object this transaction is from 17 | @property (nonatomic, strong) ABCWallet *wallet; 18 | 19 | /// ABCMetaData associated with this transaction 20 | @property (nonatomic, strong) ABCMetaData *metaData; 21 | 22 | /// Txid of this transaction 23 | @property (nonatomic, copy) NSString *txid; 24 | 25 | /// Date this transaction was detected. Note that at this time, Airbitz has 26 | /// a pending issue where the date is marked as the date the transaction is 27 | /// detected by the wallet, not necessarily when it was broadcast or confirmed. 28 | /// If a wallet is not running, it will not properly detect a transaction and 29 | /// have the correct date stamp 30 | @property (nonatomic, strong) NSDate *date; 31 | 32 | /// Block height that this transaction confirmed. 0 if unconfirmed 33 | @property (nonatomic, assign) long height; 34 | 35 | /// Amount of this transaction in satoshis. Amount is negative for outgoing spends 36 | @property (nonatomic, assign) SInt64 amountSatoshi; 37 | 38 | /// Total amount of miner fees of this transaction 39 | @property (nonatomic, assign) SInt64 minerFees; 40 | 41 | /// Amount of provider fees of transaction. Provider fees are optional fees charged by 42 | /// the operator of wallet SDK. The Airbitz mobile app charges no provider fees 43 | @property (nonatomic, assign) SInt64 providerFee; 44 | 45 | /// This transaction has the Replace by Fee (RBF) flag set. User should be warned that 46 | /// this transaction can be easily double spent 47 | @property (nonatomic, assign) BOOL isReplaceByFee; 48 | 49 | /// This transaction has been detected to have a double spend attempt on its inputs 50 | @property (nonatomic, assign) BOOL isDoubleSpend; 51 | 52 | /// The current running balance of the wallet as of this transaction 53 | @property (nonatomic, assign) SInt64 balance; 54 | 55 | /// Array of ABCTxInOut objects 56 | @property (nonatomic, strong) NSArray *inputOutputList; 57 | 58 | 59 | 60 | - (void)saveTransactionDetails; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Classes/Public/ABCTxInOut.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCTxInOut.h 3 | // AirBitz 4 | // 5 | // Created by Timbo on 6/17/14. 6 | // Copyright (c) 2014 AirBitz. All rights reserved. 7 | // 8 | 9 | #import "ABCContext.h" 10 | 11 | @interface ABCTxInOut : NSObject 12 | 13 | @property (nonatomic, strong) NSString *address; 14 | @property (nonatomic) SInt64 amountSatoshi; 15 | @property (nonatomic) BOOL isInput; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Classes/Public/ABCUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Paul P on 1/30/16. 3 | // Copyright (c) 2016 Airbitz. All rights reserved. 4 | // 5 | 6 | #import 7 | #import "ABCParsedURI.h" 8 | 9 | #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) 10 | #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) 11 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 12 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 13 | #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) 14 | 15 | #define IS_IPHONE4 (([[UIScreen mainScreen] bounds].size.height < 568) ? YES : NO) 16 | #define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height > 567 && [[UIScreen mainScreen] bounds].size.height < 569) ? YES : NO) 17 | #define IS_IPHONE6 (([[UIScreen mainScreen] bounds].size.height > 666 && [[UIScreen mainScreen] bounds].size.height < 668) ? YES : NO) 18 | #define IS_IPHONE6_PLUS (([[UIScreen mainScreen] bounds].size.height > 735 && [[UIScreen mainScreen] bounds].size.height < 737) ? YES : NO) 19 | #define IS_IPAD_MINI (([[UIScreen mainScreen] bounds].size.height > 737) ? YES : NO) 20 | 21 | #define IS_MIN_IPHONE5 ([[UIScreen mainScreen] bounds].size.height >= 568) 22 | #define IS_MIN_IPHONE6 ([[UIScreen mainScreen] bounds].size.height >= 667) 23 | #define IS_MIN_IPHONE6_PLUS ([[UIScreen mainScreen] bounds].size.height >= 736) 24 | #define IS_MIN_IPAD_MINI ([[UIScreen mainScreen] bounds].size.height > 737) 25 | 26 | @class UIImage; 27 | 28 | @interface ABCUtil : NSObject 29 | 30 | /** 31 | * Encodes a string into a QR code returned as UIImage * 32 | * @param string NSString* string to encode 33 | * @param error NSError** May be set to nil 34 | * @return UIImage* returned image 35 | */ 36 | + (UIImage *)encodeStringToQRImage:(NSString *)string error:(ABCError **)error; 37 | 38 | 39 | /** 40 | * Parses a bitcoin BIP21 URI, Wif private key, or Airbitz hbits private key 41 | * @param uri NSString to parse 42 | * @param error ABCError Pointer to ABCError object. (Optional. May be set to nil) 43 | * @return ABCParsedURI ABCParsedURI Object with various parameters parsed out 44 | */ 45 | + (ABCParsedURI *)parseURI:(NSString *)uri error:(ABCError **)error; 46 | 47 | /** 48 | * Encodes a BIP21 compatible payment request URI using various paramters 49 | * @param address NSString Bitcoin public address 50 | * @param amount uint64_t Amount of request in satoshis 51 | * @param label NSString Name of requestor 52 | * @param message NSString Misc notes of transaction request 53 | * @param category NSString Airbitz formatted category in the form "[Category]:[Subcategory]"
54 | * ie.
55 | * Income:Salary
56 | * Expense:Rent
57 | * Transfer:Airbitz Wallet
58 | * Exchange:Buy Bitcoin
59 | * @param ret NSString Return URI to send user to after payment is made 60 | * @return NSString Complete BIP21 URI 61 | */ 62 | + (NSString *)encodeURI:(NSString *)address 63 | amount:(uint64_t)amount 64 | label:(NSString *)label 65 | message:(NSString *)message 66 | category:(NSString *)category 67 | ret:(NSString *)ret; 68 | 69 | 70 | + (NSString *)platform; 71 | + (NSString *)platformString; 72 | 73 | 74 | + (NSString *)safeStringWithUTF8String:(const char *)bytes; 75 | + (void)replaceString:(char **)ppszValue withString:(const char *)szNewValue; 76 | + (void)freeStringArray:(char **)aszStrings count:(unsigned int)count; 77 | 78 | #if TARGET_OS_IPHONE 79 | + (UIImage *)dataToImage:(const unsigned char *)data withWidth:(int)width andHeight:(int)height; 80 | #else 81 | + (NSImage *)dataToImage:(const unsigned char *)data withWidth:(int)width andHeight:(int)height; 82 | #endif 83 | @end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Airbitz Inc 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms are permitted provided that 5 | the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 3. Redistribution or use of modified source code requires the express written 13 | permission of Airbitz Inc. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | The views and conclusions contained in the software and documentation are those 27 | of the authors and should not be interpreted as representing official policies, 28 | either expressed or implied, of the Airbitz Project. 29 | 30 | 31 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '8.0' 3 | # Uncomment this line if you're using Swift 4 | # use_frameworks! 5 | 6 | target 'AirbitzCore' do 7 | 8 | end 9 | 10 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | COCOAPODS: 0.39.0 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # airbitz-core-objc 2 | 3 | This repository contains the ObjC bindings to the [airbitz-core][core] library. 4 | 5 | ## Setup using CocoaPods (no need to clone this repo) 6 | 7 | In your xcode project, edit your Podfile and add 8 | 9 | target "nameOfYourProjectHere" do 10 | pod 'AirbitzCore', :http => "https://developer.airbitz.co/download/airbitz-core-objc-newest.tgz" 11 | end 12 | 13 | Of course you'll need to replace "nameOfYourProjectHere" with your actual Xcode project name. 14 | 15 | Close the XCode project and then rerun 16 | 17 | pod install 18 | 19 | from the directory with your Podfile. 20 | 21 | Reopen the nameOfYourProjectHere.xcworkspace file from Xcode (not the xcproject file). 22 | 23 | If you are using React Native, you'll likely get a link error that you are missing some libraries. This is because React Native will overwrite linker flags set by Cocoapods. To fix, go to the project target Build Settings -> Other Linker Flags. Add "$(inherited)" to the linker flags. 24 | 25 | And you're done. You should be able to call into AirbitzCore. See documentation below for code samples. 26 | 27 | ## Using with React Native 28 | 29 | Follow the above for installing the CocoaPod into the iOS project of your React Native app but use this line in your `Podfile`. 30 | 31 | target "nameOfYourProjectHere" do 32 | pod 'AirbitzCore', :http => "https://developer.airbitz.co/download/airbitz-core-objc-newest.tgz" 33 | end 34 | 35 | 36 | Clone this repo locally to your computer at the same level as your app repo. 37 | 38 | Open the iOS project workspace of your app. Drag the files 39 | 40 | ReactBridge/ABCReact.c 41 | ReactBridge/ABCReact.h 42 | 43 | and drop them into your React iOS "Libraries" folder in the XCode project. 44 | 45 | Create a softlink from the airbitz-core-objc/ReactBridge/abc-react.js file to your React app project main directory. If your project repo is at the same level as airbitz-core-objc, ie. 46 | 47 | .../airbitz-core-obj/ 48 | .../your-app-repo/YourReactApp/ 49 | 50 | Then run the following from the ```YourReactApp``` directory 51 | 52 | ln -s ../../airbitz-core-objc/ReactBridge/abc-react.js abc-react.js 53 | 54 | Sample javascript code for using AirbitzCore from ReactNative can be seen in the following repo 55 | 56 | https://github.com/Airbitz/airbitz-react-test 57 | 58 | See the file ```abc-react-test.js``` 59 | 60 | ## Documentation 61 | 62 | https://developer.airbitz.co/objc/ 63 | 64 | 65 | ## Building 66 | 67 | If you'd like to build the SDK and natively include all the code in your build 68 | 69 | First have [airbitz-core][core] cloned locally at the same level as this repository. 70 | 71 | The build process requires several pieces of software to be installed on the 72 | host system: 73 | 74 | * autoconf 75 | * automake 76 | * cmake 77 | * git 78 | * libtool 79 | * pkgconfig 80 | * protobuf 81 | 82 | To install these on the Mac, please use [Homebrew](http://brew.sh/): 83 | 84 | brew install autoconf automake cmake git libtool pkgconfig protobuf 85 | 86 | The 'wget' and 'cmake' that come from MacPorts are known to be broken. 87 | If you are building for iOS or Mac native, you also need a working installation 88 | of the XCode command-line tools. 89 | 90 | Then run from the airbitz-core-objc repo: 91 | 92 | ./mkabc 93 | 94 | Create or use an Xcode project that is at the same level as this repository. 95 | From your Xcode project edit your Podfile and include the following 96 | 97 | pod 'AirbitzCore', :path => '../airbitz-core-objc/' 98 | 99 | [core]: https://github.com/airbitz/airbitz-core 100 | -------------------------------------------------------------------------------- /ReactBridge/ABCReact.h: -------------------------------------------------------------------------------- 1 | // 2 | // ABCSpend.h 3 | // AirBitz 4 | // 5 | 6 | #import "ABCContext.h" 7 | 8 | @interface AirbitzCoreRCT : NSObject 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /Resources/api.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/Resources/api.cer -------------------------------------------------------------------------------- /help/html/Classes/ABCBitIDSignature.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCBitIDSignature Class Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 77 | 78 |
79 |
80 |
81 |
82 |

ABCBitIDSignature Class Reference

83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Inherits fromNSObject
Declared inABCAccount.h
94 | 95 | 96 | 97 | 98 |
99 | 100 |

Overview

101 |

ABCBitIDSignature is the result of a signed BitID request.

102 |
103 | 104 | 105 | 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 | 114 | 115 |
116 |
117 | 118 |

  address 119 |

120 | 121 |
122 |
123 | 124 |
125 | 126 | 127 |
128 |

Public address used to sign the request

129 |
130 | 131 | 132 | 133 |
@property (nonatomic, strong) NSString *address
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
144 |

Discussion

145 |

Public address used to sign the request

146 |
147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
155 |

Declared In

156 |

ABCAccount.h

157 |
158 | 159 | 160 |
161 |
162 |
163 | 164 |

  signature 165 |

166 | 167 |
168 |
169 | 170 |
171 | 172 | 173 |
174 |

Resulting signature of the request

175 |
176 | 177 | 178 | 179 |
@property (nonatomic, strong) NSString *signature
180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 |
190 |

Discussion

191 |

Resulting signature of the request

192 |
193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 |
201 |

Declared In

202 |

ABCAccount.h

203 |
204 | 205 | 206 |
207 |
208 |
209 |
210 | 211 |
212 | 213 | 214 | 215 | 216 | 217 | 218 |
219 | 220 |
221 | 229 |
230 |
231 |
232 |
233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /help/html/Classes/ABCExchangeCache.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCExchangeCache Class Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 77 | 78 |
79 |
80 |
81 |
82 |

ABCExchangeCache Class Reference

83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Inherits fromNSObject
Declared inABCExchangeCache.h
94 | 95 | 96 | 97 | 98 |
99 | 100 |

Overview

101 |

ABCExchangeCache provides conversion routines to convert from any fiat currency 102 | to BTC in satoshis or vice version. This object uses the exchange rate source 103 | set it ABCSettings. Exchange values are cached globally and shared between all 104 | incoming requests.

105 |
106 | 107 | 108 | 109 | 110 | 111 |
112 | 113 | 114 | 115 | 116 | 117 | 118 |
119 |
120 | 121 |

– satoshiToCurrency:currencyCode:error: 122 |

123 | 124 |
125 |
126 | 127 |
128 | 129 | 130 |
131 |

Convert bitcoin amount in satoshis to a fiat currency amount

132 |
133 | 134 | 135 | 136 |
- (double)satoshiToCurrency:(uint64_t)satoshi currencyCode:(NSString *)currencyCode error:(NSError **)error
137 | 138 | 139 | 140 |
141 |

Parameters

142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 |
satoshi

uint_64t amount to convert in satoshis

currencyCode

NSSTring* ISO currency code of fiat currency to convert to. 152 | ie “USD, CAD, EUR”

error

NSError** pointer to NSError object

161 |
162 | 163 | 164 | 165 |
166 |

Return Value

167 |

double resulting fiat currency value

168 |
169 | 170 | 171 | 172 | 173 | 174 |
175 |

Discussion

176 |

Convert bitcoin amount in satoshis to a fiat currency amount

177 |
178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 |
186 |

Declared In

187 |

ABCExchangeCache.h

188 |
189 | 190 | 191 |
192 |
193 |
194 | 195 |

– currencyToSatoshi:currencyCode:error: 196 |

197 | 198 |
199 |
200 | 201 |
202 | 203 | 204 |
205 |

Convert fiat currency amount to a bitcoin amount in satoshis

206 |
207 | 208 | 209 | 210 |
- (uint64_t)currencyToSatoshi:(double)currency currencyCode:(NSString *)currencyCode error:(NSError **)error
211 | 212 | 213 | 214 |
215 |

Parameters

216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |
currency

(double) Amount in fiat value to convert

currencyCode

NSString* ISO currency code of fiat currency to convert to. 226 | ie “USD, CAD, EUR”

error

NSError** pointer to NSError object

235 |
236 | 237 | 238 | 239 |
240 |

Return Value

241 |

uint_64t Resulting value in satoshis

242 |
243 | 244 | 245 | 246 | 247 | 248 |
249 |

Discussion

250 |

Convert fiat currency amount to a bitcoin amount in satoshis

251 |
252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 |
260 |

Declared In

261 |

ABCExchangeCache.h

262 |
263 | 264 | 265 |
266 |
267 |
268 |
269 | 270 |
271 | 272 | 273 | 274 | 275 | 276 | 277 |
278 | 279 |
280 | 288 |
289 |
290 |
291 |
292 | 293 | 294 | 295 | -------------------------------------------------------------------------------- /help/html/Classes/ABCMetaData.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCMetaData Class Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 81 | 82 |
83 |
84 |
85 |
86 |

ABCMetaData Class Reference

87 | 88 | 89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
Inherits fromNSObject
Declared inABCMetadata.h
98 | 99 | 100 | 101 | 102 | 103 | 104 |
105 | 106 | 107 | 108 | 109 | 110 | 111 |
112 |
113 | 114 |

  payeeName 115 |

116 | 117 |
118 |
119 | 120 |
121 | 122 | 123 |
124 |

Payee name to specify in the request. This should be the name of the entity intended to 125 | pay the request. This is auto tagged to transaction meta data for all incoming 126 | transactions to the address from this request

127 |
128 | 129 | 130 | 131 |
@property (nonatomic, copy) NSString *payeeName
132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 |
142 |

Discussion

143 |

Payee name to specify in the request. This should be the name of the entity intended to 144 | pay the request. This is auto tagged to transaction meta data for all incoming 145 | transactions to the address from this request

146 |
147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
155 |

Declared In

156 |

ABCMetadata.h

157 |
158 | 159 | 160 |
161 |
162 |
163 | 164 |

  category 165 |

166 | 167 |
168 |
169 | 170 |
171 | 172 | 173 |
174 |

The category to tag all transactions incoming to this request’s address

175 |
176 | 177 | 178 | 179 |
@property (nonatomic, copy) NSString *category
180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 |
190 |

Discussion

191 |

The category to tag all transactions incoming to this request’s address

192 |
193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 |
201 |

Declared In

202 |

ABCMetadata.h

203 |
204 | 205 | 206 |
207 |
208 |
209 | 210 |

  notes 211 |

212 | 213 |
214 |
215 | 216 |
217 | 218 | 219 |
220 |

Misc notes to tag all transactions incoming to this request’s address

221 |
222 | 223 | 224 | 225 |
@property (nonatomic, copy) NSString *notes
226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 |
236 |

Discussion

237 |

Misc notes to tag all transactions incoming to this request’s address

238 |
239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 |
247 |

Declared In

248 |

ABCMetadata.h

249 |
250 | 251 | 252 |
253 |
254 |
255 | 256 |

  bizId 257 |

258 | 259 |
260 |
261 | 262 |
263 | 264 | 265 |
266 |

An Airbitz Directory bizid to tag all transactions incoming to this request’s address

267 |
268 | 269 | 270 | 271 |
@property (nonatomic) unsigned int bizId
272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 |
282 |

Discussion

283 |

An Airbitz Directory bizid to tag all transactions incoming to this request’s address

284 |
285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 |
293 |

Declared In

294 |

ABCMetadata.h

295 |
296 | 297 | 298 |
299 |
300 |
301 | 302 |

  amountFiat 303 |

304 | 305 |
306 |
307 | 308 |
309 | 310 | 311 |
312 |

Amount of transaction in fiat (USD, EUR, CAD) value.

313 |
314 | 315 | 316 | 317 |
@property (nonatomic) double amountFiat
318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 |
328 |

Discussion

329 |

Amount of transaction in fiat (USD, EUR, CAD) value.

330 |
331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 |
339 |

Declared In

340 |

ABCMetadata.h

341 |
342 | 343 | 344 |
345 |
346 |
347 |
348 | 349 |
350 | 351 | 352 | 353 | 354 | 355 | 356 |
357 | 358 |
359 | 367 |
368 |
369 |
370 |
371 | 372 | 373 | 374 | -------------------------------------------------------------------------------- /help/html/Classes/ABCUtil.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCUtil Class Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 77 | 78 |
79 |
80 |
81 |
82 |

ABCUtil Class Reference

83 | 84 | 85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Inherits fromNSObject
Declared inABCUtil.h
94 | 95 | 96 | 97 | 98 | 99 | 100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 |
108 |
109 | 110 |

+ encodeStringToQRImage:error: 111 |

112 | 113 |
114 |
115 | 116 |
117 | 118 | 119 |
120 |

Encodes a string into a QR code returned as UIImage *

121 |
122 | 123 | 124 | 125 |
+ (UIImage *)encodeStringToQRImage:(NSString *)string error:(NSError **)error
126 | 127 | 128 | 129 |
130 |

Parameters

131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
string

NSString* string to encode

error

NSError** May be set to nil

144 |
145 | 146 | 147 | 148 |
149 |

Return Value

150 |

UIImage* returned image

151 |
152 | 153 | 154 | 155 | 156 | 157 |
158 |

Discussion

159 |

Encodes a string into a QR code returned as UIImage *

160 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
169 |

Declared In

170 |

ABCUtil.h

171 |
172 | 173 | 174 |
175 |
176 |
177 | 178 |

+ parseURI:error: 179 |

180 | 181 |
182 |
183 | 184 |
185 | 186 | 187 |
188 |

Parses a bitcoin BIP21 URI, Wif private key, or Airbitz hbits private key

189 |
190 | 191 | 192 | 193 |
+ (ABCParsedURI *)parseURI:(NSString *)uri error:(NSError **)error
194 | 195 | 196 | 197 |
198 |

Parameters

199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 |
uri

NSString to parse

error

NSError Pointer to NSError object. (Optional. May be set to nil)

212 |
213 | 214 | 215 | 216 |
217 |

Return Value

218 |

ABCParsedURI ABCParsedURI Object with various parameters parsed out

219 |
220 | 221 | 222 | 223 | 224 | 225 |
226 |

Discussion

227 |

Parses a bitcoin BIP21 URI, Wif private key, or Airbitz hbits private key

228 |
229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 |
237 |

Declared In

238 |

ABCUtil.h

239 |
240 | 241 | 242 |
243 |
244 |
245 | 246 |

+ encodeURI:amount:label:message:category:ret: 247 |

248 | 249 |
250 |
251 | 252 |
253 | 254 | 255 |
256 |

Encodes a BIP21 compatible payment request URI using various paramters

257 |
258 | 259 | 260 | 261 |
+ (NSString *)encodeURI:(NSString *)address amount:(uint64_t)amount label:(NSString *)label message:(NSString *)message category:(NSString *)category ret:(NSString *)ret
262 | 263 | 264 | 265 |
266 |

Parameters

267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 |
address

NSString Bitcoin public address

amount

uint64_t Amount of request in satoshis

label

NSString Name of requestor

message

NSString Misc notes of transaction request

category

NSString Airbitz formatted category in the form “[Category]: [Subcategory]”
292 | ie.
293 | Income:Salary
294 | Expense:Rent
295 | Transfer:Airbitz Wallet
296 | Exchange:Buy Bitcoin

ret

NSString Return URI to send user to after payment is made

305 |
306 | 307 | 308 | 309 |
310 |

Return Value

311 |

NSString Complete BIP21 URI

312 |
313 | 314 | 315 | 316 | 317 | 318 |
319 |

Discussion

320 |

Encodes a BIP21 compatible payment request URI using various paramters

321 |
322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 |
330 |

Declared In

331 |

ABCUtil.h

332 |
333 | 334 | 335 |
336 |
337 |
338 |
339 | 340 |
341 | 342 | 343 | 344 | 345 | 346 | 347 |
348 | 349 |
350 | 358 |
359 |
360 |
361 |
362 | 363 | 364 | 365 | -------------------------------------------------------------------------------- /help/html/Constants/ABCDenominationMultiplier.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCDenominationMultiplier Constants Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 57 | 58 |
59 |
60 |
61 |
62 |

ABCDenominationMultiplier Constants Reference

63 | 64 | 65 |
66 | 67 | 68 | 69 | 70 |
Declared inABCDenomination.h
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |

ABCDenominationMultiplier

79 | 80 |
81 | 82 | 83 |

Definition

84 | typedef NS_ENUM(NSUInteger, ABCDenominationMultiplier ) {
85 | 86 |    ABCDenominationMultiplierBTC = 100000000,
87 | 88 |    ABCDenominationMultiplierMBTC = 100000,
89 | 90 |    ABCDenominationMultiplierUBTC = 100,
91 | 92 | };
93 | 94 |
95 | 96 |
97 |

Constants

98 |
99 | 100 |
ABCDenominationMultiplierBTC
101 |
102 | 103 | 104 |

105 | Declared In ABCDenomination.h. 106 |

107 | 108 |
109 | 110 |
ABCDenominationMultiplierMBTC
111 |
112 | 113 | 114 |

115 | Declared In ABCDenomination.h. 116 |

117 | 118 |
119 | 120 |
ABCDenominationMultiplierUBTC
121 |
122 | 123 | 124 |

125 | Declared In ABCDenomination.h. 126 |

127 | 128 |
129 | 130 |
131 |
132 | 133 | 134 | 135 | 136 | 137 | 138 |
139 | 140 |
141 | 149 |
150 |
151 |
152 |
153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /help/html/Constants/ABCImportDataModel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABCImportDataModel Constants Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 57 | 58 |
59 |
60 |
61 |
62 |

ABCImportDataModel Constants Reference

63 | 64 | 65 |
66 | 67 | 68 | 69 | 70 |
Declared inABCWallet.h
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |

ABCImportDataModel

79 | 80 |
81 | 82 | 83 |

Definition

84 | typedef NS_ENUM(NSUInteger, ABCImportDataModel ) {
85 | 86 |    ABCImportWIF,
87 | 88 |    ABCImportHBitsURI,
89 | 90 | };
91 | 92 |
93 | 94 |
95 |

Constants

96 |
97 | 98 |
ABCImportWIF
99 |
100 | 101 | 102 |

103 | Declared In ABCWallet.h. 104 |

105 | 106 |
107 | 108 |
ABCImportHBitsURI
109 |
110 | 111 | 112 |

113 | Declared In ABCWallet.h. 114 |

115 | 116 |
117 | 118 |
119 |
120 | 121 | 122 | 123 | 124 | 125 | 126 |
127 | 128 |
129 | 137 |
138 |
139 |
140 |
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /help/html/css/scss/_index.scss: -------------------------------------------------------------------------------- 1 | .index-container { 2 | -webkit-flex-direction: column; 3 | flex-direction: column; 4 | 5 | @media (min-width: $desktop-min-width) { 6 | display: flex; 7 | -webkit-flex-direction: row; 8 | flex-direction: row; 9 | -webkit-flex-wrap: wrap; 10 | flex-wrap: wrap; 11 | } 12 | 13 | .index-column { 14 | -webkit-flex: 1 1 33%; 15 | flex: 1 1 33%; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /help/html/css/scss/_layout.scss: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | .clear { 6 | clear: both; 7 | } 8 | 9 | .clearfix { 10 | &:before, &:after { 11 | clear: both; 12 | display: table; 13 | content: ""; 14 | } 15 | } 16 | 17 | .xcode .hide-in-xcode { 18 | display: none; 19 | } 20 | 21 | body { 22 | font: 62.5% $body-font; 23 | background: $body-background; 24 | 25 | @media (max-width: $mobile-max-width) { 26 | background-color: $content-background; 27 | } 28 | } 29 | 30 | h1, h2, h3 { 31 | font-weight: 300; 32 | color: #808080; 33 | } 34 | 35 | h1 { 36 | font-size: 2em; 37 | color: #000; 38 | } 39 | 40 | h4 { 41 | font-size: 13px; 42 | line-height: 1.5; 43 | margin: 21px 0 0 0; 44 | } 45 | 46 | a { 47 | color: $tint-color; 48 | text-decoration: none; 49 | } 50 | 51 | pre, code { 52 | font-family: $code-font; 53 | word-wrap: break-word; 54 | } 55 | 56 | pre > code, .method-declaration code { 57 | display: inline-block; 58 | font-size: .85em; 59 | padding: 4px 0 4px 10px; 60 | border-left: 5px solid rgba(0, 155, 51, .2); 61 | 62 | &:before { 63 | content: "Objective-C"; 64 | display: block; 65 | 66 | font: 9px/1 $body-font; 67 | color: #009b33; 68 | text-transform: uppercase; 69 | letter-spacing: 2px; 70 | padding-bottom: 6px; 71 | } 72 | } 73 | 74 | pre > code { 75 | font-size: inherit; 76 | } 77 | 78 | table, th, td { 79 | border: 1px solid #e9e9e9; 80 | } 81 | 82 | table { 83 | width: 100%; 84 | } 85 | 86 | th, td { 87 | padding: 7px; 88 | 89 | > :first-child { 90 | margin-top: 0; 91 | } 92 | 93 | > :last-child { 94 | margin-bottom: 0; 95 | } 96 | } 97 | 98 | .container { 99 | @extend .clearfix; 100 | 101 | max-width: 980px; 102 | padding: 0 10px; 103 | margin: 0 auto; 104 | 105 | @media (max-width: $mobile-max-width) { 106 | padding: 0; 107 | } 108 | } 109 | 110 | header { 111 | position: fixed; 112 | top: 0; 113 | left: 0; 114 | width: 100%; 115 | z-index: 2; 116 | 117 | background: #414141; 118 | color: #fff; 119 | font-size: 1.1em; 120 | line-height: 25px; 121 | letter-spacing: .05em; 122 | 123 | #library-title { 124 | float: left; 125 | } 126 | 127 | #developer-home { 128 | float: right; 129 | } 130 | 131 | h1 { 132 | font-size: inherit; 133 | font-weight: inherit; 134 | margin: 0; 135 | } 136 | 137 | p { 138 | margin: 0; 139 | } 140 | 141 | h1, a { 142 | color: inherit; 143 | } 144 | 145 | @media (max-width: $mobile-max-width) { 146 | .container { 147 | padding: 0 10px; 148 | } 149 | } 150 | } 151 | 152 | aside { 153 | position: fixed; 154 | top: 25px; 155 | left: 0; 156 | width: 100%; 157 | height: 25px; 158 | z-index: 2; 159 | 160 | font-size: 1.1em; 161 | 162 | #header-buttons { 163 | background: rgba(255, 255, 255, .8); 164 | margin: 0 1px; 165 | padding: 0; 166 | list-style: none; 167 | text-align: right; 168 | line-height: 32px; 169 | 170 | li { 171 | display: inline-block; 172 | cursor: pointer; 173 | padding: 0 10px; 174 | } 175 | 176 | label, select { 177 | cursor: inherit; 178 | } 179 | 180 | #on-this-page { 181 | position: relative; 182 | 183 | .chevron { 184 | display: inline-block; 185 | width: 14px; 186 | height: 4px; 187 | position: relative; 188 | 189 | .chevy { 190 | background: #878787; 191 | height: 2px; 192 | position: absolute; 193 | width: 10px; 194 | 195 | &.chevron-left { 196 | left: 0; 197 | transform: rotateZ(45deg) scale(0.6); 198 | } 199 | 200 | &.chevron-right { 201 | right: 0; 202 | transform: rotateZ(-45deg) scale(0.6); 203 | } 204 | } 205 | } 206 | 207 | #jump-to { 208 | opacity: 0; 209 | font-size: 16px; 210 | 211 | position: absolute; 212 | top: 5px; 213 | left: 0; 214 | width: 100%; 215 | height: 100%; 216 | } 217 | } 218 | } 219 | } 220 | 221 | article { 222 | margin-top: 25px; 223 | 224 | #content { 225 | @extend .clearfix; 226 | 227 | background: $content-background; 228 | border: 1px solid $content-border; 229 | padding: 15px 25px 30px 25px; 230 | 231 | font-size: 1.4em; 232 | line-height: 1.45; 233 | 234 | position: relative; 235 | 236 | @media (max-width: $mobile-max-width) { 237 | padding: 15px 10px 20px 10px; 238 | border: none; 239 | } 240 | 241 | .navigation-top { 242 | position: absolute; 243 | top: 15px; 244 | right: 25px; 245 | } 246 | 247 | .title { 248 | margin: 21px 0 0 0; 249 | padding: 15px 0; 250 | } 251 | 252 | p { 253 | color: #414141; 254 | margin: 0 0 15px 0; 255 | } 256 | 257 | th, td { 258 | p:last-child { 259 | margin-bottom: 0; 260 | } 261 | } 262 | 263 | main { 264 | ul { 265 | list-style: none; 266 | margin-left: 24px; 267 | margin-bottom: 12px; 268 | padding: 0; 269 | 270 | li { 271 | position: relative; 272 | padding-left: 1.3em; 273 | 274 | &:before { 275 | content: "\02022"; 276 | 277 | color: #414141; 278 | font-size: 1.08em; 279 | line-height: 1; 280 | 281 | position: absolute; 282 | left: 0; 283 | padding-top: 2px; 284 | } 285 | } 286 | } 287 | } 288 | 289 | footer { 290 | @extend .clearfix; 291 | 292 | .footer-copyright { 293 | margin: 70px 25px 10px 0; 294 | } 295 | 296 | p { 297 | font-size: .71em; 298 | color: #a0a0a0; 299 | } 300 | } 301 | } 302 | } 303 | -------------------------------------------------------------------------------- /help/html/css/scss/_object.scss: -------------------------------------------------------------------------------- 1 | .section-specification { 2 | table { 3 | width: auto; 4 | 5 | th { 6 | text-align: left; 7 | } 8 | } 9 | } 10 | 11 | .method-title { 12 | margin-left: -15px; 13 | margin-bottom: 8px; 14 | transition: margin-left .3s ease-out; 15 | 16 | .section-method.hide & { 17 | margin-left: 0; 18 | } 19 | 20 | code { 21 | font-weight: 400; 22 | font-size: .85em; 23 | } 24 | } 25 | 26 | .method-info { 27 | background: $object-background; 28 | border-bottom: 1px solid $object-border; 29 | margin: 0 -25px; 30 | padding: 20px 25px 0 25px; 31 | transition: height .3s ease-out; 32 | 33 | position: relative; 34 | 35 | .pointy-thing { 36 | background: $content-background; 37 | height: 10px; 38 | border-bottom: 1px solid $object-border; 39 | margin: -20px -25px 16px -25px; 40 | 41 | &:before { 42 | display: inline-block; 43 | content: ""; 44 | 45 | background: $object-background; 46 | border: 1px solid $object-border; 47 | border-bottom: 0; 48 | border-right: 0; 49 | 50 | position: absolute; 51 | left: 21px; 52 | top: 3px; 53 | width: 12px; 54 | height: 12px; 55 | transform: rotate(45deg); 56 | } 57 | } 58 | 59 | .method-subsection { 60 | margin-bottom: 15px; 61 | 62 | .argument-name { 63 | width: 1px; 64 | text-align: right; 65 | 66 | code { 67 | color: #808080; 68 | font-style: italic; 69 | font-weight: 400; 70 | } 71 | } 72 | } 73 | } 74 | 75 | .section-method { 76 | &.hide .method-info { 77 | height: 0 !important; 78 | overflow: hidden; 79 | display: none; 80 | } 81 | 82 | &.hide.animating .method-info { 83 | display: block; 84 | } 85 | 86 | &.animating .method-info { 87 | overflow: hidden; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /help/html/css/scss/_print.scss: -------------------------------------------------------------------------------- 1 | @media print { 2 | body { 3 | background: #fff; 4 | padding: 8px; 5 | } 6 | 7 | header { 8 | position: static; 9 | background: #fff; 10 | color: #000; 11 | } 12 | 13 | aside { 14 | display: none; 15 | } 16 | 17 | .container { 18 | max-width: none; 19 | padding: 0; 20 | } 21 | 22 | article { 23 | margin-top: 0; 24 | 25 | #content { 26 | border: 0; 27 | background: #fff; 28 | padding: 15px 0 0 0; 29 | 30 | .title { 31 | margin-top: 0; 32 | padding-top: 0; 33 | } 34 | } 35 | } 36 | 37 | .method-info { 38 | &, & .pointy-thing { 39 | background: #fff; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /help/html/css/scss/_variables.scss: -------------------------------------------------------------------------------- 1 | $body-font: -apple-system-font, "Helvetica Neue", Helvetica, sans-serif; 2 | $code-font: "Source Code Pro", Monaco, Menlo, Consolas, monospace; 3 | 4 | $body-background: #f2f2f2; 5 | $content-background: #fff; 6 | $content-border: #e9e9e9; 7 | $tint-color: #08c; 8 | $object-background: #f9f9f9; 9 | $object-border: #e9e9e9; 10 | 11 | $mobile-max-width: 650px; 12 | $desktop-min-width: 768px; -------------------------------------------------------------------------------- /help/html/css/scss/_xcode.scss: -------------------------------------------------------------------------------- 1 | .xcode { 2 | header, aside { 3 | display: none; 4 | } 5 | 6 | .container { 7 | padding: 0; 8 | } 9 | 10 | article { 11 | margin-top: 0; 12 | 13 | #content { 14 | border: 0; 15 | margin: 0; 16 | } 17 | } 18 | 19 | .method-info { 20 | &, .section-method.hide & { 21 | max-height: auto; 22 | overflow: visible; 23 | 24 | &.hiding { 25 | display: block; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /help/html/css/scss/style.scss: -------------------------------------------------------------------------------- 1 | @import "variables", "normalize", "layout", "index", "object", "print", "xcode"; 2 | -------------------------------------------------------------------------------- /help/html/css/style.css: -------------------------------------------------------------------------------- 1 | html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}*{box-sizing:border-box}.clear{clear:both}.clearfix:before,.container:before,article #content:before,article #content footer:before,.clearfix:after,.container:after,article #content:after,article #content footer:after{clear:both;display:table;content:""}.xcode .hide-in-xcode{display:none}body{font:62.5% -apple-system-font,"Helvetica Neue",Helvetica,sans-serif;background:#f2f2f2}@media (max-width: 650px){body{background-color:#fff}}h1,h2,h3{font-weight:300;color:#808080}h1{font-size:2em;color:#000}h4{font-size:13px;line-height:1.5;margin:21px 0 0 0}a{color:#08c;text-decoration:none}pre,code{font-family:"Source Code Pro",Monaco,Menlo,Consolas,monospace;word-wrap:break-word}pre>code,.method-declaration code{display:inline-block;font-size:.85em;padding:4px 0 4px 10px;border-left:5px solid rgba(0,155,51,0.2)}pre>code:before,.method-declaration code:before{content:"Objective-C";display:block;font:9px/1 -apple-system-font,"Helvetica Neue",Helvetica,sans-serif;color:#009b33;text-transform:uppercase;letter-spacing:2px;padding-bottom:6px}pre>code{font-size:inherit}table,th,td{border:1px solid #e9e9e9}table{width:100%}th,td{padding:7px}th>:first-child,td>:first-child{margin-top:0}th>:last-child,td>:last-child{margin-bottom:0}.container{max-width:980px;padding:0 10px;margin:0 auto}@media (max-width: 650px){.container{padding:0}}header{position:fixed;top:0;left:0;width:100%;z-index:2;background:#414141;color:#fff;font-size:1.1em;line-height:25px;letter-spacing:.05em}header #library-title{float:left}header #developer-home{float:right}header h1{font-size:inherit;font-weight:inherit;margin:0}header p{margin:0}header h1,header a{color:inherit}@media (max-width: 650px){header .container{padding:0 10px}}aside{position:fixed;top:25px;left:0;width:100%;height:25px;z-index:2;font-size:1.1em}aside #header-buttons{background:rgba(255,255,255,0.8);margin:0 1px;padding:0;list-style:none;text-align:right;line-height:32px}aside #header-buttons li{display:inline-block;cursor:pointer;padding:0 10px}aside #header-buttons label,aside #header-buttons select{cursor:inherit}aside #header-buttons #on-this-page{position:relative}aside #header-buttons #on-this-page .chevron{display:inline-block;width:14px;height:4px;position:relative}aside #header-buttons #on-this-page .chevron .chevy{background:#878787;height:2px;position:absolute;width:10px}aside #header-buttons #on-this-page .chevron .chevy.chevron-left{left:0;transform:rotateZ(45deg) scale(0.6)}aside #header-buttons #on-this-page .chevron .chevy.chevron-right{right:0;transform:rotateZ(-45deg) scale(0.6)}aside #header-buttons #on-this-page #jump-to{opacity:0;font-size:16px;position:absolute;top:5px;left:0;width:100%;height:100%}article{margin-top:25px}article #content{background:#fff;border:1px solid #e9e9e9;padding:15px 25px 30px 25px;font-size:1.4em;line-height:1.45;position:relative}@media (max-width: 650px){article #content{padding:15px 10px 20px 10px;border:none}}article #content .navigation-top{position:absolute;top:15px;right:25px}article #content .title{margin:21px 0 0 0;padding:15px 0}article #content p{color:#414141;margin:0 0 15px 0}article #content th p:last-child,article #content td p:last-child{margin-bottom:0}article #content main ul{list-style:none;margin-left:24px;margin-bottom:12px;padding:0}article #content main ul li{position:relative;padding-left:1.3em}article #content main ul li:before{content:"\02022";color:#414141;font-size:1.08em;line-height:1;position:absolute;left:0;padding-top:2px}article #content footer .footer-copyright{margin:70px 25px 10px 0}article #content footer p{font-size:.71em;color:#a0a0a0}.index-container{-webkit-flex-direction:column;flex-direction:column}@media (min-width: 768px){.index-container{display:flex;-webkit-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;flex-wrap:wrap}}.index-container .index-column{-webkit-flex:1 1 33%;flex:1 1 33%}.section-specification table{width:auto}.section-specification table th{text-align:left}.method-title{margin-left:-15px;margin-bottom:8px;transition:margin-left .3s ease-out}.section-method.hide .method-title{margin-left:0}.method-title code{font-weight:400;font-size:.85em}.method-info{background:#f9f9f9;border-bottom:1px solid #e9e9e9;margin:0 -25px;padding:20px 25px 0 25px;transition:height .3s ease-out;position:relative}.method-info .pointy-thing{background:#fff;height:10px;border-bottom:1px solid #e9e9e9;margin:-20px -25px 16px -25px}.method-info .pointy-thing:before{display:inline-block;content:"";background:#f9f9f9;border:1px solid #e9e9e9;border-bottom:0;border-right:0;position:absolute;left:21px;top:3px;width:12px;height:12px;transform:rotate(45deg)}.method-info .method-subsection{margin-bottom:15px}.method-info .method-subsection .argument-name{width:1px;text-align:right}.method-info .method-subsection .argument-name code{color:#808080;font-style:italic;font-weight:400}.section-method.hide .method-info{height:0 !important;overflow:hidden;display:none}.section-method.hide.animating .method-info{display:block}.section-method.animating .method-info{overflow:hidden}@media print{body{background:#fff;padding:8px}header{position:static;background:#fff;color:#000}aside{display:none}.container{max-width:none;padding:0}article{margin-top:0}article #content{border:0;background:#fff;padding:15px 0 0 0}article #content .title{margin-top:0;padding-top:0}.method-info,.method-info .pointy-thing{background:#fff}}.xcode header,.xcode aside{display:none}.xcode .container{padding:0}.xcode article{margin-top:0}.xcode article #content{border:0;margin:0}.xcode .method-info,.section-method.hide .xcode .method-info{max-height:auto;overflow:visible}.xcode .method-info.hiding,.section-method.hide .xcode .method-info.hiding{display:block} 2 | 3 | -------------------------------------------------------------------------------- /help/html/hierarchy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | airbitz-core-objc Hierarchy 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 36 | 37 |
38 |
39 |
40 |
41 |

airbitz-core-objc Hierarchy

42 | 43 | 44 |
45 |

Class Hierarchy

46 | 47 | 84 | 85 |
86 | 87 | 88 | 89 |
90 | 91 |

Protocol References

92 | 97 | 98 | 99 |

Constant References

100 | 107 | 108 | 109 |
110 | 111 | 112 |
113 | 121 |
122 |
123 |
124 |
125 |
126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /help/html/img/button_bar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/help/html/img/button_bar_background.png -------------------------------------------------------------------------------- /help/html/img/disclosure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/help/html/img/disclosure.png -------------------------------------------------------------------------------- /help/html/img/disclosure_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/help/html/img/disclosure_open.png -------------------------------------------------------------------------------- /help/html/img/library_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/help/html/img/library_background.png -------------------------------------------------------------------------------- /help/html/img/title_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EdgeApp/airbitz-core-objc/ad8fd7a2b3e308277c9b7234b8ad682f20999192/help/html/img/title_background.png -------------------------------------------------------------------------------- /help/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | airbitz-core-objc Reference 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |

17 | airbitz-core-objc 18 |

19 | 20 |

21 | Airbitz 22 |

23 | 24 |
25 |
26 | 27 | 36 | 37 |
38 |
39 |
40 |
41 |

airbitz-core-objc Reference

42 | 43 | 44 |
45 | 46 | 47 |

AirbitzCore (ABC) is an iOS and Mac OSX client-side blockchain and Edge Security SDK providing auto-encrypted and auto-backed up accounts and wallets with zero-knowledge security and privacy. All blockchain/bitcoin private and public keys are fully encrypted by the users' credentials before being backed up on to peer to peer servers. ABC allows developers to create new Airbitz wallet accounts or login to pre-existing accounts. Account encrypted data is automatically synchronized between all devices and apps using the Airbitz SDK. This allows a third party application to generate payment requests or send funds for the users' account that may have been created on the Airbitz Mobile Bitcoin Wallet or any other Airbitz SDK application.

48 | 49 |

In addition, the ABCDataStore object in the Airbitz ABCAccount object allows developers to store arbitrary Edge-Secured data on the user’s account which is automatically encrypted, automatically backed up, and automatically synchronized between the user’s authenticated devices.

50 | 51 |

To get started, you’ll first need an API key. Get one at http://developer.airbitz.co

52 | 53 |

Next create an xcode project and install CocoaPods in the project. Include ABC by adding the following lines to your ‘Podfile’.

54 | 55 |
target "nameOfYourProjectHere" do
 56 |     pod 'AirbitzCore', :http => "https://developer.airbitz.co/download/airbitz-core-objc-newest.tgz"
 57 | end
 58 | 
59 | 60 |

Of course you’ll need to replace “nameOfYourProjectHere” with your actual Xcode project name.

61 | 62 |

Close the XCode project and then rerun ‘pod install’ from the directory with your Podfile.

63 | 64 |

Reopen the nameOfYourProjectHere.xcworkspace file from Xcode (not the xcproject file).

65 | 66 |

If you are using React Native, you’ll likely get a link error that you are missing some libraries. This is because React Native will overwrite linker flags set by Cocoapods. To fix, go to the project target Build Settings -> Other Linker Flags. Add “$(inherited)” to the linker flags.

67 | 68 |

And you’re done. You should be able to call into AirbitzCore. See below for code samples.

69 | 70 |
#import "AirbitzCore.h"
 71 | 
 72 | // Global account object
 73 | ABCAccount *gAccount;
 74 | 
 75 | - (void) exampleMethod
 76 | {
 77 |     // Create an account
 78 |     AirbitzCore *abc  = [[AirbitzCore alloc] init:@"YourAPIKeyHere"];
 79 |     gAccount = [abc createAccount:@"myusername" password:@"MyPa55w0rd!&" pin:@"4283" delegate:self error:nil];
 80 |     // New account is auto logged in after creation
 81 | 
 82 |     // Use Airbitz Edge Security to write encrypted/backed up/synchronized data to the account
 83 |     [gAccount.dataStore dataWrite:@"myAppUserInfo" withKey:@"user_email" withValue:@"theuser@hisdomain.com"];
 84 | 
 85 |     // Read back the data
 86 |     NSMutableString *usersEmail = [[NSMutableString alloc] init];
 87 |     [gAccount.dataStore dataRead:@"myAppUserInfo" withKey:@"user_email" data:usersEmail];
 88 | 
 89 |     // usersEmail now contains "theuser@hisdomain.com"
 90 | 
 91 |     // Create a wallet in the user account
 92 |     ABCWallet *wallet = [abcAccount createWallet:@"My Awesome Wallet" currency:nil];
 93 | 
 94 |     // Logout
 95 |     [gAccount logout];
 96 | 
 97 |     // Log back in with full credentials
 98 |     gAccount = [abc loginWithPassword:@"myusername" password:@"MyPa55w0rd!&" delegate:self error:nil];
 99 | 
100 |     // Logout
101 |     [gAccount logout];
102 | 
103 |     // Log back in with PIN using completion handler codeblock
104 |     [abc pinLogin:@"myusername" pin:@"4283" delegate:self complete:^(ABCAccount *account)
105 |      {
106 |          gAccount = account;
107 | 
108 |      } error:^(NSError *error) {
109 |          NSLog(@"Argh! Error code: %d. Error string:%@", (int)error.code, error.userInfo[NSLocalizedDescriptionKey]);
110 |      }];
111 | 
112 | }
113 | 
114 | // Delegate method called when wallets are loaded after a login
115 | - (void) abcAccountWalletLoaded:(ABCWallet *)wallet
116 | {
117 |     // Create a bitcoin request
118 |     ABCReceiveAddress *request = [wallet createNewReceiveAddress];
119 | 
120 |     // Put in some optional meta data into this request so incoming funds are automatically tagged
121 |     request.metaData.payeeName     = @"William Swanson"; // Name of the person receiving request
122 |     request.metaData.category      = @"Income:Rent";     // Category of payment. Auto tags category when funds come in
123 |     request.metaData.notes         = @"Rent payment for Jan 2016";
124 | 
125 |     // Put in an optional request amount and use fiat exchange rate conversion methods
126 |     request.amountSatoshi          = [gAccount.exchangeCache currencyToSatoshi:5.00 currencyCode:@"USD" error:nil];
127 | 
128 |     // Use the request results
129 |     NSString *bitcoinAddress = request.address;
130 |     NSString *bitcoinURI     = request.uri;
131 |     UIImage  *bitcoinQRCode  = request.qrCode;
132 | 
133 |     // Now go and display the QR code or send payment to address in some other way.
134 | }
135 | 
136 | // Delegate method called when bitcoin is received
137 | - (void) abcAccountIncomingBitcoin:(ABCWallet *)wallet transaction:(ABCTransaction *)transaction;
138 | {
139 |     NSLog(@"Yay, my wallet just received bitcoin. amount = %lld satoshis", transaction.amountSatoshi);
140 | }
141 | 
142 | 143 | 144 |
145 | 146 | 147 |
148 | 149 | 150 | 151 |
152 |

Class References

153 | 184 |
185 | 186 | 187 | 188 |
189 | 190 |

Protocol References

191 | 196 | 197 | 198 | 199 |

Constant References

200 | 207 | 208 | 209 | 210 |
211 | 212 |
213 | 214 |
215 | 223 |
224 |
225 |
226 |
227 |
228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /help/html/js/script.js: -------------------------------------------------------------------------------- 1 | function $() { 2 | return document.querySelector.apply(document, arguments); 3 | } 4 | 5 | if (navigator.userAgent.indexOf("Xcode") != -1) { 6 | document.documentElement.classList.add("xcode"); 7 | } 8 | 9 | var jumpTo = $("#jump-to"); 10 | 11 | if (jumpTo) { 12 | jumpTo.addEventListener("change", function(e) { 13 | location.hash = this.options[this.selectedIndex].value; 14 | }); 15 | } 16 | 17 | function hashChanged() { 18 | if (/^#\/\/api\//.test(location.hash)) { 19 | var element = document.querySelector("a[name='" + location.hash.substring(1) + "']"); 20 | 21 | if (!element) { 22 | return; 23 | } 24 | 25 | element = element.parentNode; 26 | 27 | element.classList.remove("hide"); 28 | fixScrollPosition(element); 29 | } 30 | } 31 | 32 | function fixScrollPosition(element) { 33 | var scrollTop = element.offsetTop - 150; 34 | document.documentElement.scrollTop = scrollTop; 35 | document.body.scrollTop = scrollTop; 36 | } 37 | 38 | [].forEach.call(document.querySelectorAll(".section-method"), function(element) { 39 | element.classList.add("hide"); 40 | 41 | element.querySelector(".method-title a").addEventListener("click", function(e) { 42 | var info = element.querySelector(".method-info"), 43 | infoContainer = element.querySelector(".method-info-container"); 44 | 45 | element.classList.add("animating"); 46 | info.style.height = (infoContainer.clientHeight + 40) + "px"; 47 | fixScrollPosition(element); 48 | element.classList.toggle("hide"); 49 | if (element.classList.contains("hide")) { 50 | e.preventDefault(); 51 | } 52 | setTimeout(function() { 53 | element.classList.remove("animating"); 54 | }, 300); 55 | }); 56 | }); 57 | 58 | window.addEventListener("hashchange", hashChanged); 59 | hashChanged(); 60 | -------------------------------------------------------------------------------- /main-help.m: -------------------------------------------------------------------------------- 1 | 2 | AirbitzCore (ABC) is an iOS and Mac OSX client-side blockchain and Edge Security SDK providing auto-encrypted and auto-backed up accounts and wallets with zero-knowledge security and privacy. All blockchain/bitcoin private and public keys are fully encrypted by the users' credentials before being backed up on to peer to peer servers. ABC allows developers to create new Airbitz wallet accounts or login to pre-existing accounts. Account encrypted data is automatically synchronized between all devices and apps using the Airbitz SDK. This allows a third party application to generate payment requests or send funds for the users' account that may have been created on the Airbitz Mobile Bitcoin Wallet or any other Airbitz SDK application. 3 | 4 | In addition, the ABCDataStore object in the Airbitz ABCAccount object allows developers to store arbitrary Edge-Secured data on the user’s account which is automatically encrypted, automatically backed up, and automatically synchronized between the user’s authenticated devices. 5 | 6 | To get started, you’ll first need an API key. Get one at http://developer.airbitz.co 7 | 8 | Next create an xcode project and install CocoaPods in the project. Include ABC by adding the following lines to your ‘Podfile’. 9 | 10 | target "nameOfYourProjectHere" do 11 | pod 'AirbitzCore', :http => "https://developer.airbitz.co/download/airbitz-core-objc-newest.tgz" 12 | end 13 | 14 | Of course you'll need to replace "nameOfYourProjectHere" with your actual Xcode project name. 15 | 16 | Close the XCode project and then rerun 'pod install' from the directory with your Podfile. 17 | 18 | Reopen the nameOfYourProjectHere.xcworkspace file from Xcode (not the xcproject file). 19 | 20 | If you are using React Native, you'll likely get a link error that you are missing some libraries. This is because React Native will overwrite linker flags set by Cocoapods. To fix, go to the project target Build Settings -> Other Linker Flags. Add "$(inherited)" to the linker flags. 21 | 22 | And you're done. You should be able to call into AirbitzCore. See below for code samples. 23 | 24 | #import "ABCContext.h" 25 | 26 | // Global account object 27 | ABCAccount *gAccount; 28 | 29 | - (void) exampleMethod 30 | { 31 | // Create an account 32 | AirbitzCore *abc = [AirbitzCore makeABCContext:@"YourAPIKeyHere"]; 33 | gAccount = [abc createAccount:@"myusername" password:@"MyPa55w0rd!&" pin:@"4283" delegate:self error:nil]; 34 | // New account is auto logged in after creation 35 | 36 | // Use Airbitz Edge Security to write encrypted/backed up/synchronized data to the account 37 | [gAccount.dataStore dataWrite:@"myAppUserInfo" withKey:@"user_email" withValue:@"theuser@hisdomain.com"]; 38 | 39 | // Read back the data 40 | NSMutableString *usersEmail = [[NSMutableString alloc] init]; 41 | [gAccount.dataStore dataRead:@"myAppUserInfo" withKey:@"user_email" data:usersEmail]; 42 | 43 | // usersEmail now contains "theuser@hisdomain.com" 44 | 45 | // Create a wallet in the user account 46 | ABCWallet *wallet = [abcAccount createWallet:@"My Awesome Wallet" currency:nil]; 47 | 48 | // Logout 49 | [gAccount logout]; 50 | 51 | // Log back in with full credentials 52 | gAccount = [abc loginWithPassword:@"myusername" password:@"MyPa55w0rd!&" delegate:self error:nil]; 53 | 54 | // Logout 55 | [gAccount logout]; 56 | 57 | // Log back in with PIN using completion handler codeblock 58 | [abc pinLogin:@"myusername" pin:@"4283" delegate:self callback:^(ABCError *error, ABCAccount *account) 59 | { 60 | if (!error) 61 | gAccount = account; 62 | else 63 | NSLog(@"Argh! Error code: %d. Error string:%@", (int)error.code, error.userInfo[NSLocalizedDescriptionKey]); 64 | }]; 65 | 66 | } 67 | 68 | // Delegate method called when wallets are loaded after a login 69 | - (void) abcAccountWalletLoaded:(ABCWallet *)wallet 70 | { 71 | // Create a bitcoin request 72 | ABCReceiveAddress *request = [wallet createNewReceiveAddress]; 73 | 74 | // Put in some optional meta data into this request so incoming funds are automatically tagged 75 | request.metaData.payeeName = @"William Swanson"; // Name of the person receiving request 76 | request.metaData.category = @"Income:Rent"; // Category of payment. Auto tags category when funds come in 77 | request.metaData.notes = @"Rent payment for Jan 2016"; 78 | 79 | // Put in an optional request amount and use fiat exchange rate conversion methods 80 | request.amountSatoshi = [gAccount.exchangeCache currencyToSatoshi:5.00 currencyCode:@"USD" error:nil]; 81 | 82 | // Use the request results 83 | NSString *bitcoinAddress = request.address; 84 | NSString *bitcoinURI = request.uri; 85 | UIImage *bitcoinQRCode = request.qrCode; 86 | 87 | // Now go and display the QR code or send payment to address in some other way. 88 | } 89 | 90 | // Delegate method called when bitcoin is received 91 | - (void) abcAccountIncomingBitcoin:(ABCWallet *)wallet transaction:(ABCTransaction *)transaction; 92 | { 93 | NSLog(@"Yay, my wallet just received bitcoin. amount = %lld satoshis", transaction.amountSatoshi); 94 | } 95 | 96 | -------------------------------------------------------------------------------- /mkabc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -u 3 | set -e 4 | 5 | # Pick up the current directory: 6 | CURRENT_DIR=$(pwd) 7 | if [ -z ${BUILD_DIR+x} ]; then 8 | export BUILD_DIR=${BUILD_DIR:-$CURRENT_DIR/../airbitz-core/deps/build}; 9 | fi 10 | 11 | # Testnet options: 12 | if [ "${1-}" = "testnet" ]; then 13 | shift 14 | export BUILD_DIR=${BUILD_DIR}-testnet 15 | export ENABLE_TESTNET=1 16 | fi 17 | 18 | # Do the build: 19 | touch ../airbitz-core/deps/recipes/abc/abc.recipe 20 | ( 21 | cd ../airbitz-core/deps 22 | make abc.package-ios-universal $@ 23 | ) 24 | 25 | # Copy the results locally: 26 | mkdir -m 0775 -p Libraries 27 | cp -aL $BUILD_DIR/abc/abc-ios-universal/include/* Classes/Private 28 | cp -a $BUILD_DIR/abc/abc-ios-universal/lib/* Libraries/ 29 | -------------------------------------------------------------------------------- /mkabcallclean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | set -e 5 | 6 | CURRENT_DIR=$( /bin/pwd ) 7 | 8 | mkdir -m 0775 -p Libraries 9 | mkdir -m 0775 -p LibrariesOSX 10 | 11 | touch ../airbitz-core/deps/recipes/abc/abc.recipe 12 | 13 | if [ "${1-}" = "testnet" ]; then 14 | shift 15 | ( 16 | cd ../airbitz-core/deps 17 | export BUILD_DIR=${CURRENT_DIR}/../airbitz-core/deps/build-testnet 18 | make abc.clean 19 | make abc.package-ios-universal ENABLE_TESTNET=1 $@ 20 | make abc.package-osx-universal ENABLE_TESTNET=1 $@ 21 | ) 22 | cp -aL ../airbitz-core/deps/build-testnet/abc/abc-ios-universal/include/* Classes/Private 23 | cp -a ../airbitz-core/deps/build-testnet/abc/abc-ios-universal/lib/* Libraries/ 24 | cp -a ../airbitz-core/deps/build-testnet/abc/abc-osx-universal/lib/* LibrariesOSX/ 25 | else 26 | ( 27 | cd ../airbitz-core/deps 28 | export BUILD_DIR=${CURRENT_DIR}/../airbitz-core/deps/build 29 | make abc.clean 30 | make abc.package-ios-universal $@ 31 | make abc.package-osx-universal $@ 32 | ) 33 | cp -aL ../airbitz-core/deps/build/abc/abc-ios-universal/include/* Classes/Private 34 | cp -a ../airbitz-core/deps/build/abc/abc-ios-universal/lib/* Libraries/ 35 | cp -a ../airbitz-core/deps/build/abc/abc-osx-universal/lib/* LibrariesOSX/ 36 | fi 37 | -------------------------------------------------------------------------------- /mkabcclean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | set -e 5 | 6 | CURRENT_DIR=$( /bin/pwd ) 7 | 8 | mkdir -m 0775 -p Libraries 9 | 10 | touch ../airbitz-core/deps/recipes/abc/abc.recipe 11 | 12 | if [ -z ${BUILD_DIR+x} ]; then 13 | export BUILD_DIR=${BUILD_DIR:-$CURRENT_DIR/../airbitz-core/deps/build}; 14 | fi 15 | 16 | if [ "${1-}" = "testnet" ]; then 17 | shift 18 | ( 19 | cd ../airbitz-core/deps 20 | make abc.clean 21 | make abc.package-ios-universal ENABLE_TESTNET=1 $@ 22 | ) 23 | cp -aL ../airbitz-core/deps/build-testnet/abc/abc-ios-universal/include/* Classes/Private 24 | cp -a ../airbitz-core/deps/build-testnet/abc/abc-ios-universal/lib/* Libraries/ 25 | else 26 | ( 27 | cd ../airbitz-core/deps 28 | make abc.clean 29 | make abc.package-ios-universal $@ 30 | ) 31 | cp -aL ../airbitz-core/deps/build/abc/abc-ios-universal/include/* Classes/Private 32 | cp -a ../airbitz-core/deps/build/abc/abc-ios-universal/lib/* Libraries/ 33 | fi 34 | -------------------------------------------------------------------------------- /mkabcosx: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | set -e 5 | 6 | CURRENT_DIR=$( /bin/pwd ) 7 | 8 | mkdir -m 0775 -p LibrariesOSX 9 | 10 | touch ../airbitz-core/deps/recipes/abc/abc.recipe 11 | 12 | if [ "${1-}" = "testnet" ]; then 13 | shift 14 | ( 15 | cd ../airbitz-core/deps 16 | export BUILD_DIR=${CURRENT_DIR}/../airbitz-core/deps/build-testnet 17 | make abc.package-osx-universal ENABLE_TESTNET=1 $@ 18 | ) 19 | cp -aL ../airbitz-core/deps/build-testnet/abc/abc-osx-universal/include/* Classes/Private 20 | cp -a ../airbitz-core/deps/build-testnet/abc/abc-osx-universal/lib/* LibrariesOSX/ 21 | else 22 | ( 23 | cd ../airbitz-core/deps 24 | export BUILD_DIR=${CURRENT_DIR}/../airbitz-core/deps/build 25 | make abc.package-osx-universal $@ 26 | ) 27 | cp -aL ../airbitz-core/deps/build/abc/abc-osx-universal/include/* Classes/Private 28 | cp -a ../airbitz-core/deps/build/abc/abc-osx-universal/lib/* LibrariesOSX/ 29 | fi 30 | -------------------------------------------------------------------------------- /mkdocs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -u 4 | set -e 5 | 6 | CURRENT_DIR=$( /bin/pwd ) 7 | 8 | 9 | appledoc --index-desc main-help.m --project-name airbitz-core-objc --project-company "Airbitz" --company-id co.airbitz --output ./help --no-create-docset --search-undocumented-doc Classes/Public/. 10 | 11 | --------------------------------------------------------------------------------