Skip to content

Latest commit

 

History

History
963 lines (780 loc) · 73.3 KB

File metadata and controls

963 lines (780 loc) · 73.3 KB

export const title = "Komodo DeFi SDK RPC Protocol v2.0"; export const description = "Starting with version beta-2.1.3434, the Komodo DeFi SDK supports the standardized protocol format called mmrpc 2.0.";

Komodo DeFi SDK RPC Protocol v2.0

Starting with version beta-2.1.3434, the Komodo DeFi SDK supports the standardized protocol format called mmrpc 2.0.

It includes a uniform request, successful and error response formats. At the moment, only a few RPC methods support the mmrpc 2.0 protocol.

Request

Structure Type Description
mmrpc string the string specifying the version of the Komodo DeFi SDK RPC protocol. Must be exactly "2.0"
userpass string (optional) your password for protected RPC methods. Skip this field if the specified method is public
method string the name of the method to be invoked
params object (optional) a structured value that holds the parameter values to be used during the invocation of the method. This field may be omitted if the method doesn't take arguments
id number (optional) the identifier is established by the client. Komodo DeFi SDK will reply with the same value in the Response object if the id field is included and not NULL

Response (Success)

Structure Type Description
mmrpc string the string specifying the version of the Komodo DeFi SDK RPC protocol
result object the value of this field is determined by the method invoked on Komodo DeFi SDK
id number (optional) the identifier established by the client. The same value as in the Request if it was passed

Response (Error)

Structure Type Description
mmrpc string the string specifying the version of the Komodo DeFi API RPC protocol
error string the common error description
error_path string the error path consisting of file names separated by a dot similar to JSON path notation
error_trace string the error path consisting of file and line number pairs separated by ']'
error_type string the string error identifier used to determine the cause of the error
error_data object an object containing the error data of the corresponding error_type
id number (optional) the identifier established by the client. The same value as in the Request if it was passed

📌 Examples

```json { "mmrpc": "2.0", "userpass": "RPC_UserP@SSW0RD", "method": "withdraw", "params": { "coin": "KMD", "to": "RJTYiYeJ8eVvJ53n2YbrVmxWNNMVZjDGLh", "amount": "10" }, "id": 0 } ``` #### Response (success)
{
  "mmrpc": "2.0",
  "result": {
    "tx_hex": "0400008085202f8901ef25b1b7417fe7693097918ff90e90bba1351fff1f3a24cb51a9b45c5636e57e010000006b483045022100b05c870fcd149513d07b156e150a22e3e47fab4bb4776b5c2c1b9fc034a80b8f022038b1bf5b6dad923e4fb1c96e2c7345765ff09984de12bbb40b999b88b628c0f9012102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ffffffff0200e1f505000000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ac8cbaae5f010000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ace87a5e5d000000000000000000000000000000",
    "tx_hash": "1ab3bc9308695960bc728fa427ac00d1812c4ae89aaa714c7618cb96d111be58",
    "from": ["R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW"],
    "to": ["R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW"],
    "total_amount": "60.10253836",
    "spent_by_me": "60.10253836",
    "received_by_me": "60.00253836",
    "my_balance_change": "-0.1",
    "block_height": 0,
    "timestamp": 1566472936,
    "fee_details": {
      "type": "Utxo",
      "amount": "0.1"
    },
    "coin": "DOC",
    "internal_id": ""
  },
  "id": 0
}
#### Response (error)
{
  "mmrpc": "2.0",
  "error": "The amount 0.000005 is too small",
  "error_path": "utxo_common",
  "error_trace": "utxo_common:1379] utxo_common:301]",
  "error_type": "AmountIsTooSmall",
  "error_data": {
    "amount": "0.000005"
  },
  "id": 0
}

Common Komodo DeFi SDK Request / Response Objects

The folowing objects are used in the request or response of multiple Komodo DeFi SDK methods.

ActivationParams

The ActivationParams object defines additional parameters used for activation. These params may vary depending on the coin type.

