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 user settings. Used 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’, or ‘privacy.show_as_sender’.
  • value (String) –

    the new value to set.

    • For “tx_limits”: {total: amount, per_tx: amount_per_tx, is_fiat: Boolean} * Per transaction values are not currently supported. * Fiat values should be passed as the amount * 100, e.g.
      10.50 USD should be passed as 1050.
    • 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 the users current spending limits.
Check usage on Github: JS Example
Returns:{‘total’: satoshis, ‘per_tx’: satoshis, ‘is_fiat’: Boolean}
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 GreenAddress account.

This call is used to register and create an account for a new user.
The caller should create a new BIP32 wallet and pass its master
pubkey and chaincode so that the service can generate and monitor
addresses for the wallet.

user_agent is free form ASCII text beginning with a capabilities
string surrounded by ‘[]’. As the value is logged by the service
it should not contain privacy sensitive or secret information.
Currently the caller must pass ‘[v2,sw]’ to indicate that they
are using the latest API version and support segwit addresses.

wallet_path is a 32 byte, hex encoded string which the service uses
when deriving server side keys for the users transactions. In order
to ensure that the path is unique, and to enable correct recovery of
funds, this data must be produced using the following algorithm:

1. Compute the master BIP 32 key from the users mnemonics (M)
2. Derive a child key from M using child number 0x80004741 (M’)
3. Note that the child derivation above is a BIP32 hardened deriviation
4. Create a binary buffer from hex ‘477265656e416464726573732e69742048442077616c6c65742070617468’ (S)
5. Append M’.chaincode and M’.pubkey into binary buffer (B)
6. Compute HMAC-SHA512(S, B)
7. The result of step 6 is the wallet path.
Parameters:
  • master_public (String) – public key in compressed sec format, hex-encoded
  • master_chaincode (String) – 32 byte chaincode, hex-encoded
  • user_agent (String) – Client features, name and version
  • wallet_path (String) – Derived wallet path for the user, hex-encoded
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. {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 users pricing source currency.
Note that changing the currency resets the users spending limits if
any are set in fiat.
Check usage on Github: JS Example
Parameters:String (currency) –
Returns:success
Return type:Boolean
Raises:#exchangecurrencynotsupported
com.greenaddress.login.set_exchange(exchange)
Change the users pricing source.
Note that changing the exchange resets the users spending limits if
any are set in fiat.
Check usage on Github: JS Example
Parameters:String (currency) –
Returns:success
Return type:Boolean
Raises:#exchangecurrencynotsupported
com.greenaddress.login.set_gait_path(wallet_path)
com.greenaddress.login.set_nlocktime(nlocktime[, twofac_data])
Set the number of blocks after which nLockTime transactions become spendable.
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.
Note that changing the pricing source resets the users spending limits if
any are set in fiat.
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)
com.greenaddress.login.watch_only_v2(token_type, token, user_agent)
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) – ‘custom’
  • String – login token value * for ‘custom’: {username: String, password: String}
  • user_agent (String) – client name and version