ABCAccount Class Reference

Inherits from NSObject
Declared in ABCAccount.h

Overview

The ABCAccount object represents a fully logged in account. This is returned by various signIn routines from AirbitzCore. It contains an ABCSettings object which are account settings that carry over from device to device. ABCAccount also contains an array of ABCWallet object wallets and archived wallets which should be checked for the parameter loaded=YES before being accessed.

The ABCDataStore object dataStore allows reading/writing of encrypted and backed up key/value data to the user’s account. This data is accessible from any device that the user authenticates into using an app running on the Airbitz SDK.

ABCAccount read/write public object variables

  delegate

Delegate object to handle delegate callbacks

@property (assign) id<ABCAccountDelegate> delegate

Discussion

Delegate object to handle delegate callbacks

Declared In

ABCAccount.h

  settings

ABC settings that can be set or viewed by app or ABC. Use method [ABCSettings loadSettings] to make sure they are loaded and [ABCSettings saveSettings] to ensure modified settings are latched

@property (atomic, strong) ABCSettings *settings

Discussion

ABC settings that can be set or viewed by app or ABC. Use method [ABCSettings loadSettings] to make sure they are loaded and [ABCSettings saveSettings] to ensure modified settings are latched

Declared In

ABCAccount.h

  exchangeCache

ABCExchangeCache object. Used to convert bitcoin values to/from fiat in various formats The exchange cache is internally implemented as a global object shared across all users of AirbitzCore in the same application.

@property (atomic, strong) ABCExchangeCache *exchangeCache

Discussion

ABCExchangeCache object. Used to convert bitcoin values to/from fiat in various formats The exchange cache is internally implemented as a global object shared across all users of AirbitzCore in the same application.

Declared In

ABCAccount.h

ABCAccount read-only public object variables

  arrayWallets

Array of ABCWallet objects currently loaded into account. This array is read-only and app should only access the array while in the main queue.

@property (atomic, strong) NSMutableArray *arrayWallets

Discussion

Array of ABCWallet objects currently loaded into account. This array is read-only and app should only access the array while in the main queue.

Declared In

ABCAccount.h

  arrayArchivedWallets

Array of archived ABCWallet objects currently loaded into account. This array is read-only and app should only access the array while in the main queue.

@property (atomic, strong) NSMutableArray *arrayArchivedWallets

Discussion

Array of archived ABCWallet objects currently loaded into account. This array is read-only and app should only access the array while in the main queue.

Declared In

ABCAccount.h

  arrayWalletNames

Array of NSString wallet names for non-archived wallets. This array maps index-for-index to arrayWallets. This array is read-only and app should only access the array while in the main queue.

@property (atomic, strong) NSMutableArray *arrayWalletNames

Discussion

Array of NSString wallet names for non-archived wallets. This array maps index-for-index to arrayWallets. This array is read-only and app should only access the array while in the main queue.

Declared In

ABCAccount.h

  currentWallet

Helper property that points to the “currentWallet” in the account. This can be used by GUI as the default wallet used for spending and receive requests. This value is automatically set to a different wallet if the wallet pointed to by currentWallet is deleted.

@property (atomic, strong) ABCWallet *currentWallet

Discussion

Helper property that points to the “currentWallet” in the account. This can be used by GUI as the default wallet used for spending and receive requests. This value is automatically set to a different wallet if the wallet pointed to by currentWallet is deleted.

Declared In

ABCAccount.h

  currentWalletIndex

Index into arrayWallets to where currentWallet is set to.
arrayWallets[currentWalletIndex] = currentWallet

@property (atomic) int currentWalletIndex

Discussion

Index into arrayWallets to where currentWallet is set to.
arrayWallets[currentWalletIndex] = currentWallet

Declared In

ABCAccount.h

  categories

ABCCategories object which lists category options a user could choose to tag a transaction with. Categories must start with “Income”, “Expense”, “Transfer” or “Exchange” plus a “:” and then an arbitrary subcategory such as “Food & Dining”. ie. “Expense:Rent”

@property (atomic, strong) ABCCategories *categories

Discussion