Parameter Type Description
required_confirmations integer Optional. Confirmations to wait for steps in swap. Defaults to value in the coins file if not set.
requires_notarization boolean Optional, defaults to false. For dPoW protected coins, a true value will wait for transactions to be notarised when doing swaps. Overrides value if set in coins file.
mode object QTUM, UTXO & ZHTLC coins only. A standard ActivationMode object.
zcash_params_path string ZHTLC coins only. Path to folder containing Zcash parameters. Optional, defaults to standard location as defined in this guide
scan_blocks_per_iteration integer ZHTLC coins only. Sets the number of scanned blocks per iteration during BuildingWalletDb state. Optional, default value is 1000.
scan_interval_ms integer ZHTLC coins only. Sets the interval in milliseconds between iterations of BuildingWalletDb state. Optional, default value is 0.
tx_history boolean Optional. Enable transaction history scanning. When active, the Komodo DeFi Framework API will collect transaction history data for local storage, and allow use of the my_tx_history (v2) method.
min_addresses_number integer Optional, HD wallets only. Number of addresses to generate. If not specified, addresses will be generated up to path_to_address::address_index.
scan_policy string Optional, HD wallets only. Whether or not to scan for new addresses. Select from do_not_scan, scan_if_new_wallet or scan. Defaults to scan_if_new_wallet. Note that scan will result in multple requests to the Komodo DeFi API and may take some time to complete.
gap_limit integer Optional, HD wallets only. The max number of empty addresses in a row. Transactions sent to an address outside the gap_limit, will not be identified when scanning. Defaults to 20.
path_to_address object Optional, HD wallets only. A standard AddressDerivationPath object.
get_balances boolean Optional, defaults to true. If false, coin and token balances will not be returned in the response, and the response will be returned more quickly.
Is priv\_key\_policy still a thing? Defaults to `ContextPrivKey`. Set as `Trezor` to activate in Trezor mode. For ZHTLC coins, older wallets need to set the `sync_params` field to a date before its first transaction to see all balance and history. This may take a long time on the first activation, but subsequent activations will be much faster. Using a smaller `scan_blocks_per_iteration` and larger `scan_interval_ms`, will reduce the average CPU load during ZHTLC coin activation (at the cost of a longer activation time). These optional fields are recommended when developing for iOS, where a high CPU load may kill the activation process. Android & desktop operating systems do not appear to have any problems with high CPU load during ZHTLC coin activation.

ActivationMode

Defines the activation mode for QTUM, BCH, UTXO & ZHTLC coins.

Parameter Type Description
rpc string Native if running a native blockchain node, Electrum if using electrum servers or Light for ZHTLC coins.
rpc_data object Electrum or Light mode only. A standard ActivationRpcData object.
```json { "mode": { "rpc": "Electrum", "rpc_data": { "servers": [ { "url": "electrum1.cipig.net:10020" }, { "url": "electrum2.cipig.net:10020" } ] } }, } ```

ActivationRpcData

Contains information about electrum & lightwallet_d servers for coins being used in Electrum or Light mode.

