NAV Navbar
(978) 623-1327
  • Introduction
  • 7789329986
  • Ladino clover
  • 7734274940
  • untantalizing
  • Trading API Calls
  • Status / Info
  • tradebots
  • Coin Wallet Features
  • 315-690-4847
  • Communication
  • Revenue Sharing/Operations
  • sabalo
  • Introduction

    Welcome to the BarterDEX API documentation! This documentation includes the API reference for the Komodo Platform decentralized exchange BarterDEX (marketmaker). You can use this API to access the BarterDEX network and trade hundreds of different coins in a decentralized , blockchain-based way.

    We have language bindings for almost every script and programming language, since we are using an abstract JSON-RPC interface for Komodo and BarterDEX! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

    Getting started

    Installation

    Install all required dependencies to build the BarterDEX client "marketmaker." After updating and successfully installing the clone BarterDEX sourcecodes from github, run the marketmaker makefile in the shell.

    To build the BarterDEX client "marketmaker", use these commands:

    # update
    sudo apt-get update && sudo apt-get upgrade
    # install dependencies
    sudo apt-get install git libcurl4-openssl-dev build-essential libnanomsg-dev
    # clone repository
    git clone /github.com/jl777/supernet
    cd supernet/iguana
    # build marketmaker for linux
    ./m_mm
    # build marketmaker for OSX
    ./m_mm_osx
    

    The BarerDEX binary "marketmaker" is compiled into the iguana folder.

    BarterDEX scripts "dexscripts" (optional)

    The following steps are not mandatory. After building the BarterDEX client "marketmaker," you can launch it with the required parameters and start using it. However, it is possible to install the BarterDEX scripts "dexscripts" into the folder dexscripts. This set of scripts contains the most-needed BarterDEX API calls for easy and quick shell usage.

    To install the optional BarterDEX scripts, use these commands:

    # install the dexscripts
    cd exchanges && ./install
    cd ../dexscripts
    

    The installed set of scripts contains various API call examples.

    Running the BarterDEX client

    Run the client script after storing the eviroment variable passphrase into a passphrase file inside the dexcripts directory. The file contains: export passphrase=YOUR_SECURE_PASSPHRASE

    The optional parameters netid and seednode will allow you to connect to various parallel BbarterDEX networks.

    If you are running the barterDEX client "marketmaker" for the first time you only have to set the passphrase.

    The client startup script is in the dexscripts folder.

    # start the client up
    ./client
    

    Your marketmaker client is running now

    . Instead of starting the barterDEX client via script you can also do it one level lower and directly start the marketmaker binary with the appropriate parameters.

    Start the marketmaker with the needed parameters

    # start the marketmaker up manually
    ./marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" &
    

    Your marketmaker client is running now.

    You will now see the BarterDEX client "marketmaker" starting up. After successful launch issue any rpc call to fire up the keypairs and netconns.

    Authentication

    Due to security reasons the barterDEX client will start with a default hardcoded passphrase resulting in the static userpass 1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f after the first call has been issued. Use this userpass to set your desired passphrase/seed which will result in your base58 pubkeys (your smartaddresses).

    For this purpose, issue the passphrase call to set your own passphrase which generates your desired keypair.

    Start the marketmaker with the needed parameters

    # issue the passphrase call and json-format it
    curl --url "/127.0.0.1:7783" --data "{\"method\":\"passphrase\",\"userpass\":\"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f\",\"passphrase\":\"YOUR_SECURE_PASSPHRASE\",\"gui\":\"beerDEX\"}" | python -m json.tool```
    
    > Your marketmaker client uses the seed generated keypairs now
    
    
    > The above command returns a JSON structured like below:
    
    ```json
    {
        "BTC": "1QHdoNayTfjuYPrg2XUePKM2D5Wqbh5pnz",
        "KMD": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
        "NXT": "NXT-QKF4-5SCD-JRAJ-CGE4F",
        "coins": [
            {
                "KMDvalue": 0,
                "balance": 0,
                "coin": "BTC",
                "height": 0,
                "installed": true,
                "p2shtype": 5,
                "pubtype": 0,
                "rpc": "127.0.0.1:8332",
                "smartaddress": "1QHdoNayTfjuYPrg2XUePKM2D5Wqbh5pnz",
                "status": "inactive",
                "txfee": 18446744048109551616,
                "wiftype": 128
            },
            {
                "KMDvalue": 0,
                "balance": 0,
                "coin": "KMD",
                "height": 0,
                "installed": true,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:7771",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188,
                "zcredits": 0,
                "zdebits": {
                    "pendingswaps": 0,
                    "swaps": []
                }
            },
            {
                "balance": 0,
                "coin": "PIZZA",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:11116",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "BEER",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:8923",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "BTCH",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:8800",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "ETOMIC",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:10271",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "QTUM",
                "height": -1,
                "installed": false,
                "p2shtype": 50,
                "pubtype": 58,
                "rpc": "127.0.0.1:3889",
                "smartaddress": "Qjtcufsge8ciyXwhSro8Wb8eiLTYtbJR93",
                "status": "inactive",
                "txfee": 400000,
                "wiftype": 128
            },
            {
                "balance": 0,
                "coin": "KV",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:8299",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "CEAL",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:11116",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            },
            {
                "balance": 0,
                "coin": "MESH",
                "height": -1,
                "installed": false,
                "p2shtype": 85,
                "pubtype": 60,
                "rpc": "127.0.0.1:9455",
                "smartaddress": "RYZpstUG4VYUcQDsVhTmUqgDyLySKznuLW",
                "status": "inactive",
                "txfee": 1000,
                "wiftype": 188
            }
        ],
        "mypubkey": "7a9c9dce245b69cfac30d9f3ac804b45807bd812ed774cc21508a341210a497c",
        "pubsecp": "020d9944939fd7526b0db190fea67cae49d056e950b1586ff25206717e60280b6d",
        "result": "success",
        "userpass": "103761802884e4decd2eeda76ef95ffa655be6bb59fa5b81dec78daa75fc9014"
    }
    

    network API calls

    You are connected to the network and can add the coins you want to trade or receive/send. The barterDEX gives you two options to do so:

    1) native (coindaemon with full blockchain sync) This means the blockchain information that is needed by barterDEX will be parsed from the local blockchain copy on your harddisk. This is (depending on the used coins) memory and time consuming.

    2) SPV (lightweight network, electrum based) Thanks to Komodos unique electrum server based barterDEX integration the needed blockchain information gets fetched from electrum servers all over the world which do provide the data from full blockchain copies on their infrastructure. This safes a lot of memory and time.

    native

    Add native coins

    electrum

    Add electrum coins

    barterDEX Operation

    client

    The first API to run which will start barterDEX in client mode. Next script to run is setpassphrase. If you want to close barterDEX, issue pkill -15 marketmaker every time. This ensures all barterDEX process is killed safely.

    Sample File Contents:

    #!/bin/bash
    source passphrase
    source coins
    ./stop
    git pull;
    cd ..; 
    ./m_mm;
    pkill -15 marketmaker; 
     ./marketmaker "{\"gui\":\"nogui\",\"client\":1,\"netid\":0, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}"  &
    

    Fields that can be used:

    gui:nogui or gui:SimpleUI - to identify the CLI/GUI being used to run marketmaker. client:1 - to start marketmaker as client mode. "userhome\":\"/${HOME#"/" - defines the data dir for barterDEX. DB dir contains PRICES, SWAPS, UNSPENTS and instantdex_deposit (0conf) files. passphrase:$passphrase - is to set the passphrase to run the marketmaker with, to run and login into marketmaker using WIF (Wallet Import Format) key instead of passphrase. You need to use the WIF key as passphrase inside passphrase file. barterDEX supports login using WIF Key for all supported coins instead of passphrase. wif:1 - will display the passphrase's WIF during the first api return. rpcport:port - to change the 7782 port to other open port of choice.

    netid

    For the startup JSON default is 0, max is 19240, which should be plenty of p2p networks for a while. Each netid will operate totally independent of the other netids. The rpcport field can be used to specify different ones so you can run multiple mm on the same node, but they will be on separate netid. This way you can broadcast the marketmaker prices to all the netids. You also need to use the same netid in setpassphrase script.

    Example usage: ./marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins, \"netid\":1}"

    client_osx

    It is the same script as above but only for MacOS.

    Sample File Contents:

    #!/bin/bash
    source passphrase
    source coins
    pkill -15 marketmaker; 
    git pull;
    cd ..; 
    ./m_mm;
    ./marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}/Library/Application\ Support\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" &
    

    convaddress

    This script should work with p2sh addresses and also with normal addresses to convert. You just have to specify the coin, address & destcoin parameter and run.

    Sample file contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"convaddress\",\"coin\":\"BTC\",\"address\":\"1KPctPk4Zs4Qbe1x32A5bC1roAnmpvi9Fy\",\"destcoin\":\"KMD\"}"
    

    Sample Output 1:

    {"result":"success","coin":"BTC","address":"1KPctPk4Zs4Qbe1x32A5bC1roAnmpvi9Fy","destcoin":"KMD","destaddress":"RTfoxudMAgryfeP9WC9CgiM4ZSFNVM2VvK"}
    

    Sample Output 2:

    {"result":"success","coin":"BTC","address":"1KPctPk4Zs4Qbe1x32A5bC1roAnmpvi9Fy","destcoin":"DGB","destaddress":"DPXiReghsGxh8eCYmc9e8xBTgJX5CdnALu"}
    

    debug

    This script will let you debug if you run into problem with marketmaker using gdb. This will kill the marketmaker first, do a git pull for fresh data and build it again. Once ready, type run and hit enter to start. In case of marketmaker crash, you can use backtrace command to find the reason of the crash. To exit from this mode type quit and hit enter.

    Sample File Contents:

    #!/bin/bash
    source passphrase
    source coins
    pkill -15 marketmaker; 
    git pull;
    cd ..; 
    ./m_mm;
    gdb -args ./marketmaker "{\"gui\":\"nogui\",\"client\":1,\"userhome\":\"/${HOME#"/"}\",\"passphrase\":\"$passphrase\",\"coins\":$coins}"
    

    enable

    This method enables a coin by connecting to a locally running native coin daemon, otherwise, known as Native Mode. To be eligible for trading a coin must be enabled and the daemon should be running. You can edit the sample enable script file to activate the native coins you want to trade. you can stop it by using the disable script.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PIZZA\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REVS\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}"
    #curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTC\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CHIPS\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SUPERNET\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CRYPTO\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DEX\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BOTS\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BET\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"HODL\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MSHARK\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MGW\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PANGEA\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JUMBLR\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"HUSH\"}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTCH\"}"
    

    Sample Output:

    [{"coin":"SUPERNET","installed":true,"height":85017,"balance":0.94386703,"KMDvalue":35.77755890,"status":"active","smartaddress":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","rpc":"127.0.0.1:11341","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":1000}]
    [{"coin":"BOTS","installed":true,"height":14118,"balance":8.61219046,"KMDvalue":95.90388479,"status":"active","electrum":"electrum1.cipig.net:10007","smartaddress":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","rpc":"127.0.0.1:11964","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":1000}]
    [{"coin":"BET","installed":true,"height":16555,"balance":36.65094825,"KMDvalue":0,"status":"active","electrum":"electrum1.cipig.net:10012","smartaddress":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","rpc":"127.0.0.1:14250","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":1000}]
    [{"coin":"MSHARK","installed":true,"height":21221,"balance":61.90419488,"KMDvalue":356.23889156,"status":"active","smartaddress":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","rpc":"127.0.0.1:8846","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":1000}]
    [{"coin":"BTCH","installed":true,"height":17922,"balance":1890.26497637,"KMDvalue":1085.25152617,"status":"active","smartaddress":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","rpc":"127.0.0.1:8800","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":1000}]
    

    disable

    This method disables a coin. A disabled coin is not eligible for trading.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"disable\",\"coin\":\"REVS\"}"
    

    getcoin

    This method will show coin data including smartaddress, balance etc. Do NOT use getcoin to get balance in SPV mode, use the balance API.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getcoin\",\"coin\":\"LTC\"}"
    

    Sample Output:

    {
      "result": "success",
      "enabled": 5,
      "disabled": 88,
      "coin": {
        "coin": "BTCH",
        "installed": true,
        "height": 17914,
        "balance": 1890.26497637,
        "KMDvalue": 1060.52748251,
        "status": "active",
        "smartaddress": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "rpc": "127.0.0.1:8800",
        "pubtype": 60,
        "p2shtype": 85,
        "wiftype": 188,
        "txfee": 1000
      }
    }
    

    getcoins

    This will display the list of all coins that barterDEX supports. It will list both disabled and enabled coins. Along with the status of the coin, this function will also display your smartaddress for that given coin. This method does not need user defined inputs and will just display all the coins.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getcoins\"}"
    

    Sample Output:

    [
      {
        "coin": "BTC",
        "height": 0,
        "status": "inactive",
        "smartaddress": "15XAhHK4ULofD6BTckrCWK6XSkCjscX7jj",
        "rpc": "127.0.0.1:8332",
        "pubtype": 0,
        "p2shtype": 5,
        "wiftype": 128,
        "txfee": 0
      },
      {
        "coin": "KMD",
        "height": 538355,
        "status": "active",
        "smartaddress": "RDoMmoCM5AcEH6Yf5vqKbqRjD1fLcQHuWb",
        "rpc": "127.0.0.1:7771",
        "pubtype": 60,
        "p2shtype": 85,
        "wiftype": 188,
        "txfee": 10000
      }
    ]
    

    getpeers

    The ./getpeers script prints the connected nodes available to trade in the network.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getpeers\"}"
    

    Sample Output:

    [
      {
        "ipaddr": "5.9.253.202",
        "port": 7783,
        "session": 1508151814
      },
      {
        "ipaddr": "5.9.253.195",
        "port": 7783,
        "session": 1508151804
      },
      {
        "ipaddr": "5.9.253.196",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.197",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.198",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.199",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.200",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.201",
        "port": 7783,
        "session": 0
      },
      {
        "ipaddr": "5.9.253.203",
        "port": 7783,
        "session": 0
      }
    ]
    

    getpeersIP

    The ./getpeersIP script prints all the connected nodes, their port and session number.

    Sample File Contents:

    curl --url "/5.9.253.195:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.196:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.197:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.198:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.199:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.200:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.201:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.202:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.203:7783" --data "{\"method\":\"getpeers\"}"
    curl --url "/5.9.253.204:7783" --data "{\"method\":\"getpeers\"}"
    

    Sample Output:

    [{"ipaddr":"5.9.253.195","port":7783,"session":1508151804},
    {"ipaddr":"5.9.253.196","port":7783,"session":0},
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0},
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.196","port":7783,"session":1508151807}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.197","port":7783,"session":1508151808}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.198","port":7783,"session":1508151809}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.199","port":7783,"session":1508151809}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.200","port":7783,"session":1508151812}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.201","port":7783,"session":1508151813}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","po###barterDEX Trading###rt":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.202","port":7783,"session":1508151814}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.203","port":7783,"session":1508151814}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":1508151804}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.197","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":0}]
    [{"ipaddr":"5.9.253.197","port":7783,"session":1506966021}, 
    {"ipaddr":"5.9.253.195","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.196","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.199","port":7783,"session":1506966023}, 
    {"ipaddr":"5.9.253.201","port":7783,"session":1506966027}, 
    {"ipaddr":"5.9.253.202","port":7783,"session":1506966028}, 
    {"ipaddr":"5.9.253.200","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.203","port":7783,"session":0}, 
    {"ipaddr":"5.9.253.198","port":7783,"session":0}, 
    {"ipaddr":"82.7.169.222","port":7783,"session":0}]
    

    help

    The ./help API will display a list of all the available API available on barterDEX and usage options.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"help\"}"
    

    Sample Output:

    {"result":" available localhost RPC commands: 
     setprice(base, rel, price, broadcast=1)
    autoprice(base, rel, fixed, minprice, maxprice, margin, refbase, refrel, factor, offset)*
    goal(coin=*, val=<autocalc>)
    myprice(base, rel)
    enable(coin)
    disable(coin)
    notarizations(coin)
    statsdisp(starttime=0, endtime=0, gui=, pubkey=, base=, rel=)
    ticker(base=, rel=)
    tradesarray(base, rel, starttime=<now>-timescale*1024, endtime=<now>, timescale=60) -> [timestamp, high, low, open, close, relvolume, basevolume, aveprice, numtrades]
    pricearray(base, rel, starttime=0, endtime=0, timescale=60) -> [timestamp, avebid, aveask, highbid, lowask]
    getrawtransaction(coin, txid)
    inventory(coin, reset=0, [passphrase=])
    lastnonce()
    buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)
    sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)
    withdraw(coin, outputs[])
    sendrawtransaction(coin, signedtx)
    swapstatus(pending=0, fast=0)
    swapstatus(coin, limit=10)
    swapstatus(base, rel, limit=10)
    swapstatus(requestid, quoteid, pending=0, fast=0)
    recentswaps(limit=3)
    notarizations(coin)
    public API:
     getcoins()
    getcoin(coin)
    portfolio()
    getpeers()
    passphrase(passphrase, gui, netid=0, seednode=)
    listunspent(coin, address)
    setconfirms(coin, numconfirms, maxconfirms=6)
    trust(pubkey, trust) # positive to trust, 0 for normal, negative to blacklist
    balance(coin, address)
    balances(address)
    fundvalue(address=, holdings=[], divisor=0)
    orderbook(base, rel, duration=3600)
    getprices()
    inuse()
    getmyprice(base, rel)
    getprice(base, rel)
    /sendmessage(base=coin, rel=, pubkey=zero, <argjson method2>)
    /getmessages(firsti=0, num=100)
    /deletemessages(firsti=0, num=100)
    secretaddresses(prefix='secretaddress', passphrase, num=10, pubtype=60, taddr=0)
    electrum(coin, ipaddr, port)
    snapshot(coin, height)
    snapshot_balance(coin, height, addresses[])
    dividends(coin, height, <args>)
    stop()
    bot_list()
    bot_statuslist()
    bot_buy(base, rel, maxprice, relvolume) -> botid
    bot_sell(base, rel, minprice, basevolume) -> botid
    bot_settings(botid, newprice, newvolume)
    bot_status(botid)
    bot_stop(botid)
    bot_pause(botid)
    calcaddress(passphrase, coin=KMD)
    convaddress(coin, address, destcoin)
    instantdex_deposit(weeks, amount, broadcast=1)
    instantdex_claim()
    timelock(coin, duration, destaddr=(tradeaddr), amount)
    unlockedspend(coin, txid)
    opreturndecrypt(coin, txid, passphrase)
    getendpoint()
    jpg(srcfile, destfile, power2=7, password, data=, required, ind=0)
    "}
    

    jpg

    barterDEX supports password encrypting data into a .jpg. The dest image is virtually indistinguishable from the original. Best to use a raw .jpg you created with a camera and not some file from the internet. As from the internet, it can be compared as to what bits are changed and in that case the encrypted rawdata will be visible.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"password\":\"123\",\"ind\":3453,\"userpass\":\"$userpass\",\"method\":\"jpg\",\"srcfile\":\"/root/boost_1_64_0/libs/gil/doc/doxygen/images/monkey_steps.jpg\",\"destfile\":\"dest.jpg\",\"power2\":3,\"data\":\"68656c6c6f20776f726c64\",\"required\":88}"
    

    To write into a .jpg file, specify password, srcfile, destfile, data (hexstring) and required number of bits, power2. The same values of power2, password and required are needed to extract the data. curl --url "/127.0.0.1:7783" --data "{\"password\":\"123\",\"userpass\":\"$userpass\",\"method\":\"jpg\",\"srcfile\":\"dest.jpg\",\"power2\":3,\"required\":88}" Just the name of the image, power2 are required along with the password

    Sample Output:

    47007d0d6e91a7844e14f685153c71f57b20f79b3d0204009eb1bcef0000000000000000000000000000000067622f82d97186d2c561f7abd6880b8d692563b8c71b1ab299e525 encoded.71
    47007d0d6e91a7844e14f685153c71f57b20f79b3d0204009eb1bcef0000000000000000000000000000000067622f82d97186d2c561f7abd6880b8d692563b8c71b1ab299e525 restored
    68656c6c6f20776f726c64 VERIFIED decryption.11 ind.3453 msglen.71 required.568
    New DCT coefficients successfully written to dest.jpg, capacity 35672 modifiedrows.1/114 emit.568
    {"result":"success","modifiedrows":1,"outputfile":"dest.jpg","power2":3,"capacity":35672,"required":88,"ind":65535,"decoded":"3a4e7dc2785e40d58b8784"}
    47007d0d6e91a7844e14f685153c71f57b20f79b3d0204009eb1bcef0000000000000000000000000000000067622f82d97186d2c561f7abd6880b8d692563b8c71b1ab299e525 restored
    {"result":"success","modifiedrows":0,"power2":3,"capacity":35672,"required":88,"ind":3453,"decoded":"68656c6c6f20776f726c64"}
    

    millis

    millis is a new debug API. James put the millis display in the swaploop, which is once per 10 minutes.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"millis\"}"
    

    Sample Output:

                      queue_loop elapsed    209.91 millis > threshold      50.00, ave       5.11 millis, count.18616
                    LP_reserved_msgs lag       0.90 millis, threshold      20.00, ave       3.09 millis, count.32100
                         utxosQ_loop lag       9.36 millis, threshold      50.00, ave      10.09 millis, count.9834
                     command_rpcloop lag       6.76 millis, threshold    1000.00, ave      10.06 millis, count.9863
                          queue_loop lag       3.67 millis, threshold      50.00, ave       5.11 millis, count.19431
                         prices_loop lag   38831.90 millis, threshold   61000.00, ave   60432.92 millis, count.1
                    other coins loop lag       0.88 millis, threshold     200.00, ave       1.11 millis, count.89747
                       BTC coin loop lag       0.54 millis, threshold     200.00, ave       1.10 millis, count.89834
                       KMD coin loop lag       1.09 millis, threshold     200.00, ave       1.15 millis, count.86644
                      LP_pubkeysloop lag    2229.59 millis, threshold    3100.00, ave    3001.13 millis, count.29
                     LP_privkeysloop lag   79262.36 millis, threshold  140860.00, ave       0.00 millis, count.0
                        LP_swapsloop lag   49262.25 millis, threshold  605000.00, ave       0.00 millis, count.0
                     utxosQ_loop elapsed     94.28 millis > threshold      50.00, ave      10.10 millis, count.10738
    

    notarizations

    This script will display coin notarization status for a specified coin. Use the script like this ./notarizations KMD, ./notarizations REVS, etc.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"notarizations\",\"coin\":\"$1\"}"
    

    Sample Output:

    {
      "result": "success",
      "coin": "KMD",
      "lastnotarization": 553573,
      "bestheight": 553578
    }
    

    parselog

    ./parselog will parse the stats.log file, just the incremental since last time.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"parselog\"}"
    

    Sample Output:

    {
      "result": "success",
      "newlines": 0,
      "request": 0,
      "reserved": 0,
      "connect": 0,
      "connected": 0,
      "duplicates": 0,
      "parse_errors": 0,
      "uniques": 0,
      "tradestatus": 0,
      "unknown": 0
    }
    

    run

    ./run starts barterDEX in LP (Liquid Provider) mode while ./client is for client mode. After it starts (takes a tiny bit time to complete) execute your API calls from the dexscripts directory.

    Sample File Contents:

    #!/bin/bash
    source passphrase
    source coins
    ./stop
    git pull;
    cd ..; 
    ./m_mm;
    pkill -15 marketmaker; 
     $1 ./marketmaker "{\"gui\":\"nogui\", \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" &
    

    setpassphrase

    This method helps the GUI build to take input of the passphrase and generate userpass. This is the second API to run in BarterDEX. On the first call it will display the userpass value at the top of output.

    Sample File Content:

    #!/bin/bash
    source userpass
    source passphrase
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f\",\"method\":\"passphrase\",\"passphrase\":\"$passphrase\",\"gui\":\"nogui\"}"
    

    stop

    This method will stop barterDEX.

    Sample File Content:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"stop\"}"
    

    trust

    Make your pubkey trusted by using this ./trust method. You need to add your pubkey after the command. If you want the pubkey to be not trusted use \"trust\":-1. -1 means dont trust, 1 means to trust. This API works immediately.

    Sample File Contents:

    echo "usage: ./trust <pubkey>"
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"pubkey\":\"$1\",\"method\":\"trust\",\"trust\":1}"
    

    Sample Output:

    usage: ./trust <pubkey>
    {"result":"success"}
    

    trusted

    This method will display the pubkey you made trusted. No need to edit the file.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"trusted\"}"
    

    Sample Output:

    [
      "040f1d2d5d12027afa2cec30477312e225b0d24c77cc4aa08d3fffe51277b904"
    ]
    

    Trading API Calls

    Below you will find all calls that are needed to trade via barterDEX and their relation and relevance to each other.

    buy

    In simple terms, this command will post a buy order. If there is a matching order in the orderbooks, then this will automatically start a trade. If a match is not found, a bid order will be added in the orderbook. Buy fills asks from the orderbook using relvolume. Trade request will last as long as defined in the 'timeout' field.

    Call 'recentswaps' to check the status of the trade request. Alice side does not give feedback about expired trade request, unless a 'recentswaps' call is done.

    base, rel, price, relvolume are the most important parameters you need to set. timeout and duration is optional. base: the currency you want to buy rel: the currency you are paying with price: the max price you are willing to pay for 1 base relvolume: the amount of rel you want to trade timeout: the amount of time Alice or Bob should wait for payment. Default: 10 seconds (might be deprecated in future) duration: after the specified duration it wont be displayed

    This is an example buy script.

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"KMD\",\"rel\":\"BTC\",\"relvolume\":0.005,\"price\":0.0005}"
    

    Output

    {
      "result": "success",
      "swaps": [
        [
          45030989,
          41860326
        ],
        [
          264022270,
          1424922977
        ],
        [
          3882191272,
          3366340834
        ]
      ],
      "pending": {
        "expiration": 1509564162,
        "timeleft": 15,
        "requestid": 0,
        "quoteid": 0,
        "bob": "MNZ",
        "base": "MNZ",
        "basevalue": 0.02803687,
        "alice": "KMD",
        "rel": "KMD",
        "relvalue": 0.0048,
        "aliceid": 7785695213943587000
      }
    }
    

    sell

    This script is completely opposite of buy and uses the same parameters. Edit the file with specific coin pair name, volume and price.

    Sample File Contents:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"KMD\",\"rel\":\"BTC\",\"basevolume\":10.0,\"price\":0.0005}"
    

    Sample Output:

    {
      "result": "success"
    }
    

    orderbook

    Displays bid/ask for a specific coin/asset pair. You can display multiple pairs, just need to edit the file and add more line. The numutxos/minvolume/maxvolume are the state of your local utxo cache. It might or might not be 100% accurate. Also, if all 0's it could be that it hasn't been queried yet. Even if all zeros, it is possible, even likely that there are actually utxo available.

    If you do an ./orderbook, it will start fetching the details from the best prices. You can do listunspent for a specific address, but it is not possible to know for sure what trades are possible, especially as there are other nodes that might be going after the same utxo. Specifically doing a listunspent api will also fetch the details, also doing a trade will fetch the details as well. James uses just in time fetching to get the utxo data. This way we don't flood the network with data for utxo info.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"DGB\",\"rel\":\"KMD\"}"
    

    Sample Output:

    {
      "bids": [
        {
          "coin": "KMD",
          "address": "RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD",
          "price": 0.00492739,
          "numutxos": 13,
          "minvolume": 0.072,
          "maxvolume": 0.76,
          "pubkey": "8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c",
          "age": 16
        },
        {
          "coin": "KMD",
          "address": "RHPBQQpjVqpwWC8NrpAxdoRQAkigA2zjRo",
          "price": 0.00487791,
          "numutxos": 5,
          "minvolume": 0.00016002,
          "maxvolume": 96,
          "pubkey": "22aaf8e3686d31ee9f5ebe61c97231114717aee943ef01cc58e9f843ddad0240",
          "age": 53
        }
      ],
      "numbids": 2,
      "asks": [
        {
          "coin": "DGB",
          "address": "D6ztNQyQF3mMTYcMFVq1q2cd6eXzqPKGc8",
          "price": 0.00532946,
          "numutxos": 38,
          "minvolume": 0.00586622,
          "maxvolume": 2.20800448,
          "pubkey": "8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c",
          "age": 16
        },
        {
          "coin": "DGB",
          "address": "DDF5s9t6CRveyBwn8EBQ63FoHczNsyFsFi",
          "price": 0.0053779,
          "numutxos": 3,
          "minvolume": 0.67844886,
          "maxvolume": 7.06141621,
          "pubkey": "22aaf8e3686d31ee9f5ebe61c97231114717aee943ef01cc58e9f843ddad0240",
          "age": 53
        }
      ],
      "numasks": 2,
      "base": "DGB",
      "rel": "KMD",
      "timestamp": 1508410319
    }
    

    autoprice

    autoprice is a very powerful API and it allows you to specify the price for a specific trading pair that is automatically updated as the market price of it changes. barterDEX uses external price sources (Bittrex, Cryptopia, Coinmarketcap) to get up to date prices. You can use fixed price instead of margin or use autoprice based on coinmarketcap. For now, it is a relatively simple set of things you can do with the following fields (base, rel, fixed, minprice, maxprice, margin, refbase, refrel, factor, offset).

    Knowledge Base:

    refbase and refrel allow you to specify a different base/rel pair as the basis for the price, if there is no refbase and refrel, the the base/rel price from external sources is used as the starting point. This is calculated approximately once per minute and a set price done automatically:

    setprice of (1. + margin) * ((price * factor) + offset)

    The margin is usually set to 0.01 for 1% profit margin. using factor and offset it is possible to map a starting price to a standard multiple.

    There is also a minprice field which sets the absolute minimum (post calculation) price that is accepted.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":0.0001}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTC\",\"rel\":\"KMD\",\"margin\":0.0001}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"HUSH\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"USD\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"USD\",\"rel\":\"KMD\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"JUMBLR\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"JUMBLR\",\"rel\":\"KMD\",\"margin\":0.01}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"MNZ\",\"rel\":\"KMD\",\"offset\":0.1,\"refbase\":\"KMD\",\refrel\":\"BTC\",\"factor\":15000,\"margin\"-:0.2}"
    

    Sample Output:

    {
      "result": "success"
    },
    {
      "result": "success"
    }
    ...
    

    Example autoprice script using coinmarketcap price

    curl --url "/127.0.0.1:7783" --data "{\"minprice\":0.00002,\"maxprice\":0.0001,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"
    
    curl --url "/127.0.0.1:7783" --data "{\"minprice\":0.04,\"maxprice\":0.1,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"
    

    autoprice using usdpeg

    There is a way for autoprice coinmarketcap to do USD pegs for orderbooks denominated in any coin. The syntax is pretty arbitrary but it works.

    Make sure the usdpeg is set to non-zero. In that case put in the orderbook BACKWARDS (dont ask me why, it just works only in this way) for the coin that is the coinmarketcap refbase. Based on the example it is KMD so base KMD and rel OOT, will create OOT/KMD orderbooks using factor 0.15 (fifteen cents) denominated in KMD. The example script used different margins for buymargin and sellmargin, so it works for dICO scenario (allow people to sell back but at a steep loss) and also it is backwards (dont ask me why).

    What this means is if you do a base DOGE rel OOT and refbase dogecoin, it should maintain an orderbook in DOGE pegged to the 15 cents price. Any CMC coin can be used. If you want to change the price, change the value of factor accordingly.

    Sample File Content:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"OOT\",\"factor\":0.15,\"buymargin\":0.0001,\"sellmargin\":0.2,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\",\"usdpeg\":1}"
    

    Sample Output:

    {"result":"success"}
    

    getprices

    The ./getprices API lists all currently available trading pairs and its current prices. You need to specify a base and rel coin if you need a specific pair price.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprices\",\"coin\":\"KMD\"}"
    

    Sample Output:

    [
      {
        "pubkey": "040f1d2d5d12027afa2cec30477312e225b0d24c77cc4aa08d3fffe51277b904",
        "rmd160": "8784673d815a20300412a9010b72e771963d45b6",
        "pubsecp": "03829863f4ed7660fbf62b2f84b0e655f523a33f23a1f681107d2a2942987584b1",
        "timestamp": 1508160175,
        "asks": [
          [
            "BTC",
            "KMD",
            3304.53174512
          ],
          [
            "KMD",
            "BTC",
            0.00030268
          ],
          [
            "KMD",
            "REVS",
            0.78551134
          ],
          [
            "KMD",
            "JUMBLR",
            0.10432527
          ],
          [
            "KMD",
            "HUSH",
            1.17931676
          ],
          [
            "REVS",
            "KMD",
            1.29051134
          ],
          [
            "JUMBLR",
            "KMD",
            9.77904977
          ],
          [
            "HUSH",
            "KMD",
            0.86507888
          ]
        ]
      }
    ]
    

    goal

    The ./goal command is basically the automatic trading tool of the API. When you execute this command, orders will be set until the goals are reached. The idea is that you set the goal for each coin and if you have more than the goal for a specific coin, it will allow sales of that coin. If you have less than the goal percentage, it will allow buys of that coin.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"KMD\",\"val\":99}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"BTC\",\"val\":10}"
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\",\"coin\":\"REVS\",\"val\":1}"
    

    Sample Output:

    {
      "result": "success",
      "kmd_equiv": 29.03290329,
      "buycoin": "KMD",
      "buyforce": 125.75072424,
      "sellcoin": "DGB",
      "sellforce": -412.28377122,
      "portfolio": [
        {
          "coin": "BTC",
          "address": "15XAhHK4ULofD6BTckrCWK6XSkCjscX7jj",
          "amount": 0,
          "price": 3315.35638637,
          "kmd_equiv": 0,
          "perc": 0,
          "goal": 10,
          "goalperc": 9.09090909,
          "relvolume": 0,
          "force": 82.6446281,
          "balanceA": 0,
          "valuesumA": 0,
          "balanceB": 0,
          "valuesumB": 0,
          "balance": 0
        },
        {
          "coin": "KMD",
          "address": "RDoMmoCM5AcEH6Yf5vqKbqRjD1fLcQHuWb",
          "amount": 22.87390295,
          "price": 1,
          "kmd_equiv": 22.87390295,
          "perc": 78.78613696,
          "goal": 99,
          "goalperc": 90,
          "relvolume": 0,
          "force": 125.75072424,
          "balanceA": 22.6448,
          "valuesumA": 22.87390295,
          "aliceutil": 98.99840901,
          "balanceB": 22.6448,
          "valuesumB": 22.87390295,
          "balance": 22.87390295,
          "bobutil": 98.99840901
        },
        {
          "coin": "DGB",
          "address": "D9fGEYFhmkhwk6N4MLqm45G8Ksw3E2AmTR",
          "amount": 919,
          "price": 0.00670185,
          "kmd_equiv": 6.15900034,
          "perc": 21.21386304,
          "goal": 1,
          "goalperc": 0.90909091,
          "relvolume": 186.60085587,
          "force": -412.28377122,
          "balanceA": 479.499,
          "valuesumA": 919,
          "aliceutil": 52.17616975,
          "balanceB": 479.499,
          "valuesumB": 919,
          "balance": 919,
          "bobutil": 52.17616975
        }
      ]
    }
    

    goals

    Displays the goal percentage for each coin and their status.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"goal\"}"
    

    Sample Output:

    {
      "result": "success",
      "kmd_equiv": 28.98048555,
      "buycoin": "BTC",
      "buyforce": 625,
      "sellcoin": "KMD",
      "sellforce": -2908.30091422,
      "base": "BTC",
      "rel": "KMD",
      "relvolume": 12.33191136,
      "portfolio": [
        {
          "coin": "BTC",
          "address": "15XAhHK4ULofD6BTckrCWK6XSkCjscX7jj",
          "amount": 0,
          "price": 3321.5219084,
          "kmd_equiv": 0,
          "perc": 0,
          "goal": 25,
          "goalperc": 25,
          "relvolume": 0,
          "force": 625,
          "balanceA": 0,
          "valuesumA": 0,
          "balanceB": 0,
          "valuesumB": 0,
          "balance": 0
        },
        {
          "coin": "KMD",
          "address": "RDoMmoCM5AcEH6Yf5vqKbqRjD1fLcQHuWb",
          "amount": 22.87391037,
          "price": 1,
          "kmd_equiv": 22.87391037,
          "perc": 78.92866505,
          "goal": 25,
          "goalperc": 25,
          "relvolume": 12.33559451,
          "force": -2908.30091422,
          "balanceA": 22.6448,
          "valuesumA": 22.87391037,
          "aliceutil": 98.9983769,
          "balanceB": 22.6448,
          "valuesumB": 22.87391037,
          "balance": 22.87391037,
          "bobutil": 98.9983769
        },
        {
          "coin": "ZEC",
          "address": "t1NPmhcjCSfbFojEMZBfKe8CShQPpkcn4W7",
          "amount": 0,
          "price": 135.89703925,
          "kmd_equiv": 0,
          "perc": 0,
          "goal": 25,
          "goalperc": 25,
          "relvolume": 0,
          "force": 625,
          "balanceA": 0,
          "valuesumA": 0,
          "balanceB": 0,
          "valuesumB": 0,
          "balance": 0
        },
        {
          "coin": "DGB",
          "address": "D9fGEYFhmkhwk6N4MLqm45G8Ksw3E2AmTR",
          "amount": 919,
          "price": 0.0066448,
          "kmd_equiv": 6.10657518,
          "perc": 21.07133495,
          "goal": 25,
          "goalperc": 25,
          "relvolume": 0,
          "force": 15.43440909,
          "balanceA": 479.499,
          "valuesumA": 919,
          "aliceutil": 52.17616975,
          "balanceB": 479.499,
          "valuesumB": 919,
          "balance": 919,
          "bobutil": 52.17616975
        }
      ]
    }
    

    myprice

    Shows number of bids andprices you set for a given coin. Your wallet must be active to display the prices.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"myprice\",\"base\":\"REVS\",\"rel\":\"KMD\"}"
    

    Sample Output:

    {
      "base": "REVS",
      "rel": "KMD",
      "bid": 2,
      "ask": 0
    }
    

    myprices

    ./myprices shows numer of bids and ask for your ./buy coin pair.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"myprices\"}"
    

    Sample Output:

    [
      {
        "base": "KMD",
        "rel": "REVS",
        "bid": 0,
        "ask": 0.5
      },
      {
        "base": "REVS",
        "rel": "KMD",
        "bid": 2,
        "ask": 0
      }
    ]
    

    pubkeystats

    This API will display swaps stats based on pubkey.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"statsdisp\",\"starttime\":0,\"endtime\":0,\"pubkey\":\"a2593155464e37fcc88245780240a412a38cf3d316809445aad73f4e7789187d\"}"
    

    setconfirms

    This will allow each node to set the number of required confirms on a coin by coin basis. During the atomic swap, each side sends to the other the required confirms and the "protocol" is that both sides use the bigger value.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setconfirms\",\"coin\":\"DGB\",\"numconfirms\":1}"
    

    Sample Output:

    {
      "result": "success"
    }
    

    setprice

    To create a bob utxo (or an ask order) you need to first set the price. To set price you need to edit the ./setprice script in the dexscripts folder

    Note: To fully cancel an autotrade, setprice 0 needs to be called twice, once with base/rel and then with rel/base, since there are actually 2 prices (bid and ask). Doing setprice 0 for an order made with coinmarketcap api call doesn't end it. It is likely as it has two 0's and you can only set one 0 at a time. The only way to stop an order made with coinmarketcap api is to kill marketmaker.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"KMD\",\"rel\":\"REVS\",\"price\":0.5}"
    

    Sample Output:

    {
      "result": "success"
    }
    

    fomo

    fomo Fear of missing out API will allow you buy for your specified relvol at the best current orderbook price. Orderbook has to be visible for this API to work. When using fomo you won't get the best price. No need to fomo if you are able to do normal ordermatch. It adds 5% to the orderbook entry that is the biggest that fits.

    Sample file content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"KMD\",\"rel\":\"HODL\",\"fomo\":40.00038}"
    

    dump

    As the name suggests, you can use dump API to dump the coins you want to at current orderbook price. Orderbook has to be visible for this API to work.

    Sample file content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"KMD\",\"rel\":\"HODL\",\"dump\":40.00038}"
    

    Status / Info

    getendpoint

    There is a new websockets realtime events to the barterDEX API family, getendpoint. It returns a nanomsg NN_PAIR endpoint that if you connect to it. You get an event stream, with hopefully all the relevant events, especially about the change in state of swap. The even stream is started as soon as the getendpoint API is called.

    There is also a new mode for marketmaker: ./marketmaker events which we should run in a new terminal. This should connect to the endpoint created by getendpoint API call. This will simply launch a new process and printout all the events. It will be like the console spew of printouts so you might want to nohup it and then grep to find things. This allows GUI to be done in an event driven way. Any command can add a "queueid":nn with a non-zero nn and it will queue the command. Its completion will arrive in the nanomsg event stream with the queueid and the result.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getendpoint\"}"
    

    Sample Output:

    {"result":"success","endpoint":"ws:/127.0.0.1:5555","socket":20,"sockopt":0}
    

    pendings

    ./pendings is a special case of statsdisp and will display all the pending swaps. Using recentswaps API is better suitable for most usecases.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"statsdisp\",\"starttime\":2000000000,\"endtime\":2000000000}"
    

    Sample Output:

    {
      "result": "success",
      "newlines": 0,
      "swaps": [
        {
          "aliceid": "7276253190735921153",
          "src": "30eb3d952f66eba2df0100b97d6707257cf91dc8c8b0237cfb7c3aa70dc52d4d",
          "base": "REVS",
          "basevol": 0.13338748,
          "dest": "1282417c4e7d5bb870067f5c05ffe87a0d8c8ce9956befff560e92b7c8d23741",
          "rel": "KMD",
          "relvol": 0.1505,
          "price": 1.12913831,
          "requestid": 2339417255,
          "quoteid": 1177391651,
          "line": "2017-10-30T16:16:00Z (nogui).(nogui) 0    connected    7276253190735921153: (0.13338748  REVS) -> (0.15050000   KMD) 1.12913831 finished.0 expired.0"
        }
      ],
      "volumes": [
        {
          "coin": "KMD",
          "srcvol": 0,
          "destvol": 0.1505,
          "numtrades": 1,
          "total": 0.1505
        },
        {
          "coin": "REVS",
          "srcvol": 0.13338748,
          "destvol": 0,
          "numtrades": 1,
          "total": 0.13338748
        }
      ],
      "request": 4,
      "reserved": 2,
      "connect": 4,
      "connected": 1,
      "duplicates": 4,
      "parse_errors": 0,
      "uniques": 1,
      "tradestatus": 0,
      "unknown": 0
    }
    

    swapstatus

    This will display the swap status for your trades along with requestid and quoteid. This API also helps unstuck swaps and help claim funds if the swap wasn't successfully completed. In order to claim stuck funds, remove all .finished file, start barterDEX, add coins and issue this script.

    These available API options are described below:

    swapstatus(pending=0)
    swapstatus(coin, limit=10)
    swapstatus(base, rel, limit=10)
    swapstatus(requestid, quoteid, pending=0)
    

    The base/rel swapstatus will scan ALL your historical swaps and that could take a very long time. There is a new parameter for the swapstatus API, fast:1. You can use this flag with swapstatus for base/rel, requestid/quoteid for faster and optimised performance while getting the response.

    2 different example scripts:

    curl --url "/127.0.0.1:7783" --data "{\"pending\":1,\"userpass\":\"$userpass\",\"method\":\"swapstatus\", \"base\":\"CHIPS\", \"rel\":\"KMD\", \"fast\":1}"
    
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"requestid\":2291973695,\"quoteid\":3387529385}, \"fast\":1}"
    # This is very helpful when you have so many swap files in DB/SWAPS dir.
    

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\"}"
    

    Sample Output:

    {
      "result": "success",
      "swaps": [
        {
          "status": "realtime",
          "requestid": 157581336,
          "quoteid": 2717912442
        },
        {
          "status": "realtime",
          "requestid": 2050117881,
          "quoteid": 263483411
        }
      ]
    }
    

    baserelswaps

    This method uses the swapstatus API and displays base/rel swapstatus.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"base\":\"MNZ\",\"rel\":\"KMD\"}"
    

    pendingswaps

    This way you can see what swaps are still pending. This uses pending=1 arg to swapstatus method.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"pending\":1}"
    

    Sample Output:

    {
    
    "result":"success",
    "swaps":[
    {
    "expiration":1512738286,
    "tradeid":4038861795,
    "requestid":1887485571,
    "quoteid":2755902417,
    "iambob":0,
    "Bgui":"",
    "Agui":"nogui",
    "gui":"nogui",
    "bob":"BTC",
    "srcamount":0.02555775,
    "bobtxfee":0.00212221,
    "alice":"KMD",
    "destamount":95,
    "alicetxfee":0.0001,
    "aliceid":"9807693779256541185",
    "sentflags":[
    "bobspend",
    "bobpayment",
    "alicepayment",
    "bobdeposit",
    "myfee",
    "bobrefund"
    ],
    "values":[
    0.02343554,
    0,
    0.02555775,
    95.0002,
    0.02875246,
    0,
    0.12226512,
    0.0279102,
    0,
    0,
    0
    ],
    "result":"success",
    "status":"finished",
    "finishtime":1512839121,
    "bobdeposit":"ec1e73395a7bd855bcf3afe58b0b1d478532ef398f2df68d2d10424e9d36743f",
    "alicepayment":"d3edb95bb9f3bd898f8b655398c5ab0ae86bc90d14176068096b6111eb201a05",
    "bobpayment":"9ff00880871d1474474378a4b9fc445ec13367be51a7b797a3cc76c1c4da52b6",
    "paymentspent":"0000000000000000000000000000000000000000000000000000000000000000",
    "Apaymentspent":"1fd16aaf9a41e44efe30bf01087470b9db3cf287b0b7a2634b25b97601e2acda",
    "depositspent":"27d774b0765eee97f7423785a4c80d3cea36adaccb5fa9f4fa5fe0e8fa68bfbe",
    "method":"tradestatus"
    }
    ]
    }
    

    coinswaps

    This method uses swapstatus for a spcific coin.

    Sample File Content:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"coin\":\"CHIPS\"}"
    

    swapstatus(requestid, quoteid, pending=0)

    You can get more information about the swaps by quering with requestid and quoteid. This API helps query about stuck swap and helps them unstuck. The sample file looks like below. pending=0 is optional.

    Sample file contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"requestid\":157581336,\"quoteid\":2717912442}"
    

    The sample result is below:

    {
      "requestid": 157581336,
      "quoteid": 2717912442,
      "iambob": 0,
      "bob": "REVS",
      "srcamount": 1.79816276,
      "bobtxfee": 0.0001,
      "alice": "KMD",
      "destamount": 2,
      "alicetxfee": 0.0001,
      "sentflags": [
        "alicespend",
        "bobpayment",
        "alicepayment",
        "bobdeposit",
        "myfee"
      ],
      "values": [
        1.79806276,
        0,
        1.79816276,
        2.0001,
        2.0229331,
        0,
        0.002674,
        0,
        0,
        0,
        0
      ],
      "result": "success",
      "status": "finished",
      "bobdeposit": "6f36a465184f9c2a377dc7a338ff24c1096c97a7cc13aa3a8e3cf2bd46d88c03",
      "alicepayment": "7221eb0ac7cb9985cd580d82310a1f95b4e47617597c1b747d7840e776d73a93",
      "bobpayment": "7a05b28041b112178ecf5d532a18ff8e75d280fec8a7bc4511fce0215a3c66d3",
      "paymentspent": "9a541250257346de1b7d5b4ca11814b2df7098b750af23d0fad5b245c5435110",
      "Apaymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
      "depositspent": "0000000000000000000000000000000000000000000000000000000000000000"
    }
    

    recentswaps

    This api returns up to "limit" in reverse order the swaps on the node and the current pending swap (if any) so you can see what trade might happen.

    'limit' = the number of latest swaps to be visible in output.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"recentswaps\",\"limit\":1}"
    

    Sample Output:

    {
      "result": "success",
      "swaps": [
        [
          2779577435,
          2461904533
        ],
        [
          932852928,
          3189912026
        ]
      ],
      "pending": {
        "expiration": 1508343494,
        "timeleft": 5,
        "base": "",
        "basevalue": 0,
        "rel": "",
        "relvalue": 0
      }
    }
    

    tradebots

    bot_buy

    Starts a auto tradebot to do the trading for you. maxprice is the highest price you want to pay for 1 base, relvolume is the total amount of coins you want to spend.

    Sample file contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_buy\",\"base\":\"MNZ\",\"rel\":\"KMD\",\"maxprice\":3,\"relvolume\":10.0}"
    

    Sample output:

    {
      "result": "success",
      "name": "buy_MNZ_KMD.1509539940",
      "botid": 3601212692,
      "started": 1509539940,
      "action": "buy",
      "base": "MNZ",
      "rel": "KMD",
      "maxprice": 3,
      "totalrelvolume": 10,
      "totalbasevolume": 3.33333333,
      "trades": []
    }
    

    bot_list

    This script will display a list of all botids that you used.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_list\"}"
    

    Sample Output:

    [
      2833291137,
      3601212692,
      2712409213
    ]
    

    bot_pause

    This command will pause a bot_buy order.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_pause\",\"botid\":$1}"
    

    Sample usage:

    ./bot_resume 3601212692 # here 3601212692 is the botid from ./bot_buy or ./bot_sell script output.

    Sample Output:

    {"result":"success"}
    

    bot_resume

    Resumes a paused tradebot.

    Sample file contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_resume\",\"botid\":$1}"
    

    Sample Usage:

    ./bot_resume 3601212692 # here 3601212692 is the botid from ./bot_buy or ./bot_sell script output.

    Sample Output:

    {"result":"success"}
    

    bot_sell

    Place a sell order using tradebots. minprice is the lowest you will sell for 1 coin, basevolume is the total amount of coins you want to sell.

    Sample file contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_sell\",\"base\":\"REVS\",\"rel\":\"KMD\",\"minprice\":2,\"basevolume\":5.0}"
    

    Sample Output:

    {
      "result": "success",
      "name": "sell_MNZ_KMD.1509549405",
      "botid": 2247122510,
      "started": 1509549405,
      "action": "sell",
      "base": "MNZ",
      "rel": "KMD",
      "minprice": 2,
      "totalbasevolume": 5,
      "totalrelvolume": 10,
      "trades": []
    }
    

    bot_settings

    ./bot_settings allows you to change price or volume after starting the bot_buy or bot_sell.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_settings\",\"botid\":$1,\"newprice\":$1,\"newvolume\":$2}"
    

    Sample Usage:

    ./bot_settings 2247122510 3 6 # here 2247122510 is botid and 3 is the new price, 6 is the new volume

    Sample Outputs:

    {
      "result": "success",
      "name": "sell_MNZ_KMD.1509549405",
      "botid": 2247122510,
      "started": 1509549405,
      "paused": 1509549517,
      "action": "sell",
      "base": "MNZ",
      "rel": "KMD",
      "minprice": 2247122510,
      "totalbasevolume": 0,
      "totalrelvolume": 3,
      "aveprice": 2,
      "volume": 4,
      "trades": [
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {}
      ],
      "completed": 4,
      "percentage": 149808167333.3333,
      "pending": 6,
      "pendingprice": 2,
      "pendingvolume": 6
    }
    

    bot_status

    Tradebot status. Use botid after the ./bot_status script.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_status\",\"botid\":$1}"
    

    Sample Usage:

    ./bot_status 3601212692 # here 3601212692 is the botid from ./bot_buy or ./bot_sell script output.

    Sample Output:

    {
      "result": "success",
      "name": "buy_MNZ_KMD.1509542273",
      "botid": 2384827585,
      "started": 1509542273,
      "paused": 1509542452,
      "action": "buy",
      "base": "MNZ",
      "rel": "KMD",
      "maxprice": 0.21,
      "totalrelvolume": 0.1,
      "totalbasevolume": 0.47619048,
      "aveprice": 0.20486144,
      "volume": 0.0672,
      "trades": [
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {},
        {}
      ],
      "completed": 7,
      "percentage": 67.2,
      "pending": 4,
      "pendingprice": 0.20633316,
      "pendingvolume": 0.0387
    }
    

    bot_statuslist

    Displays the status of all bots.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_statuslist\"}"
    

    bot_stop

    To stop the tradebots. Use botid from your buy or sell order.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_stop\",\"botid\":$1}"
    

    Sample usage:

    ./bot_stop 3601212692 # here 3601212692 is the botid from ./bot_buy or ./bot_sell script output.

    Sample Output:

    {"result":"success"}
    

    Coin Wallet Features

    balance

    This will display the balance of a specific smartaddress for barterDEX trading. The idea of the barterDEX balance are, utxo. That are "hot" / "live" ready for trading. It is the analogue of funds in an exchange account. This will not show your full wallet balance, and you wouldn't want the exchange account balance to show the amount of all your coins, including the ones not deposited in the exchange. Edit the file with coin name and smartaddress and it will display balance of your smartaddress(s).

    KMD balance will display zcredits as well.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balance\",\"coin\":\"KMD\",\"address\":\"RDoMmoCM5AcEH6Yf5vqKbqRjD1fLcQHuWb\"}"
    

    Sample Output:

    {"result":"success","coin":"KMD","address":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","balance":360.33996021,"zcredits":0,"zdebits":{"swaps":[],"pendingswaps":0}}
    {"result":"success","coin":"REVS","address":"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ","balance":39.10219798}
    {"result":"success","coin":"BTC","address":"126nKAnGxWtsfPoxGh1snvbtLitkstZbvV","balance":0.00400000}
    

    balances

    This method will display balance of all active coins in your wallet. No need to use a curl script for a specific coin and address.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\"}"
    

    Sample Output:

    {"coin":"BTC","balance":0.00400000}, {"coin":"KMD","balance":360.33996021}, {"coin":"MNZ","balance":55.70756040}, {"coin":"REVS","balance":39.10219798}, {"coin":"JUMBLR","balance":1.12038776}, {"coin":"SUPERNET","balance":0.91430900}, {"coin":"PANGEA","balance":1}, {"coin":"DEX","balance":1}, {"coin":"BET","balance":1}, {"coin":"CRYPTO","balance":1}, {"coin":"HODL","balance":1}, {"coin":"BOTS","balance":1}, {"coin":"COQUI","balance":10.85596031}
    

    calcaddress

    Useful to get your private key for specific seed passphrase for any supported coin or asset except ETH & ERC20 tokens for now. Edit the passphrase section and change the word default with your own seed passphrase and coin name. We used Digibyte (DGB) as example.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"calcaddress\",\"passphrase\":\"default\",\"coin\":\"DGB\"}"
    

    Sample Output: This output is based on the passphrase default. Change that to your seed passphrase to get your desired private key.

    {
      "passphrase": "default",
      "pubsecp": "03562035ac51f940b7f6e1e390df91fb0fe7f59f99acf8f6f389d9472a14797b5f",
      "coinaddr": "DKRQHUtFhFfViZPCcCut3uB45cATTXXBMh",
      "p2shaddr": "3FyKfmS3wk5bGiu2ziauvmNPLzisePpY3W",
      "privkey": "30a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0684f",
      "wif": "KxrJKHQ7phDnVnsbs2XEZUeWxjH3zSG6SzftyQGfojEG7ZkU9Zsn"
    }
    

    fundvalue

    fundvalue will process "holdings":[] array and also do an internal balances api call if address is specified. This will only work for watchonly addresses that have been rescanned and with active coins. In order for external addresses to work, you need to have importaddress and rescan done, for obvious reasons, in native mode. SPV mode should just work without that.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}"
    

    Sample Output:

    {"holdings":[{"coin":"KMD","KMD":6000000}, {"coin":"REVS","error":"no price source"}, {"coin":"JUMBLR","KMD":4177502.22193679}, {"coin":"SUPERNET","error":"no price source"}, {"coin":"PANGEA","error":"no price source"}, {"coin":"DEX","error":"no price source"}, {"coin":"BET","error":"no price source"}, {"coin":"CRYPTO","error":"no price source"}, {"coin":"HODL","error":"no price source"}, {"coin":"MSHARK","error":"no price source"}, {"coin":"BOTS","error":"no price source"}],"fundvalue":10177502.22193679}
    

    getrawtransaction

    barterDEX now has getrawtransaction API for any installed coin and will use Electrum or native depending on whether electrum was called, that should help us directly issue Electrum for the oversized txid and directly cause any overflows.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getrawtransaction\",\"coin\":\"KMD\",\"txid\":\"107a2683abbfa9188f78e17d3bcba66ece5bd7cbe105ab5bbaae79364159e84d\"}"
    

    inuse

    This API will return you all the UTXOs that are locked for swaps. The UTXOs that are locked for swaps are not spendable until they become free. The lock is basically for about 2 minutes, after that the UTXOs becomes free.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"inuse\"}"
    

    Sample Output:

    [
      {
        "expiration": 1520277125,
        "txid": "74a9f85dc372c3941bdfa7bc517f209db11c2fbdf7c83df3f4c8ccf15afa9e75",
        "vout": 1
      },
      {
        "expiration": 1520277125,
        "txid": "46f021a999b5f62fc42afeb431d09c85a2f2bc113aa23b5142cafb868a877bd0",
        "vout": 1
      }
    ]
    

    listunspent

    barterDEX uses utxo pairs instead of total balance to do the trading. For this the balance has be broken down and fund the address using 1x, 1.2x & 0.1x ratio. It is due to the nature of atomic swap protocol that is bartering specific utxo and the need for two utxo per atomic swap. Analogy: If you need a quarter and a dime, exactly to make a purchase, is it possible to use just a single coin? barterDEX is swapping PAIRS (as in two) utxos. ./listunspent Gives similar output like your coin wallet. It will list all the unspent transactions (utxo) you have in a given coin wallet smartaddress.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"listunspent\",\"coin\":\"CHIPS\",\"address\":\"RDoMmoCM5AcEH6Yf5vqKbqRjD1fLcQHuWb\"}"
    

    Sample Output:

    [
      {
        "tx_hash": "873e12d89eb9a25c1c40f0301b77414da0567982e3a06ce55a3501ff726bd253",
        "tx_pos": 1,
        "height": 534479,
        "value": "1251800000"
      },
      {
        "tx_hash": "8a62bb10f700c16629a52ad0dc8c730490de3038e30af82b1a706c91f337d968",
        "tx_pos": 1,
        "height": 535408,
        "value": "11000000"
      },
      {
        "tx_hash": "8848abd97daca43c702dbb176dac50d85261449c808f19324f5be1b4a495ad69",
        "tx_pos": 1,
        "height": 535379,
        "value": "11000000"
      },
      {
        "tx_hash": "79684e9c19c996292ad4a25c9dc05c89a3a9243af1b83727362bb2e2f92e08f6",
        "tx_pos": 1,
        "height": 534027,
        "value": "1012700000"
      }
    ]
    

    listtransactions

    This API just passes through the call to native mode and filters out any with a different address. For spv it just returns the SPV history.

    Sample File Content:

    #!/bin/bash
    source userpass
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"listtransactions\",\"coin\":\"JUMBLR\",\"address\":\"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ\"}"
    

    Sample output using Native mode:

    [
      {
        "account": "",
        "address": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "category": "receive",
        "amount": 0.26042583,
        "vout": 0,
        "confirmations": 8904,
        "blockhash": "00009eeaa7458a5d781830c166158481fda6ae039450607f90e239d839694050",
        "blockindex": 2,
        "blocktime": 1521983789,
        "txid": "2ff201697e8486865638d35f4de796ce025ec72734c4053a6b835dfb50340ca9",
        "walletconflicts": [],
        "time": 1521983789,
        "timereceived": 1522155873,
        "vjoinsplit": [],
        "size": 300
      },
      {
        "account": "",
        "address": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "category": "receive",
        "amount": 0.00203615,
        "vout": 1,
        "confirmations": 5955,
        "blockhash": "00000e1d26d1e13cb9c9456f2f2112fd2c3079fbdf66a88dbbf96db6114aecfe",
        "blockindex": 1,
        "blocktime": 1522161804,
        "txid": "2235aa0b2beed7b2a79619df044912af3baec026cda6a4eb00c9de5b6a1f6788",
        "walletconflicts": [],
        "time": 1522161801,
        "timereceived": 1522161801,
        "vjoinsplit": [],
        "size": 223
      },
      {
        "account": "",
        "address": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "category": "send",
        "amount": -0.00203615,
        "vout": 1,
        "fee": -1e-05,
        "confirmations": 5955,
        "blockhash": "00000e1d26d1e13cb9c9456f2f2112fd2c3079fbdf66a88dbbf96db6114aecfe",
        "blockindex": 1,
        "blocktime": 1522161804,
        "txid": "2235aa0b2beed7b2a79619df044912af3baec026cda6a4eb00c9de5b6a1f6788",
        "walletconflicts": [],
        "time": 1522161801,
        "timereceived": 1522161801,
        "vjoinsplit": [],
        "size": 223
      },
      {
        "involvesWatchonly": true,
        "account": "",
        "address": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "category": "receive",
        "amount": 14.4499848,
        "vout": 0,
        "confirmations": 4278,
        "blockhash": "0000f759c96b9c866e6417bb3c653e323feea999ce1dabcc27c007f72543f14c",
        "blockindex": 1,
        "blocktime": 1522261902,
        "txid": "6b2b506cffe3423e25d3519c64a5279213993e0d235ff89cbb3bf53be7a727fb",
        "walletconflicts": [],
        "time": 1522261807,
        "timereceived": 1522261807,
        "vjoinsplit": [],
        "size": 300
      },
      {
        "involvesWatchonly": true,
        "account": "",
        "address": "RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ",
        "category": "send",
        "amount": -14.4499848,
        "vout": 0,
        "fee": -1e-05,
        "confirmations": 4278,
        "blockhash": "0000f759c96b9c866e6417bb3c653e323feea999ce1dabcc27c007f72543f14c",
        "blockindex": 1,
        "blocktime": 1522261902,
        "txid": "6b2b506cffe3423e25d3519c64a5279213993e0d235ff89cbb3bf53be7a727fb",
        "walletconflicts": [],
        "time": 1522261807,
        "timereceived": 1522261807,
        "vjoinsplit": [],
        "size": 300
      }
    ]
    

    Sample output using SPV mode:

      {
        "tx_hash": "7c536b8f3d1e33f110ae62399f181b4c5af9a16938b1ecef59f48c226dd2a9be",
        "height": 8285
      },
      {
        "tx_hash": "f3169db98c3b7263130d8d0d91aa17df361b76737f8df8363e3b4caeb1afaa55",
        "height": 8288
      },
      {
        "tx_hash": "24874d70f3cfa5ae3a1c31916af7bdc6cb6d6fe5d428a12873c373db703bd101",
        "height": 8833
      },
      {
        "tx_hash": "9281bcfc9c3262cb3e6d8440fd0250357a8660a24aa22abeca8ce7512c0cf111",
        "height": 9012
      },
      {
        "tx_hash": "c3561504f2ce0af8f5c63fa01424d6acb5576caddfa543dc3e16301d51f744f6",
        "height": 9013
      },
      {
        "tx_hash": "dce11261eaae611347a5967ea727f0bc0a3ee87e11250ad2ef0758a999d7e920",
        "height": 9602
      },
      {
        "tx_hash": "afc2fd0991bdef89da2cd1018c86ab56a5989c6f2b1d4e40861e88bc6125cbec",
        "height": 10076
      }
    

    secretaddresses

    It will display secret 10 addresses with their private keys for a given pubtype. You can change the num, pubtype etc by editing the script.

    Sample File Contents:

    echo "usage: ./secretaddresses 'passphrase'"
    
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"secretaddresses\",\"num\":16,\"passphrase\":\"$1\"}"
    

    Sample Output:

    usage: ./secretaddresses 'passphrase'
    {"R9oeSNXqR499PFz2BgUeZJvSsp331TFDYi":"UxKrG3xxxxxx",
    "RX7sUCvxV45LmrmVRvkbm8kUedFqhXgqtt":"UuNeHYexxxxxx",
    "RRKf3RnmbNDnCfC6P7HHYNBJuRrVxEm7Db":"UsXUNtmxxxxxx",
    "RSo6exWzMbnGnwM4b3WcT1MvxvnRuRSURP":"UsFuDaWxxxxxx",
    "RRve3cdBJPF2dcT6uD8gT2Bfhg7ZU9krFU":"Uw1Xbcoxxxxxx",
    "REkV8JMBuLFTjYH93QfJ4UpmoLw85LomP4":"UpYxoFMxxxxxx",
    "RKJ6vpCTYjDCoyrLyuxJRvjiraM5ZEwos5":"Urin6VUxxxxxx",
    "RDHo38pWxDEvqx99C2aJhprHQwf9bYoKRE":"UuNsFyBxxxxxx",
    "RLGRaoQ7FCu8dk653CMR4nLiRnfYZiXb7D":"UvT2utaxxxxxx",
    "RJABFzJzBNoPUGZrMBcBfL5UqYjY8hptJU":"UsoAJqRxxxxxx",
    "RN2TRHQBFWMB9G1MkHKdYbg4oU7ToxRTdB":"UqNiGgAxxxxxx",
    "RJYuYeXAnWoVPbgHpc1rtxkoBWFCtzib1E":"Uqeaxmzxxxxxx",
    "RXkZYAD13G89foJbN7uHpD2A2oZJaDTMzr":"UqejSkPxxxxxx",
    "RUfuMah7a9QXar5XcJpage4S7jtoiL99Kv":"Uq7e4Hdxxxxxx",
    "RTS385Ny2feDBgLGzrAPRw2Q7u5jpv9jZs":"UvUcSEPxxxxxx",
    "RP7haeUQv56FW9X6W1rRbhbqvXPyvX23Fi":"UpqRcKMxxxxxx"}
    

    sendrawtransaction

    This method will broadcast a raw transaction over the network. Uses tx-hex from ./withdraw API output. This API will output only txid.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sendrawtransaction\",\"coin\":\"KMD\",\"signedtx\":\"$1\"}"
    

    supernet

    supernet script uses the balances API and returs all SuperNET aseet balances along with KMD for a specific address. In order for external addresses to work, you need to have importaddress and rescan done, for obvious reasons, in native mode. SPV mdoe just works without that.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}"
    

    Sample Output:

    [{"coin":"KMD","balance":6000000}, {"coin":"REVS","balance":6335.95500000}, {"coin":"JUMBLR","balance":239022.38900000}, {"coin":"SUPERNET","balance":6335.95500000}, {"coin":"PANGEA","balance":602828.14640000}, {"coin":"DEX","balance":257733}, {"coin":"BET","balance":2688}, {"coin":"CRYPTO","balance":320754.73700000}, {"coin":"HODL","balance":70000}, {"coin":"MSHARK","balance":385403.90000000}, {"coin":"BOTS","balance":288157}]
    

    timelock and unlockedspend

    BarterDEX now have a coin agnostic timelock/unlock mechanism. Of course the coin will need to support CLTV or it wont work. The timelock will work partially, but the unlockspend will NOT. Test with small amount. Don't confuse these APIs with 0conf deposit and claim.

    timelock Sample file content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"timelock\",\"coin\":\"KMD\",\"duration\":1000,\"amount\":1}"
    

    unlockedspend Sample file content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"unlockedspend\",\"coin\":\"KMD\",\"txid\":\"e858e382a816b4cab22e3fd3e29901c7ef497cd1fdad7683314cc9187eca34fd\"}"
    

    timelock API is pretty simple, just specify coin, duration in seconds and the amount. An extra txfee will be added to amount so the unlockspend can send the specified amount. there is an optional destaddr field that will allow you to send to any address. Like withdraw, timelock will not actually broadcast the tx, so you need to use sendrawtransaction to actually broadcast it.

    Once its broadcast, and the time lock expires, you can do an unlockedspend using just the coin and the txid. The requirement is that it must be sent to your smartaddress that you are logged into and it will only just unlock and send to yourself.

    withdraw

    To withdraw, you just need to specify the array of outputs and the coin. It returns the rawtx, the signed transaction in hex the txid and if it was complete or not. All inputs are assumed to be standard pay to pubkeyhash, having other non-standard utxo will make it create invalid rawtx. Withdrawing ETH/ERC20 tokens works using different parameters (please see 3478256821,).

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"KMD\",\"outputs\":[{\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.001}, {\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.002}],\"broadcast\":1}"
    

    Sample Output:

    {"method":"withdraw","coin":"KMD","outputs":[{"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf":0.00100000}, {"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf":0.00200000}]} -> f6b04d157c007bf688822a73c754934f53cf28516f64dc64372fa397789e9ce1
    {"rawtx":"0100000001b5384fc2f0b737a17239eaf2172bf24c4f410f720e672c3f56a9b5a8e0b33a910100000000ffffffff03a0860100000000001976a914d4d2ffc812cdce0c30c5184e8ea1deb7bfeb5b3888ac400d0300000000001976a914d4d2ffc812cdce0c30c5184e8ea1deb7bfeb5b3888ac06771300000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688ac7dd4e359","hex":"0100000001b5384fc2f0b737a17239eaf2172bf24c4f410f720e672c3f56a9b5a8e0b33a91010000006b483045022100df405fe4f79e66052a952968b93ed3f56b2fc75908a90c70d9d409b4da45996902200b9136063fcdb0bfdfeb09801d2fcbb0658236d69135711a20ac4aa50c8d3bf0012102ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92ffffffff03a0860100000000001976a914d4d2ffc812cdce0c30c5184e8ea1deb7bfeb5b3888ac400d0300000000001976a914d4d2ffc812cdce0c30c5184e8ea1deb7bfeb5b3888ac06771300000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688ac7dd4e359","txid":"f6b04d157c007bf688822a73c754934f53cf28516f64dc64372fa397789e9ce1","complete":true}
    

    If the last output is doing a withdraw to the smartaddress, it is combined with change. Here are two sample console output below. The first one is withdrawing 10 KMD to the same smartaddress. Second one is 10 & 10.0001 KMD withdraw to the same smartaddress. The last output is increased by 0.0001 & change combined in both example.

    vout.0 10.00010000 -> total 10.00020000
    dustcombine.0 numpre.0 min0.(nil) min1.(nil) numutxos.172 amount 10.00020000
    minutes.381 tiptime.1514745296 locktime.1514722428
    46bbfbe93ebfc0a9262143193fe50d5c9ce5c2739da768ce8b5ec919ffaa570f/0 40.01342800 interest 0.00122360 -> sum 0.00122360
    numunspents.171 vini.0 value 40.01342800, total 40.01342800 remains -30.01322800 interest 0.00122360 sum 0.00122360 46bbfbe93ebfc0a9262143193fe50d5c9ce5c2739da768ce8b5ec919ffaa570f/v0
    set inuse until 1514746673 lag.600 for 46bbfbe93ebfc0a9262143193fe50d5c9ce5c2739da768ce8b5ec919ffaa570f/v0
    change 30.01445160 = total 40.01465160 - amount 10.00020000, adjust 0.00000000 numvouts.1
    combine last vout 10.00010000 with change 30.01445160
    LP_withdraw.KMD {"method":"withdraw","coin":"KMD","outputs":[{"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ":10.00010000}]} -> d3f32d814e20edcbc0c654eec79d0399b38b907ecc8cb9418da17a543d299e17
    
    vout.0 10.00000000 -> total 10.00010000
    vout.1 10.00010000 -> total 20.00020000
    dustcombine.0 numpre.0 min0.(nil) min1.(nil) numutxos.172 amount 20.00020000
    numunspents.171 vini.0 value 40.01455160, total 40.01455160 remains -20.01435160 interest 0.00000000 sum 0.00000000 d3f32d814e20edcbc0c654eec79d0399b38b907ecc8cb9418da17a543d299e17/v0
    set inuse until 1514747480 lag.600 for d3f32d814e20edcbc0c654eec79d0399b38b907ecc8cb9418da17a543d299e17/v0
    change 20.01435160 = total 40.01455160 - amount 20.00020000, adjust 0.00000000 numvouts.2
    combine last vout 10.00010000 with change 20.01435160
    LP_withdraw.KMD {"method":"withdraw","coin":"KMD","outputs":[{"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ":10}, {"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ":10.00010000}]} -> f24361b13b7f0188ea422572b882c0df50bef2a33bf8aed7bf0776946332cece
    

    eth_withdraw

    This method is required to withdraw ETH/ERC20 coin/tokens. Similar functionality to withdraw for Bitcoin protocol based coins.

    Sample File Content:

    curl --url "/127.0.0.1:7783 " --data "{\"userpass\":\"$userpass\",\"method\":\"eth_withdraw\",\"coin\":\"DEC8\",\"to\":\"0xbAB36286672fbdc7B250804bf6D14Be0dF69fa29\",\"amount\":1000}"
    

    opreturn

    OP_RETURN is just built into the withdraw API. If an "opreturn":"<hex>" is defined, it will create an OP_RETURN with the binary of the hex. Without outputs value, it will return {"error":"withdraw needs to have outputs"}. There is encryption to the opreturn mode of withdraw. Basically if you specify a non-null passphrase, it encrypts with that passphrase and you will need that passphrase to decode it. The second parameter in the first example script is the passphrase. So, if you don't specify it, it is unencrypted.

    3 different sample scripts:

    curl -X POST --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"COQUI\",\"passphrase\":\"$2\", \"opreturn\":\"$(echo -n "$1" | od -A n -t x1 | perl -pe 's/\W+/g')\"}"
    
    curl -X POST --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"COQUI\",\"outputs\":[{\"RGCVXhUxepCxh77thy7XgMrQ5XU9u7SWSR\":0.01}], \"opreturn\":\"$(echo -n "$1" | od -A n -t x1 | perl -pe 's/\W+/g')\"}"
    
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"KMD\",\"outputs\":[{\"RANyPgfZZLhSjQB9jrzztSw66zMMYDZuxQ\":$1}], \"opreturn\":\"deadbeef\"}"
    

    Sample Output:

    {"rawtx":"01000000029059515dd331b448b213c12e607b4f104a025f9461d1c094d98010a06406b62d0100000000ffffffff6843fc7a13218df69cd7e03c64af2cefae7b1121ed55206da21c57d5665c8b640100000000ffffffff02565c1700000000001976a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac0000000000000000066a04deadbeef1a69a05a","hex":"01000000029059515dd331b448b213c12e607b4f104a025f9461d1c094d98010a06406b62d010000006b483045022100d80b9fcf9561c889bcdbab79d2215e1fe66118ad1c1d1e8ec5421ced6b2de2ad02206ef83ed458e974ecc8fa9b667e34ab571b06f5e62dd83bff37c00ab5e372bdef012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff6843fc7a13218df69cd7e03c64af2cefae7b1121ed55206da21c57d5665c8b64010000006b483045022100ec7c86079d1ce7512a835d81cedd850028e297ce22841ae925d5aceaff6f5e78022045a09dcad77f0bcc6d9d85f27ca9c13ba407c0c7968f85c50887b231067050e3012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff02565c1700000000001976a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac0000000000000000066a04deadbeef1a69a05a","tx":{"version":1,"locktime":1520462106,"vin":[{"txid":"2db60664a01080d994c0d161945f024a104f7b602ec113b248b431d35d515990","vout":1,"scriptPubKey":{"hex":"76a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac"}}, {"txid":"648b5c66d5571ca26d2055ed21117baeef2caf643ce0d79cf68d21137afc4368","vout":1,"scriptPubKey":{"hex":"76a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac"}}],"vout":[{"satoshis":"1530966","scriptPubKey":{"hex":"76a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac"}}, {"satoshis":"0","scriptPubKey":{"hex":"6a04deadbeef"}}]},"txid":"4e2a338232d13643cdbd6fb0c47d649b9c1842284a78ab6ca9cf03088f3dc0cc","complete":true}
    

    opreturndecrypt

    This method will decrypt the encrypted OP_RETURN easily.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"opreturndecrypt\",\"coin\":\"KMD\",\"txid\":\"06e59c6e9217ef1e526a1419e231e5f927689765feab9cd48167e089301f6fc2\",\"passphrase\":\"test\"}"
    
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"opreturndecrypt\",\"coin\":\"KMD\",\"txid\":\"34bf4bc2247e43c0c6a2223b79d3f1a3e9962102fb4a563612e5bbb91fb85348\",\"passphrase\":\"test\"}"
    
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"opreturndecrypt\",\"coin\":\"KMD\",\"txid\":\"a9e94e6890d6998b3c2b89685e8c7c2b9e380a53fb813192701d0966480807eb\",\"passphrase\":\"test\"}"
    

    Sample Output:

    {"coin":"KMD","opreturntxid":"06e59c6e9217ef1e526a1419e231e5f927689765feab9cd48167e089301f6fc2","opreturn":"6a4c4c4c0058501c2c290f7241932a8b4614b844bae28cc3117eeb79d5c0c900000000000000000000000000000000a30dc015ac4e4085f0cdb2c7cc24bca01d771449912d2982d7e9401ef52e5a81","result":"success","decrypted":"68656c6c6f2c20776f726c6474657374","original":"hello, worldtest"}
    
    {"coin":"KMD","opreturntxid":"34bf4bc2247e43c0c6a2223b79d3f1a3e9962102fb4a563612e5bbb91fb85348","opreturn":"6a4c4d4d00215bb9fee0d7685c5fcf913f4da4fab726104b1b242d5226939b00000000000000000000000000000000cc5eedec8e34b68726ff77cad0558659333fee18e5b63f8ef259444f66f185e62e","result":"success","decrypted":"68656c6c6f2c20776f726c647465737431","original":"hello, worldtest1"}
    
    {"coin":"KMD","opreturntxid":"a9e94e6890d6998b3c2b89685e8c7c2b9e380a53fb813192701d0966480807eb","opreturn":"6a4b4b0057a7b6c2ac0354f967534060bc3719a687bedc3b4741c3c64b7d00000000000000000000000000000000fe4170681aab23ba044516812bc5fe9dd5adb3a2f05fbc8d46e7be69f02040","result":"success","decrypted":"68656c6c6f2c20776f726c64746573","original":"hello, worldtes"}
    

    All three recreated the original string passed into the 203-420-1891 script. This functionality should allow apps to easily created and retrieve encrypted OP_RETURN.

    Statistics

    guistats

    guistats method is for GUI apps to display statistics, based on the statsdisp API.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"statsdisp\",\"starttime\":0,\"endtime\":0,\"gui\":\"SimpleUI\"}"
    

    pricearray

    pricearray will display statistical price data based on timescale.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"pricearray\",\"base\":\"REVS\",\"rel\":\"KMD\",\"timescale\":300}"
    

    This will output the data in an order of [timestamp, avebid, aveask, highbid, lowask]

    Sample output:

    [
     [1510603500, 1.40944454, 1.40944453, 3.13224635, 1.07003092],
     [1510603800, 1.50064727, 1.50064726, 3.13224635, 1.07003092],
     [1510604100, 1.50064727, 1.50064726, 3.13224635, 1.07003092],
     [1510607100, 1.44868382, 1.44868381, 3.13224635, 1.07003092],
     [1510607400, 1.50064727, 1.50064726, 3.13224635, 1.07003092],
     [1510607700, 1.52877070, 1.52877069, 3.13224635, 1.07003092],
     [1510608000, 1.55019807, 1.55019806, 3.13224635, 1.09860370],
     [1510608300, 1.57205536, 1.57205536, 3.13224635, 1.09860370],
     [1510608600, 1.30344136, 1.30344135, 1.76975636, 1.17393764],
     [1510611600, 1.21488583, 1.21488582, 1.25583401, 1.17393764],
     [1510611900, 1.25661049, 1.25661048, 1.34097978, 1.17393764]
    ]
    

    statsdisp

    statsdisp processes the stats.log file on your node. It will display the swaps as best as it can figure out the unique number of swaps, you can set specific starttime and endtime. If not specified, will display all. If both are the same time from the future, it will display only the pending stats.

    This is a very good feature as it can identify any node that is trying to do too many trades at once

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"statsdisp\",\"starttime\":0,\"endtime\":0}"
    

    Sample Output:

    {
      "result": "success",
      "newlines": 0,
      "request": 0,
      "reserved": 0,
      "connect": 0,
      "connected": 0,
      "duplicates": 0,
      "parse_errors": 0,
      "uniques": 0,
      "tradestatus": 0,
      "unknown": 0
    }
    

    ticker

    'ticker' API returns trades for the previous 24hours. You can set base/rel optionally. Most useful for price and marketcap statistics.

    Sample File Content:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"ticker\",\"base\":\"REVS\",\"rel\":\"KMD\"}"
    

    Sample Output:

    [{"timestamp":1513174486,"KMD":4.02827942,"CHIPS":80.00010000,"price":19.85962036}, {"timestamp":1513168630,"KMD":0.07448089,"MNZ":0.25609997,"price":3.43846549}, {"timestamp":1513166465,"CRYPTO":44.00844307,"KMD":500.00010000,"price":11.36145851}, {"timestamp":1513158008,"KMD":463.91820708,"SUPERNET":10.00010000,"price":0.02155574}]
    

    tradesarray

    tradesarray will display statistical trade data based on timescale in seconds.

    Sample File Content (This will output the data in an order of [timestamp, high, low, open, close, relvolume, basevolume, aveprice, numtrades]):

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"tradesarray\",\"base\":\"REVS\",\"rel\":\"KMD\",\"timescale\":120}"
    

    Sample output:

    [
     [1511480400, 1.27614172, 1.27614172, 1.27614172, 1.27614172, 0.04990000, 0.03910224, 1.27614172, 1],
     [1511480520, 1.97936698, 1.36595231, 1.97936698, 1.36595231, 0.09980000, 0.06174137, 1.61642024, 2],
     [1511480640, 2.11837065, 2.11837065, 2.11837065, 2.11837065, 0.04990000, 0.02355584, 2.11837065, 1],
     [1511481840, 1.63195519, 1.55147942, 1.63195519, 1.55147942, 0.09980000, 0.06273967, 1.59070011, 2],
     [1511481960, 1.82528276, 1.82528276, 1.82528276, 1.82528276, 0.04990000, 0.02733823, 1.82528276, 1],
     [1511482680, 1.77777461, 1.77777461, 1.77777461, 1.77777461, 0.04990000, 0.02806880, 1.77777461, 1]]
    

    Communication

    deletemessages

    As the name suggests this API will let you delete messages received from other nodes.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"deletemessages\",\"firsti\":0,\"num\":10}"
    

    Sample Output:

    {
      "result": "success"
    }
    

    getmessages

    This API will allow to retrieve messages sent from other nodes.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getmessages\",\"firsti\":0,\"num\":10}"
    

    Sample Output:

    {
      "messages": []
    }
    

    message

    The ./message script let nodes communicate with each other with end to end encryption. It is recommended to message a node first before doing an actual trade to make sure they can communicate.

    To send a message you need to have the recipients public key. The public key can be found when launching the ./client or running any other script the first time after launching ./client. Edit the ./message script to write your custom message. Execute ./message <pubkey of recipient> to send the message.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"pubkey\":\"$1\",\"method\":\"sendmessage\",\"message\":\"some sort of message\"}"
    

    Sample Output:

    {
      "result": "success"
    }
    

    Revenue Sharing/Operations

    dividends

    This script will allow users / organizations to send dividends for any specific coins/asstets

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"dividends\",\"coin\":\"KMD\",\"height\":$1,\"prefix\":\"fiat/jumblr sendtoaddress\",\"suffix\":\"\",\"dividend\":50000,\"dust\":1}"
    

    snapshot

    The name says it all, snapshot will take a snap of the blockchain for a specified coin/asset on a certain block height for sending dividends or airdrop.

    Sample File Contents:

    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"snapshot\",\"coin\":\"KMD\",\"height\":$1}"
    

    snapshot_balance

    This API will display the snapshot balance of a specific coin address after snapshot taken on a specific block height. You need to have jq installed (/stedolan.github.io/jq/).

    Sample File Contents:

    ht=$1
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"snapshot_balance\",\"coin\":\"KMD\",\"height\":$ht,\"addresses\":[\"RSAzPFzgTZHNcxLNLdGyVPbjbMA8PRY7Ss\", \"RBgD5eMGwZppid4x7PTEC2Wg1AzvxbsQqB\"]}"
    

    snapshot_loop

    This API is used to automate snapshot process for coins/assets at given block height and certain number thereafter. You can configure the script to run on certain block height increments.

    Sample File Contents:

    ht=$1
    while true
    do
    curl --url "/127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"snapshot\",\"coin\":\"KMD\",\"height\":$ht}"
    #ht=`komodo-cli getinfo | jq .blocks`
    ht=$(( $ht + 1000 ))
    echo next height $ht
    sleep 1
    done
    

    Errors