ABCCategories object which lists category options a user could choose to tag a transaction with. Categories must start with “Income”, “Expense”, “Transfer” or “Exchange” plus a “:” and then an arbitrary subcategory such as “Food & Dining”. ie. “Expense:Rent”

Declared In

ABCAccount.h

  dataStore

ABCDataStore object for allowing arbitrary Edge Secure data storage and retrieval on this ABCAccount.

@property ABCDataStore *dataStore

Discussion

ABCDataStore object for allowing arbitrary Edge Secure data storage and retrieval on this ABCAccount.

Declared In

ABCAccount.h

  bAllWalletsLoaded

YES once all wallets in this account have been successfully loaded after a signIn

@property (atomic) BOOL bAllWalletsLoaded

Discussion

YES once all wallets in this account have been successfully loaded after a signIn

Declared In

ABCAccount.h

  numWalletsLoaded

Number of wallets that have been loaded after a signIn

@property (atomic) int numWalletsLoaded

Discussion

Number of wallets that have been loaded after a signIn

Declared In

ABCAccount.h

  numTotalWallets

Number of wallets in this account

@property (atomic) int numTotalWallets

Discussion

Number of wallets in this account

Declared In

ABCAccount.h

  name

This account’s username

@property (atomic, copy) NSString *name

Discussion

This account’s username

Declared In

ABCAccount.h

– createExchangeRateString:includeCurrencyCode:

Creates a user displayable exchange rate string using the current user’s denomination settings. ie. “1 BTC = $451” or “1 mBTC = $0.451”

- (NSString *)createExchangeRateString:(ABCCurrency *)currency includeCurrencyCode:(bool)includeCurrencyCode

Parameters

currency

ABCCurrency object representing choice of fiat currency to use for conversion

includeCurrencyCode

BOOL If YES, include the fiat currency code in the conversion string. ie. “1 BTC = $451 USD”

Discussion

Creates a user displayable exchange rate string using the current user’s denomination settings. ie. “1 BTC = $451” or “1 mBTC = $0.451”

Declared In

ABCAccount.h

Account Management

– changePassword:complete:error:

NSString new password for currently logged in user (Optional. If used, method returns immediately with void)

- (void)changePassword:(NSString *)password complete:(void ( ^ ) ( void ))completionHandler error:(void ( ^ ) ( NSError *))errorHandler

Parameters

password

NSString new password for currently logged in user (Optional. If used, method returns immediately with void)

completionHandler

(Optional) completion handler code block

errorHandler

(Optional) Code block called on error with parameters
- param NSError

Return Value

NSError object or nil if success. Return void if using completion handler

Declared In

ABCAccount.h

– changePIN:complete:error:

NSString New pin for currently logged in user (Optional. If used, method returns immediately with ABCCConditionCodeOk)

- (void)changePIN:(NSString *)pin complete:(void ( ^ ) ( void ))completionHandler error:(void ( ^ ) ( NSError *))errorHandler

Parameters

pin

NSString New pin for currently logged in user (Optional. If used, method returns immediately with ABCCConditionCodeOk)

completionHandler

Completion handler code block

errorHandler

Error handler code block which is called with the following args
- param NSError

Return Value

NSError Error object. Nil if success. Returns void if completion handlers used

Declared In

ABCAccount.h

– accountHasPassword:

Check if this user has a password on the account or if it is a PIN-only account.

- (BOOL)accountHasPassword:(NSError **)error

Parameters

error

(Optional) NSError* Error object. Nil if success

Return Value

BOOL true if user has a password

Discussion

Check if this user has a password on the account or if it is a PIN-only account.

Declared In

ABCAccount.h

– recentlyLoggedIn

Check if this user has logged in “recently”. Currently fixed to return TRUE within 120 seconds of login. Useful for requiring less security for spending such as a PIN on spend.

- (BOOL)recentlyLoggedIn

Return Value

BOOL

Discussion

Check if this user has logged in “recently”. Currently fixed to return TRUE within 120 seconds of login. Useful for requiring less security for spending such as a PIN on spend.

Declared In

ABCAccount.h

– checkPIN:error:

Checks a PIN for correctness. This checks against the PIN used during account creation in [AirbitzCore createAccount] or the PIN changed with [ABCAccount changePIN]
This is used to guard access to certain actions in the GUI.