Parameter Type Description
light_wallet_d_servers list ZHTLC only. A list of urls which are hosting lightwallet_d servers for a coin.
electrum_servers list of objects ZHTLC only. A list of standard ActivationServers objects.
electrum list of objects QTUM, BCH & UTXO coins only. A list of standard ActivationServers objects.
sync_params integer or string ZHTLC coins only. Optional, defaults to two days ago. Defines where to start scanning blockchain data upon initial activation. Options: "earliest" (the coin's sapling_activation_height), height (a specific block height) or date (a unix timestamp).

ActivationServers

Contains information electrum servers for coins being used in Electrum or Light mode.

Parameter Type Description
url string The URL and port for an electrum server.
ws_url string Optional, for WSS only. The URL and port for an electrum server's WSS port.
protocol string Optional, defaults to TCP. Transport protocol used to connect to the server. Options: TCP or SSL
disable_cert_verification boolean Optional, defaults to false. If true, this disables server SSL/TLS certificate verification (e.g. for self-signed certificates). Use at your own risk!
#### ZHTLC Example
{
  "activation_params": {
    "mode": {
      "rpc": "Light",
      "rpc_data": {
        "electrum_servers": [
          {
            "url":"zombie.dragonhound.info:10033"
          }
        ],
        "light_wallet_d_servers": [
          "http://zombie.dragonhound.info:443"
        ]
      },
      "sync_params": { 
          "height":  2528700
      }
    },
    "zcash_params_path": "/home/username/path_to/.zcash-params",
    "scan_blocks_per_iteration": 100,
    "scan_interval_ms": 200
  }
}

HD UTXO Activation (v2)

{
"activation_params": {
    "mode": {
        "rpc": "Electrum",
        "rpc_data": {
            "servers": [
                {
                    "url": "electrum2.cipig.net:10001"
                },
                {
                    "url": "electrum3.cipig.net:20001",
                    "ws_url": "electrum3.cipig.net:30001",
                    "protocol": "SSL"
                }
            ]
        }
    },
    "scan_policy": "scan_if_new_wallet",
    "priv_key_policy": "Trezor",
    "min_addresses_number": 3,
    "gap_limit": 20
}
}

HD UTXO Activation (v2)

{
    "activation_params": {
        "mode": {
            "rpc": "Electrum",
            "rpc_data": {
                "servers": [
                    {
                        "url": "electrum2.cipig.net:10001"
                    },
                    {
                        "url": "electrum3.cipig.net:20001",
                        "ws_url": "electrum3.cipig.net:30001",
                        "protocol": "SSL"
                    }
                ]
            }
        },
        "scan_policy": "scan_if_new_wallet",
        "min_addresses_number": 3,
        "gap_limit": 20
    }
}

AddressDerivationPath

The AddressDerivationPath object defines the account / change / address_index of the derivation path used for your wallet. Using different values for account_id or address_id parameters will result in a different address and private key for each combination. The chain parameter is used to specify if the change from a transaction. Set to External 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.

Parameter Type Description
account_id integer Optional, defaults to 0. Used as a layer of separation or hierarchy.
chain string Optional. Accepted values are External (0) and Internal (1). Defaults to External.
address_id integer Optional, defaults to 0. Used as a layer of separation or hierarchy.
```json { "path_to_address": { "account_id": 0, "chain": "External", "address_id": 1 } } ```

AddressInfos

The addressInfos object includes the following items for a given address:

Parameter Type Description
balances object A standard BalanceInfo object. Not included in responses where get_balances is false
derivation_method object A standard DerivationMethod object
pubkey string The public key associated with the seed used to launch Komodo DeFi
tickers array A list of tokens which were successfully activated. Only included in responses where get_balances is false
#### Example with balances
"bitcoincash:qrf5vpn78s7rjexrjhlwyzzeg7gw98k7t5qx64fztj": {
    "derivation_method": {
        "type": "Iguana"
    },
    "pubkey": "036879df230663db4cd083c8eeb0f293f46abc460ad3c299b0089b72e6d472202c",
    "balances": {
        "spendable": "0.11398301",
        "unspendable": "0.00001"
    }
}

Example without balances

"bitcoincash:qrf5vpn78s7rjexrjhlwyzzeg7gw98k7t5qx64fztj": {
    "derivation_method": {
        "type": "Iguana"
    },
    "pubkey": "036879df230663db4cd083c8eeb0f293f46abc460ad3c299b0089b72e6d472202c",
    "tickers": ["ASLP-SLP"]
}

BalanceInfo

The balanceInfo object includes the following items for a given coin or token:

Parameter Type Description
spendable string (numeric) The available amount of a coin or token which is ready to be traded or withdrawn.
unspendable string (numeric) The amount of a coin or token which is awaiting confirmation on the block chain for an incoming or outgoing transaction.
```json { "spendable": "12.11398301", "unspendable": "0.53" } ```

DerivationMethod

The DerivationMethod object includes the following items for a given coin or token:

Parameter Type Description
type string Defines how keypairs will be generated. Possible values: Iguana or HDWallet
Using the same seed or private key to generate keypairs using different derivation methods will result in a different address and private key for each method.

Where the value indicates:

  • Iguana: The coin or token is was activated using Iguana derivation (default).
  • HDWallet: The coin or token is was activated using a Hierarchical Deterministic (HD) Wallet derivation path.
```json { "type": "Iguana" } ```

EvmNode

The EvmNode object includes the following items for a given coin or token:

Parameter Type Description
url string URL of an RPC node
gui_auth boolean Optional, defaults to false. Must be set to true to access RPC nodes run officially by the Komodo Platform team
```json { "url": "http://eth1.cipig.net:8555", "gui_auth": false } ```

CoinProtocol

Parameter Type Description
type integer One of the supported [coin types](link TBA)
protocol_data object A standard CoinProtocolData object.

CoinProtocolData

Parameter Type Description
platform string Indicates the platform parent coin for EMV-like protocols, or the coin used for lightning nodes.
network string Either mainnet or `testnet
confirmation_targets object A standard ConfirmationTargets object.

ConfirmationTargets

This object represents the number of blocks required for an on-chain lightning-related transaction to be confirmed. It is used for estimating the transaction fee rate (feerate) for different transaction types in the context of permissionless transactions performed by the node. Different target types are background, normal, and high_priority.

Parameter Type Description
background integer Used for transactions that can tolerate slower confirmation times when the transaction fee rate decreases. These transactions are not time-sensitive and can afford to wait longer for confirmation. The recommended range is 12 to 144 blocks to ensure a low feerate.
normal integer Used for transactions that we want to confirm promptly, without significant delay (e.g, transactions for opening payment channels). These transactions are important but not critical. Suggested value is 6 blocks to ensure a moderate feerate.
high_priority integer Used for transactions that require quick confirmation to prevent potential loss of funds (e.g. redeeming a Hashed Time Lock Contract (HTLC) on the blockchain before it times out). These transactions are time-critical and must be confirmed promptly to ensure the security of funds. Recommended value for high_priority is 1-2 blocks to ensure a high feerate.
Using the recommended values in the above table with a coin that has a block time of 10 minutes, the equivalent time in minutes is:
  • background: 120 minutes to 1440 minutes (2 hours to 1 day).
  • normal: 60 minutes (one hour).
  • high_priority: 10 to 20 minutes.

CounterpartyChannelConfig

Parameter Type Description
allow_outbound_0conf boolean Optional, defaults to true. When setting an outbound channel, it can be used straight away without waiting for any on-chain confirmations.
force_announced_channel_preference boolean Optional, defaults to true. Set to force an incoming channel to match our announced channel preference in ChannelOptions announced_channel.
outbound_channels_confirmations integer Optional, defaults to 144. Confirmations we will wait for before considering an inbound channel locked in.
our_locktime_limit boolean Optional, defaults to 2016. Set to the amount of blocks we're willing to wait to claim money back to us.
min_funding_sats boolean Optional, defaults to 0. Minimum allowed satoshis when an inbound channel is funded.
max_funding_sats boolean Optional, defaults to 16777215. Maximum allowed satoshis when an inbound channel is funded.
max_htlc_minimum_msat boolean Optional, defaults to 18446744073709551615. The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows us to limit the maximum minimum-size they can require.
min_max_htlc_value_in_flight_msat boolean Optional, defaults to 0. The remote node sets a limit on the maximum value of pending HTLCs to them at any given time to limit their funds exposure to HTLCs. This allows us to set a minimum such value.
max_channel_reserve_sats boolean Optional, defaults to 18446744073709551615. The remote node will require us to keep a certain amount in direct payment to ourselves at all time, ensuring that we are able to be punished if we broadcast an old state. This allows us to limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
min_max_accepted_htlcs boolean Optional, defaults to 0. The remote node sets a limit on the maximum number of pending HTLCs to them at any given time. This allows us to set a minimum such value.

FeeInfo

The FeeInfo response object includes the following items for withdraw (v2) requests:

Parameter Type Description
type string Type of transaction fee; possible values: UtxoFixed, UtxoPerKbyte, EthGas
amount string (numeric) Fee amount in coin units, used only when type is UtxoFixed (fixed amount not depending on tx size) or UtxoPerKbyte (amount per Kbyte)
gas_price string (numeric) Used only when fee type is EthGas; sets the gas price in gwei units
gas number (integer) Used only when fee type is EthGas; sets the gas limit for transaction

LightningActivationParams

Parameter Type Description
name string The name of the node that will be used in lightning explorers
listening port integer Optional, defaults to 9735. The port that this node listens for incoming connections on.
color string Optional, defaults to 2b6680. A hexidecimal color string which will be used in network graphs on lightning explorers
payment_retries integer Optional, defaults to 5. Number of times a payment will be retried if it fails.
backup_path string Optional. The backup path for channel backups, preferably on an external drive.

LightningChannelAmount

Parameter Type Description
type string Exact for a specific amount or Max for whole balance.
value object Only required if type is Exact. The amount in BTC you want to open the channel with.

LightningChannelConfig

The values in this object are only used if the channel is being opened by the user. If the channel is being opened by the counterparty, the values in this object are ignored. If not specified when using the [open\_channel](/komodo-defi-framework/api/v20-dev/lightning/channels/#open-channel) or [update\_channel](/komodo-defi-framework/api/v20-dev/lightning/channels/#update-channel) methods, the values in this object will default to the values set in the `coins` configuration file.
Parameter Type Description
inbound_channels_confirmations string Optional, defaults to 6. Should be set in coins file, and applies to all channels. Confirmations we will wait for before considering an inbound channel locked in.
max_inbound_in_flight_htlc_percent integer Optional, defaults to 10. Should be set in coins file, and applies to all channels. Sets the percentage of the channel value we will cap the total value of outstanding inbound HTLCs to.
our_htlc_minimum_msat integer Optional, defaults to 1. The smallest value HTLC we will accept to process. The channel gets closed any time our counterparty misbehaves by sending us an HTLC with a value smaller than this.
announced_channel boolean Optional, defaults to false. Set to announce the channel publicly and notify all nodes that they can route via this channel. GUIs and wallet apps should be set to false.
commit_upfront_shutdown_pubkey boolean Optional, defaults to true. When true (and the counterparty agrees), the user must use the same key for cooperative closing. This prevents a user from changing the destination address in a cooperative close, which slightly increases security (however, this option is not required if the counterparty does not support it and a channel can be accepted regardless). Note that the key for forced closing is always fixed when opening a channel and is different from shutdown_pubkey.
counterparty_locktime integer Optional, defaults to 144. The number of blocks we require our counterparty to wait to claim their money on chainif they broadcast a revoked transaction. We have to be online at least once during this time to punish our counterparty for broadcasting a revoked transaction. We have to account also for the time to broadcast and confirm our transaction, possibly with time in between to RBF (Replace-By-Fee) the spending transaction.
negotiate_scid_privacy integer Optional, defaults to false. If true, we attempt to negotiate the scid_privacy (referred to as scid_alias in the BOLTs) option for outbound private channels. This provides better privacy by not including our real on-chain channel UTXO in each invoice and requiring that our counterparty only relay HTLCs to us using the channel's SCID alias.
their_channel_reserve_sats boolean Optional, defaults to 10000 or 1% of channel value. The minimum balance that the other node has to maintain on their side, at all times. This ensures that if our counterparty broadcasts a revoked state, we can punish them by claiming at least this value on chain.
For GUIs and wallet apps, it is recommended to set `announced_channel` to `false` (the default value), as the node is not expected to be reliably online.

LightningChannelOptions

Parameter Type Description
proportional_fee_in_millionths_sats integer Optional, defaults to 0. Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in excess of proportional_fee_in_millionths_sats.
base_fee_msat integer Optional, defaults to 1000. Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in excess of proportional_fee_in_millionths_sats.
cltv_expiry_delta integer Optional, defaults to 72. Blocks until CheckLockTimeVerify (CLTV) expiry.
max_dust_htlc_exposure_msat integer Optional, defaults to 5000000. Limit our total exposure to in-flight HTLCs which are burned to fees as they are too small to claim on-chain.
force_close_avoidance_max_fee_sats integer Optional, defaults to 1000. The additional fee we're willing to pay to avoid waiting for the counterparty's locktime to reclaim funds.

LightningClosedChannelsFilter

Parameter Type Description
channel_id string Optional. Unique string identifying a channel by its ID.
counterparty_node_id string Optional. A hexidecimal string identifying a counterparty node.
funding_tx string Optional. A transaction ID which added funds.
from_funding_value integer Optional. The minimum value of channel funding in satoshis.
to_funding_value integer Optional. The maximum value of channel funding in satoshis.
channel_type string Optional. Inbound or Outbound.
closing_tx integer Optional. A transaction ID which closed the channel.
closure_reason integer Optional. The reason a channel was closed.
claiming_tx integer Optional. The ID of the transaction that returned the remaining outbound funds when the channel was closed to our on-chain address.
from_claimed_balance integer Optional. The minimum balance of channel funds claimed in satoshis.
to_claimed_balance integer Optional. The maximum balance of channel funds claimed in satoshis.
channel_visibility integer Optional. Public or Private.
Response may change to be more consistent in future. [https://github.com/KomodoPlatform/komodo-docs-mdx/pull/31#discussion\\\_r1206446309](https://github.com/KomodoPlatform/komodo-docs-mdx/pull/31#discussion\\_r1206446309)

LightningOpenChannelsFilter

Parameter Type Description
channel_id string Optional. Unique string identifying a channel by its ID.
counterparty_node_id string Optional. A hexidecimal string identifying a counterparty node.
funding_tx string Optional. A transaction ID which added funds.
from_funding_value_sats integer Optional. The minimum value of channel funding in satoshis.
to_funding_value_sats integer Optional. The maximum value of channel funding in satoshis.
is_outbound boolean Optional. If true, limits the response to outbound channels only.
from_balance_msat integer Optional. The minimum channel balance in millisatoshis.
to_balance_msat integer Optional. The maximum channel balance in millisatoshis.
from_outbound_capacity_msat integer Optional. The minimum outbound capacity of the channel balance in millisatoshis.
to_outbound_capacity_msat integer Optional. The maximum outbound capacity of the channel balance in millisatoshis.
from_inbound_capacity_msat integer Optional. The minimum inbound capacity of the channel balance in millisatoshis.
to_inbound_capacity_msat integer Optional. The maximum inbound capacity of the channel balance in millisatoshis.
confirmed boolean Optional. If true, only channels with channel opening transactions that passed the number of confirmations required for the channel to be usable will be returned.
is_usable boolean Optional. If true, only channels that are confirmed and the counterparty is online, meaning that these channels can be used for payments will be returned.
is_public boolean Optional. If true, only channels that our node announces to the lightning network, these channels are visible on lightning explorers will be returned.

LightningPayment

Parameter Type Description
type string The payment type. Accepted values are invoice or keysend.
invoice string Only used if type is invoice. An identifying string which represents the invoice.
destination string Only used if type is keysend. A node_pubkey (which is also the node address in lightning context). Not to be confused with an onchain address.
amount_in_msat string Only used if type is keysend. Amount to be paid, in millisatoshis (A thousandth of a satoshi; the same as 0.00000000001 bitcoin).
expiry string Only used if type is keysend. Optional, defaults to 3600. Seconds until the payment expires.

LightningPaymentFilter

Parameter Type Description
payment_type object A standard LightningPaymentType object.
description string Optional. A note to indicate the purpose of the invoice.
status string Optional. Accepted values: pending, succeeded, failed.
from_amount_msat integer Optional. Minimum amount sent in millisatoshis
to_amount_msat integer Optional. Maximum amount sent in millisatoshis
from_fee_paid_msat integer Optional. Minimum transaction fee paid in millisatoshis
to_fee_paid_msat integer Optional. Maximum transaction fee paid in millisatoshis
from_timestamp string Optional. Minimum timestamp (in milliseconds) of payment results to return.
to_timestamp string Optional. Maximum timestamp (in milliseconds) of payment results to return.

LightningPaymentType

Parameter Type Description
type object Accepted values are Outbound Payment or Inbound Payment.
destination string Only used if type is Outbound Payment. A pubkey which will receive the payment.
Response may change in future. See [https://github.com/KomodoPlatform/komodo-docs-mdx/pull/31#discussion\\\_r1206176530](https://github.com/KomodoPlatform/komodo-docs-mdx/pull/31#discussion\\_r1206176530)

Pagination

For requests which return many results, pagination offsets may be applied. ** Use either value, not both. **

Parameter Type Description
PageNumber integer Optional, defaults to 1. Offset for paginated results
FromId integer Optional. Ignores any results prior to this UUID
#### Example
{
    "PageNumber": 1
}
{
    "FromId": 4
}

HistoryTarget

Used to specify a HD wallet account_id or address_id for [my_tx_history (v2)] requests.

Parameter Type Description
type string Filters results by account_id or address_id part of the derivation path.
account_id integer ACCOUNT_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path.
address_id integer Only required when type is address_id. ADDRESS_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path.
chain string Only required when type is address_id. Internal, or External. 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.
#### Example
{
  "type": "account_id",
  "account_id": 77
}
{
  "type": "address_id",
  "account_id": 0,
  "chain": "External", // Accepted values: "External" and "Internal"
  "address_id": 1
}

TokensRequest

The TokensRequest object includes the following items for a given coin or token:

Parameter Type Description
ticker string Ticker of the token to be enabled
required_confirmations integer How many confirmations to wait during the transaction steps of an atomic swap. Overwrites value in coins file; defaults to 3
```json { "ticker": "MINDS-ERC20", "required_confirmations": 4 } ```

WalletBalanceInfo

The WalletBalanceInfo object includes the following items in the activation response for a coin in HD mode:

Parameter Type Description
wallet_type string In HD wallet mode, this will return HD. What are the other values?
accounts object A standard WalletAccountInfo object.
{
    "wallet_balance": {
        "wallet_type": "HD",
        "accounts": [
            ...
        ]
    }
}

WithdrawFromInfo

The WithdrawFromInfo response object includes the following items for HD Wallet withdraw (v2) requests. You can use either the derivation_path on its own, or the account_id, chain and address_id together.

Parameter Type Description
derivation_path string The BIP44 derivation path of the address.
account_id integer ACCOUNT_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path. Please don't confuse with the global account.
address_id integer ADDRESS_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path.
chain string Internal, or External. 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.

FeeInfo

The FeeInfo response object includes the following items for withdraw (v2) requests:

Parameter Type Description
type string Type of transaction fee; possible values: UtxoFixed, UtxoPerKbyte, EthGas
amount string (numeric) Fee amount in coin units, used only when type is UtxoFixed (fixed amount not depending on tx size) or UtxoPerKbyte (amount per Kbyte)
gas_price string (numeric) Used only when fee type is EthGas; sets the gas price in gwei units
gas number (integer) Used only when fee type is EthGas; sets the gas limit for transaction

ScanAddressesInfo

The ScanAddressesInfo response object includes the following items for request in HD mode:

Parameter Type Description
account_index integer ACCOUNT_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path. Please don't confuse with the global account.
derivation_path string The BIP44 derivation path of the account.
new_addresses list A list of standard NewAddressInfo objects.
Confirm `new_addresses` array has the structure of `NewAddressInfo`.

NewAddressInfo

The NewAddressInfo response object includes the following items for request in HD mode:

Parameter Type Description
address string The account address for a specific derivation path under the account_index.
derivation_path string The BIP44 derivation path of the address. If there are no more addresses with balances within the gap limit, the address index will increment.
balance object A standard balanceInfo object.
chain string Internal, or External. 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.

WalletAccountInfo

The WalletAccountInfo object includes the following items in the activation response for a coin in HD mode:

Parameter Type Description
account_index integer ACCOUNT_ID child in the m/44'/COIN'/ACCOUNT_ID'/CHAIN/ADDRESS_ID BIP44 derivation path. Please don't confuse with the global account.
derivation_path string Derivation path up to the COIN child. E.g. "m/44'/141'/0'"
total_balance object A standard balanceInfo object.
addresses list A list of standard AccountAddressInfo objects.
{
    "account_index": 0,
    "derivation_path": "m/44'/141'/0'",
    "total_balance": {
        "spendable": "23.08710255",
        "unspendable": "0"
    },
    "addresses": [
        ...
    ]
}

AccountAddressInfo

The AccountAddressInfo object includes the following items for active addresses in the activation response for a coin in HD mode:

Parameter Type Description
address string The account address for a specific derivation path under the account_index.
derivation_path string The BIP44 derivation path of the address.
chain string External or Internal, as defined in the activation request.
balance object A standard balanceInfo object.
```json { "address": "RXNtAyDSsY3DS3VxTpJegzoHU9bUX54j56", "derivation_path": "m/44'/141'/0'/0/0", "chain": "External", "balance": { "spendable": "7.64018255", "unspendable": "0" } } ```

Error types

NotSufficientBalance

The available balance is not sufficient to transfer the specified amount.

Structure Type Description
coin string the name of the coin which balance is not sufficient. This coin name may differ from the requested coin. For example, ERC20 fees are paid by ETH (gas)
available string (numeric) the balance available for transfer
required string (numeric) the amount required to transfer the specified amount. This amount is necessary but may not be sufficient

Response (NotSufficientBalance error)

{
  "mmrpc": "2.0",
  "error": "Not enough DOC to withdraw: available 69.75066225, required at least 1000.00001",
  "error_path": "utxo_common",
  "error_trace": "utxo_common:1379] utxo_common:449]",
  "error_type": "NotSufficientBalance",
  "error_data": {
    "coin": "DOC",
    "available": "69.75066225",
    "required": "1000.00001"
  },
  "id": 0
}

ZeroBalanceToWithdrawMax

The available balance is zero.

Structure Type Description
(none)

AmountTooLow

The specified amount is too low. Required at least threshold.

Structure Type Description
amount string (numeric) the amount the user was willing to transfer
threshold string (numeric) the amount has not to be less than the threshold

InvalidAddress

The specified to address is not valid.

Structure Type Description
(none) string the error description

InvalidFeePolicy

The specified fee is not valid.

Structure Type Description
(none) string the error description

Response (InvalidFeePolicy error - attempt to use EthGas for UTXO coin)

{
  "mmrpc": "2.0",
  "error": "Invalid fee policy: Expected 'UtxoFixed' or 'UtxoPerKbyte' fee types, found EthGas",
  "error_path": "utxo_common",
  "error_trace": "utxo_common:1371]",
  "error_type": "InvalidFeePolicy",
  "error_data": "Expected 'UtxoFixed' or 'UtxoPerKbyte' fee types, found EthGas",
  "id": 0
}

Response (InvalidFeePolicy error - attempt to use UtxoFixed or UtxoPerKbyte for ETH coin)

{
  "mmrpc": "2.0",
  "error": "Invalid fee policy: Expected 'EthGas' fee type, found UtxoFixed",
  "error_path": "eth",
  "error_trace": "eth:535]",
  "error_type": "InvalidFeePolicy",
  "error_data": "Expected 'EthGas' fee type, found UtxoFixed",
  "id": 0
}

NoSuchCoin

The specified coin was not found or is not activated yet.

Structure Type Description
coin string the not found coin specified in the Request

Transport

The request was failed due to a network error.

Structure Type Description
(none) string the transport error description

InternalError

The request was failed due to an Komodo DeFi API internal error.

Structure Type Description
(none) string the internal error description

Error cases

Error - Coin not active

{
  "mmrpc": "2.0",
  "error": "TTT-SLP",
  "error_path": "my_tx_history_v2.lp_coins",
  "error_trace": "my_tx_history_v2:389] lp_coins:2847]",
  "error_type": "CoinIsNotActive",
  "error_data": "TTT-SLP",
  "id": null
}

Error - Coin not compatible

{
  "mmrpc": "2.0",
  "error": "TTT-SLP",
  "error_path": "my_tx_history_v2",
  "error_trace": "my_tx_history_v2:336]",
  "error_type": "NotSupportedFor",
  "error_data": "TTT-SLP",
  "id": null
}

Error - Coin enabled without tx_history = true

{
  "mmrpc": "2.0",
  "error": "Storage is not initialized for TTT-SLP",
  "error_path": "my_tx_history_v2",
  "error_trace": "my_tx_history_v2:343]",
  "error_type": "StorageIsNotInitialized",
  "error_data": "Storage is not initialized for TTT-SLP",
  "id": null
}

Error - Local database failed

{
  "mmrpc": "2.0",
  "error": "SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\"no such column: block_height\"))",
  "error_path": "my_tx_history_v2.sql_tx_history_storage",
  "error_trace": "my_tx_history_v2:351] sql_tx_history_storage:472]",
  "error_type": "StorageError",
  "error_data": "SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\"no such column: block_height\"))",
  "id": null
}
There are some common objects that are used in the Komodo DeFi SDK RPC protocol. These standard objects have been collected and grouped into the following sections: