Task: Get New Address#
task::get_new_address::initAPI-v2 task::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.
Note
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`.
Arguments#
Parameter Type Description coin string The ticker of the coin you want to get a new address for account_id integer Generally this will be 0 unless you have multiple accounts registered on your Trezor chain string Internal, 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_limit integer Optional. The maximum number of empty addresses in a row. Defaults to the value provided on activation or 20 if no value was provided
Response#
Parameter Type Description new_address object A 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
📌 Examples#
Command#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::init" ,
"params" : {
"coin" : "DOC" ,
"account_id" : 0 ,
"chain" : "External" ,
"gap_limit" : 20
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::get_new_address::init",
"params": {
"coin": "DOC",
"account_id": 0,
"chain": "External",
"gap_limit": 20
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::init" ,
"params" : {
"coin" : "DOC" ,
"account_id" : 0 ,
"chain" : "External" ,
"gap_limit" : 20
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::init" ,
"params" : {
"coin" : "DOC" ,
"account_id" : 0 ,
"chain" : "External" ,
"gap_limit" : 20
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::init" ,
"params" : {
"coin" : "DOC" ,
"account_id" : 0 ,
"chain" : "External" ,
"gap_limit" : 20
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"task::get_new_address::init","params":{"coin":"DOC","account_id":0,"chain":"External","gap_limit":20}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::init" ,
"params" : {
"coin" : "DOC" ,
"account_id" : 0 ,
"chain" : "External" ,
"gap_limit" : 20
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Response Response (success)# {
"mmrpc" : "2.0" ,
"result" : {
"task_id" : 3
},
"id" : null
}
task::get_new_address::statusAPI-v2 task::get_new_address::status #
Use the task::get_new_address::status method to check the status of a HD address creation task.
Parameter Type Description task_id integer The identifying number returned when initiating the task. forget_if_finished boolean If false, will return final response for completed tasks. Optional, defaults to true.
Response#
Parameter Type Description status string Status of the task. Ok, InProgress or Error. details string or object Once complete, a standard NewAddressesInfo object.
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::status" ,
"params" : {
"task_id" : 3
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "task::get_new_address::status",
"params": {
"task_id": 3
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::status" ,
"params" : {
"task_id" : 3
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::status" ,
"params" : {
"task_id" : 3
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::status" ,
"params" : {
"task_id" : 3
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"task::get_new_address::status","params":{"task_id":3}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "task::get_new_address::status" ,
"params" : {
"task_id" : 3
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Response {
"mmrpc" : "2.0" ,
"result" : {
"status" : "Ok" ,
"details" : {
"new_address" : {
"address" : "RDKyU11wFTa8kYETaDbr4YuJZG8C4e6JUm" ,
"derivation_path" : "m/44'/141'/0'/0/3" ,
"chain" : "External" ,
"balance" : {
"DOC" : {
"spendable" : "0" ,
"unspendable" : "0"
}
}
}
}
},
"id" : null
} {
"mmrpc" : "2.0" ,
"result" : {
"status" : "Ok" ,
"details" : {
"new_address" : {
"address" : "0xAcDf1eb42FF03F5a2aCFc4B40CBDE459A515498A" ,
"derivation_path" : "m/44'/60'/0'/0/1" ,
"chain" : "External" ,
"balance" : {
"ETH" : {
"spendable" : "0" ,
"unspendable" : "0"
},
"USDT-ERC20" : {
"spendable" : "0" ,
"unspendable" : "0"
},
"XRP-ERC20" : {
"spendable" : "0" ,
"unspendable" : "0"
}
}
}
}
},
"id" : null
}
task::get_new_address::user_actionAPI-v2 task::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
Arguments#
Parameter Type Description task_id integer The identifying number returned when initiating the task. user_action object Object containing the params below user_action.action_type string Will be TrezorPin for this method user_action.pin string (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.
Response#
Parameter Type Description result string The outcome of the request.
📌 Examples#
Command#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"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"
}
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"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"
}
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"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"
}
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"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"
}
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"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"
}
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"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"}}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"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"
}
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Response Response (success)# {
"mmrpc" : "2.0" ,
"result" : "success" ,
"id" : null
}
task::get_new_address::cancelAPI-v2 task::get_new_address::cancel #
If you want to cancel the enabling process before it has completed, you can use this method.
Arguments#
Structure Type Description task_id integer The identifying number returned when initiating the enabling process.
Response#
Structure Type Description result string Indicates task cancellation was succesful. error string An error message to explain what went wrong. error_path string An indicator of the class or function which reurned the error. error_trace string An indicator of where in the source code the error was thrown. error_type string An enumerated value for the returned error. error_data string The input task ID which resulted in the error.
📌 Examples#
Command#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"method" : "task::get_new_address::cancel" ,
"mmrpc" : "2.0" ,
"params" : {
"task_id" : 3
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"method": "task::get_new_address::cancel",
"mmrpc": "2.0",
"params": {
"task_id": 3
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"method" : "task::get_new_address::cancel" ,
"mmrpc" : "2.0" ,
"params" : {
"task_id" : 3
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"method" : "task::get_new_address::cancel" ,
"mmrpc" : "2.0" ,
"params" : {
"task_id" : 3
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"method" : "task::get_new_address::cancel" ,
"mmrpc" : "2.0" ,
"params" : {
"task_id" : 3
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","method":"task::get_new_address::cancel","mmrpc":"2.0","params":{"task_id":3}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"method" : "task::get_new_address::cancel" ,
"mmrpc" : "2.0" ,
"params" : {
"task_id" : 3
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Response Response (success)# {
"mmrpc" : "2.0" ,
"result" : "success" ,
"id" : null
}