login module

The login module gives different ways of logging in to your GreenAddress wallet. This module allows the user to authenticate against the server.

Also, initial settings, like the nLocktime and Fiat price source, are provided within the login process.

com.greenaddress.login

com.greenaddress.login.authenticate(signature, logout[, path_hex][, device_id][, user_agent])
Validates the signature of the challenge done using current wallet’s private key.
Check usage on Github: JS Example
Or see our simple Python Login example
Parameters:
  • signature (Array) –

    [r, s[, recid]] integers encoded as strings

    • recid is required for Trezor authentication only
  • logout (Boolean) – whether to force log out existing session of the same user
  • path_hex (String) –

    32 bit path for deriving subkey which was used for login

    • ‘GA’ if using constant m/0x4741b11e (m/1195487518) path and deterministic signatures
    • 16 hex chars if using 4 path components (soon to be deprecated)
  • device_id (String) – unique device identifier. When doing forced logout, user is not warned about having “logged in elsewhere” if the same device forced the logout.
  • user_agent (String) – client name and version
Returns:

{‘appearance’: JSON, ‘currency’: String, ‘exchange’: String, ‘receiving_id’: String, ‘expired_deposits’: Array, ‘nlocktime_blocks’: Number, ‘cache_password’: String, ‘gait_path’: hex, ‘privacy’: {...}, ‘limits’: {‘is_fiat’: Boolean, ‘total’: satoshis, ‘per_tx’: satoshis}, ‘earliest_key_creation_time’: Number}

com.greenaddress.login.available_currencies()
Returns a list of allowed currencies for all available pricing sources.
Check usage on Github: JS Example
Returns:{“all”: [list of all currencies], “per_exchange”: {pricing_source_name: [list of supported currencies]}}
com.greenaddress.login.change_settings(key, value[, twofac_data])
Change settings. Currently used only for privacy settings and transaction limits.
Check usage on Github: JS Example
Parameters:
  • key (String) – name of the value to change. Can be one of ‘tx_limits’, ‘privacy.send_me’, ‘privacy.show_as_sender’.
  • value (String) –

    the value to set.

    • for tx_limits: {total: satoshis, per_tx: satoshis, is_fiat: Boolean}
    • for privacy.send_me: one of:
      • 0 (PRIVATE)
      • 1 (ADDRBOOK)
      • 2 (PUBLIC)
    • for privacy.show_as_sender: one of:
      • 0 (PRIVATE)
      • 1 (MUTUAL_ADDRBOOK)
      • 2 (PUBLIC)
  • twofac_data – Two factor authentication data. Required to increase transaction limits. {method: ‘gauth’|’email’|’sms’|’phone’, code: String}
Returns:

success

Return type:

Boolean

com.greenaddress.login.create_session(token)
com.greenaddress.login.get_challenge(pubkey_hash)
Generate and return a challenge that must be signed for a successful authentication.
Check the usage on Github: JS Example or take a look at the Python mnemonic login example
Parameters:pubkey_hash (String) – address calculated from pubkey - base58
Returns:number to be signed from 0..2^256 range
Return type:Number
com.greenaddress.login.get_spending_limits()
Returns spending limits.
Check usage on Github: JS Example
Returns:{‘total’: satoshis, ‘per_tx’: satoshis}
com.greenaddress.login.get_trezor_challenge(pubkey_hash[, hw_nlocktime_support])
Generate and return a Trezor challenge that must be signed for a successful authentication.
A string ‘greenaddress.it      login ABCDE‘ (‘greenaddress.it’ + 6 spaces + the returned random token) must be signed to proceed with authentication.
Check usage on Github: JS Example
Or see our simple Python Login example
Parameters:
  • pubkey_hash (String) – address calculated from pubkey - base58
  • hw_nlocktime_support (Boolean) – whether the hw wallet supports nlocktime transactions
Returns:

random 5-character string to be signed

Return type:

String

com.greenaddress.login.register(master_public, master_chaincode[, user_agent][, wallet_path])
Create a new account.
Check usage on Github: JS Example
Parameters:
  • master_public (String) – public key in compressed sec format, hex-encoded
  • master_chaincode (String) – 32 byte chaincode, hex-encoded
  • user_agent (String) – client name and version
Returns:

boolean

com.greenaddress.login.remove_account(twofac_data)
Remove the account
Check the usage on Github: JS Example
Parameters:twofac_data – Two factor authentication data. Required to increase transaction limits. {method: ‘gauth’|’email’|’sms’|’phone’, code: String}
Returns:success
Return type:Boolean
com.greenaddress.login.set_appearance(appearance)
Update appearance settings.
Check usage on Github: JS Example
Parameters:appearance (JSON) – {“sound”: Boolean, “altimeout”: Number, “pgp”: String, “unit”: String (‘BTC’, ‘mBTC’, ‘µBTC’, ‘bits’ }
com.greenaddress.login.set_currency(currency)
Change the pricing source currency.
Check usage on Github: JS Example
Parameters:String (currency) –
Returns:success
Return type:Boolean
Raises:#exchangecurrencynotsupported
com.greenaddress.login.set_exchange(exchange)
Change the pricing source. GreenAddress indexes a large number of Bitcoin exchanges, and return to the user the preferred price.
Check usage on Github: JS Example
Parameters:String (currency) –
Returns:success
Return type:Boolean
Raises:#exchangecurrencynotsupported
com.greenaddress.login.set_gait_path(wallet_path)
Set the server-side subkey path. Required after first login.
The server-side subkey path is a unique per-user value used to derive server-side signing keys. This protects users’ privacy by ensuring the GreenAddress public key used for signing transactions is different for each user. The subkey path must be computed from the users mnemonics using::
HMAC-SHA512(“GreenAddress.it HD wallet path”, PBKDF2-HMAC-SHA512(mnemonic, “greenaddress_path”, 2048));

WARNING Using any other algorithm to calculate the subkey path will result in the user losing access to their funds.
Check the usage on Github: JS Example
Parameters:String (wallet_path) – The hash calculated by the algorithm given above, hex-encoded
com.greenaddress.login.set_nlocktime(nlocktime[, twofac_data])
Set the number of blocks after which nLockTime transaction is generated.
Check usage on Github: JS Example
Parameters:
  • nlocktime Number (Number) – Number of blocks
  • twofac_data (Array) – Two factor authentication data. {method: ‘gauth’|’email’|’sms’|’phone’, code: String}
Returns:

success

Return type:

Boolean

com.greenaddress.login.set_pricing_source(currency, exchange)
Change the pricing source and currency.
Check the usage on Github: JS Example
Parameters:
  • String (exchange) –
  • String – pricing source
Returns:

success

Return type:

Boolean

com.greenaddress.login.watch_only(token_type, token, logout)
Log in to watch-only mode. It is limited to 100 watch only logins per day.
Check usage on Github: JS Example
Or see our Python custom login example
Parameters:
  • String (token) – one of ‘facebook’, ‘reddit’, ‘custom’
  • String

    login token value

    • for ‘facebook’: FB access_token
    • for ‘reddit’: bearer token
    • for ‘custom’: {username: String, password: String}
  • Boolean (logout) – deprecated (currently multiple parallel watch only sessions are allowed, so there is no need to force logout here)