On this page

latest contributor to this doc

Last Edit:

@gcharang

Withdraw Tasks

API-v2task::withdraw::init

The task::withdraw::init method generates, signs, and returns a transaction that transfers the amount of coin to the address indicated in the to argument. The status of this method can be queried via the withdraw_status method.

It will return the transaction hex (via task::withdraw::status), which then needs to be broadcast with the sendrawtransaction to complete the withdrawal. This method is uses the same input fields as the standard v2 withdraw method, with additional optional fields to specify the from address when using a hardware or HD wallet. There are two way to indicate which HD address to send funds from:

  • Using derivation_path as a single input. E.g m/44'/20'/0'/0/2
  • Using account_id (0), chain (External) & address_id (2) inputs. The bracketed values are the equavalent of the derivation path above.

To cancel the transaction generation, use the withdraw_cancel method.

When used for ZHTLC coins like ARRR or ZOMBIE, it may take some time to complete.

StructureTypeDescription
coinstringThe name of the coin the user desires to withdraw
tostringCoins are withdrawn to this address
amountstring (numeric)The amount the user desires to withdraw, ignored when max=true
memostringOptional, used for ZHTLC and Tendermint coins only. Attaches a memo to the transaction.
fromstringOptional, used only for transactions using a hardware wallet. For more information, see the Trezor Integration guide
from.derivation_pathstringOptional, HD wallets only. Follows the format m/44'/COIN_ID'/ACCOUNT_ID'/CHAIN/ADDRESS_ID
from.account_idintegerOptional, HD wallets only. Generally this will be 0 unless you have multiple accounts registered on your HD wallet
from.chainstringOptional, HD wallets only. Internal, or 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.
from.address_idintegerOptional, HD wallets only. Check the output from coin activation to find the ID of an address with balance.
maxboolOptional. Withdraw the maximum available amount. Defaults to false
feeobjectOptional. Used only to set a custom fee, otherwise fee value will be derived from a deamon's estimatefee (or similar) RPC method
fee.typestringType of transaction fee; possible values: UtxoFixed or UtxoPerKbyte
fee.amountstring (numeric)Fee amount in coin units, used only when type is UtxoFixed (fixed amount not depending on tx size) or UtxoPerKbyte (amount per Kbyte)

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

POST
task::withdraw::init
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "RECIPIENT_ADDRESS",
    "amount": "AMOUNT"
  },
  "id": 0
}

POST
task::withdraw::init
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "RECIPIENT_ADDRESS",
    "max": true
  },
  "id": 0
}

POST
task::withdraw::init
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "RECIPIENT_ADDRESS",
    "amount": "AMOUNT",
    "fee": {
      "type": "UtxoFixed",
      "amount": "0.001"
    }
  },
  "id": 0
}

POST
task::withdraw::init
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "RECIPIENT_ADDRESS",
    "amount": "AMOUNT",
    "fee": {
      "type": "UtxoPerKbyte",
      "amount": "0.00097"
    }
  },
  "id": 0
}

POST
task::withdraw::init
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "ADDRESS_OF_RECIPIENT",
    "amount": "AMOUNT_TO_SEND",
    "from": {
      "derivation_path": "DERIVATION_PATH"
    }
  }
}

POST
task::withdraw::init
{
  "userpass": "RPC_UserP@SSW0RD",
  "mmrpc": "2.0",
  "method": "task::withdraw::init",
  "params": {
    "coin": "COIN_NAME",
    "to": "ADDRESS_OF_RECIPIENT",
    "amount": "AMOUNT_TO_SEND",
    "from": {
      "account_id": 0,
      "chain": "External",
      "address_id": "ADDRESS_ID"
    }
  }
}
API-v2task::withdraw::status

To get the status of your withdrawal transaction generation, use the task::withdraw::status method. Once ready, it will provide the raw hex used to broadcast your transaction with sendrawtransaction. The response returned is the same as what is returned from the standard v2 withdraw method

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

StructureTypeDescription
statusstringA short indication of how the withdrawal is progressing.
detailsobjectDepending on the state of withdrawal progress, this will contain different information as shown in the responses below.
details.toarray of stringsCoins are withdrawn to these addresses; this may contain the my_address address, where change from UTXO coins is sent.
details.fromarray of stringsCoins are withdrawn from this address; the array contains a single element, but transactions may be sent from several addresses (UTXO coins)
details.my_balance_changestring (numeric)the expected balance of change in my_address after the transaction broadcasts
details.received_by_mestring (numeric)the amount of coins received by my_address after the transaction broadcasts; the value may be above zero when the transaction requires that the Komodo DeFi Framework API send change to my_address
details.spent_by_mestring (numeric)the amount of coins spent by my_address; this value differ from the request amount, as the transaction fee is added here
details.total_amountstring (numeric)the total amount of coins transferred
details.fee_detailsobjectthe fee details of the generated transaction; fee_details.type is "Utxo" for Z coins. fee_details.coin will be the same as details.coin, and fee_details.amount will be a numeric value.
details.tx_hashstringthe hash of the generated transaction
details.tx_hexstringtransaction bytes in hexadecimal format; use this value as input for the send_raw_transaction
details.coinstringthe name of the coin the user wants to withdraw
details.transaction_typestringTransaction type will be StandardTransfer for Z coin transactions.
details.kmd_rewardsobject (optional)If supported (e.g. when withdrawing KMD), an object containing information about accrued rewards.
details.kmd_rewards.amountstring (numeric, optional)The amount of accrued rewards
details.kmd_rewards.claimed_by_mebool (optional)Whether or not the rewards been claimed by me.

POST
task::withdraw::status
{
  "mmrpc": "2.0",
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::status",
  "params": {
    "task_id": 3,
    "forget_if_finished": false
  },
  "id": 0
}
API-v2task::withdraw::cancel

Use the task::withdraw::cancel method to cancel the withdrawal preparation task.

StructureTypeDescription
task_idintegerThe identifying number returned when initiating the withdraw 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::withdraw::cancel
{
  "userpass": "RPC_UserP@SSW0RD",
  "method": "task::withdraw::cancel",
  "mmrpc": "2.0",
  "params": {
    "task_id": 6
  }
}