- (BOOL)checkPIN:(NSString *)pin error:(NSError **)error

Parameters

pin

NSString* Pin to check

error

(Optional) NSError* Error object. Nil if success

Return Value

BOOL YES if PIN is correct

Discussion

Checks a PIN for correctness. This checks against the PIN used during account creation in [AirbitzCore createAccount] or the PIN changed with [ABCAccount changePIN]
This is used to guard access to certain actions in the GUI.

Declared In

ABCAccount.h

– checkPassword:

Checks if password is the correct password for this account

- (BOOL)checkPassword:(NSString *)password

Parameters

password

NSString Password to check

Return Value

BOOL YES if password is correct

Discussion

Checks if password is the correct password for this account

Declared In

ABCAccount.h

– pinLoginSetup:

Enable or disable PIN login on this account. Set enable = YES to allow PIN login. Enabling PIN login creates a local account decryption key that is split with one have in local device storage and the other half on Airbitz servers. When using [AirbitzCore pinLogin:username:pin:delegate:error] the PIN is sent to Airbitz servers to authenticate the user. If the PIN is correct, the second half of the decryption key is sent back to the device. Combined with the locally saved key, the two are then used to decrypt the local account thereby loggin in the user.

- (NSError *)pinLoginSetup:(BOOL)enable

Parameters

enable

BOOL set to YES to enable PIN login

Return Value

NSError* Nil if success

Discussion

Enable or disable PIN login on this account. Set enable = YES to allow PIN login. Enabling PIN login creates a local account decryption key that is split with one have in local device storage and the other half on Airbitz servers. When using [AirbitzCore pinLogin:username:pin:delegate:error] the PIN is sent to Airbitz servers to authenticate the user. If the PIN is correct, the second half of the decryption key is sent back to the device. Combined with the locally saved key, the two are then used to decrypt the local account thereby loggin in the user.

Declared In

ABCAccount.h

– hasPINLogin

Check if this account is allowed to login via PIN

- (BOOL)hasPINLogin

Return Value

BOOL YES if PIN login is enabled

Discussion

Check if this account is allowed to login via PIN

Declared In

ABCAccount.h

– logout

Logout the current ABCAccount object

- (void)logout

Return Value

void

Discussion

Logout the current ABCAccount object

Declared In

ABCAccount.h

Wallet Management

– createWallet:currency:complete:error:

Create a wallet in the current account with completion handlers

- (void)createWallet:(NSString *)walletName currency:(NSString *)currency complete:(void ( ^ ) ( ABCWallet *))completionHandler error:(void ( ^ ) ( NSError *))errorHandler

Parameters

walletName

NSString* Name of wallet or set to nil to use default wallet name

currency

