latest contributor to this doc

Last Edit: @smk762 ,

Heirarchical Deterministic Address Management

A hierarchical-deterministic (HD) wallet generates a new key pair from a master key pair, allowing for multiple addresses to be generated from the same seed so that change from transactions go to a previously unused address, enhancing privacy and security. The hierarchical structure resembles that of a tree, with the master key β€œdetermining” the key pairs that follow it in the hierarchy. If you have activated a coin with the task::enable_utxo::init or task::enable_qtum::init and used the "priv_key_policy": "Trezor" parameter, you can use the methods below to generate new addresses.

To avoid generating too many addresses at once, we can use a gap_limit constraint so that no more than a specific amount of unused addresses can be generated before more addresses can be generated.

ParameterTypeDescription
coinstringThe ticker of the coin you want to get a new address for
account_idintegerGenerally this will be 0 unless you have multiple accounts registered on your Trezor
chainstringInternal, or External. External is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving payments). Internal is used for addresses which are not meant to be visible outside of the wallet and is used for return transaction change.
gap_limitintegerThe maximum number of empty addresses in a row.

ParameterTypeDescription
resultstringReturns with value success when successful, otherwise returns the error values below
result.allowedbooleanWhether or not you can get a new address.
result.reasonstringThe reason you cant get a new address (if allowed is false).
result.detailsobjectContains extra contextual information about the reason why allowed is false
result.details.addressbooleanIf reason is LastAddressNotUsed, this is the address that should be used before you can get a new address.

Other reasons you might not be able to get a new address are:

  • EmptyAddressesLimitReached - Last gap_limit addresses are still unused.
  • AddressLimitReached - Addresses limit reached. Currently, the limit is 2^31

POST
can_get_new_address
{
  "userpass": "testpsw",
  "mmrpc": "2.0",
  "method": "can_get_new_address",
  "params": {
    "coin": "DOC",
    "account_id": 0,
    "chain": "External",
    "gap_limit": 20
  }
}

If we don't already have too many unused addresses, we can use the get_new_address method to generate a new address. The generated address will be shown in account_balance and init_account_balance RPCs and on the next coin activation.

ParameterTypeDescription
coinstringThe ticker of the coin you want to get a new address for
account_idintegerGenerally this will be 0 unless you have multiple accounts registered on your Trezor
chainstringInternal, or External. External is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving payments). Internal is used for addresses which are not meant to be visible outside of the wallet and is used for return transaction change.
gap_limitintegerThe maximum number of empty addresses in a row.

ParameterTypeDescription
resultstringReturns with value success when successful, otherwise returns the error values below
result.new_addressobjectContains details about your new address.
result.addressstringThe new address that was generated.
result.detailsobjectContains extra contextual information about the reason why allowed is false
result.details.addressbooleanIf reason is LastAddressNotUsed, this is the address that should be used before you can get a new address.
result.details.derivation_pathstringThe BIP44 derivation path of the address.
result.details.chainstringExternal or Internal External is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving payments). Internal is used for addresses which are not meant to be visible outside of the wallet and is used for return transaction change.
result.details.balanceobjectContains the spendable and unspendable balance for this address
result.details.balance.spendablestring(numeric)Spendable balance for this address
result.details.balance.unspendablestring(numeric)Unspendable balance for this address (e.g. from unconfirmed incoming transactions)

Other reasons you might not be able to get a new address are:

  • EmptyAddressesLimitReached - Last gap_limit addresses are still unused.
  • AddressLimitReached - Addresses limit reached. Currently, the limit is 2^31

POST
get_new_address
{
  "userpass": "testpsw",
  "mmrpc": "2.0",
  "method": "get_new_address",
  "params": {
    "coin": "DOC",
    "account_id": 0,
    "chain": "External",
    "gap_limit": 20
  }
}