On this page

latest contributor to this doc

Last Edit:

@smk762

get_private_keys

The get_private_keys method provides unified offline private key export functionality, with optional HD support. There are two export modes: iguana and hd. The mode to be used should match the MM2.json enable_hd configuration. This method supports various coin protocols including UTXO-based coins (Bitcoin, Komodo, etc.), Ethereum-based tokens, Tendermint-based coins, and ZHTLC.

StructureTypeDescription
coinsarray of stringsarray of coin tickers to export private keys for
modestring (optional)export mode: "hd" for HD wallet export, "iguana" for legacy Iguana format. Defaults based on MM2.json config
start_indexinteger (optional)"mode": hd only. starting address index for HD mode (default: 0).
end_indexinteger (optional)"mode": hd only. ending address index for HD mode (default: start_index + 10).
account_indexinteger (optional)"mode": hd only. account index for HD derivation path (default: 0).

The response format depends on the mode value:

StructureTypeDescription
resultarray of HdCoinKeysarray of coin key information with HD derivation data

StructureTypeDescription
resultarray of IguanaKeysInfoarray of coin key information in Iguana format

For detailed information about the structure fields and examples for different coin types (UTXO, ETH, ZHTLC, Tendermint), refer to the HdKeysInfo and IguanaKeysInfo common structures.

  • This method replaces the legacy show_priv_key, and works with coins that are not currently activated in MM2 (as long as they are in the coins configuration).
  • For HD mode, the maximum range is 100 addresses per request to prevent excessive resource usage. Make multiple requests if you need more addresses.
  • For HD mode, keys from any account or address index are available for any coin which includes a derivation_path value in the coins configuration.
  • ZHTLC coins like ARRR include additional viewing_key field in HD mode responses for enhanced privacy features.

POST
get_private_keys
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "get_private_keys",
  "params": {
    "mode": "hd",
    "coins": [
      "KMD",
      "ETH",
      "ARRR",
      "ATOM",
      "LTC-segwit"
    ],
    "start_index": 0,
    "end_index": 1,
    "account_index": 0
  }
}

POST
get_private_keys
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "get_private_keys",
  "coins": [
    "KMD",
    "ETH",
    "ARRR",
    "ATOM",
    "LTC-segwit"
  ],
  "mode": "iguana"
}

Error TypeDescription
HdRangeTooLargeend_index must not be > 100 higher than start_index
InvalidHdRangestart_indexmust be ≤ end_index
InvalidRequeststart_index, end_index or account_index value must not be negative
KeyDerivationFailedMany causes, see examples below for more information
CoinConfigNotFoundRequested coin does not exist in coins configuration
InvalidParametersForModeHD-specific parameters provided when using Iguana mode