On this page

latest contributor to this doc

Last Edit:

@smk762β†—

Hierarchical 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.

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.

For hardware wallets (e.g. Trezor), you need to use the task based address creation methods: task::get_new_address::init, task::get_new_address::status, task::get_new_address::user_actionandtask::get_new_address::cancel`.

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. Defaults to External. External is used for addresses that are intended 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 to return the leftover change from a transaction.
gap_limitintegerOptional. The maximum number of empty addresses in a row. Defaults to the value provided on activation or 20 if no value was provided

ParameterTypeDescription
new_addressobjectA standard NewAddressInfo object.

Some 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": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "get_new_address",
  "params": {
    "coin": "DOC",
    "account_id": 0,
    "chain": "External",
    "gap_limit": 20
  }
}
API-v2task::get_new_address::init

POST
task::get_new_address::init
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::get_new_address::init",
  "params": {
    "coin": "KMD",
    "account_id": 0
  }
}
API-v2task::get_new_address::status

ParameterTypeDescription
task_idintegerThe identifying number returned when initiating the task.

Status

POST
task::get_new_address::status
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::get_new_address::status",
  "params": {
    "task_id": 2
  }
}
API-v2task::get_new_address::user_action

If the task::get_new_address::status returns UserActionRequired, we need to use the task::get_new_address::user_action method to enter our PIN

ParameterTypeDescription
task_idintegerThe identifying number returned when initiating the task.
user_actionobjectObject containing the params below
user_action.action_typestringWill be TrezorPin for this method
user_action.pinstring (number)When the Trezor device is displaying a grid of numbers for PIN entry, this param will contain your Trezor pin, as mapped through your keyboard numpad. See the image below for more information.
Trezor Pin

ParameterTypeDescription
resultstringThe outcome of the request.

User Action

POST
task::get_new_address::user_action
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::get_new_address::user_action",
  "params": {
    "task_id": 0,
    "user_action": {
      "action_type": "TrezorPin",
      "pin": "862743"
    }
  }
}
API-v2task::get_new_address::cancel

If you want to cancel the enabling process before it has completed, you can use this method.

StructureTypeDescription
task_idintegerThe identifying number returned when initiating the enabling process.

StructureTypeDescription
resultstringIndicates task cancellation was succesful.
errorstringAn error message to explain what went wrong.
error_pathstringAn indicator of the class or function which reurned the error.
error_tracestringAn indicator of where in the source code the error was thrown.
error_typestringAn enumerated value for the returned error.
error_datastringThe input task ID which resulted in the error.

Cancel

POST
task::get_new_address::cancel
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::get_new_address::cancel",
  "mmrpc": "2.0",
  "params": {
    "task_id": 3
  }
}

ParameterTypeDescription
coinstringThe ticker of the coin you want to scan addresses for
account_idintegerOptional, HD wallets only. Generally this will be 0 unless you have multiple accounts registered on your HD wallet
gap_limitintegerOptional. The maximum number of empty addresses in a row. Defaults to the value provided on activation or 20 if no value was provided

ParameterTypeDescription
task_idintegerAn identifying number which is used to query task status.

POST
get_new_address
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::scan_for_new_addresses::init",
  "params": {
    "coin": "DGB",
    "account_index": 0,
    "gap_limit": 20
  }
}

Use the task::scan_for_new_addresses::status method to query the status of a HD address scanning task.

ParameterTypeDescription
task_idintegerThe identifying number returned when initiating the withdrawal process.
forget_if_finishedbooleanIf false, will return final response for completed tasks. Optional, defaults to true.

ParameterTypeDescription
statusstringStatus of the task. Ok, InProgress or Error.
detailsstring or objectOnce complete, a standard ScanAddressesInfo object.

POST
get_new_address
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::scan_for_new_addresses::status",
  "params": {
    "task_id": 3
  }
}