-
Notifications
You must be signed in to change notification settings - Fork 24
Home
Welcome to the stellar-android-wallet wiki!
LocalStore is your one and only interface with the sharedPreferences on the device, accessed through WalletApplication instance. From here you have access to:
-
encryptedPhraseThe RSA encrypted mnemonic. IfisPassphraseUsedis true, then the passphrase is appended to this mnemonic with a space seperating it. -
publicKeyPublic key for the Stellar account. -
balancesAn array ofAccountResponse.Balancethat either is empty on initialization or filled with the horizon server response. -
availableBalanceA string of the available balance on the account. -
isRecoveryPhraseBoolean that indicates whether account was recovered with a recovery phrase (true) or with a secret seed (false) -
showPinOnSendBoolean that indicates whether to show PIN on sending payment -
isPassphraseUsedBoolean that indicates whether a passphrase was used to recover the account in addition to the mnemonic phrase.
The UserSession object, accessed through WalletApplication instance, stores information about the current selected and displayed asset for the wallet.
Variables:
-
currAssetCodeString that is the current asset code (Examples: XLM, BTC, CAD, PTS) -
currAssetNameString that is the current asset name (Examples: Stellar Lumens, Bitcoin, Canadian Dollar, Blockpoints) -
currAssetIssuerString that is the public address of the issuer of the current asset (Example: none for XLM, , ) -
minimumBalanceMinimumBalance object calculated from number of trustlines, signers, and offers. -
pinString that is the login PIN (this is required for making account operations that require PIN but we have chosen to cache it so we don't need to request it again: specifically for ChangeTrustline and JoinInflation)
Methods:
-
fun getFormattedCurrentAssetCode() : StringReturns a formatted current asset code "BTC" -
fun getAvailableBalance(): StringReturns unformatted available balance "1.2000" -
fun getFormattedCurrentAvailableBalance(): StringReturns a formatted current available balance. "Available: 1.2000 BTC"
AccountUtils is a class that provides static methods for getting important Stellar account data.
Methods:
-
fun getSecretSeed() : CharArrayReturns the secret seed for the Stellar account, used for network calls and showing the secret seed -
fun getDecryptedMnemonicPhrasePair(encryptedPhrase: String, masterKey: java.security.KeyPair) : Pair<String, String?>Returns a Pair where the first String is the decrypted mnemonic phrase and the second String is the passphrase (if the account was not recovered with a passphrase, then this value is null) -
fun getTotalBalance(type : String) : StringReturns the total balance of Stellar Lumens of the account -
fun getPinMasterKey(pin: String) : java.security.KeyPair?Returns the RSA KeyPair used to decrypt the mnemonic phrase -
fun getKeyPair(recoveryString: String, passphrase: String?) : KeyPairReturns the Stellar KeyPair -
fun calculateAvailableBalance(): StringCalculates the available balance of the account by substracting minimum balance from the total balance
NetworkUtils provides methods for checking network status and displaying network errors to the user.
Methods:
-
fun isNetworkAvailable(): BooleanReturnstrueif the network is available, elsefalse -
fun displayNoNetwork()Displays a toast explaining a no network error
StringFormat provides static formatting functions.
Methods:
-
fun getFormattedDate(str: String): StringConsumes a UTC-Instant string date and returns a formattedMMM dd, uuuustring -
fun truncateDecimalPlaces(string: String?): StringRounds the input string number to 4 decimal places -
fun getNumDecimals(num: String): IntCalculate the number of decimals of a string -
fun hasDecimalPoint(text: String): BooleanChecks whether a string has a comma or not -
fun formatAssetCode(assetCode: String): StringConvertsnativetoxlm, otherwise returns the same asset code
Horizon provides all the network calls to the Horizon Stellar api.
Methods:
-
LoadAccountTaskGets account info, including balance -
LoadEffectsTaskGets the account effects list (account transactional/activity history) -
SendTaskSends a payment to a destination address -
JoinInflationDestinationSets the inflation destination address -
ChangeTrustChanges the trustline for an asset
How to launch: Call BaseActivity.launchPINView() specifying the type of PIN situation to use
PinTypes and what logic is applied after PIN is validated:
- CREATE: Creates a new stellar keypair from mnemonic phrase
- LOGIN: Launches the MainActivity
- VIEW_PHRASE: Launches ShowMnemonicActivity
- VIEW_SEED: Launches ViewSecretSeedActivity
- CLEAR_WALLET: Wipes all shared preferences and returns to LoginActivity
- CHECK: Returns secret seed to the calling activity
Create a Pin listener callback when launching the PinActivity and returns the secret seed that can be used for Horizon calls
- Right now using Volley for 1 network request to our own BlockEQ api that is outside of the Horizon SDK calls
AssetsActivity.kt > loadSupportedAssets()- This can be refactored to use Retrofit2, and remove Volley from the project
Things to add for app:
- Dependency injection (dagger)
- Kotlin coroutines instead of Asynctasks
- Retrofit2 as mentioned in networking