On this page

latest contributor to this doc

Last Edit:

@smk762β†—

Task: Get New Address

API-v2task::get_new_address::init

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 are running KDF in HD mode, and don't already have too many unused addresses, you can use the get_new_address method to generate a new address. The generated address will be shown in the task::account_balance RPCs and at 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

task::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": "DOC",
    "account_id": 0,
    "chain": "External",
    "gap_limit": 20
  }
}
API-v2task::get_new_address::status

Use the task::get_new_address::status method to check the status of a HD address creation task.

ParameterTypeDescription
task_idintegerThe identifying number returned when initiating the task.
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 NewAddressesInfo object.

task::get_new_address::status

POST
task::get_new_address::status
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::get_new_address::status",
  "params": {
    "task_id": 3
  }
}
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.

task::get_new_address::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.

task::get_new_address::cancel

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