On this page

task::enable_bch

API-v2task::enable_bch::init

BCH and SLP tokens can be activated in a task managed manner using this method.

ParameterTypeDescription
tickerstringTicker of the platform protocol coin. Options: BCH or tBCH
bchd_urlsarray of stringsA list of BCHD gRPC API server URLs, used for validation of SLP token transactions. It's recommended to add as many servers as possible. The URLs list can be found at https://bchd.fountainhead.cash/.
modeobjectA standard ActivationMode object.
tx_historybooleanIf true, spawns a background loop to store the local cache of address(es) transactions. Defaults to false.
slp_tokens_requestsarray of objectsA list of standard TokensRequest objects.
address_formatobjectOptional. Overwrites the address format from coins file, if set. A standard AddressFormat object.
allow_slp_unsafe_confbooleanOptional, defaults to false. If true, allows bchd_urls to be empty. Warning: it is highly unsafe to do so as it may lead to invalid SLP transactions generation and tokens burning.
get_balancesbooleanOptional, defaults to true. If false, coin and token balances will not be returned in the response, and the response will be returned more quickly.
required_confirmationsintegerOptional, defaults to value in the coins file, or 3 if not set. Confirmations to wait for steps in swap.
requires_notarizationbooleanOptional, defaults to true. Has no effect on BCH.
tx_historybooleanOptional, defaults to true. If true the Komodo DeFi Framework API will preload transaction history as a background process. Must be set to true to use the my_tx_history method
utxo_merge_paramsobjectA standard UtxoMergeParams object. Used to reduce a wallet's UTXO count in cases where it is causing significantly slower RPC responses.

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

POST
task::enable_bch::init
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::enable_bch::init",
  "params": {
    "ticker": "BCH",
    "activation_params": {
      "bchd_urls": [
        "https://bchd.dragonhound.info"
      ],
      "mode": {
        "rpc": "Electrum",
        "rpc_data": {
          "servers": [
            {
              "url": "bch.imaginary.cash:50002",
              "protocol": "SSL"
            },
            {
              "url": "cashnode.bch.ninja:50002",
              "protocol": "SSL"
            },
            {
              "url": "bch.soul-dev.com:50002",
              "protocol": "SSL"
            },
            {
              "url": "electrum3.cipig.net:20055",
              "protocol": "SSL"
            }
          ]
        }
      },
      "slp_tokens_requests": [
        {
          "ticker": "USDF"
        },
        {
          "ticker": "ASLP-SLP",
          "required_confirmations": 3
        }
      ],
      "tx_history": true,
      "required_confirmations": 5,
      "requires_notarization": false,
      "address_format": {
        "format": "cashaddress",
        "network": "bitcoincash"
      },
      "utxo_merge_params": {
        "merge_at": 50,
        "check_every": 10,
        "max_merge_at_once": 25
      }
    }
  }
}
API-v2task::enable_bch::status

After running the task::enable_bch::init method, we can query the status of activation to check its progress. The response will return the following:

  • Result of the task (success or error)
  • Progress status (what state the task is in)
  • Required user action (what user should do before the task can continue)

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

POST
task::enable_bch::status
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::enable_bch::status",
  "params": {
    "task_id": 0,
    "forget_if_finished": false
  }
}

ParameterTypeDescription
statusstringA short indication of how the requested process is progressing.
details.resultobjectDepending on the state of process progress, this will contain different information as detailed in the items below.
.tickerstringThe ticker of the coin being activated
.current_blockintegerThe block height of the coin being activated
.wallet_balanceobjectInformation about the addresses of the coin being activated
..wallet_typestringIn Trezor mode, this will return HD
..accountslistA list of addresses and related information for the coin being activated
...account_indexintegerACCOUNT_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path. Please don't confuse with kdf global Iguana/HD/HW account.
...derivation_pathstringDerivation path up to the COIN child. E.g. "m/44'/141'/0'"
...total_balanceobjectCombined total spendable and unconfirmed balances of all account addresses
....spendablestring(numeric)Combined total spendable balance of all account addreesses
....unspendablestring(numeric)Combined total unspendable balance of all account addreesses
...addresseslistA list of addresses in the account for the coin being activated
....addressstringOne of the addresses in the account for the coin being activated
....derivation_pathstringThe BIP44 derivation path of the address.
....chainstringReturns External when CHAIN=0 in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID derivation path. Returns Internal when CHAIN=1 in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID derivation path. 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.
....balanceobjectContains the spendable and unspendable balance for this address
.....spendablestring(numeric)Spendable balance for this address
.....unspendablestring(numeric)Unspendable balance for this address (e.g. from unconfirmed incoming transactions)

ParameterTypeDescription
statusstringA short indication of how the requested process is progressing.
details.resultobjectDepending on the state of process progress, this will contain different information as detailed in the items below.
.tickerstringThe ticker of the coin being activated
.current_blockintegerThe block height of the coin being activated
.wallet_balanceobjectInformation about the addresses of the coin being activated
..wallet_typestringIn Trezor mode, this will return HD
..addressstringOne of the addresses in the account for the coin being activated
..balanceobjectContains the spendable and unspendable balance for this address
...spendablestring(numeric)Spendable balance for this address
...unspendablestring(numeric)Unspendable balance for this address (e.g. from unconfirmed incoming transactions)

ParameterTypeDescription
statusstringWill return InProgress if task is not yet comepleted
detailsstringAn indication of the current step of the activation process

Possible In Progress Cases:

  • ActivatingCoin: The first step of activation. It does not require any action from the user.
  • RequestingWalletBalance: The first step of activation, while initial balances info is being requested. It does not require any action from the user.
  • Finishing: Activation process completed
  • WaitingForTrezorToConnect: Waiting for the user to plugin a Trezor device
  • FollowHwDeviceInstructions: Waiting for the user to follow the instructions on the device

ParameterTypeDescription
statusstringA short indication of how the requested process is progressing.
details.resultobjectDepending on the state of process progress, this will contain different information as detailed in the items below.
.errorstringThe ticker of the coin being activated
.error_pathstringUsed for debugging. A reference to the function in code base which returned the error
.error_tracestringUsed for debugging. A trace of lines of code which led to the returned error
.error_typestringAn enumerated error identifier to indicate the category of error
.error_datastringAdditonal context for the error type

Possible Error Cases:

  • TaskTimedOut - Timed out waiting for coin activation, connecting to the device trezor or for user to confirm pubkey)
  • CoinCreationError - Error during activation. E.g. incorrect or inactive electrum servers.
  • HwError - This is the most important error type. Unlike other error types, HwError requires the GUI / User to check the details in error_data field to know which action is required. View the HwError error type details for more info.
API-v2task::enable_bch::user_action

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

ParameterTypeDescription
task_idintegerThe identifying number returned when initiating the initialisation process.
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.

POST
task::enable_bch::user_action
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::enable_bch::user_action",
  "params": {
    "task_id": 0,
    "user_action": {
      "action_type": "TrezorPin",
      "pin": "862743"
    }
  }
}
API-v2task::enable_bch::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.
POST
task::enable_bch::cancel
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::enable_bch::cancel",
  "mmrpc": "2.0",
  "params": {
    "task_id": 3
  }
}