NSString* ISO 3 digit currency code for wallet. Set to nil to use default currency from settings or the global default currency if settings unavailable. ie. “USD, EUR, CAD, PHP” (Optional. If used, method returns immediately with void

completionHandler

Code block called on success.
- param ABCWallet Fully created ABCWallet object.

errorHandler

Code block called on error with parameters
- param NSError*

Return Value

void

Discussion

Create a wallet in the current account with completion handlers

Declared In

ABCAccount.h

– createWallet:currency:error:

Create a wallet in the current account.

- (ABCWallet *)createWallet:(NSString *)walletName currency:(NSString *)currency error:(NSError **)error

Parameters

walletName

NSString* Name of wallet or set to nil to use default wallet name

currency

NSString* ISO 3 digit currency code for wallet. Set to nil to use default currency from settings or the global default currency if settings unavailable. ie. “USD, EUR, CAD, PHP”

error

NSError** May be set to nil. (Optional)

Return Value

ABCWallet wallet object or nil if failure.

Discussion

Create a wallet in the current account.

Declared In

ABCAccount.h

– getWallet:

Returns an ABCWallet object looked up by walletUUID

- (ABCWallet *)getWallet:(NSString *)walletUUID

Parameters

walletUUID

NSString* uuid of wallet to find

Return Value

ABCWallet Returned wallet object or nil if not found

Discussion

Returns an ABCWallet object looked up by walletUUID

Declared In

ABCAccount.h

– reorderWallets:toIndexPath:

Changes the order of wallets in [ABCAccount arrayWallets] & [ABCAccount arrayArchivedWallets] The wallet to move is specified by the ‘section’ and ‘row’ of the indexPath. Section 0 specifies wallets in arrayWallets. Section 1 specifies arrayArchivedWallet. The ‘row’ specifies the position within the array. Wallets are reordered by specifying the source wallet position in sourceIndexPath and destination position in destinationIndexPath.

- (NSError *)reorderWallets:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

Parameters

sourceIndexPath

NSIndexPath* The position of the wallet to move

destinationIndexPath

NSIndexPath* The destination array position of the wallet

Return Value

NSError* Error object. Nil if success.

Discussion

Changes the order of wallets in [ABCAccount arrayWallets] & [ABCAccount arrayArchivedWallets] The wallet to move is specified by the ‘section’ and ‘row’ of the indexPath. Section 0 specifies wallets in arrayWallets. Section 1 specifies arrayArchivedWallet. The ‘row’ specifies the position within the array. Wallets are reordered by specifying the source wallet position in sourceIndexPath and destination position in destinationIndexPath.

Declared In

ABCAccount.h

– listWalletIDs:

Returns an array of the wallet IDs in the account

- (NSArray *)listWalletIDs:(NSError **)error

Parameters

error

NSError (optional)

Return Value

NSArray array of NSString wallet IDs

Discussion

Returns an array of the wallet IDs in the account

Declared In

ABCAccount.h

One Time Password (OTP) (2 Factor Authentication)

– setOTPKey:

Associates an OTP key with the account. An OTP key can be retrieved from a previously logged in account using [ABCAccount getOTPLocalKey]. The account must have had OTP enabled by using [ABCAccount enableOTP]

- (NSError *)setOTPKey:(NSString *)key

Parameters

key

NSString* key to set

Return Value

NSError*

Discussion

Associates an OTP key with the account. An OTP key can be retrieved from a previously logged in account using [ABCAccount getOTPLocalKey]. The account must have had OTP enabled by using [ABCAccount enableOTP]

Declared In

ABCAccount.h

– getOTPLocalKey:

Gets the locally saved OTP key for the current user.

- (NSString *)getOTPLocalKey:(NSError **)error

Parameters

error

NSError error object or nil if success

Return Value

NSString OTP key

Discussion

Gets the locally saved OTP key for the current user.

Declared In

ABCAccount.h

– getOTPDetails:timeout:

Reads the OTP configuration from the server. Gets information on whether OTP is enabled for the current account, and how long a reset request will take. An OTP reset is a request to disable OTP made through the method [AirbitzCore requestOTPReset]

- (NSError *)getOTPDetails:(bool *)enabled timeout:(long *)timeout

Parameters

enabled

bool* enabled flag if OTP is enabled for this user

timeout

long* number seconds required after a reset is requested

Return Value

NSError* or nil if no error

Discussion

Reads the OTP configuration from the server. Gets information on whether OTP is enabled for the current account, and how long a reset request will take. An OTP reset is a request to disable OTP made through the method [AirbitzCore requestOTPReset]

Declared In

ABCAccount.h

– enableOTP:

Sets up OTP authentication on the server for currently logged in user This will generate a new token if the username doesn’t already have one.

- (NSError *)enableOTP:(long)timeout

Parameters

timeout

long number seconds required after a reset is requested before OTP is disabled.

Return Value

NSError* or nil if no error

Discussion

Sets up OTP authentication on the server for currently logged in user This will generate a new token if the username doesn’t already have one.

Declared In

ABCAccount.h

– disableOTP

Removes the OTP authentication requirement from the server for the currently logged in user. Also removes local key from device

- (NSError *)disableOTP

Return Value

NSError* or nil if no error

Discussion

Removes the OTP authentication requirement from the server for the currently logged in user. Also removes local key from device

Declared In

ABCAccount.h

– cancelOTPResetRequest

Removes the OTP reset request from the server for the currently logged in user

- (NSError *)cancelOTPResetRequest

Return Value

NSError* or nil if no error

Discussion

Removes the OTP reset request from the server for the currently logged in user

Declared In

ABCAccount.h

Password Recovery

– setupRecoveryQuestions:answers:complete:error:

Sets account recovery questions and answers in case use forgets their password

- (void)setupRecoveryQuestions:(NSString *)questions answers:(NSString *)answers complete:(void ( ^ ) ( void ))completionHandler error:(void ( ^ ) ( NSError *error ))errorHandler

Parameters

questions

NSString* concatenated string of recovery questions separated by ‘\n’ after each question

answers

NSString* concatenated string of recovery answers separated by ‘\n’ after each answer

completionHandler

(Optional) code block which is called upon success with void (Optional. If used, method returns immediately with void)

errorHandler

(Optional) Code block called on error with parameters
- param NSError*

Return Value

NSError* or nil if no error. Returns void if using completionHandler

Discussion

Sets account recovery questions and answers in case use forgets their password

Declared In

ABCAccount.h

– needsRecoveryQuestionsReminder

GUI utility function to help determine if the user should be asked to setup recovery questions and answers. This routine factors the amount of funds the account has received and whether or not recovery Q/A has already been setup.

- (BOOL)needsRecoveryQuestionsReminder

Return Value

BOOL YES if user should be asked.

Discussion

GUI utility function to help determine if the user should be asked to setup recovery questions and answers. This routine factors the amount of funds the account has received and whether or not recovery Q/A has already been setup.

Declared In

ABCAccount.h

Misc ABCAccount methods

– clearBlockchainCache:error:

Clears the local cache of blockchain information and force a re-download. This will cause wallets to report incorrect balances which the blockchain is resynced

- (void)clearBlockchainCache:(void ( ^ ) ( void ))completionHandler error:(void ( ^ ) ( NSError *error ))errorHandler

Parameters

completionHandler

(Optional) code block which is called upon success with void (Optional. If used, method returns immediately with void)

errorHandler

(Optional) Code block called on error with parameters
- param NSError*

Return Value

NSError* or nil if no error. Returns void if using completionHandler

Discussion

Clears the local cache of blockchain information and force a re-download. This will cause wallets to report incorrect balances which the blockchain is resynced

Declared In

ABCAccount.h

– shouldAskUserToEnableTouchID

Evaluates if user should be asked to enable touch ID based on various factors such as if they have ever disabled touchID in the past, if they have touchID hardware support, and if this account has a password. PIN only accounts can’t user TouchID at the moment. If user previously had touchID enabled, this will automatically enable touchID and return NO. Should be called while logged in.

- (BOOL)shouldAskUserToEnableTouchID

Return Value

BOOL: Should GUI ask if user wants to enable

Discussion

Evaluates if user should be asked to enable touch ID based on various factors such as if they have ever disabled touchID in the past, if they have touchID hardware support, and if this account has a password. PIN only accounts can’t user TouchID at the moment. If user previously had touchID enabled, this will automatically enable touchID and return NO. Should be called while logged in.

Declared In

ABCAccount.h

BitID methods

– bitidParseURI:

Parses a BitID URI and returns the domain of the URL for display to user.

- (NSString *)bitidParseURI:(NSString *)uri

Parameters

uri

NSString URI to parse

Return Value

NSString Domain of BitID request

Discussion

Parses a BitID URI and returns the domain of the URL for display to user.

Declared In

ABCAccount.h

– bitidLogin:

Login to a BitID server given the request URI

- (NSError *)bitidLogin:(NSString *)uri

Parameters

uri

NSString URI request from server in the form “bitid://server.com/bitid?x=NONCE”

Return Value

NSError Error object if failure. Nil if success.

Discussion

Login to a BitID server given the request URI

Declared In

ABCAccount.h

– bitidSign:message:

Sign an arbitrary message with a BitID URI. The URI determines the key derivation used to sign the message.

- (ABCBitIDSignature *)bitidSign:(NSString *)uri message:(NSString *)message

Parameters

uri

NSString URI request from server in the form “bitid://server.com/bitid?x=NONCE”

message

NSString message to sign.

Return Value

ABCBitIDSignature BitID signature object

Discussion

Sign an arbitrary message with a BitID URI. The URI determines the key derivation used to sign the message.

Declared In

ABCAccount.h