NAV
cURL CLI javascript
  • Introduction
  • Authentication
  • Configuring Clients
  • hsd - Node
  • hsd - Coins
  • hsd - Transactions
  • RPC Calls - Node
  • RPC Calls - Chain
  • RPC Calls - Block
  • RPC Calls - Mempool
  • RPC Calls - Transactions
  • RPC Calls - Mining
  • RPC Calls - Network
  • RPC Calls - Names
  • Wallet
  • Wallet - Admin Commands
  • Wallet - Accounts
  • Wallet - Transactions
  • Wallet - Auctions
  • RPC Calls - Wallet Auctions
  • RPC Calls - Wallet
  • Sockets
  • Node Sockets
  • Wallet Sockets
  • Errors
  • Introduction

    Welcome to the hsd API!

    hsd is a fork of bcoin and so if you are familiar with it, you'll find that the API is very similar to the bcoin API. bcoin was released with a JSON-RPC API that was based on the Bitcoin Core RPC interface. The actual Bitcoin Core RPC API has changed a lot since then, but if you are familiar with using bitcoind, you'll find a lot of the same RPC calls available in hsd.

    # Examples:
    
    # Get a transaction by hash from the full node HTTP API:
    
    
    curl http://x:api-key@127.0.0.1:14037/tx/\
      4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f
    
    
    # Get a raw transaction by hash from the full node RPC API:
    
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ \
        "method": "getrawtransaction", \
        "params": [ "4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f"] \
      }'
    
    
    # Get a transaction by hash from the "primary" wallet HTTP API:
    
    
    curl http://x:api-key@127.0.0.1:14039/wallet/primary/tx/\
      4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f
    
    
    # Get a transaction by hash from the wallet RPC API:
    
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ \
        "method": "gettransaction", \
        "params": [ "4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f" ] \
      }'
    

    There are four API servers in hsd

    The full node and the wallet are separate modules in hsd, and their API servers run on separate ports. The wallet is configured as a plug-in by default but can actually be run as a separate process (even on a remote server) using websockets and HTTP requests to sync with the full node.

    Network Wallet API Port Node API Port
    main 12039 12037
    testnet 13039 13037
    regtest 14039 14037
    simnet 15039 15037

    In addition, each server has two API formats: JSON-RPC and a RESTful HTTP API. Much of the functionality is duplicated between the HTTP API and RPC API. Note that if multiple user-agents are using the wallet at the same time, the wallet RPC API is not safe as it maintains global state (more on this below) It is recommended to use the wallet HTTP API in multiprocess/multithreaded environments.

    Values

    The smallest unit of the Handshake currency (HNS) is called the "dollarydoo" — one millionth of the whole.
    So 1 HNS = 1 000 000 dollarydoos.
    Different APIs require value and fee rate parameters denominated either in dollarydoos (subunits) which are integer values or in whole HNS, which are floats.

    When using HTTP API endpoints:
    value and rate are expressed in dollarydoos when using cURL or Javascript.
    value and rate are expressed in whole HNS when using CLI commands.

    When using RPC API commands:
    value and rate are always expressed in whole HNS, no matter the entry method.

    Indexing

    hsd has two indexer modules that are inactive by default. When turned on, the indexers enable additional API calls.

    Transaction indexer: enabled by --index-tx=true. Allows lookup of arbitrary transactions by their hash (txid). When disabled, the wallet still tracks all of its own transactions by hash and the full node can still be used to look up UTXO (unspent transaction outputs). The UTXOs are indexed by outpoint, which is the transaction ID that created the UTXO along with its index in that transaction.

    Address indexer: enabled by --index-address=true. Allows lookup of all transactions involving a certain address.

    Wallet plugin

    The main purpose of hsd node is to store blockchain data and to exchange messages with other nodes, for example messages about new blocks.

    Strictly speaking, any additional functionality is not part of the node itself. So the wallet is implemented as hsd node plugin.

    By default hsd runs with wallet plugin activated, but it can be disabled by providing command line flag --no-wallet. This flag works only in command line mode.

    Wallet runs its own server, which listens for requests.

    Wallet can also be run as a standalone application, connecting to local or external node: wallet --node-host=127.0.0.1

    More information about available arguments and flags can be found here.

    Wallet: BIP44

    The hsd wallet follows a BIP44 structure with cointype 5353 for mainnet. A single hsd instance can have multiple BIP44 wallets in its database.

    The hierarchy looks like this:

    WalletDB: A levelDB database stored in a wallet directory, accessed by the wallet module plugged-in by default to the full node. Can process transactions for multiple wallets.

    Wallet: A BIP44 wallet based on 128 or 256 bits of entropy and backed up by a 12- or 24- word phrase. Multiple accounts can be derived from a single wallet.

    Account: A branch of a BIP44 wallet. Multiple addresses can be derived from a single account, and the wallet can be configured to spend coins from a single specified account.

    Address: A hash of a public key or script that can be given to a counterparty with the intent of receiving funds. There are two types of outputs currently defined for witness version 0: Pay-to-Witness-Pubkeyhash has a 20 byte hash of a public key and can be spent if the owner reveals the public key and provides a signature from the corresponding private key. Pay-to-Witness-Scripthash has a 32 byte hash of a script and can be spent if the owner reveals the script along with any additional data required to satisfy the script.

    Wallet: rpc selectwallet vs --id=...

    The wallet RPC module is STATEFUL, and is always focused on one single wallet. On boot, the primary wallet and its default account are the target of all wallet RPC calls. To switch wallets, the client must call rpc selectwallet before making the command for that specific wallet.

    The wallet HTTP module is NOT stateful, meaning API calls can target any wallet, specified on-the-fly by adding the command line argument --id=<wallet>

    Wallet: recovery

    There are known issues with the hsd wallet that may make wallet recovery difficult in some cases. The fact that addresses can be imported (or "watched") adds to the possible failure states during recovery.

    In addition, Handshake wallet users should be careful when recovering a wallet that is bidding on in-progress auctions. Because BIDs are BLINDED on the blockchain, they can not be recovered using the BIP44 process (which is computed exclusively with a seed phrase plus blockchain data). This issue is well-known and some solutions have been proposed to assist in wallet recovery of blinded bid data.

    Authentication

    Auth

    # default regtest port is 14037 (may be reconfigured by user), API key is required in URL
    curl http://x:api-key@127.0.0.1:14037/
    
    cli --api-key=api-key --network=regtest info
    
    # store API key and network type in environment variables:
    export HSD_API_KEY=api-key
    export HSD_NETWORK=regtest
    cli info
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    // network type derived from hsd object, client object stores API key
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const clientinfo = await client.getInfo();
      console.log(clientinfo);
    })();
    

    Make sure to replace api-key with your own key.

    Auth is accomplished via HTTP Basic Auth, using your node's API key.

    Configuring Clients

    Default Listeners

    # With curl you just send HTTP Requests based on further docs
    curl http://127.0.0.1:14037/ # will get info from regtest
    

    By default the API server listens on these localhost ports:

    Network API Port
    main 12037
    testnet 13037
    regtest 14037
    simnet 15037

    You can interact with hsd with its REST API as well as with RPC. There are couple of ways you can use the API:

    Only thing to keep in mind is authentication, which is described in the "Authentication" section.

    Configuring hsd-cli

    # You can configure it by passing arguments:
    hsd-cli --network=regtest info
    hsd-cli info --network=regtest
    
    # Or use environment variables (Starting with HSD_)
    export HSD_NETWORK=regtest
    export HSD_API_KEY=$YOUR-API-KEY
    hsd-cli info
    

    Install hsd-cli and hsw-cli command line tools with the hs-client package. Included with hsd by default, but can be installed separately: npm install -g hs-client

    hsd-cli params:

    General configuration

    Config Options Description
    network main, testnet, regtest This will configure which network to load, also where to look for hsd.conf file
    uri, url Base HTTP URI This can be used for custom port
    api-key string Secret used by RPC for authorization

    Wallet specific configuration

    Config Options Description
    id string Specify which account to use by default
    token string Token specific wallet
    # Example hsd.conf syntax:
    network: main
    prefix: ~/.hsd
    api-key: <api-key>
    index-tx: true
    

    hsd.conf and hsw.conf files

    These files may contain any of the configuration parameters, and will be interpreted by hs-client at startup. The node and wallet clients look for their own respective conf files.

    Command line flags should be formatted as flag: true in .conf files.
    For example command line flag --persistent-mempool becomes persistent-mempool: true in hsd.conf.

    More information about .conf files can be found here.

    Using Javascript Clients

    const {NodeClient, WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    const wallet = new WalletClient(walletOptions);
    

    You can also use the API with a Javascript library (used by hsd-cli). There are two objects: NodeClient for general API and WalletClient for wallet API. hsd also provides an object Network and its method get which will return the default configuration paramaters for a specified network. Custom port numbers are also configurable by the user.

    NodeClient and WalletClient options:

    Config Type Description
    port int hsd socket port (defaults specific for each network)
    host string hsd API host URI (defaults to 127.0.0.1)
    apiKey string API secret
    ssl boolean TLS (defaults to false: http, unless url has https)

    hsd - Node

    hsd client requests

    Complete list of commands:

    Command cURL method Description
    / GET get info
    /coin/address/:address GET UTXO by address
    /coin/:hash/:index GET UTXO by txid
    /coin/address POST Bulk read UTXOs
    /tx/:hash GET TX by hash
    /tx/address/:address GET TX by address
    /tx/address POST Bulk read TXs
    /block/:block GET Block by hash or height
    /header/:block GET Header by hash or height
    /mempool GET Mempool snapshot
    /mempool/invalid GET Mempool rejects filter
    /mempool/invalid/:hash GET Test mempool rejects filter
    /broadcast POST Broadcast TX
    /claim POST Broadcast Claim
    /fee GET Estimate fee
    /reset POST Reset chain to specific height

    Get server info

    curl http://x:api-key@127.0.0.1:14037/
    
    hsd-cli info
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const clientinfo = await client.getInfo();
      console.log(clientinfo);
    })();
    

    The above command returns JSON structured like this:

    {
      "version": "2.0.1",
      "network": "regtest",
      "chain": {
        "height": 1,
        "tip": "6b054a7a561fdfa7c2f11550db4d5341d101be044df24dd58c465b2abac94c3f",
        "treeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
        "progress": 0.6125905181398805,
        "state": {
          "tx": 2,
          "coin": 1360,
          "value": 237416588368270,
          "burned": 0
        }
      },
      "pool": {
        "host": "0.0.0.0",
        "port": 14038,
        "identitykey": "aorsxa4ylaacshipyjkfbvzfkh3jhh4yowtoqdt64nzemqtiw2whk",
        "agent": "/hsd:2.0.1/",
        "services": "1",
        "outbound": 0,
        "inbound": 0
      },
      "mempool": {
        "tx": 0,
        "size": 0,
        "claims": 0,
        "airdrops": 0,
        "orphans": 0
      },
      "time": {
        "uptime": 3,
        "system": 1581299165,
        "adjusted": 1581299165,
        "offset": 0
      },
      "memory": {
        "total": 78,
        "jsHeap": 11,
        "jsHeapTotal": 29,
        "nativeHeap": 49,
        "external": 14
      }
    }
    

    Get server Info.

    HTTP Request

    Get server info. No params.

    GET /

    No Params.

    Get mempool snapshot

    curl http://x:api-key@127.0.0.1:14037/mempool
    
    hsd-cli mempool
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const mempool = await client.getMempool();
      console.log(mempool);
    })().catch((err) => {
      console.error(err.stack);
    });
    

    The above command returns JSON structured like this:

    [
      "2ef8051e6c38e136ba4d195c048e78f9077751758db710475fa532b9d9489324",
      "bc3308b61959664b71ac7fb8e9ee17d13476b5a32926f512882851b7631884f9",
      "53faa103e8217e1520f5149a4e8c84aeb58e55bdab11164a95e69a8ca50f8fcc",
      "fff647849be7408faedda377eea6c37718ab39d656af8926e0b4b74453624f32",
      "b3c71dd8959ea97d41324779604b210ae881cdaa5d5abfcbfb3502a0e75c1283",
      ...
    ]
    

    Get mempool snapshot (array of json txs).

    HTTP Request

    GET /mempool

    No Params.

    Get mempool rejects filter

    curl http://x:api-key@127.0.0.1:14037/mempool/invalid
    
    > no CLI command available
    
    // no JS client function available
    

    The above command returns JSON structured like this:

    {
      "items": 161750,
      "size": 5175951,
      "entries": 0,
      "n": 20,
      "limit": 60000,
      "tweak": 3433901487
    }
    

    Get mempool rejects filter (a Bloom filter used to store rejected TX hashes).

    HTTP Request

    GET /mempool/invalid

    URL Parameters

    Parameter Description
    verbose (bool) Returns entire Bloom Filter in filter property, hex-encoded.

    Test mempool rejects filter

    hash=8e4c9756fef2ad10375f360e0560fcc7587eb5223ddf8cd7c7e06e60a1140b15
    curl http://x:api-key@127.0.0.1:14037/mempool/invalid/$hash
    
    > no CLI command available
    
    // no JS client function available
    

    The above command returns JSON structured like this:

    {
      "invalid": false
    }
    

    Test a TX hash against the mempool rejects filter.

    HTTP Request

    GET /mempool/invalid/:hash

    URL Parameters

    Parameter Description
    :hash Transaction hash

    Get block by hash or height

    let blockHash, blockHeight;
    
    blockHash='ae3895cf597eff05b19e02a70ceeeecb9dc72dbfe6504a50e9343a72f06a87c5';
    blockHeight='0';
    
    curl http://x:api-key@127.0.0.1:14037/block/$blockHash # by hash
    curl http://x:api-key@127.0.0.1:14037/block/$blockHeight # by height
    
    hsd-cli block $blockHash # by hash
    hsd-cli block $blockHeight # by height
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const blockByHeight = await client.getBlock(blockHeight);
      const blockByHash = await client.getBlock(blockHash);
      console.log("By height: \n", blockByHeight);
      console.log("By hash: \n", blockByHash);
    })();
    

    The above command returns JSON structured like this:

    {
      "hash": "ae3895cf597eff05b19e02a70ceeeecb9dc72dbfe6504a50e9343a72f06a87c5",
      "height": 0,
      "depth": 2,
      "version": 0,
      "prevBlock": "0000000000000000000000000000000000000000000000000000000000000000",
      "merkleRoot": "8e4c9756fef2ad10375f360e0560fcc7587eb5223ddf8cd7c7e06e60a1140b15",
      "witnessRoot": "1a2c60b9439206938f8d7823782abdb8b211a57431e9c9b6a6365d8d42893351",
      "treeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedRoot": "0000000000000000000000000000000000000000000000000000000000000000",
      "time": 1580745080,
      "bits": 545259519,
      "nonce": 0,
      "extraNonce": "000000000000000000000000000000000000000000000000",
      "mask": "0000000000000000000000000000000000000000000000000000000000000000",
      "txs": [
        {
          "hash": "9553240e6f711271cfccf9407c9348996e61cb3bd39adbc2ec258ff940ff22c6",
          "witnessHash": "49880b0f9dd1b0b5dd43f6d64803276d54717e5f98b71d82bf170cb4dd0c2388",
          "fee": 0,
          "rate": 0,
          "mtime": 1581299280,
          "index": 0,
          "version": 0,
          "inputs": [
            {
              "prevout": {
                "hash": "0000000000000000000000000000000000000000000000000000000000000000",
                "index": 4294967295
              },
              "witness": [
                "50b8937fc5def08f9f3cbda7e5f08c706edb80aba5880c000000000000000000",
                "2d5de58609d4970fb548f85ad07a87db40e054e34cc81c951ca995a58f674db7",
                "10d748eda1b9c67b94d3244e0211677618a9b4b329e896ad90431f9f48034bad",
                "e2c0299a1e466773516655f09a64b1e16b2579530de6c4a59ce5654dea45180f"
              ],
              "sequence": 4294967295,
              "address": null
            }
          ],
          "outputs": [
            {
              "value": 2002210000,
              "address": "rs1q7q3h4chglps004u3yn79z0cp9ed24rfrhvrxnx",
              "covenant": {
                "type": 0,
                "action": "NONE",
                "items": []
              }
            }
          ],
          "locktime": 0,
          "hex": "00000000010000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff01d04c5777000000000014f0237ae2e8f860f7d79124fc513f012e5aaa8d23000000000000042050b8937fc5def08f9f3cbda7e5f08c706edb80aba5880c000000000000000000202d5de58609d4970fb548f85ad07a87db40e054e34cc81c951ca995a58f674db72010d748eda1b9c67b94d3244e0211677618a9b4b329e896ad90431f9f48034bad20e2c0299a1e466773516655f09a64b1e16b2579530de6c4a59ce5654dea45180f"
        }
      ]
    }
    

    Returns block info by block hash or height.

    HTTP Request

    GET /block/:blockhashOrHeight

    URL Parameters

    Parameter Description
    :blockhashOrHeight Hash or Height of block

    Get Header by hash or height

    let blockHash, blockHeight;
    
    blockHash='ae3895cf597eff05b19e02a70ceeeecb9dc72dbfe6504a50e9343a72f06a87c5';
    blockHeight='0';
    
    curl http://x:api-key@127.0.0.1:14037/header/$blockHash # by hash
    curl http://x:api-key@127.0.0.1:14037/header/$blockHeight # by height
    
    # None available
    
    // None available
    

    The above command returns JSON structured like this:

    {
      "hash": "ae3895cf597eff05b19e02a70ceeeecb9dc72dbfe6504a50e9343a72f06a87c5",
      "height": 0,
      "depth": 2,
      "version": 0,
      "prevBlock": "0000000000000000000000000000000000000000000000000000000000000000",
      "merkleRoot": "8e4c9756fef2ad10375f360e0560fcc7587eb5223ddf8cd7c7e06e60a1140b15",
      "witnessRoot": "1a2c60b9439206938f8d7823782abdb8b211a57431e9c9b6a6365d8d42893351",
      "treeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedRoot": "0000000000000000000000000000000000000000000000000000000000000000",
      "time": 1580745080,
      "bits": 545259519,
      "nonce": 0,
      "extraNonce": "000000000000000000000000000000000000000000000000",
      "mask": "0000000000000000000000000000000000000000000000000000000000000000",
      "chainwork": "0000000000000000000000000000000000000000000000000000010001000100"
    }
    

    Returns block header by block hash or height.

    HTTP Request

    GET /header/:blockhashOrHeight

    URL Parameters

    Parameter Description
    :blockhashOrHeight Hash or Height of header

    Broadcast transaction

    let tx;
    
    tx='010000000106b014e37704109fefe2c5c9f4227d68840c3497fc89a9832db8504df039a6c7000000006a47304402207dc8173fbd7d23c3950aaf91b1bc78c0ed9bf910d47a977b24a8478a91b28e69022024860f942a16bc67ec54884e338b5b87f4a9518a80f9402564061a3649019319012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff0280c3c901000000001976a91400ba915c3d18907b79e6cfcd8b9fdf69edc7a7db88acc41c3c28010000001976a91437f306a0154e1f0de4e54d6cf9d46e07722b722688ac00000000';
    
    curl http://x:api-key@127.0.0.1:14037/broadcast \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "tx": "'$tx'" }'
    
    hsd-cli broadcast $tx
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.broadcast(tx);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    {
      "success": true
    }
    

    Broadcast a transaction by adding it to the node's mempool. If mempool verification fails, the node will still forcefully advertise and relay the transaction for the next 60 seconds.

    HTTP Request

    POST /broadcast

    POST Parameters (JSON)

    Parameter Description
    tx raw transaction in hex

    Broadcast claim

    let claim;
    
    claim='310d030300003000010002a30001080101030803010001acffb409bcc939f...';
    
    curl http://x:api-key@127.0.0.1:14037/claim \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "claim": "'$claim'" }'
    
    > no CLI command available
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.broadcastClaim(claim);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    {
      "success": true
    }
    

    Broadcast a claim by adding it to the node's mempool.

    HTTP Request

    POST /claim

    POST Parameters (JSON)

    Parameter Description
    claim raw claim in hex

    Estimate fee

    let blocks;
    
    blocks=3
    
    curl http://x:api-key@127.0.0.1:14037/fee?blocks=$blocks
    
    hsd-cli fee $blocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.estimateFee(blocks);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    {
      "rate": 13795
    }
    

    Estimate the fee required (in dollarydoos per kB) for a transaction to be confirmed by the network within a targeted number of blocks (default 1).

    HTTP Request

    GET /fee

    GET Parameters

    Parameter Description
    blocks Number of blocks to target confirmation

    Reset blockchain

    let height;
    
    height=1000;
    
    curl http://x:api-key@127.0.0.1:14037/reset \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "height": '$height' }'
    
    hsd-cli reset $height
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.reset(height);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    {
      "success": true
    }
    

    Triggers a hard-reset of the blockchain. All blocks are disconnected from the tip down to the provided height. Indexes and Chain Entries are removed. Useful for "rescanning" an SPV wallet. Since there are no blocks stored on disk, the only way to rescan the blockchain is to re-request [merkle]blocks from peers.

    HTTP Request

    POST /reset

    POST Parameters (JSON)

    Parameter Description
    height block height to reset chain to

    hsd - Coins

    Getting coin information via API.

    Coin stands for UTXO

    Get coin by Outpoint

    let hash, index;
    
    hash='7d142b878b7894fb916280d0bee0b5c4f8970e1adbc9d1a2e9057a0b8187b709';
    index=0;
    
    curl http://x:api-key@127.0.0.1:14037/coin/$hash/$index
    
    hsd-cli coin $hash $index
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getCoin(hash, index);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    {
      "version": 0,
      "height": 0,
      "value": 2002210000,
      "address": "rs1q7q3h4chglps004u3yn79z0cp9ed24rfrhvrxnx",
      "covenant": {
        "type": 0,
        "action": "NONE",
        "items": []
      },
      "coinbase": true,
      "hash": "9553240e6f711271cfccf9407c9348996e61cb3bd39adbc2ec258ff940ff22c6",
      "index": 0
    }
    

    Get coin by outpoint (hash and index). Returns coin in hsd coin JSON format. value is always expressed in subunits.

    HTTP Request

    GET /coin/:hash/:index

    URL Parameters

    Parameter Description
    :hash Hash of tx
    :index Output's index in tx

    Get coins by address

    let address;
    
    address='rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5';
    
    curl http://x:api-key@127.0.0.1:14037/coin/address/$address
    
    hsd-cli coin $address
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getCoinsByAddress(address);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    [
      {
        "version": 0,
        "height": 69,
        "value": 2000000000,
        "address": "rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5",
        "covenant": {
          "type": 0,
          "action": "NONE",
          "items": []
        },
        "coinbase": true,
        "hash": "fcc1f0656b5e6a0856abf21424579b87c30bc30b89a3c3925923052cb636d80b",
        "index": 0
      },
      {
        "version": 0,
        "height": 74,
        "value": 2000000000,
        "address": "rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5",
        "covenant": {
          "type": 0,
          "action": "NONE",
          "items": []
        },
        "coinbase": true,
        "hash": "ffaab95b75c3db650191920a69915e480ced19a8f58cba867382fc8163654299",
        "index": 0
      }
    ]
    

    Get coin objects array by address.

    HTTP Request

    GET /coin/address/:address

    URL Parameters

    Parameter Description
    :address handshake address

    Get coins by addresses

    let address0, address1;
    
    address0='rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5';
    address1='rs1qcxuurryemelaj64k6rswn8x9aa8nd9nafa47ag';
    
    curl http://x:api-key@127.0.0.1:14037/coin/address \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "addresses":[ "'$address0'", "'$address1'" ]}'
    
    No CLI Option.
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getCoinsByAddresses([address0, address1]);
      console.log(result);
    })().catch((err) => {
      console.error(err.stack);
    });
    

    The above command returns JSON structured like this:

    [
      {
        "version": 0,
        "height": 69,
        "value": 2000000000,
        "address": "rs1qcxuurryemelaj64k6rswn8x9aa8nd9nafa47ag",
        "covenant": {
          "type": 0,
          "action": "NONE",
          "items": []
        },
        "coinbase": true,
        "hash": "fcc1f0656b5e6a0856abf21424579b87c30bc30b89a3c3925923052cb636d80b",
        "index": 0
      },
      {
        "version": 0,
        "height": 74,
        "value": 2000000000,
        "address": "rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5",
        "covenant": {
          "type": 0,
          "action": "NONE",
          "items": []
        },
        "coinbase": true,
        "hash": "ffaab95b75c3db650191920a69915e480ced19a8f58cba867382fc8163654299",
        "index": 0
      }
    ]
    

    Get coins by addresses, returns array of coin objects.

    HTTP Request

    POST /coin/address

    POST Parameters (JSON)

    Parameter Description
    addresses List of handshake addresses

    hsd - Transactions

    Getting transaction information via API.

    Get tx by txhash

    let txhash;
    
    txhash='4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f';
    
    curl http://x:api-key@127.0.0.1:14037/tx/$txhash
    
    hsd-cli tx $txhash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getTX(txhash);
      console.log(result);
    })().catch((err) => {
      console.error(err.stack);
    });
    

    The above command returns JSON structured like this:

    {
      "hash": "ffaab95b75c3db650191920a69915e480ced19a8f58cba867382fc8163654299",
      "witnessHash": "23103d0e91632760a69a8abfb80c0589caf1acfde829b219372d2cd595153f3a",
      "fee": 0,
      "rate": 0,
      "mtime": 1581299437,
      "height": 74,
      "block": "19f0de035bfdb5482eb148f49be7e4427ebbcf0b7522665766154e0873637e18",
      "time": 1581299449,
      "index": 0,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "0000000000000000000000000000000000000000000000000000000000000000",
            "index": 4294967295
          },
          "witness": [
            "6d696e656420627920687364",
            "e591dce4a94f7b28",
            "0000000000000000"
          ],
          "sequence": 3610282069,
          "address": null
        }
      ],
      "outputs": [
        {
          "value": 2000000000,
          "address": "rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 74,
      "hex": "00000000010000000000000000000000000000000000000000000000000000000000000000ffffffff558830d701009435770000000000140f1fa7047677f37a78bbe0f28be3b095f85e391900004a000000030c6d696e65642062792068736408e591dce4a94f7b28080000000000000000",
      "confirmations": 28
    }
    

    HTTP Request

    GET /tx/:txhash

    URL Parameters

    Parameter Description
    :txhash Hash of tx.

    Get tx by address

    let address;
    
    address='rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5';
    
    curl http://x:api-key@127.0.0.1:14037/tx/address/$address
    
    hsd-cli tx $address
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getTXByAddress(address);
      console.log(result);
    })().catch((err) => {
      console.error(err.stack);
    });
    

    The above command returns JSON structured like this:

    [
      {
        "hash": "ffaab95b75c3db650191920a69915e480ced19a8f58cba867382fc8163654299",
        "witnessHash": "23103d0e91632760a69a8abfb80c0589caf1acfde829b219372d2cd595153f3a",
        "fee": 0,
        "rate": 0,
        "mtime": 1581299437,
        "height": 74,
        "block": "19f0de035bfdb5482eb148f49be7e4427ebbcf0b7522665766154e0873637e18",
        "time": 1581299449,
        "index": 0,
        "version": 0,
        "inputs": [
          {
            "prevout": {
              "hash": "0000000000000000000000000000000000000000000000000000000000000000",
              "index": 4294967295
            },
            "witness": [
              "6d696e656420627920687364",
              "e591dce4a94f7b28",
              "0000000000000000"
            ],
            "sequence": 3610282069,
            "address": null
          }
        ],
        "outputs": [
          {
            "value": 2000000000,
            "address": "rs1qpu06wprkwleh579mureghcasjhu9uwge6pltn5",
            "covenant": {
              "type": 0,
              "action": "NONE",
              "items": []
            }
          }
        ],
        "locktime": 74,
        "hex": "00000000010000000000000000000000000000000000000000000000000000000000000000ffffffff558830d701009435770000000000140f1fa7047677f37a78bbe0f28be3b095f85e391900004a000000030c6d696e65642062792068736408e591dce4a94f7b28080000000000000000",
        "confirmations": 28
      },
      ...
    ]
    

    Returns transaction objects array by address

    HTTP Request

    GET /tx/address/:address

    URL Parameters

    Parameter Description
    :address Handshake address.

    Get tx by addresses

    let address0, address1;
    
    address0='rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap';
    address1='rs1qx38r5mjzlxfus9yx7nhx3mrg00sv75xc5mksk5';
    
     curl http://x:api-key@127.0.0.1:14037/tx/address \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "addresses":[ "'$address0'", "'$address1'" ]}'
    
    No CLI Option.
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.getTXByAddresses([address0, address1]);
      console.log(result);
    })();
    

    The above command returns JSON structured like this:

    [
      {
        "hash": "f64f1a1bea51883ef365ac5008656f0eecedfa58c0215e97a0f2c5046ebb73c0",
        "witnessHash": "f9429e86143084392a9d23d0680bf7570ddc7e2bfe51405d44a554dbad8ab51d",
        "fee": 0,
        "rate": 0,
        "mtime": 1528329693,
        "height": 3,
        "block": "be818dc2e986f872118e2c4d2995d14beb03edada40a448d24daf7b62cc272cf",
        "time": 1528329693,
        "index": 0,
        "version": 0,
        "inputs": [
          {
            "prevout": {
              "hash": "0000000000000000000000000000000000000000000000000000000000000000",
              "index": 4294967295
            },
            "witness": [
              "6d696e65642062792068736b64",
              "72bc06c17f58df4e",
              "0000000000000000"
            ],
            "sequence": 816606577,
            "address": null
          }
        ],
        "outputs": [
          {
            "value": 500000000,
            "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
            "covenant": {
              "type": 0,
              "items": []
            }
          }
        ],
        "locktime": 3,
        "hex": "00000000010000000000000000000000000000000000000000000000000000000000000000ffffffff030d6d696e65642062792068736b640872bc06c17f58df4e080000000000000000716dac30010065cd1d000000000014f039bea7884a3e8568ed967ee1f830afd5cba990000003000000",
        "confirmations": 1
      },
      {
        "hash": "4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f",
        "witnessHash": "337189c003cf9c2ea413b5b6041c5b9e62f5fdfafcdd6cb54d5829c6cd59dd77",
        "fee": 2800,
        "rate": 20000,
        "mtime": 1528329716,
        "height": -1,
        "block": null,
        "time": 0,
        "index": -1,
        "version": 0,
        "inputs": [
          {
            "prevout": {
              "hash": "2277cbd9dd1c2552f9998e6861c7fd6866b9a48fa94ec85f03697390e8fa5d4b",
              "index": 0
            },
            "witness": [
              "ef5ae8c401a69123b69da2922514ff62a76a040abb615e79453ad8172a31916c65c82ecebf15d40678b3c749411908e9aaeed1785b23789c746e5f17d11bb4c801",
              "02deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9"
            ],
            "sequence": 4294967295,
            "coin": {
              "version": 0,
              "height": 2,
              "value": 500000000,
              "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
              "covenant": {
                "type": 0,
                "items": []
              },
              "coinbase": true
            }
          }
        ],
        "outputs": [
          {
            "value": 100000000,
            "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
            "covenant": {
              "type": 0,
              "items": []
            }
          },
          {
            "value": 399997200,
            "address": "rs1qx38r5mjzlxfus9yx7nhx3mrg00sv75xc5mksk5",
            "covenant": {
              "type": 0,
              "items": []
            }
          }
        ],
        "locktime": 0,
        "hex": "00000000012277cbd9dd1c2552f9998e6861c7fd6866b9a48fa94ec85f03697390e8fa5d4b000000000241ef5ae8c401a69123b69da2922514ff62a76a040abb615e79453ad8172a31916c65c82ecebf15d40678b3c749411908e9aaeed1785b23789c746e5f17d11bb4c8012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9ffffffff0200e1f505000000000014f0d9374a2ce80c377187f4bc6c68993c561cb13600001079d717000000000014344e3a6e42f993c81486f4ee68ec687be0cf50d8000000000000",
        "confirmations": 5
      }
    ]
    

    Returns transaction objects array by addresses

    HTTP Request

    POST /tx/address

    POST Parameters (JSON)

    Parameter Description
    addresses array of handshake addresses

    RPC Calls - Node

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "<method>", "params": [...] "id": "some-id" }'
    
    hsd-cli rpc <method> <params>
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('<method>', [ <params> ]);
      console.log(result);
    })();
    

    The above cURL command returns JSON structured like this:

    {"result": resultObject ,"error": errorObject, "id": passedID}
    

    Further examples will only include "result" part. CLI and Javascript calls return just the "result" or an error.

    hsd RPC calls mimic Bitcoin Core's RPC.

    RPC Calls are accepted at: POST /

    Notes:

    hsd-cli rpc and Javascript will either return an error OR the result.

    Javascript result will return the "result" part of the object, not the id or error

    If a Javascript error is encountered it will be thrown instead of returned in JSON

    Be sure to check the debug log for error reports as well!

    POST Parameters RPC

    Parameter Description
    method Name of the RPC call
    params Parameters accepted by method
    id int Will be returned with the response (cURL only)

    stop

    curl http://x:api-key@127.0.0.1:14037/ \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "method": "stop" }'
    
    hsd-cli rpc stop
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('stop');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "Stopping."
    

    Stops the running node.

    Params

    N. Name Default Description
    None.

    getinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getinfo" }'
    
    hsd-cli rpc getinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "version": "0.0.0",
      "protocolversion": 70015,
      "walletversion": 0,
      "balance": 0,
      "blocks": 205,
      "timeoffset": 0,
      "connections": 3,
      "proxy": "",
      "difficulty": 4.6565423739069247e-10,
      "testnet": true,
      "keypoololdest": 0,
      "keypoolsize": 0,
      "unlocked_until": 0,
      "paytxfee": 0.0002,
      "relayfee": 0.00001,
      "errors": ""
    }
    

    Returns general info

    Params

    N. Name Default Description
    None.

    getmemoryinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getmemoryinfo" }'
    
    hsd-cli rpc getmemoryinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmemoryinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "total": 72,
      "jsHeap": 14,
      "jsHeapTotal": 17,
      "nativeHeap": 54,
      "external": 12
    }
    

    Returns Memory usage info.

    Params

    N. Name Default Description
    None.

    setloglevel

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "setloglevel",
        "params": [ "none" ]
      }'
    
    hsd-cli rpc setloglevel none
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('setloglevel', [ 'none' ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Change Log level of the running node.

    Levels are: NONE, ERROR, WARNING, INFO, DEBUG, SPAM

    Params

    N. Name Default Description
    1 level Required Level for the logger

    validateaddress

    let address;
    
    address='rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap';
    
    curl http://x:api-key@127.0.0.1:14037/ \
      -X POST \
      --data '{
        "method": "validateaddress",
        "params": [ "'$address'" ]
      }'
    
    hsd-cli rpc validateaddress $address
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('validateaddress', [ address ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "isvalid": true,
      "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
      "isscript": false,
      "isspendable": true,
      "witness_version": 0,
      "witness_program": "f0d9374a2ce80c377187f4bc6c68993c561cb136"
    }
    

    Validates address.

    Params

    N. Name Default Description
    1 address Required Address to validate

    createmultisig

    let nrequired, pubkey0, pubkey1, pubkey2;
    
    nrequired=2;
    pubkey0='02e3d6bb36b0261628101ee67abd89d678522dc1199912512f814e70803652f395';
    pubkey1='03d7ded41bb871936bf4d411371b25d706c572f28ef8d2613b45392e9f9c4348a5';
    pubkey2='034bc2280e68d3bdd0ef0664e0ad2949a467344d8e59e435fe2d9be81e39f70f76';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "createmultisig",
        "params": [ '$nrequired', [ "'$pubkey0'", "'$pubkey1'", "'$pubkey2'" ] ]
      }'
    
    hsd-cli rpc createmultisig $nrequired '[ "'$pubkey0'", "'$pubkey1'", "'$pubkey2'" ]'
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createmultisig', [ nrequired, [ pubkey0, pubkey1, pubkey2 ] ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "address": "rs1qlt977782vv7xxy45xgp9yzhtp90v6e5az9p05q7q8d2072m77xese5xxfl",
      "redeemScript": "522102e3d6bb36b0261628101ee67abd89d678522dc1199912512f814e70803652f39521034bc2280e68d3bdd0ef0664e0ad2949a467344d8e59e435fe2d9be81e39f70f762103d7ded41bb871936bf4d411371b25d706c572f28ef8d2613b45392e9f9c4348a553ae"
    }
    

    create multisig address

    Params

    N. Name Default Description
    1 nrequired Required Required number of approvals for spending
    2 keyArray Required Array of public keys

    signmessagewithprivkey

    let privkey, message;
    
    privkey='ENced8VD7YWkzPC8FTJ3gTTq4pQhF2PF79QS51mgZq7BgCfiEP5A';
    message='hello';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "signmessagewithprivkey",
        "params": [ "'$privkey'", "'$message'"]
      }'
    
    hsd-cli rpc signmessagewithprivkey $privkey $message
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('signmessagewithprivkey', [ privkey, message ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "arjD5y4glPea270IiExx04E+tTvryHKhWZcA2oy8svVHr9q/AvGA647UF2ICaIGJHazbRyyj3draiNnBns9aWQ=="
    

    Signs message with private key.

    Params

    N. Name Default Description
    1 privkey Required Private key
    1 message Required Message you want to sign.

    verifymessage

    let address, signature, message;
    
    address='rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc';
    signature='arjD5y4glPea270IiExx04E+tTvryHKhWZcA2oy8svVHr9q/AvGA647UF2ICaIGJHazbRyyj3draiNnBns9aWQ==';
    message='hello';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "verifymessage",
        "params": [ "'$address'", "'$signature'", "'$message'" ]
      }'
    
    hsd-cli rpc verifymessage $address $signature "$message"
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('verifymessage', [ address, signature, message ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Verify signature.

    Params

    N. Name Default Description
    1 address Required Address of the signer
    2 signature Required Signature of signed message
    3 message Required Message that was signed

    verifymessagewithname

    let name, signature, message;
    
    name='handshake';
    signature='arjD5y4glPea270IiExx04E+tTvryHKhWZcA2oy8svVHr9q/AvGA647UF2ICaIGJHazbRyyj3draiNnBns9aWQ==';
    message='hello';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "verifymessagewithname",
        "params": [ "'$name'", "'$signature'", "'$message'" ]
      }'
    
    hsd-cli rpc verifymessagewithname $name $signature "$message"
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('verifymessagewithname', [ name, signature, message ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Retrieves the address that owns a name and verifies signature.

    Params

    N. Name Default Description
    1 name Required Name to retrieve the address used to sign
    2 signature Required Signature of signed message
    3 message Required Message that was signed

    setmocktime

    let timestamp;
    
    timestamp=1503058155;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "setmocktime",
        "params": [ '$timestamp' ]
      }'
    
    hsd-cli rpc setmocktime $timestamp
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('setmocktime', [ timestamp ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Changes network time (This is consensus-critical)

    Params

    N. Name Default Description
    1 timestamp Required timestamp to change to

    RPC Calls - Chain

    pruneblockchain

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "pruneblockchain",
        "params": []
      }'
    
    hsd-cli rpc pruneblockchain
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('pruneblockchain');
      console.log(result);
    })();
    

    Prunes the blockchain, it will keep blocks specified in Network Configurations.

    Default Prune Options

    Network keepBlocks pruneAfter
    main 288 1000
    testnet 10000 1000
    regtest 10000 1000

    Params

    N. Name Default Description
    None.

    invalidateblock

    let blockhash;
    
    blockhash='52d7beaf4c7f392bef2744167c7f4db4bb4113b2635496edcf2d1c94128696aa';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "invalidateblock",
        "params": [ "'$blockhash'" ]
      }'
    
    hsd-cli rpc invalidateblock $blockhash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('invalidateblock', [ blockhash ]);
      console.log(result);
    })();
    

    Invalidates the block in the chain. It will rewind network to blockhash and invalidate it.

    It won't accept that block as valid. Invalidation will work while running, restarting node will remove invalid block from list.

    Params

    N. Name Default Description
    1 blockhash Required Block's hash

    reconsiderblock

    let blockhash;
    
    blockhash='1896e628f8011b77ea80f4582c29c21b3376183683f587ee863050376add3891'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "reconsiderblock",
        "params": [ "'$blockhash'" ]
      }'
    
    hsd-cli rpc reconsiderblock $blockhash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('reconsiderblock', [ blockhash ]);
      console.log(result);
    })().catch((err) => {
      console.error(err.stack);
    });
    

    This rpc command will remove block from invalid block set.

    Params

    N. Name Default Description
    1 blockhash Required Block's hash

    RPC Calls - Block

    getblockchaininfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getblockchaininfo" }'
    
    hsd-cli rpc getblockchaininfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblockchaininfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "chain": "regtest",
      "blocks": 101,
      "headers": 101,
      "bestblockhash": "76fb75dcb6d27b167dac8c01ad9e4fc68490bd9c3515cda02a20db412bf23930",
      "treeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
      "difficulty": 4.6565423739069247e-10,
      "mediantime": 1581299452,
      "verificationprogress": 1,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000cc",
      "pruned": false,
      "softforks": {
        "hardening": {
          "status": "defined",
          "bit": 0,
          "startTime": 1581638400,
          "timeout": 1707868800
        },
        "testdummy": {
          "status": "defined",
          "bit": 28,
          "startTime": 0,
          "timeout": 4294967295
        }
      },
      "pruneheight": null
    }
    

    Returns blockchain information.

    Params

    N. Name Default Description
    None.

    getbestblockhash

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getbestblockhash" }'
    
    hsd-cli rpc getbestblockhash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getbestblockhash');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "498d003ecfc60ee829cdc3640dc305583057d88e2c38a7d57dbe0f92aa2bb512"
    

    Returns Block Hash of the tip.

    Params

    N. Name Default Description
    None.

    getblockcount

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getblockcount" }'
    
    hsd-cli rpc getblockcount
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblockcount');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    98
    

    Returns block count.

    Params

    N. Name Default Description
    None.

    getblock

    let blockhash, details, verbose;
    
    blockhash='76fb75dcb6d27b167dac8c01ad9e4fc68490bd9c3515cda02a20db412bf23930';
    verbose=1;
    details=0;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getblock",
        "params": [ "'$blockhash'", '$verbose', '$details' ]
      }'
    
    hsd-cli rpc getblock $blockhash $verbose $details
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblock', [ blockhash, verbose, details ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hash": "76fb75dcb6d27b167dac8c01ad9e4fc68490bd9c3515cda02a20db412bf23930",
      "confirmations": 1,
      "strippedsize": 319,
      "size": 351,
      "weight": 1308,
      "height": 101,
      "version": 0,
      "versionHex": "00000000",
      "merkleroot": "67f0c36f0a12f276cdd0feb26dacf1bb93df31b9df68c4be09c7ac8231e76794",
      "witnessroot": "c8a4848c5d4b3b669ff5642ecfc5ab146d928d174c8d708d252a635819b4ccce",
      "treeroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "mask": "0000000000000000000000000000000000000000000000000000000000000000",
      "coinbase": [
        "6d696e656420627920687364",
        "efc784672034e0ec",
        "0000000000000000"
      ],
      "tx": [
        "d43a1192315124dcddf3b59902dd6bfef9cf6bcfbb07377e1b69ab1919f99d4e"
      ],
      "time": 1581299453,
      "mediantime": 1581299452,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000cc",
      "previousblockhash": "21ff4a8264d4b23db3b6a0d870e16d5e49c2b1f8c87b9b79ea342808a2914ed0",
      "nextblockhash": null
    }
    

    Returns information about block.

    Params

    N. Name Default Description
    1 blockhash Required Hash of the block
    2 verbose true If set to false, it will return hex of the block
    3 details false If set to true, it will return transaction details too.

    getblockbyheight

    let blockhash, details, verbose;
    
    blockheight=101;
    verbose=1;
    details=0;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getblockbyheight",
        "params": [ '$blockheight', '$verbose', '$details' ]
      }'
    
    hsd-cli rpc getblockbyheight $blockheight $verbose $details
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblockbyheight', [ blockheight, verbose, details ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hash": "5ff00e4394407ee68deaeebe9034be2ba3c4f1a74e66363200ee3f7bba0bd494",
      "confirmations": 10,
      "strippedsize": 319,
      "size": 351,
      "weight": 1308,
      "height": 101,
      "version": 0,
      "versionHex": "00000000",
      "merkleroot": "6b26e5e0c450fc7ab1565e376af0c728c34d1350ea2a940a7d717e893f697816",
      "witnessroot": "bc95c2a01f5857cb90444516f4581b010e84e9c99b36d33cd7d00e245bcfb401",
      "treeroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "mask": "0000000000000000000000000000000000000000000000000000000000000000",
      "coinbase": [
        "6d696e656420627920687364",
        "7a801f3eacdfec0c",
        "0000000000000000"
      ],
      "tx": [
        "eb63b57dec72917ed747fa14901bb7f07689138afa98a7c9a5aef754c5a143c2"
      ],
      "time": 1581346912,
      "mediantime": 1581346912,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000cc",
      "previousblockhash": "233e475602c7c0c002237e0a8ea6d02346216bc06b2447bfe80b38c756ef1eba",
      "nextblockhash": "75cdf5d53071d5629f12dac01d2f312ec04b17f46c085b57bb87df604748817a"
    }
    

    Returns information about block by height.

    Params

    N. Name Default Description
    1 blockheight Required height of the block in the blockchain.
    2 verbose true If set to false, it will return hex of the block.
    3 details false If set to true, it will return transaction details too.

    getblockhash

    let blockheight;
    
    blockheight=50;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getblockhash",
        "params": [ '$blockheight' ]
      }'
    
    hsd-cli rpc getblockhash $blockheight
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblockhash', [ blockheight ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "51726259de9560e1924f3cb554ad16e889b6170eb4d01d01f5a4ca8a81d1e318"
    

    Returns block's hash given its height.

    Params

    N. Name Default Description
    1 blockheight Required height of the block in the blockchain.

    getblockheader

    let blockhash, verbose;
    
    blockhash='5ff00e4394407ee68deaeebe9034be2ba3c4f1a74e66363200ee3f7bba0bd494';
    verbose=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getblockheader",
        "params": [ "'$blockhash'", '$details' ]
      }'
    
    hsd-cli rpc getblockheader $blockhash $verbose
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblockheader', [ blockhash, verbose ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hash": "5ff00e4394407ee68deaeebe9034be2ba3c4f1a74e66363200ee3f7bba0bd494",
      "confirmations": 10,
      "height": 101,
      "version": 0,
      "versionHex": "00000000",
      "merkleroot": "6b26e5e0c450fc7ab1565e376af0c728c34d1350ea2a940a7d717e893f697816",
      "witnessroot": "bc95c2a01f5857cb90444516f4581b010e84e9c99b36d33cd7d00e245bcfb401",
      "treeroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "mask": "0000000000000000000000000000000000000000000000000000000000000000",
      "time": 1581346912,
      "mediantime": 1581346912,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000cc",
      "previousblockhash": "233e475602c7c0c002237e0a8ea6d02346216bc06b2447bfe80b38c756ef1eba",
      "nextblockhash": "75cdf5d53071d5629f12dac01d2f312ec04b17f46c085b57bb87df604748817a"
    }
    

    Returns a block's header given its hash.

    Params

    N. Name Default Description
    1 blockheight Required height of the block in the blockchain.
    2 verbose true If set to false, it will return hex of the block.

    getchaintips

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getchaintips"
      }'
    
    hsd-cli rpc getchaintips
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getchaintips');
      console.log(result);
    })();
    

    Returns chaintips.

    The above command returns JSON "result" like this:

    [
      {
        "height": 3,
        "hash": "be818dc2e986f872118e2c4d2995d14beb03edada40a448d24daf7b62cc272cf",
        "branchlen": 0,
        "status": "active"
      },
      ...
    ]
    

    Params

    N. Name Default Description
    None.

    getdifficulty

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getdifficulty"
      }'
    
    hsd-cli rpc getdifficulty
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getdifficulty');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    1048576
    

    Params

    N. Name Default Description
    None.

    RPC Calls - Mempool

    getmempoolinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getmempoolinfo"
      }'
    
    hsd-cli rpc getmempoolinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmempoolinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "size": 5,
      "bytes": 14120,
      "usage": 14120,
      "maxmempool": 100000000,
      "mempoolminfee": 0.00001
    }
    

    Returns informations about mempool.

    Params

    N. Name Default Description
    None.

    getmempoolancestors

    let txhash, verbose;
    
    txhash='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    verbose=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getmempoolancestors",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    hsd-cli rpc getmempoolancestors $txhash $verbose
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmempoolancestors', [ txhash, verbose ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    // verbose=1
    [
      {
        "size": 226,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103521,
        "height": 100,
        "startingpriority": 0,
        "currentpriority": 0,
        "descendantcount": 1,
        "descendantsize": 451,
        "descendantfees": 9080,
        "ancestorcount": 2,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": [
          "7922c798ea02c3957393bb7c373ba89e0a337d049564aeb64a9fd2b8d4998795"
        ]
      },
      {
        "size": 225,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103519,
        "height": 100,
        "startingpriority": 0,
        "currentpriority": 0,
        "descendantcount": 2,
        "descendantsize": 676,
        "descendantfees": 13620,
        "ancestorcount": 1,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": [
          "d54e576d30f9014ffb06a31b9e36f2f5bb360e8c54980188ee4b09a979e092c2"
        ]
      },
      ...
    ]
    
    // verbose=0
    [
      "56ab7663c80cb6ffc9f8a4b493d77b2e6f52ae8ff64eefa8899c2065922665c8"
    ]
    

    returns all in-mempool ancestors for a transaction in the mempool.

    Params

    N. Name Default Description
    1 txhash Required Transaction Hash
    2 verbose false False returns only tx hashs, true - returns dependency tx info

    getmempooldescendants

    let txhash, verbose;
    
    txhash='7922c798ea02c3957393bb7c373ba89e0a337d049564aeb64a9fd2b8d4998795';
    verbose=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getmempooldescendants",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    hsd-cli rpc getmempooldescendants $txhash $verbose
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmempooldescendants', [ txhash, verbose ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    // verbose=1
    [
      {
        "size": 226,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103521,
        "height": 100,
        "startingpriority": 0,
        "currentpriority": 0,
        "descendantcount": 1,
        "descendantsize": 451,
        "descendantfees": 9080,
        "ancestorcount": 2,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": [
          "7922c798ea02c3957393bb7c373ba89e0a337d049564aeb64a9fd2b8d4998795"
        ]
      },
      {
        "size": 225,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103523,
        "height": 100,
        "startingpriority": 0,
        "currentpriority": 0,
        "descendantcount": 0,
        "descendantsize": 225,
        "descendantfees": 4540,
        "ancestorcount": 3,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": [
          "e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea"
        ]
      }
    ]
    [e
    
    // verbose=0
    [
      "939a3b8485b53a718d89e7e4412473b3762fa1d9bbd555fc8b01e73be0ab1881"
    ]
    

    returns all in-mempool descendants for a transaction in the mempool.

    Params

    N. Name Default Description
    1 txhash Required Transaction hash
    2 verbose false False returns only tx hashs, true - returns dependency tx info

    getmempoolentry

    let txhash;
    
    txhash='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getmempoolentry",
        "params": [ "'$txhash'" ]
      }'
    
    hsd-cli rpc getmempoolentry $txhash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmempoolentry', [ txhash ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "size": 225,
      "fee": 0.0000454,
      "modifiedfee": 0,
      "time": 1527103523,
      "height": 100,
      "startingpriority": 0,
      "currentpriority": 0,
      "descendantcount": 0,
      "descendantsize": 225,
      "descendantfees": 4540,
      "ancestorcount": 3,
      "ancestorsize": 0,
      "ancestorfees": 0,
      "depends": [
        "e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea"
      ]
    }
    

    returns mempool transaction info by its hash.

    Params

    N. Name Default Description
    1 txhash Required Transaction Hash

    getrawmempool

    let verbose;
    
    verbose=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getrawmempool",
        "params": [ '$verbose' ]
      }'
    
    hsd-cli rpc getrawmempool $verbose
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getrawmempool', [ verbose ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "d54e576d30f9014ffb06a31b9e36f2f5bb360e8c54980188ee4b09a979e092c2": {
        "size": 225,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103516,
        "height": 100,
        "startingpriority": 2200000000,
        "currentpriority": 2200000000,
        "descendantcount": 3,
        "descendantsize": 901,
        "descendantfees": 18160,
        "ancestorcount": 0,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": []
      },
      "7922c798ea02c3957393bb7c373ba89e0a337d049564aeb64a9fd2b8d4998795": {
        "size": 225,
        "fee": 0.0000454,
        "modifiedfee": 0,
        "time": 1527103519,
        "height": 100,
        "startingpriority": 0,
        "currentpriority": 0,
        "descendantcount": 2,
        "descendantsize": 676,
        "descendantfees": 13620,
        "ancestorcount": 1,
        "ancestorsize": 0,
        "ancestorfees": 0,
        "depends": [
          "d54e576d30f9014ffb06a31b9e36f2f5bb360e8c54980188ee4b09a979e092c2"
        ]
      },
      ...
    }
    

    Returns mempool detailed information (on verbose). Or mempool tx list.

    Params

    N. Name Default Description
    1 verbose false False returns only tx hashs, true - returns full tx info

    prioritisetransaction

    let txhash, priorityDelta, feeDelta;
    
    txhash='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    priorityDelta=1000;
    feeDelta=1000;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "prioritisetransaction",
        "params": [ "'$txhash'", '$priorityDelta', '$feeDelta' ]
      }'
    
    hsd-cli rpc prioritisetransaction $txhash $priorityDelta $feeDelta
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('prioritisetransaction', [ txhash, priorityDelta, feeDelta ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Prioritises the transaction.

    Note: changing fee or priority will only trick local miner (using this mempool) into accepting Transaction(s) into the block. (even if Priority/Fee doen't qualify)

    N. Name Default Description
    1 txhash Required Transaction hash
    2 priority delta Required Virtual priority to add/subtract to the entry
    3 fee delta Required Virtual fee to add/subtract to the entry

    estimatefee

    let nblocks;
    
    nblocks=10;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "estimatefee",
        "params": [ '$nblocks' ]
      }'
    
    hsd-cli rpc estimatefee $nblocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('estimatefee', [ nblocks ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    0.001
    

    Estimates fee to be paid for transaction.

    Params

    N. Name Default Description
    1 nblocks 1 Number of blocks to check for estimation.

    estimatepriority

    let nblocks;
    
    nblocks=10;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "estimatepriority",
        "params": [ '$nblocks' ]
      }'
    
    hsd-cli rpc estimatepriority $nblocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('estimatepriority', [ nblocks ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    718158904.3501
    

    estimates the priority (coin age) that a transaction needs in order to be included within a certain number of blocks as a free high-priority transaction.

    Params

    N. Name Default Description
    1 nblocks 1 Number of blocks to check for estimation.

    estimatesmartfee

    let nblocks;
    
    nblocks=10;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "estimatesmartfee",
        "params": [ '$nblocks' ]
      }'
    
    hsd-cli rpc estimatesmartfee $nblocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('estimatesmartfee', [ nblocks ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "fee": 0.001,
      "blocks": 10
    }
    

    Estimates smart fee to be paid for transaction.

    Params

    N. Name Default Description
    1 nblocks 1 Number of blocks to check for estimation.

    estimatesmartpriority

    let nblocks;
    
    nblocks=10;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "estimatesmartpriority",
        "params": [ '$nblocks' ]
      }'
    
    hsd-cli rpc estimatesmartpriority $nblocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('estimatesmartpriority', [ nblocks ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "priority": 718158904.3501,
      "blocks": 10
    }
    

    estimates smart priority (coin age) that a transaction needs in order to be included within a certain number of blocks as a free high-priority transaction.

    Params

    N. Name Default Description
    1 nblocks 1 Number of blocks to check for estimation.

    RPC Calls - Transactions

    gettxout

    let txhash, index, includemempool;
    
    txhash='b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb3';
    index=0;
    includemempool=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "gettxout",
        "params": [ "'$txhash'", '$index', '$includemempool' ]
      }'
    
    hsd-cli rpc gettxout $txhash $index $includemempool
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('gettxout', [ txhash, index, includemempool ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "bestblock": "be818dc2e986f872118e2c4d2995d14beb03edada40a448d24daf7b62cc272cf",
      "confirmations": 3,
      "value": 500,
      "address": {
        "version": 0,
        "hash": "f039bea7884a3e8568ed967ee1f830afd5cba990"
      },
      "version": 0,
      "coinbase": true
    }
    

    Get outpoint of the transaction.

    Params

    N. Name Default Description
    1 txid Required Transaction hash
    2 index Required Index of the Outpoint tx.
    3 includemempool true Whether to include mempool transactions.

    gettxoutsetinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "gettxoutsetinfo",
        "params": []
      }'
    
    hsd-cli rpc gettxoutsetinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('gettxoutsetinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "height": 100,
      "bestblock": "0e11d85b2081b84e131ba6692371737e6bb2aa7bc6d16e92954ffb1f9ad762e5",
      "transactions": 101,
      "txouts": 100,
      "bytes_serialized": 0,
      "hash_serialized": 0,
      "total_amount": 5000
    }
    

    Returns information about UTXO's from Chain.

    Params

    N. Name Default Description
    None.

    getrawtransaction

    let txhash, verbose;
    
    txhash='b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb3';
    verbose=0;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getrawtransaction",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    hsd-cli rpc getrawtransaction $txhash $verbose
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getrawtransaction', [ txhash, verbose ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "00000000010000000000000000000000000000000000000000000000000000000000000000ffffffff030d6d696e65642062792068736b64088d8679b7393cc0ac0800000000000000000bf6305f010065cd1d000000000014f039bea7884a3e8568ed967ee1f830afd5cba990000001000000"
    

    Returns raw transaction

    Params

    N. Name Default Description
    1 txhash Required Transaction hash
    2 verbose false Returns json formatted if true

    decoderawtransaction

    let rawtx;
    
    rawtx='000000000103858fc9d1c73d5250f2526ef71e17cb37d542d0fd7c8ddd061ab5f42ac47c5900000000ffffffff0250690f000000000000206237ceaffc6f2960a97c82e5a0b1e40455ee34010b1dd9c3481877a0883459760000d01e267700000000001464ae86dbe6f80c1d50daf5eafade990a5e1bcbdb0000000000000241813478628bcca531d716e088a7efef90eb8155d1afa87156dd6996e12b68e1776121cfbb022de662ce32e2b4c005fbcb033dc4cd06bbd7b99ff64f2af7cb29fc0121021ecadaa8a5146e04aad0d05e7116eeb961f1457b3094b7030f362e31552c2ed0';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "decoderawtransaction",
        "params": [ "'$rawtx'" ]
      }'
    
    hsd-cli rpc decoderawtransaction $rawtx
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('decoderawtransaction', [ rawtx ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "txid": "d1a4c16e5771115c3f251c0e13a912871af70ffde5cef8b5d5e3357806c80f24",
      "hash": "550f276f2acbb5c7c84e62b591ff9f13cd7c06a36bcf1c42a2b53105bfc4c9e9",
      "size": 227,
      "vsize": 152,
      "version": 0,
      "locktime": 0,
      "vin": [
        {
          "coinbase": false,
          "txid": "03858fc9d1c73d5250f2526ef71e17cb37d542d0fd7c8ddd061ab5f42ac47c59",
          "vout": 0,
          "txinwitness": [
            "813478628bcca531d716e088a7efef90eb8155d1afa87156dd6996e12b68e1776121cfbb022de662ce32e2b4c005fbcb033dc4cd06bbd7b99ff64f2af7cb29fc01",
            "021ecadaa8a5146e04aad0d05e7116eeb961f1457b3094b7030f362e31552c2ed0"
          ],
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 1.01,
          "n": 0,
          "address": {
            "version": 0,
            "hash": "6237ceaffc6f2960a97c82e5a0b1e40455ee34010b1dd9c3481877a088345976"
          },
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        },
        {
          "value": 1998.98696,
          "n": 1,
          "address": {
            "version": 0,
            "hash": "64ae86dbe6f80c1d50daf5eafade990a5e1bcbdb"
          },
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "blockhash": null,
      "confirmations": 0,
      "time": 0,
      "blocktime": 0
    }
    

    Decodes raw tx and provide chain info.

    Params

    N. Name Default Description
    1 rawtx Required Raw transaction hex

    decodescript

    let script;
    
    script='76c014af92ad98c7f77559f96430dfef2a6805b87b24f888ac';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "decodescript",
        "params": [ "'$script'" ]
      }'
    
    hsd-cli rpc decodescript $script
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('decodescript', [ script ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "asm": "OP_DUP OP_BLAKE160 af92ad98c7f77559f96430dfef2a6805b87b24f8 OP_EQUALVERIFY OP_CHECKSIG",
      "type": "PUBKEYHASH",
      "reqSigs": 1,
      "p2sh": "rs1qvgmuatludu5kp2tustj6pv0yq327udqppvwans6grpm6pzp5t9mqwn05ud"
    }
    

    Decodes script

    Params

    N. Name Default Description
    1 script Required Script hex

    sendrawtransaction

    let rawtx;
    
    rawtx='0100000001eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6010000006a4730440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add656012103142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057abffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac10ca0f24010000001976a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac00000000';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "sendrawtransaction",
        "params": [ "'$rawtx'" ]
      }'
    
    hsd-cli rpc sendrawtransaction $rawtx
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendrawtransaction', [ rawtx ]);
      console.log(result);
    })();
    
    "0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8"
    

    Sends raw transaction without verification

    Params

    N. Name Default Description
    1 rawtx Required Raw transaction hex

    createrawtransaction

    let txhash, txindex, amount, address, data;
    
    txhash='b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb3';
    txindex=0;
    amount=1;
    address='rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap';
    data='deadbeef';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "createrawtransaction",
        "params": [
          [{ "txid": "'$txhash'", "vout": '$txindex' }],
          { "'$address'": '$amount', "data": "'$data'" }
        ]
      }'
    
    hsd-cli rpc createrawtransaction \
      '[{ "txid": "'$txhash'", "vout": '$txindex' }]' \
      '{ "'$address'": '$amount', "data": "'$data'" }'
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const sendTo = {
        data: data
      };
      sendTo[address] = amount;
      const result = await client.execute('createrawtransaction', [ [{ txid: txhash, vout: txindex }], sendTo]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "0000000001b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb300000000ffffffff0240420f00000000000014f0d9374a2ce80c377187f4bc6c68993c561cb136000000000000000000001f04deadbeef00000000000000"
    

    Creates raw, unsigned transaction without any formal verification.

    Params

    N. Name Default Description
    1 outpoints Required Outpoint list
    1.1 txid Transaction Hash
    1.2 vout Transaction Outpoint Index
    1.3 sequence Sequence number for input
    2 sendto Required Map of addresses we are sending to with amounts as values.
    2.1 address 0 address: amount key pairs (string: float)
    3 locktime earliest time a transaction can be added

    signrawtransaction

    let rawtx, txhash, txindex, scriptPubKey, amount, privkey;
    
    rawtx='0000000001b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb300000000ffffffff0240420f00000000000014f0d9374a2ce80c377187f4bc6c68993c561cb136000000000000000000001f04deadbeef00000000000000';
    txhash='b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb3';
    txindex=0;
    address='rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc';
    amount=1;
    privkey='ENced8VD7YWkzPC8FTJ3gTTq4pQhF2PF79QS51mgZq7BgCfiEP5A';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "signrawtransaction",
        "params": [
          "'$rawtx'",
          [{
            "txid": "'$txhash'",
            "vout": '$txindex',
            "address": "'$address'",
            "amount": '$amount'
          }],
          [ "'$privkey'" ]
        ]
      }'
    
    hsd-cli rpc signrawtransaction $rawtx \
      '[{ "txid": "'$txhash'", "vout": '$txindex', "address": "'$address'", "amount": '$amount' }]' \
      '[ "'$privkey'" ]'
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('signrawtransaction', [ rawtx,
        [{
          txid: txhash,
          vout: txindex,
          address: address,
          amount: amount
        }],
        [ privkey ]
      ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hex": "0000000001b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb300000000ffffffff0240420f00000000000014f0d9374a2ce80c377187f4bc6c68993c561cb136000000000000000000001f04deadbeef0000000000000241b04faee027f8d4f2b5b3f30446624d46aee82406df161095118e2f587a117d2146ab4fbd90734ab1a339f4813e62cf1723993cbad5bcdfe9d1beda453fc822d9012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9",
      "complete": true
    }
    

    Signs raw transaction

    Params

    N. Name Default Description
    1 rawtx Required raw tx
    2 inputs Required Coins you're going to spend
    2.1 txid Transaction Hash
    2.2 vout Transaction Outpoint Index
    2.3 address Address which received the output you're going to sign
    2.4 amount Amount the output is worth
    3 privkeylist List of private keys
    4 sighashtype Type of signature hash

    gettxoutproof

    let txid0, txid1;
    
    txid0='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    txid1='e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "gettxoutproof",
        "params": [ ["'$txid0'", "'$txid1'"] ]
      }'
    
    hsd-cli rpc gettxoutproof '[ "'$txid0'", "'$txid1'" ]'
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('gettxoutproof', [ [ txid0, txid1 ] ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "00000020e562d79a1ffb4f95926ed1c67baab26b7e73712369a61b134eb881205bd8110ef08c63626ea13ca11fddad4f2c0a2b67354efdcd50f769b73330af205dcdd054cbd3055bffff7f20010000000500000004ae4be9cd199b09f605119820680eb23462746e98fbc2b0c635643f00b34c3cd8958799d4b8d29f4ab6ae6495047d330a9ea83b377cbb937395c302ea98c72279eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e02eb01"
    

    Checks if transactions are within block. Returns proof of transaction inclusion (raw MerkleBlock).

    Params

    N. Name Default Description
    1 txidlist Required array of transaction hashes
    2 blockhash Based on TX Block hash

    verifytxoutproof

    let proof;
    
    proof='00000020e562d79a1ffb4f95926ed1c67baab26b7e73712369a61b134eb881205bd8110ef08c63626ea13ca11fddad4f2c0a2b67354efdcd50f769b73330af205dcdd054cbd3055bffff7f20010000000500000004ae4be9cd199b09f605119820680eb23462746e98fbc2b0c635643f00b34c3cd8958799d4b8d29f4ab6ae6495047d330a9ea83b377cbb937395c302ea98c72279eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e02eb01';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "verifytxoutproof",
        "params": [ "'$proof'" ]
      }'
    
    hsd-cli rpc verifytxoutproof $proof
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('verifytxoutproof', [ proof ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      "e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea",
      "0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8"
    ]
    

    Checks the proof for transaction inclusion. Returns transaction hash if valid.

    Params

    N. Name Default Description
    1 proof Required Proof of transaction inclusion (raw MerkleBlock).

    RPC Calls - Mining

    Note: many mining-related RPC calls require hsd to be started with the flag --coinbase-address designating a comma-separated list of payout addresses, randomly selected during block creation

    getnetworkhashps

    let blocks, height;
    
    blocks=120;
    height=1000000;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getnetworkhashps",
        "params": [ '$blocks', '$height' ]
      }'
    
    hsd-cli rpc getnetworkhashps $blocks $height
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnetworkhashps', [ blocks, height ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    453742051556.55084
    

    Returns the estimated current or historical network hashes per second, based on last blocks.

    Params

    N. Name Default Description
    1 blocks 120 Number of blocks to lookup.
    2 height 1 Starting height for calculations.

    getmininginfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getmininginfo",
        "params": []
      }'
    
    hsd-cli rpc getmininginfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getmininginfo', []);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "blocks": 101,
      "currentblocksize": 0,
      "currentblockweight": 0,
      "currentblocktx": 0,
      "difficulty": 0,
      "errors": "",
      "genproclimit": 0,
      "networkhashps": 8.766601909687916e-7,
      "pooledtx": 0,
      "testnet": true,
      "chain": "regtest",
      "generate": false
    }
    
    

    Returns mining info.

    Note: currentblocksize, currentblockweight, currentblocktx, difficulty are returned when there's active work. generate - is true when hsd itself is mining.

    Params

    N. Name Default Description
    None.

    getwork

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getwork",
        "params": []
      }'
    
    hsd-cli rpc getwork
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    (async () => {
      const result = await client.execute('getwork');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "network": "regtest",
      "data": "00000000ae127a29c02d7b13ed0a3d57f913392a7f8f82b50295970585cbfad8bc6577b23ce9a239a694cbea6345611ce9683894d2b2a277c8c939a237dc7f9d784880bf1497421d274050a429329682277a21a0e7410137c8ff1b93dff083c6a4885b48f57e593ae36828007cb731af13f68e3c33b39c81a126d921102baccd930ec13b4ff8195b00000000ffff7f200000000000000000000000000000000000000000",
      "target": "7fffff0000000000000000000000000000000000000000000000000000000000",
      "height": 6,
      "time": 1528428623
    }
    

    Returns hashing work to be solved by miner. Or submits solved block.

    Params

    N. Name Default Description
    1 data Data to be submitted to the network.

    getworklp

    # Because there is a request timeout set on CLI http requests.
    # without manually adjusting the timeout (or receiving a new transaction on the current
    # network) this call will timeout before the request is complete.
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getworklp",
        "params": []
      }'
    
    # Because there is a request timeout set on CLI http requests.
    # without manually adjusting the timeout (or receiving a new transaction on the current
    # network) this call will timeout before the request is complete.
    hsd-cli rpc getworklp
    
    // Because there is a request timeout set on CLI http requests.
    // without manually adjusting the timeout (or receiving a new transaction on the current
    // network) this call will timeout before the request is complete.
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getworklp');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "network": "regtest",
      "data": "00000000ae127a29c02d7b13ed0a3d57f913392a7f8f82b50295970585cbfad8bc6577b23ce9a239a694cbea6345611ce9683894d2b2a277c8c939a237dc7f9d784880bf1497421d274050a429329682277a21a0e7410137c8ff1b93dff083c6a4885b48f57e593ae36828007cb731af13f68e3c33b39c81a126d921102baccd930ec13b4ff8195b00000000ffff7f200000000000000000000000000000000000000000",
      "target": "7fffff0000000000000000000000000000000000000000000000000000000000",
      "height": 6,
      "time": 1528428623
    }
    

    Long polling for new work.

    Returns new work, whenever new TX is received in the mempool or new block has been discovered. So miner can restart mining on new data.

    Params

    N. Name Default Description
    None.

    getblocktemplate

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getblocktemplate",
        "params": []
      }'
    
    hsd-cli rpc getblocktemplate
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getblocktemplate');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "capabilities": [
        "proposal"
      ],
      "mutable": [
        "time",
        "transactions",
        "prevblock"
      ],
      "version": 0,
      "rules": [],
      "vbavailable": {},
      "vbrequired": 0,
      "height": 111,
      "previousblockhash": "6817423dbb46da50ef7bde47c6dab28e53cbe91f06ecf68e8da0c5283d08e1fe",
      "treeroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "reservedroot": "0000000000000000000000000000000000000000000000000000000000000000",
      "mask": "0000fd0ab9566be24f5d76763172b89c513361d67016a03e57baac69155f2eda",
      "target": "7fffff0000000000000000000000000000000000000000000000000000000000",
      "bits": "207fffff",
      "noncerange": "000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff",
      "curtime": 1581347561,
      "mintime": 1581346914,
      "maxtime": 1581354761,
      "expires": 1581354761,
      "sigoplimit": 80000,
      "sizelimit": 1000000,
      "weightlimit": 4000000,
      "longpollid": "6817423dbb46da50ef7bde47c6dab28e53cbe91f06ecf68e8da0c5283d08e1fe00000001",
      "submitold": false,
      "coinbaseaux": {
        "flags": "6d696e656420627920687364"
      },
      "coinbasevalue": 2000003040,
      "claims": [],
      "airdrops": [],
      "transactions": [
        {
          "data": "000000000103858fc9d1c73d5250f2526ef71e17cb37d542d0fd7c8ddd061ab5f42ac47c5900000000ffffffff0250690f000000000000206237ceaffc6f2960a97c82e5a0b1e40455ee34010b1dd9c3481877a0883459760000d01e267700000000001464ae86dbe6f80c1d50daf5eafade990a5e1bcbdb0000000000000241813478628bcca531d716e088a7efef90eb8155d1afa87156dd6996e12b68e1776121cfbb022de662ce32e2b4c005fbcb033dc4cd06bbd7b99ff64f2af7cb29fc0121021ecadaa8a5146e04aad0d05e7116eeb961f1457b3094b7030f362e31552c2ed0",
          "txid": "d1a4c16e5771115c3f251c0e13a912871af70ffde5cef8b5d5e3357806c80f24",
          "hash": "550f276f2acbb5c7c84e62b591ff9f13cd7c06a36bcf1c42a2b53105bfc4c9e9",
          "depends": [],
          "fee": 3040,
          "sigops": 0,
          "weight": 605
        }
      ]
    }
    

    returns block template or proposal for use with mining. Also validates proposal if mode is specified as proposal.

    Note: This is described in BIP22 - Fundamentals, BIP23 - Pooled Mining, BIP145 - Updates for Segregated Witness

    Params

    N. Name Default Description
    1 jsonrequestobject {} JSONRequestObject.

    submitblock

    let blockdata;
    
    blockdata='000000203f6397a1442eb6a9901998c4a4b432f8573c7a490b2d5e6d6f2ad0d0fca25e2c56940d79c8f81f3eb5e998bcf79dbf8c7d3b13b01adaac526cf9df8ee385ec0c1ac0055bffff7f20000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f01640e6d696e65642062792062636f696e046c62c046080000000000000000ffffffff0100f2052a010000001976a91473815900ee35f3815b3407af2eeb1b611cf533d788ac00000000';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "submitblock",
        "params": [ "'$blockdata'" ]
      }'
    
    hsd-cli rpc submitblock $blockdata
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('submitblock', [ blockdata ]);
      console.log(result);
    })();
    

    Adds block to chain.

    Params

    N. Name Default Description
    1 blockdata Required. Mined block data (hex)

    verifyblock

    let blockdata;
    
    blockdata='000000203f6397a1442eb6a9901998c4a4b432f8573c7a490b2d5e6d6f2ad0d0fca25e2c56940d79c8f81f3eb5e998bcf79dbf8c7d3b13b01adaac526cf9df8ee385ec0c1ac0055bffff7f20000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f01640e6d696e65642062792062636f696e046c62c046080000000000000000ffffffff0100f2052a010000001976a91473815900ee35f3815b3407af2eeb1b611cf533d788ac00000000';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "verifyblock",
        "params": [ "'$blockdata'" ]
      }'
    
    hsd-cli rpc verifyblock $blockdata
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      // Block data is old, so it should return error
      const result = await client.execute('verifyblock', [ blockdata ]);
      console.log(result);
    })();
    

    Verifies the block data.

    Params

    N. Name Default Description
    1 blockdata Required. Mined block data (hex)

    setgenerate

    let mining, proclimit;
    
    mining=1;
    proclimit=1;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "setgenerate",
        "params": [ '$mining', '$proclimit' ]
      }'
    
    hsd-cli rpc setgenerate $mining $proclimit
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('setgenerate', [ mining, proclimit ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Will start the mining on CPU.

    Params

    N. Name Default Description
    1 mining 0 true will start mining, false will stop.
    2 proclimit 0

    getgenerate

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getgenerate",
        "params": []
      }'
    
    hsd-cli rpc getgenerate
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getgenerate');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Returns status of mining on Node.

    Params

    N. Name Default Description

    None.

    generate

    let numblocks;
    
    numblocks=2;
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "generate",
        "params": [ '$numblocks' ]
      }'
    
    hsd-cli rpc generate $numblocks
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      // Timeout error
      const result = await client.execute('generate', [ numblocks ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      "11c5504f63aebe71b3e6f46a31f83dd24e65e392a11e905f6acdb7346c8b18c0",
      "64455db5aa23d6277027aea1851d85da8ee07958ed7caee2ca630b065f4faaa8"
    ]
    

    Mines numblocks number of blocks. Will return once all blocks are mined. CLI command may timeout before that happens.

    Params

    N. Name Default Description
    1 numblocks 1 Number of blocks to mine.
    2 maxtries

    generatetoaddress

    let numblocks, address;
    
    numblocks=2;
    address='RTZJdYScA7uGb5pbQPEczpDmq9HiYLv2fJ';
    
    # Will return once all blocks are mined.
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "generatetoaddress",
        "params": [ '$numblocks', "'$address'" ]
      }'
    
    # Timeout error
    hsd-cli rpc generatetoaddress $numblocks $address
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      // Timeout error
      const result = await client.execute('generatetoaddress', [ numblocks, address ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      "65e54939c20f61e54173596eb72a7b00b96baac0c58d2cb30d1fad64d1b51dbb",
      "3959ee3f58bb1ac05af9bebb51ebf7872bcd4231fa41c384bcfef468541b5166"
    ]
    

    Mines numblocks blocks, with address as coinbase.

    Params

    N. Name Default Description
    1 numblocks 1 Number of blocks to mine.
    2 address Coinbase address for new blocks.

    RPC Calls - Network

    getconnectioncount

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getconnectioncount",
        "params": []
      }'
    
    hsd-cli rpc getconnectioncount
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getconnectioncount');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    8
    

    Returns connection count.

    Params

    N. Name Default Description
    None.

    ping

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "ping",
        "params": []
      }'
    
    hsd-cli rpc ping
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('ping');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Will send ping request to every connected peer.

    Params

    N. Name Default Description
    None.

    getpeerinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getpeerinfo",
        "params": []
      }'
    
    hsd-cli rpc getpeerinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getpeerinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "id": 65,
        "addr": "127.0.0.1:14038",
        "addrlocal": "127.0.0.1:42930",
        "name": "localhost",
        "services": "00000009",
        "relaytxes": true,
        "lastsend": 1527116003,
        "lastrecv": 1527116003,
        "bytessent": 20734,
        "bytesrecv": 19905,
        "conntime": 348,
        "timeoffset": 0,
        "pingtime": 0.001,
        "minping": 0,
        "version": 70015,
        "subver": "/hsd:0.0.0/",
        "inbound": false,
        "startingheight": 5456,
        "besthash": "43bc66d363025c8953d0920d0bdd5d78e88905687dc0321053ce8f4c6ca0319d",
        "bestheight": 5470,
        "banscore": 0,
        "inflight": [],
        "whitelisted": false
      },
      ...
    ]
    

    Returns information about all connected peers.

    Params

    N. Name Default Description
    None.

    addnode

    let nodeAddr, cmd;
    
    nodeAddr='127.0.0.1:14038';
    cmd='add'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "addnode",
        "params": [ "'$nodeAddr'", "'$cmd'" ]
      }'
    
    hsd-cli rpc addnode $nodeAddr $cmd
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('addnode', [ nodeAddr, cmd ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Adds or removes peers in Host List.

    Params

    N. Name Default Description
    1 addr Required IP Address of the Node.
    2 cmd Required Command

    Commands

    Command Description
    add Adds node to Host List and connects to it
    onetry Tries to connect to the given node
    remove Removes node from host list

    disconnectnode

    let nodeAddr;
    
    nodeAddr='127.0.0.1:14038';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "disconnectnode",
        "params": [ "'$nodeAddr'" ]
      }'
    
    hsd-cli rpc disconnectnode $nodeAddr
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('disconnectnode', [ nodeAddr ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Disconnects node.

    Params

    N. Name Default Description
    1 addr Required IP Address of the Node.

    getaddednodeinfo

    let nodeAddr;
    
    nodeAddr='127.0.0.1:14038';
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getaddednodeinfo",
        "params": [ "'$nodeAddr'" ]
      }'
    
    hsd-cli rpc getaddednodeinfo $nodeAddr
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getaddednodeinfo', [ nodeAddr ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "addednode": "127.0.0.1:14038",
        "connected": true,
        "addresses": [
          {
            "address": "127.0.0.1:14038",
            "connected": "outbound"
          }
        ]
      }
    ]
    

    Returns node information from host list.

    Params

    N. Name Default Description
    1 addr Required IP Address of the Node.

    getnettotals

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getnettotals",
        "params": []
      }'
    
    hsd-cli rpc getnettotals
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnettotals');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "totalbytesrecv": 42175,
      "totalbytessent": 42175,
      "timemillis": 1527116369308
    }
    

    Returns information about used network resources.

    Params

    N. Name Default Description
    None.

    getnetworkinfo

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "getnetworkinfo",
        "params": []
      }'
    
    hsd-cli rpc getnetworkinfo
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnetworkinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "version": "0.0.0",
      "subversion": "/hsd:0.0.0/",
      "protocolversion": 70015,
      "localservices": "00000009",
      "localrelay": true,
      "timeoffset": 0,
      "networkactive": true,
      "connections": 2,
      "networks": [],
      "relayfee": 0.00001,
      "incrementalfee": 0,
      "localaddresses": [
        {
          "address": "18.188.224.12",
          "port": 14038,
          "score": 3
        }
      ],
      "warnings": ""
    }
    

    Returns local node's network information

    Params

    N. Name Default Description
    None.

    setban

    let nodeAddr, cmd;
    
    nodeAddr='127.0.0.1:14038';
    cmd='add'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "setban",
        "params": [ "'$nodeAddr'", "'$cmd'" ]
      }'
    
    hsd-cli rpc setban $nodeAddr $cmd
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('setban', [ nodeAddr, cmd ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Adds or removes nodes from banlist.

    Params

    N. Name Default Description
    1 addr Required IP Address of the Node.
    2 cmd Required Command

    Commands

    Command Description
    add Adds node to ban list, removes from host list, disconnects.
    remove Removes node from ban list

    listbanned

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "listbanned",
        "params": []
      }'
    
    hsd-cli rpc listbanned
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('listbanned');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "address": "127.0.0.1",
        "banned_until": 1527202858,
        "ban_created": 1527116458,
        "ban_reason": ""
      }
    ]
    

    Lists all banned peers.

    Params

    N. Name Default Description
    None.

    clearbanned

    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{
        "method": "clearbanned",
        "params": []
      }'
    
    hsd-cli rpc clearbanned
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('clearbanned');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Removes all banned peers.

    Params

    N. Name Default Description
    None.

    RPC Calls - Names

    getnameinfo

    name='pi'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getnameinfo", "params": ["'$name'"] }'
    
    hsd-rpc getnameinfo "$name"
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnameinfo', [ name ]);
      console.log(result);
    })();
    

    getnameinfo returns JSON structured like this: ("info" is empty if name has not yet been auctioned).

    {
      "result": {
        "start": {
          "reserved": false,
          "week": 20,
          "start": 3024
        },
        "info": {
          "name": "pi",
          "nameHash": "512da52b8aba40722262447a53ff36f1ab854a5dd1ea1bf92d0aed18a50ebca9",
          "state": "CLOSED",
          "height": 7203,
          "renewal": 14636,
          "owner": {
            "hash": "47510cf5ba035cfc97f3e2e6cbe9c06e536fa87e81350343d30f2d021dc1dd36",
            "index": 0
          },
          "value": 1000000,
          "highest": 2000000,
          "data": "0000a8030a526567697374657265640477697468086e616d656261736501344765080d0980208120822e696f2f",
          "transfer": 0,
          "revoked": 0,
          "claimed": false,
          "weak": false,
          "stats": {
            "renewalPeriodStart": 14636,
            "renewalPeriodEnd": 23276,
            "blocksUntilExpire": 6154,
            "daysUntilExpire": 21.37
          }
        }
      }
    }
    

    Returns information on a given name. Use this function to query any name in any state.

    Params

    Name Default Description
    name Required Name you wish to look up

    Return values

    Name Type Description
    reserved Boolean true if the name is pre-reserved for it's existing owner to claim via DNSSEC proof.
    week int estimated number of weeks after mainnet launch that name will become available (if not reserved)
    start int exact block number that name will become available for bidding (if not reserved)
    state string the current auction state of the name (BIDDING, REVEAL, CLOSED, REVOKED, TRANSFER)
    height int block height at which auction started
    renewal int block height at which renewal period begins
    owner int UTXO to which the name belongs
    value int penultimate bid amount, paid by winner
    highest int highest bid amount, made by winner
    data serialized the dns record data of the name stored on chain
    claimed boolean true if the name was reserved and then unlocked and claimed via DNSSEC proof.

    getnames (hsd)

    hsd-rpc getnames
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnames');
      console.log(result);
    })();
    

    getnames returns JSON structured like this: (warning this does not yet support pagination)

    [
      {
        "name": "why",
        "nameHash": "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
        "state": "CLOSED",
        "height": 189,
        "renewal": 398,
        "owner": {
          "hash": "7bd7c709e5d5e5cc2382f45daad29d280641bf9d1fdf5f88efb6a1809b16a01b",
          "index": 0
        },
        "value": 1000000,
        "highest": 3000000,
        "data": "00000000",
        "transfer": 0,
        "revoked": 0,
        "claimed": false,
        "weak": false,
        "stats": {
          "renewalPeriodStart": 398,
          "renewalPeriodEnd": 10398,
          "blocksUntilExpire": 9917,
          "daysUntilExpire": 34.43
        }
      },
      {
        "name": "wizard",
        "nameHash": "89474af5538c39b1486a82202cf26a1d80e0a3630b7a0c413e9be1803a6bda4c",
        "state": "CLOSED",
        "height": 114,
        "renewal": 114,
        "owner": {
          "hash": "3f97093abcc2a39f88f99a98fdf86e590730699eada96afe62940c5018f92712",
          "index": 0
        },
        "value": 1000000,
        "highest": 5000000,
        "data": "",
        "transfer": 0,
        "revoked": 0,
        "claimed": false,
        "weak": false,
        "stats": {
          "renewalPeriodStart": 114,
          "renewalPeriodEnd": 10114,
          "blocksUntilExpire": 9633,
          "daysUntilExpire": 33.45
        }
      },
    ]
    

    Returns info for all names that have been opened or claimed. NOTE: this is primarily for debugging on regtest or testnet. It does not yet support pagination. Note this is different from the hsw-rpc getnames which only returns info on the names your wallet is tracking.

    getnamebyhash

    namehash='e4dfb97162995a696714a84f3bd3f242b02f5f071c1c6670a24f5ae1e1235007'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getnamebyhash", "params": ["'$namehash'"] }'
    
    hsd-rpc getnamebyhash $namehash
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnamebyhash', [ namehash ]);
      console.log(result);
    })();
    

    getnamebyhash returns the name

    
    test-txt
    
    

    Returns the name for a from a given nameHash.

    Params

    Name Default Description
    nameHash Required hash for which you want to the name.

    Return values

    Name Type Description
    name String

    getnameresource

    name='test-txt'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getnameresource", "params": ["'$name'"] }'
    
    hsd-rpc getnameresource $name
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnameresource', [ name ]);
      console.log(result);
    })();
    

    getnameresource returns JSON structured like this:

    {
      "records": [
        {
          "type": "GLUE4",
          "ns": "ns1.handshake.",
          "address": "44.231.6.183"
        },
        {
          "type": "GLUE4",
          "ns": "ns2.handshake.",
          "address": "23.239.11.203"
        },
        {
          "type": "NS",
          "ns": "ns1.handshake."
        }
      ]
    }
    

    Returns the resource records for the given name (added to the trie by the name owner using sendupdate).

    Params

    Name Default Description
    name Required name for resource records.

    getnameproof

    name='test-txt'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "getnameproof", "params": ["'$name'"] }'
    
    hsd-rpc getnameproof $name
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getnameproof', [ name ]);
      console.log(result);
    })();
    

    getnameproof returns JSON structured like this:

    {
      "hash": "67ec4b4e0f51c7bbc708372dcfcd0ef84c16e3f0ec5eec7e3c414cb0409ebeef",
      "height": 478,
      "root": "f1917a89eea3fbcccf8eff42ab68afb67def86a8993d205b35cfeaf8388c6eb6",
      "name": "trees",
      "key": "92ec68524dbcc44bc3ff4847ed45e3a86789009d862499ce558c793498413cec",
      "proof": {
        "type": "TYPE_EXISTS",
        "depth": 4,
        "nodes": [
          [
            "",
            "f649bafd4cd34035ccdd3c1585c6722736f88251ac7c0a07ec71c5145f0aff93"
          ],
          [
            "",
            "5ca9816e027df9cbe464bcf5bd6148795e37d5f3165e4b3c9f017887a33a8630"
          ],
          [
            "",
            "2bf92bbf3664fe4a2ee8e0757327bef3ed5101a37639d2152dc0ab44b9c19ed4"
          ],
          [
            "",
            "5a79b7ad97d4cc3cc282e0f8ccdc0a1b0d97eeba145749aa7e23de5379aad4cd"
          ]
        ],
        "value": "0574726565732c00000a8c000906036e7331076578616d706c6503636f6d000102030400000000000000000000000000000000004300000014010000075d04759a92c5d3bd4ef6856ebcde45cd5ce4e8563a6377d9edac5161014940c900fe404b4c00fe002d3101"
      }
    }
    

    Returns the merkle trie proof for a given name.

    Params

    Name Default
    name Required

    Proof types

    Type Description
    'TYPE_DEADEND' Name does not exist in trie.
    'TYPE_SHORT' Name does not exist in trie (path stops short).
    'TYPE_COLLISION' Name does not exist in trie (path collides with existing key).
    'TYPE_EXISTS' Name exists in trie. Returns array of nodes as proof.
    'TYPE_UNKNOWN' Some error occured.

    sendrawclaim

    base64_string='AwEAAd334XDnsXiofaipnUTULW5CW4VZlWzNKXDzQKsaCyFQEd28I9Xx'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "sendrawclaim", "params": ["'base64_string'"] }'
    
    hsd-rpc sendrawclaim $base64_string
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendrawclaim', [ base64_string ]);
      console.log(result);
    })();
    

    send rawclaim allows you to publish your claim directly and returns the claim ID

    0ba16efc2ace2b38726206e3b05ddeccbfbf87d191510d137a72ea4eceaded77
    

    If you already have DNSSEC setup, you can avoid publishing a TXT record publicly by creating the proof locally. This requires that you have direct access to your zone-signing keys. The private keys themselves must be stored in BIND's private key format and naming convention.

    See the README for hsd or the Name Claims guide for more.

    Params

    Name Default Description
    claim Required raw serialized base64-string

    getdnssecproof

    name='icann.org'
    
    hsd-rpc getdnssecproof "$name"
    
    curl http://x:api-key@127.0.0.1:14037 \
        -X POST \
        --data '{ "method": "getdnssecproof" , "params": ["'$name'"] }'
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getdnssecproof', [ name ]);
      console.log(result);
    })();
    
    {
      "zones": [...]
    }
    

    Query for and build a Handshake DNSSEC ownership proof. This is the same proof that is included in a name claim. See the sendclaim RPC method to build a transaction that includes the DNSSEC ownership proof. The estimate param is used to validate the proof. If set to false, it will strictly require the proof to be valid. If set to true, the proof will be built and returned to the caller, even if it is invalid. The default value for estimate is false.

    A Handshake DNSSEC ownership proof is a more strict subset of a DNSSEC proof. Each parent/child zone must operate through a series of DS->DNSKEY relationships, no CNAMEs or wildcards are allowed, each label separation (.) must behave like a zone cut (with an appropriate child zone referral) and weak cryptography is not allowed. This means that SHA1 digests for DS hashes are not allowed, and RSA-1024 is subject to be disabled via soft-fork.

    Params

    Name Default Description
    name Domain name
    estimate false No validation when true
    verbose true Returns hex when false

    sendrawairdrop

    base64_string='6XzakHKLJGuK3kgyCOEfJ8XPT1IJtvZZL9zaTC5x6QxqQIqfhSnqy3guOtwuMWs'
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "sendrawairdrop", "params": ["'$base64_string'"] }'
    
    hsd-rpc sendrawairdrop $base64_string
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendrawairdrop', [ base64_string ]);
      console.log(result);
    })();
    

    send rawairdrop allows you to publish your airdrop proof

    Airdrop proofs create brand new coins directly to a Handshake address

    For details on how to create an airdrop proof, see the hs-airdrop tool.

    Params

    Name Default Description
    claim Required raw serialized base64-string

    grindname

    length=4
    
    curl http://x:api-key@127.0.0.1:14037 \
      -X POST \
      --data '{ "method": "grindname", "params": [ '$length' ] }'
    
    hsd-rpc grindname $length
    
    const {NodeClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('grindname', [ length ]);
      console.log(result);
    })();
    

    grindname returns a randomly derived available name

    girn
    

    Grind a rolled-out available name.

    Params

    Name Default Description
    length 10 length of name to generate

    Wallet

    The Wallet Client

    npm i -g hs-client
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    const id = 'primary'; // or whatever your wallet name is
    
    const wallet = walletClient.wallet(id);
    

    The best way to interact with the wallet API is with the hsw-cli in the hs-client package. Installing globally with npm i -g hs-client gives you access to the cli. You can also install locally to your project.

    Note that when using it in your own program, you will need to explicitly pass in a port option. The easiest way to do this is with hsd.Network.

    You can create a client for a specific wallet (and be compatible with the old api) with the wallet method on WalletClient class.

    The wallet HTTP server listens on it's own port, separate from the node's server. By default the wallet server listens on these localhost ports:

    Network API Port
    main 12039
    testnet 13039
    regtest 14039
    simnet 15039

    Configuration

    Persistent configuration can be added to hsw.conf in your prefix directory. Same directory has hsd.conf for the node server.

    Example Configuration:

    network: regtest
    wallet-auth: true
    api-key: api-key
    http-host: 0.0.0.0
    

    Wallet Authentication

    The following samples return a wallet object using a wallet token

    let token, id;
    
    id='primary'
    token='17715756779e4a5f7c9b26c48d90a09d276752625430b41b5fcf33cf41aa7615'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id?token=$token
    
    hsw-cli get --token=$token
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id, token);
    
    (async () => {
      const result = await wallet.getInfo();
      console.log(result);
    })();
    

    There are three levels of authentication for the hsd wallet API server:

    1. API Key

    The API key is set either in hsw.conf or with the argument --api-key= at launch. When set, the API key is required (using HTTP Basic Authorization) to access ALL endpoints, otherwise a 401 Unauthorized error is returned. See the section on node API server authentication for tips on creating a strong key.

    2. Wallet tokens

    Every individual wallet has its own security token, which is a 32 byte hash calculated from the wallet master key:

    SHA256(m/44' Private Key | tokenDepth)

    A wallet is always created with a corresponding token. Even watch-only wallets will have a master private key, used just for this purpose. The token is returned when a wallet is created, or from the wallet info API endpoint (which is restricted to admin access, see next subsection). When wallet-auth is set to true, the token must be sent in the query string or JSON body for any requests regarding that wallet. Requests with incorrect tokens are rejected with a 403 Forbidden error.

    3. Wallet admin token

    The admin token is set by the user in hsw.conf, with the launch argument hsd --wallet-admin-token= or, if running hs-wallet as a separate server, just hs-wallet --admin-token=. It is required to be a 32 byte hex string. Like the individual wallet tokens, it is only required when wallet-auth: true, and must be included in the query string or JSON body. Requests sent with an admin token automatically overrides individual wallet tokens, and can therefore access all wallets.

    The admin token also enables access to extra API endpoints outlined in Wallet Admin Commands.

    The WalletDB and Object

    let id;
    
    id="primary"
    
    curl http://x:api-key@127.0.0.1:14039/wallet # will list regtest (default port 14039) wallets
    
    # Like the node client, you can configure it by passing arguments:
    hsw-cli --network=regtest --id=$id get
    
    # ...or you can use environment variables. The default `id` is `primary`:
    export HSD_API_KEY=yoursecret
    export HSD_NETWORK=regtest
    hsw-cli get
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getInfo();
      console.log(result);
    })();
    

    The wallet object will look something like this:

    {
      "network": "regtest",
      "wid": 0,
      "id": "primary",
      "watchOnly": false,
      "accountDepth": 1,
      "token": "540db9e0c4315e00febee2c2565f8430b00903af33aaa6b3b06db67bd1209f9b",
      "tokenDepth": 0,
      "master": {
        "encrypted": false
      },
      "balance": {
        "tx": 9,
        "coin": 9,
        "unconfirmed": 2500000000,
        "confirmed": 2500000000,
        "lockedUnconfirmed": 0,
        "lockedConfirmed": 0
      }
    }
    

    hsd maintains a wallet database which contains every wallet. Wallets are not usable without also using a wallet database. For testing, the wallet database can be in-memory, but it must be there. Wallets are uniquely identified by an id and the walletdb is created with a default id of primary. (See Create a Wallet below for more details.)

    Wallets in hsd use bip44. They also originally supported bip45 for multisig, but support was removed to reduce code complexity, and also because bip45 doesn't seem to add any benefit in practice.

    The wallet database can contain many different wallets, with many different accounts, with many different addresses for each account. hsd should theoretically be able to scale to hundreds of thousands of wallets/accounts/addresses.

    Each account can be of a different type. You could have a pubkeyhash account, as well as a multisig account, a witness pubkeyhash account, etc.

    Note that accounts should not be accessed directly from the public API. They do not have locks which can lead to race conditions during writes.

    wallet object vs wallet client object

    hs-client returns a WalletClient object that can perform admin functions without specifying a wallet, and may be useful when managing multiple wallets. WalletClient can also return a wallet object specified by an id. This object performs functions (and may be authorized by a token) specific to that wallet only.

    Create A Wallet

    let id, passphrase, watchOnly, accountKey;
    
    id='newWallet'
    passphrase='secret456'
    watchOnly=true
    accountKey='rpubKBAoFrCN1HzSEDye7jcQaycA8L7MjFGmJD1uuvUZ21d9srAmAxmB7o1tCZRyXmTRuy5ZDQDV6uxtcxfHAadNFtdK7J6RV9QTcHTCEoY5FtQD'
    
    id='newWallet'
    passphrase='secret456'
    watchOnly=true
    accountKey='rpubKBAoFrCN1HzSEDye7jcQaycA8L7MjFGmJD1uuvUZ21d9srAmAxmB7o1tCZRyXmTRuy5ZDQDV6uxtcxfHAadNFtdK7J6RV9QTcHTCEoY5FtQD'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id \
      -X PUT \
      --data '{"passphrase":"'$passphrase'", "watchOnly": '$watchOnly', "accountKey":"'$accountKey'"}'
    
    id='newWallet'
    passphrase='secret456'
    watch=true
    key='rpubKBAoFrCN1HzSEDye7jcQaycA8L7MjFGmJD1uuvUZ21d9srAmAxmB7o1tCZRyXmTRuy5ZDQDV6uxtcxfHAadNFtdK7J6RV9QTcHTCEoY5FtQD'
    
    # watchOnly defaults to true if --key flag is set
    
    hsw-cli mkwallet $id --passphrase=$passphrase --watch=$watch --key=$key
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    const options = {
      passphrase: passphrase,
      watchOnly: watchOnly,
      accountKey: accountKey
    };
    
    (async() => {
      const result = await walletClient.createWallet(id, options);
      console.log(result);
    })();
    

    Sample response:

    {
      "network": "regtest",
      "wid": 2,
      "id": "newWallet",
      "watchOnly": true,
      "accountDepth": 1,
      "token": "21b728d8f9e4d909349cf0c8f1e4e74fd45b180103cb7f1885a197d04012ba08",
      "tokenDepth": 0,
      "master": {
        "encrypted": true,
        "until": 1527181467,
        "iv": "53effaf192a346b40b08a52dac0658ce",
        "algorithm": "pbkdf2",
        "n": 50000,
        "r": 0,
        "p": 0
      },
      "balance": {
        "tx": 0,
        "coin": 0,
        "unconfirmed": 0,
        "confirmed": 0
      }
    }
    

    Create a new wallet with a specified ID.

    HTTP Request

    PUT /wallet/:id

    Parameters:

    Name Type Default Description
    id String Wallet ID (used for storage)
    type String 'pubkeyhash' Type of wallet (pubkeyhash, multisig)
    master HDPrivateKey Master HD key. If not present, it will be generated
    mnemonic String A mnemonic phrase to use to instantiate an hd private key. One will be generated if none provided
    m Number 1 m value for multisig (m-of-n)
    n Number 1 n value for multisig (m-of-n)
    passphrase String A strong passphrase used to encrypt the wallet
    watchOnly Boolean false (watch for CLI)
    accountKey String The extended public key for the primary account in the new wallet. This value is ignored if watchOnly is false
    (key for CLI)
    accountDepth* Number 0 The index of the next BIP44 account index

    (*) options are only available in Javascript usage, not CLI or curl

    Reset Authentication Token

    let id;
    
    id='primary'
    passphrase='secret123'
    
    hsw-cli retoken --id=$id --passphrase=$passphrase
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/retoken \
      -X POST \
      --data '{"passphrase":"'$passphrase'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.retoken(passphrase);
      console.log(result);
    })();
    

    Sample response:

    {
      "token": "2d04e217877f15ba920d02c24c6c18f4d39df92f3ae851bec37f0ade063244b2"
    }
    

    Derive a new wallet token, required for access of this particular wallet.

    HTTP Request

    POST /wallet/:id/retoken

    Get Wallet Info

    let id;
    
    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id
    
    hsw-cli get --id=$id
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getInfo();
      console.log(result);
    })();
    

    Sample output

    {
      "network": "regtest",
      "wid": 0,
      "id": "primary",
      "watchOnly": false,
      "accountDepth": 1,
      "token": "4d9e2a62f67929340b8c600bef0c965370f29cc64afcdeb7aea9cb52906c1d27",
      "tokenDepth": 13,
      "master": {
        "encrypted": true,
        "until": 0,
        "iv": "e33424f46674d4010fb0715bb69abc98",
        "algorithm": "pbkdf2",
        "n": 50000,
        "r": 0,
        "p": 0
      },
      "balance": {
        "tx": 5473,
        "coin": 5472,
        "unconfirmed": 1504999981750,
        "confirmed": 1494999998350
      }
    }
    

    Get wallet info by ID. If no id is passed in the CLI it assumes an id of primary.

    HTTP Request

    GET /wallet/:id

    Parameters Description
    id
    string
    named id of the wallet whose info you would like to retrieve

    Get Master HD Key

    let id;
    
    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/master
    
    hsw-cli master --id=$id
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getMaster();
      console.log(result);
    })();
    

    Sample responses:

    BEFORE passphrase is set:

    {
      "encrypted": false,
      "key": {
        "xprivkey": "tprv8ZgxMBicQKsPe7977psQCjBBjWtLDoJVPiiKog42RCoShJLJATYeSkNTzdwfgpkcqwrPYAmRCeudd6kkVWrs2kH5fnTaxrHhi1TfvgxJsZD",
        "mnemonic": {
          "bits": 128,
          "language": "english",
          "entropy": "a560ac7eb5c2ed412a4ba0790f73449d",
          "phrase": "pistol air cabbage high conduct party powder inject jungle knee spell derive"
        }
      }
    }
    

    AFTER passphrase is set:

    {
      "encrypted": true,
      "until": 1527121890,
      "iv": "e33424f46674d4010fb0715bb69abc98",
      "ciphertext": "c2bd62d659bc92212de5d9e939d9dc735bd0212d888b1b04a71d319e82e5ddb18008e383130fd0409113264d1cbc0db42d997ccf99510b168c80e2f39f2983382457f031d5aa5ec7a2d61f4fc92c62117e4eed59afa4a17d7cb0aae3ec5fa0d4",
      "algorithm": "pbkdf2",
      "n": 50000,
      "r": 0,
      "p": 0
    }
    

    Get wallet master HD key. This is normally censored in the wallet info route. The provided API key must have admin access.

    HTTP Request

    GET /wallet/:id/master

    Parameters Description
    id
    string
    named id of the wallet whose info you would like to retrieve

    Change Passphrase

    let id, oldPass, newPass;
    
    id='newWallet'
    oldPass='secret456'
    newPass='789secret'
    
    > No cli command available
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/passphrase \
      -X POST \
      --data '{"old":"'$oldPass'", "passphrase":"'$newPass'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.setPassphrase(oldPass, newPass);
      console.log(result);
    })();
    

    Sample Response:

    {"success": true}
    

    Change wallet passphrase. Encrypt if unencrypted.

    HTTP Request

    POST /wallet/:id/passphrase

    Body Parameters

    Parameters Description
    old
    string
    Old passphrase. Pass in empty string if none
    new
    string
    New passphrase

    Send a transaction

    id="primary"
    passphrase="secret123"
    rate=0.00000500
    value=0.00001000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    hsw-cli send --id=$id --value=$value --address=$address ---passphrase=$passphrase
    
    id="primary"
    passphrase="secret123"
    rate=500
    value=1000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/send \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "rate":'$rate',
        "outputs":[
          {"address":"'$address'", "value":'$value'}
        ]
      }'
    
    let id, passphrase, rate, value, address;
    id="primary"
    passphrase="secret123"
    rate=500
    value=1000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {
      passphrase: passphrase,
      rate: rate,
      outputs: [{ value: value, address: address }]
    };
    
    (async () => {
      const result = await wallet.send(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "bc0f93bb233fdf42a25a086ffb744fcb4f64afe6f5d4243da8e3745835fd57b3",
      "height": -1,
      "block": null,
      "time": 0,
      "mtime": 1528468930,
      "date": "1970-01-01T00:00:00Z",
      "mdate": "2018-06-08T14:42:10Z",
      "size": 215,
      "virtualSize": 140,
      "fee": 2800,
      "rate": 20000,
      "confirmations": 0,
      "inputs": [
        {
          "value": 500002800,
          "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/0"
          }
        }
      ],
      "outputs": [
        {
          "value": 100000000,
          "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
          "covenant": {
            "type": 0,
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/1"
          }
        },
        {
          "value": 400000000,
          "address": "rs1q2x2suqr44gjn2plm3f99v2ae6ead3rpat9qtzg",
          "covenant": {
            "type": 0,
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/4"
          }
        }
      ],
      "tx": "0000000001758758e600061e62b92831cb40163011e07bd42cac34467f7d34f57c4a921e35000000000241825ebb96f395c02d3cdce7f88594dab343347879dd96af29320bf020f2c5677d4ab7ef79349007d562a4cdafb54d8e1cbd538275deef1b78eb945155315ae648012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9ffffffff0200e1f505000000000014f0d9374a2ce80c377187f4bc6c68993c561cb13600000084d71700000000001451950e0075aa253507fb8a4a562bb9d67ad88c3d000000000000"
    }
    

    Create, sign, and send a transaction.

    HTTP Request

    POST /wallet/:id/send

    Post Paramaters

    Parameter Description
    outputs
    array
    An array of outputs to send for the transaction
    account
    string
    account to use for transaction
    passphrase
    string
    passphrase to unlock the account
    smart
    bool
    If set, will spend unconfirmed change outputs (only from transactions sent from this wallet).
    blocks
    int
    number of blocks to use for fee estimation.
    rate
    int
    the rate for transaction fees. Denominated in subunits per kb
    maxFee
    int
    maximum fee you're willing to pay
    subtractFee
    bool
    whether to subtract fee from outputs (evenly)
    subtractIndex
    int
    subtract only from specified output index
    selection
    enum - all, random, age, value
    How to select coins
    depth
    int
    number of confirmation for coins to spend
    value
    int (or float)
    Value to send in subunits (or whole HNS, see warning above)
    address
    string
    destination address for transaction

    Create a Transaction

    id="multisig1"
    passphrase="multisecret123"
    rate=0.00000500
    value=0.05000000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    hsw-cli mktx --id=$id --value=$value --address=$address ---passphrase=$passphrase
    
    id="multisig1"
    passphrase="multisecret123"
    rate=500
    value=5000000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/create \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "rate":'$rate',
        "outputs":[
          {"address":"'$address'", "value":'$value'}
        ]
      }'
    
    let id, passphrase, rate, value, address;
    id="multisig1"
    passphrase="multisecret123"
    rate=500
    value=5000000
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {
      passphrase: passphrase,
      rate: rate,
      outputs: [{ value: value, address: address }]
    };
    
    (async () => {
      const result = await wallet.createTX(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "ce2b8ea52f54f2d170ce0e32b4dfb5f6553e7aad065413a570ce9d683ab14abc",
      "witnessHash": "980923fa0e9fa634e2c0bbc4d34a6303c7967b65173c2a36fe0b458f40bd070d",
      "fee": 2800,
      "rate": 20000,
      "mtime": 1528470021,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9",
            "index": 1
          },
          "witness": [
            "b25cb7e4d1269410d1bd625aaea3b23a3c6397549d708e3970e6dd9b40ce87bc579b6bf216b328bf58e5397a7480967d909e14e95bc7a5a3044e5994e460224301",
            "03d2a6f3eea124947217d0b0e56d81dc665df1fc08c4585269d706ec960cecb28f"
          ],
          "sequence": 4294967295,
          "coin": {
            "version": 0,
            "height": 5,
            "value": 399997200,
            "address": "rs1q5rjhy20r2hmcxjpc8zv70xkck05pecdew6a798",
            "covenant": {
              "type": 0,
              "items": []
            },
            "coinbase": false
          }
        }
      ],
      "outputs": [
        {
          "value": 5000000,
          "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
          "covenant": {
            "type": 0,
            "items": []
          }
        },
        {
          "value": 394994400,
          "address": "rs1q4s4lnf94su2padkt3wsgv9xenlyh8qygyl9j0x",
          "covenant": {
            "type": 0,
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9010000000241b25cb7e4d1269410d1bd625aaea3b23a3c6397549d708e3970e6dd9b40ce87bc579b6bf216b328bf58e5397a7480967d909e14e95bc7a5a3044e5994e4602243012103d2a6f3eea124947217d0b0e56d81dc665df1fc08c4585269d706ec960cecb28fffffffff02404b4c00000000000014f0d9374a2ce80c377187f4bc6c68993c561cb1360000e0228b17000000000014ac2bf9a4b587141eb6cb8ba08614d99fc9738088000000000000"
    }
    

    Create and template a transaction (useful for multisig). Does not broadcast or add to wallet.

    HTTP Request

    POST /wallet/:id/create

    Post Parameters

    Parameter Description
    outputs
    array
    An array of outputs to send for the transaction
    passphrase
    string
    passphrase to unlock the account
    smart
    bool
    If set, will spend unconfirmed change outputs (only from transactions sent from this wallet).
    rate
    int
    the rate for transaction fees. Denominated in subunits per kb
    maxFee
    int
    maximum fee you're willing to pay
    subtractFee
    bool
    whether to subtract fee from outputs (evenly)
    subtractIndex
    int
    subtract only from specified output index
    selection
    enum - all, random, age, value
    How to select coins
    depth
    int
    number of confirmation for coins to spend
    value
    int (or float)
    Value to send in subunits (or whole HNS, see warning above)
    address
    string
    destination address for transaction

    Sign Transaction

    let id, tx, passphrase;
    
    id="multisig2"
    passphrase="multisecret456"
    tx="0100000001be4330126fc108092daffca823d9b5d8bf0ee86ed727d19880e5a03977d8eb3100000000920000473044022064ac064f8b0e224413cf7e7c3aa2758013dd0cff6b421a273fb6f870894b200f022064da80d0ea08110b1c18817a66b1e576f945f73256407175b0fcc9936644b3320147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652aeffffffff02b0304c000000000017a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887404b4c00000000001976a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac00000000"
    
    hsw-cli sign --id=$id --passphrase=$passphrase --tx=$tx
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/sign \
      -X POST \
      --data '{"tx": "'$tx'", "passphrase":"'$passphrase'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = { tx: tx, passphrase: passphrase };
    
    (async () => {
      const result = await wallet.sign(options);
      console.log(result);
    })();
    

    Sample Output

    {
      "hash": "ce2b8ea52f54f2d170ce0e32b4dfb5f6553e7aad065413a570ce9d683ab14abc",
      "witnessHash": "980923fa0e9fa634e2c0bbc4d34a6303c7967b65173c2a36fe0b458f40bd070d",
      "fee": 2800,
      "rate": 20000,
      "mtime": 1528470021,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9",
            "index": 1
          },
          "witness": [
            "b25cb7e4d1269410d1bd625aaea3b23a3c6397549d708e3970e6dd9b40ce87bc579b6bf216b328bf58e5397a7480967d909e14e95bc7a5a3044e5994e460224301",
            "03d2a6f3eea124947217d0b0e56d81dc665df1fc08c4585269d706ec960cecb28f"
          ],
          "sequence": 4294967295,
          "coin": {
            "version": 0,
            "height": 5,
            "value": 399997200,
            "address": "rs1q5rjhy20r2hmcxjpc8zv70xkck05pecdew6a798",
            "covenant": {
              "type": 0,
              "items": []
            },
            "coinbase": false
          }
        }
      ],
      "outputs": [
        {
          "value": 5000000,
          "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
          "covenant": {
            "type": 0,
            "items": []
          }
        },
        {
          "value": 394994400,
          "address": "rs1q4s4lnf94su2padkt3wsgv9xenlyh8qygyl9j0x",
          "covenant": {
            "type": 0,
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9010000000241b25cb7e4d1269410d1bd625aaea3b23a3c6397549d708e3970e6dd9b40ce87bc579b6bf216b328bf58e5397a7480967d909e14e95bc7a5a3044e5994e4602243012103d2a6f3eea124947217d0b0e56d81dc665df1fc08c4585269d706ec960cecb28fffffffff02404b4c00000000000014f0d9374a2ce80c377187f4bc6c68993c561cb1360000e0228b17000000000014ac2bf9a4b587141eb6cb8ba08614d99fc9738088000000000000"
    }
    

    Sign a templated transaction (useful for multisig).

    HTTP Request

    POST /wallet/:id/sign

    Post Parameters

    Parameter Description
    tx
    string
    the hex of the transaction you would like to sign
    passphrase
    string
    passphrase to unlock the wallet

    Zap Transactions

    id="primary"
    account="default"
    age=259200 # 72 hours
    
    hsw-cli zap --id=$id --account=$account --age=$age
    
    id="primary"
    account="default"
    age=259200 # 72 hours
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/zap \
      -X POST \
      --data '{
        "account": "'$account'",
        "age": '$age'
      }'
    
    let id, age, account;
    id="primary"
    account="default"
    age=259200 // 72 hours
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.zap(account, age);
      console.log(result);
    })();
    

    Sample Response

    Zapped!
    
    {
      "success": true
    }
    
    {
      "success": true
    }
    

    Remove all pending transactions older than a specified age.

    HTTP Request

    POST /wallet/:id/zap?age=3600

    Post Parameters

    Paramaters Description
    account
    string or number
    account to zap from
    age
    number
    age threshold to zap up to (seconds)

    Unlock Wallet

    let id, pass, timeout
    
    id='primary'
    pass='secret123'
    timeout=60
    
    hsw-cli unlock --id=$id $pass $timeout
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/unlock \
      -X POST \
      --data '{"passphrase":"'$pass'", "timeout": '$timeout'}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.unlock(pass, timeout);
      console.log(result);
    })();
    

    Sample Response

    {"success": true}
    
    {"success": true}
    
    Unlocked.
    

    Derive the AES key from passphrase and hold it in memory for a specified number of seconds. Note: During this time, account creation and signing of transactions will not require a passphrase.

    HTTP Request

    POST /wallet/:id/unlock

    Body Parameters

    Parameter Description
    passphrase
    string
    Password used to encrypt the wallet being unlocked
    timeout
    number
    time to re-lock the wallet in seconds. (default=60)

    Lock Wallet

    let id;
    
    id='primary'
    
    hsw-cli lock --id=$id
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/lock \
      -X POST
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.lock(id);
      console.log(result);
    })();
    

    Sample Response

    {"success": true}
    
    {"success": true}
    
    Locked.
    

    If unlock was called, zero the derived AES key and revert to normal behavior.

    HTTP Request

    POST /wallet/:id/lock

    Import Public/Private Key

    let id, account, key;
    
    id='primary'
    watchid='watchonly1'
    account='default'
    pubkey='0215a9110e2a9b293c332c28d69f88081aa2a949fde67e35a13fbe19410994ffd9'
    privkey='EMdDCvF1ZjsCnimTnTQfjw6x8CQmVidtJxKBegCVzPw3g6yRoDkK'
    
    hsw-cli --id=$id --account=$account import $privkey
    hsw-cli --id=$watchid --account=$account import $pubkey
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/import \
      -X POST \
      --data '{"account":"'$account'", "privateKey":"'$privkey'"}'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$watchid/import \
      -X POST \
      --data '{"account":"'$account'", "publicKey":"'$pubkey'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    const watchwallet = walletClient.wallet(watchid);
    
    (async () => {
      const result = await watchwallet.importPublic(account, pubkey);
      console.log(result);
    })();
    
    (async () => {
      const result = await wallet.importPrivate(account, privkey);
      console.log(result);
    })();
    

    Sample Responses

    Imported private key.
    
    Imported public key.
    

    Import a standard WIF key.

    An import can be either a private key or a public key for watch-only. (Watch Only wallets will throw an error if trying to import a private key)

    A rescan will be required to see any transaction history associated with the key.

    HTTP Request

    POST /wallet/:id/import

    Body Parameters

    Parameter Description
    id
    string
    id of target wallet to import key into
    privateKey
    string
    Bech32 encoded private key
    publicKey
    string
    Hex encoded public key

    Will return following error if incorrectly formatted: Bad key for import

    Import Address

    let id, account, address;
    
    id='watchonly1'
    account='default'
    address='rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap'
    
    hsw-cli watch --id=$id --account=$account $address
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/import \
      -X POST \
      --data '{"account":"'$account'", "address":"'$address'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.importAddress(account, address);
      console.log(result);
    })();
    

    Sample Response

    {
      "success": true
    }
    

    Import a Bech32 encoded address. Addresses (like public keys) can only be imported into watch-only wallets

    The HTTP endpoint is the same as for key imports.

    HTTP Request

    POST /wallet/:id/import

    Body Parameters

    Parameter Description
    id
    string
    id of target wallet to import key into
    address
    string
    Bech32 encoded address

    Get Blocks with Wallet Txs

    let id;
    
    id="primary"
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/block
    
    hsw-cli blocks --id=$id
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getBlocks();
      console.log(result);
    })();
    

    Sample Response

    [ 1179720, 1179721, 1180146, 1180147, 1180148, 1180149 ]
    

    List all block heights which contain any wallet transactions. Returns an array of block heights

    HTTP Request

    GET /wallet/:id/block

    Parameters Description
    id
    string
    id of wallet to query blocks with its transactions in it

    Get Wallet Block by Height

    let id, height;
    
    id="primary"
    height=50
    
    hsw-cli --id=$id block $height
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/block/$height
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getBlock(height);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "5a630279111118885f4489471ddf6f7a318b3510e5e17aa73412088d19b8ba78",
      "height": 50,
      "time": 1527181141,
      "hashes": [
        "4255c0784ae89cfe7ccf878be3a408d8c1f6c665d5df331e27962b4defe3beb8"
      ]
    }
    

    Get block info by height.

    HTTP Request

    GET /wallet/:id/block/:height

    Paramaters Description
    id
    string
    id of wallet which has tx in the block being queried
    height
    int
    height of block being queried

    Add xpubkey (Multisig)

    let id, key, account;
    
    id="multisig3"
    account="default"
    key="rpubKBBGCWqgVn4RRVpJTDUvTJnFHYiQuoUNy7s6W57U36KJ3r5inJp7iVRJZHvkFjbgfaGVs9fkvcCQS5ZMmc7BYFCrkADgmGKDCsjYK1vGmoFw"
    
    hsw-cli --id=$id --account=$account shared add $key
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/shared-key \
      -X PUT \
      --data '{"accountKey": "'$key'", "account": "'$account'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.addSharedKey(account, key);
      console.log(result);
    })();
    

    Sample Response

    {
      "success": true,
      "addedKey": true
    }
    

    Add a shared xpubkey to wallet. Must be a multisig wallet.

    Response will return addedKey: true true if key was added on this request. Returns false if key already added, but will still return success: true with status 200.

    HTTP Request

    PUT /wallet/:id/shared-key

    Body Parameters

    Parameter Description
    accountKey
    string
    xpubkey to add to the multisig wallet
    account
    string
    multisig account to add the xpubkey to (default='default')

    Remove xpubkey (Multisig)

    let id, key;
    
    id="multisig3"
    account="default"
    key="rpubKBBGCWqgVn4RRVpJTDUvTJnFHYiQuoUNy7s6W57U36KJ3r5inJp7iVRJZHvkFjbgfaGVs9fkvcCQS5ZMmc7BYFCrkADgmGKDCsjYK1vGmoFw"
    
    hsw-cli --id=$id --account=$account shared remove $key
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/shared-key \
      -X DELETE \
      --data '{"accountKey": "'$key'", "account": "'$account'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.removeSharedKey(account, key);
      console.log(result);
    })();
    

    Sample Response

    {
      "success": true,
      "removedKey": true
    }
    

    Remove shared xpubkey from wallet if present.

    Response will return removedKey: true true if key was removed on this request. Returns false if key was already removed, but will still return success: true with status 200.

    HTTP Request

    DEL /wallet/:id/shared-key

    Body Parameters

    Parameter Description
    accountKey
    string
    xpubkey to add to the multisig wallet
    account
    string
    multisig account to remove the key from (default='default')

    Get Public Key By Address

    let id, address;
    
    id="primary"
    address="rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    
    hsw-cli --id=$id key $address
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/key/$address
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getKey(address);
      console.log(result);
    })();
    

    Sample Response

    {
      "name": "default",
      "account": 0,
      "branch": 0,
      "index": 1,
      "publicKey": "03d4cf5be0633367d3b544931bd21c963661dc5561ec8c23c08723445a50c29caf",
      "script": null,
      "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap"
    }
    

    Get wallet key by address. Returns wallet information with address and public key

    HTTP Request

    GET /wallet/:id/key/:address

    Parameters Description
    id
    string
    id of wallet that holds the address being queried
    address
    string
    Bech32 encoded address to get corresponding public key for

    Get Private Key By Address

    let id, address;
    
    id='primary'
    passphrase='secret123'
    address='rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap'
    
    hsw-cli --id=$id --passphrase=$passphrase dump $address
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/wif/$address?passphrase=$passphrase
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getWIF(address, passphrase);
      console.log(result);
    })();
    

    Sample Response

    {
      "privateKey": "EQWCFedg76dU1qaknKXnD4WkbMesyCEfVpPXkcQiY4qDMn1J3mFf"
    }
    

    Get wallet private key (WIF format) by address. Returns just the private key

    HTTP Request

    GET /wallet/:id/wif/:address

    Parameters Description
    id
    string
    id of wallet that holds the address being queried
    address
    string
    Bech32 encoded address to get corresponding public key for

    Generate Receiving Address

    let id, account;
    
    id="primary"
    account="default"
    
    hsw-cli --id=$id --account=$account address
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/address -X POST --data '{"account":"'$account'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.createAddress(account);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "default",
      "account": 0,
      "branch": 0,
      "index": 4,
      "publicKey": "023f2963bcbc853daa690909bb89022d4da109fb7c922607a8f37d8da4e69c72d5",
      "script": null,
      "address": "rs1qy9uplxpt5cur32rw3zmyf8e7tp87w8slly2fms"
    }
    
    

    Derive new receiving address for account.

    HTTP Request

    POST /wallet/:id/address

    Post Parameters

    Parameter Description
    account
    string
    BIP44 account to generate address from

    Generate Change Address

    let id, account;
    
    id="primary"
    account="default"
    
    hsw-cli --id=$id --account=$account change
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/change -X POST --data '{"account":"'$account'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.createChange(account);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "default",
      "account": 0,
      "branch": 1,
      "index": 6,
      "publicKey": "0232b907306e5bea1899874b813aed4e82eace6cb75c2a039434ce81576cf299c7",
      "script": null,
      "address": "rs1q30ppv5gyrwpy4wyk0v6uzawxygdtvrpux8yrg2"
    }
    

    Derive new change address for account.

    HTTP Request

    POST /wallet/:id/change

    Post Parameters

    Parameter Description
    account
    string
    BIP44 account to generate address from

    Get Balance

    let id, account;
    
    id='primary'
    account='default'
    
    hsw-cli --id=$id balance --account=$account
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/balance?account=$account
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getBalance(account);
      console.log(result);
    })();
    

    Sample response:

    {
      "account": 0,
      "tx": 10,
      "coin": 10,
      "unconfirmed": 2499997200,
      "confirmed": 2500000000,
      "lockedUnconfirmed": 0,
      "lockedConfirmed": 0
    }
    

    Get wallet or account balance. If no account option is passed, the call defaults to wallet balance (with account index of -1). Balance values for unconfirmed and confirmed are expressed in subunits.

    HTTP Request

    GET /wallet/:id/balance?account=:account

    Request Parameters

    Parameters Description
    id
    string
    wallet id to get balance of
    account
    string
    account name (optional, defaults to entire wallet balance)

    List all Coins

    let id;
    
    id="primary"
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/coin
    
    hsw-cli --id=$id coins
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getCoins();
      console.log(result);
    })();
    

    Sample Response

    [
      {
        "version": 0,
        "height": 4,
        "value": 100000000,
        "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
        "covenant": {
          "type": 0,
          "items": []
        },
        "coinbase": false,
        "hash": "4674eb87021d9e07ff68cfaaaddfb010d799246b8f89941c58b8673386ce294f",
        "index": 0
      },
      {
        "version": 0,
        "height": 5,
        "value": 500008400,
        "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
        "covenant": {
          "type": 0,
          "items": []
        },
        "coinbase": true,
        "hash": "1eab12e7682fd7442f1ee26ae349b1a34fd10c8e686da8161df09f7512fa2563",
        "index": 0
      },
      ...
    ]
    

    List all wallet coins available.

    HTTP Request

    GET /wallet/:id/coin

    Lock Coin/Outpoints

    let id, hash, index;
    
    id="primary"
    hash="52ada542512ea95be425087ee4b891842d81eb6f9a4e0350f14d0285b5fd40c1"
    index="0"
    
    # Not Supported in CLI
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/locked/$hash/$index -X PUT
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.lockCoin(hash, index);
      console.log(result);
    })();
    

    Sample response:

    {
      "success": true
    }
    

    Lock outpoints.

    HTTP Request

    PUT /wallet/:id/locked/:hash/:index

    Request Parameters

    Parameters Description
    id
    string
    id of wallet that contains the outpoint
    hash
    string
    hash of transaction that created the outpoint
    index
    string or int
    index of the output in the transaction being referenced

    Body Parameters

    Parameter Description
    passphrase
    string
    passphrase of wallet being referenced

    Unlock Outpoint

    let id, passphrase, hash, index;
    
    id="primary"
    hash="52ada542512ea95be425087ee4b891842d81eb6f9a4e0350f14d0285b5fd40c1"
    index="0"
    
    # Not Supported in CLI
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/locked/$hash/$index -X DELETE
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.unlockCoin(hash, index);
      console.log(result);
    })();
    

    Sample response:

    {
      "success": true
    }
    

    Unlock outpoints.

    HTTP Request

    DEL /wallet/:id/locked/:hash/:index

    Request Parameters

    Parameters Description
    id
    string
    id of wallet that contains the outpoint
    hash
    string
    hash of transaction that created the outpoint
    index
    string or int
    index of the output in the transaction being referenced

    Body Parameters

    Parameter Description
    passphrase
    string
    passphrase of wallet being referenced

    Get Locked Outpoints

    let id;
    
    id="primary"
    
    # Not supported in CLI
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/locked
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getLocked();
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "hash": "52ada542512ea95be425087ee4b891842d81eb6f9a4e0350f14d0285b5fd40c1",
        "index": 0
      }
    ]
    

    Get all locked outpoints.

    HTTP Request

    GET /wallet/:id/locked

    Request Parameters

    Parameters Description
    id
    string
    id of wallet to check for outpoints

    Get Wallet Coin

    let id, hash, index;
    
    id="primary"
    hash="52ada542512ea95be425087ee4b891842d81eb6f9a4e0350f14d0285b5fd40c1"
    index="0"
    
    # command is wallet agnostic, same as in vanilla coin command
    
    hsd-cli coin $hash $index
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/coin/$hash/$index
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getCoin(hash, index);
      console.log(result);
    })();
    

    Sample response:

    {
      "version": 1,
      "height": 104,
      "value": 5000000000,
      "script": "76a91403a394378a680558ea205b604b182566381e116e88ac",
      "address": "R9cS4kuYVWHaDJmRGMpwx7zCNjw97Zm5LL",
      "coinbase": true,
      "hash": "52ada542512ea95be425087ee4b891842d81eb6f9a4e0350f14d0285b5fd40c1",
      "index": 0
    }
    

    Get wallet coin

    HTTP Request

    GET /wallet/:id/coin/:hash/:index

    Request Parameters

    Parameters Description
    id
    string
    id of wallet that contains the outpoint
    hash
    string
    hash of transaction that created the outpoint
    index
    string or int
    index of the output in the transaction being referenced

    Wallet - Admin Commands

    curl http://x:api-key@127.0.0.1:14039 # will access admin functions for regtest (port 14039) wallets
    

    Admin commands are simply commands not specific to any particular wallet, and may impact all wallets on the system. Retrieving a wallet's master hd private key is also an admin command.

    Additional security is available by specifying admin-token in your configuration if wallet-auth is also enabled. If admin-token is specified, add ?token= to all admin requests.

    This is highly recommended, especially on production instances.

    Wallet Rescan

    let height;
    
    height=50
    
    curl http://x:api-key@127.0.0.1:14039/rescan \
      -X POST \
      --data '{"height": '$height'}'
    
    hsw-cli rescan $height
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.rescan(height);
      console.log(result);
    })();
    
    

    Response Body:

    {"success": true}
    

    Initiates a blockchain rescan for the walletdb. Wallets will be rolled back to the specified height (transactions above this height will be unconfirmed).

    Example HTTP Request

    POST /rescan?height=50

    Wallet Resend

    curl http://x:api-key@127.0.0.1:14039/resend \
    -X POST
    
    hsw-cli resend
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      result = await walletClient.resend();
      console.log(result);
    })();
    

    Response Body:

        {"success": true}
    

    Rebroadcast all pending transactions in all wallets.

    HTTP Request

    POST /resend

    Wallet Backup

    let path;
    
    path='/home/user/walletdb-backup.ldb'
    
    curl http://x:api-key@127.0.0.1:14039/backup?path=$path \
      -X POST
    
    hsw-cli backup $path
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.backup(path);
      console.log(result);
    })();
    

    Response Body:

    {"success": true}
    

    Safely backup the wallet database to specified path (creates a clone of the database).

    HTTP Request

    POST /backup?path=/home/user/walletdb-backup.ldb

    Wallet Master HD Private Key

    let id;
    
    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/$id/master
    
    hsw-cli master --id=$id
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getMaster();
      console.log(result);
    })();
    

    Sample responses:

    BEFORE passphrase is set:

    {
      "encrypted": false,
      "key": {
        "xprivkey": "tprv8ZgxMBicQKsPe7977psQCjBBjWtLDoJVPiiKog42RCoShJLJATYeSkNTzdwfgpkcqwrPYAmRCeudd6kkVWrs2kH5fnTaxrHhi1TfvgxJsZD",
        "mnemonic": {
          "bits": 128,
          "language": "english",
          "entropy": "a560ac7eb5c2ed412a4ba0790f73449d",
          "phrase": "pistol air cabbage high conduct party powder inject jungle knee spell derive"
        }
      }
    }
    

    AFTER passphrase is set:

    {
      "encrypted": true,
      "until": 1527121890,
      "iv": "e33424f46674d4010fb0715bb69abc98",
      "ciphertext": "c2bd62d659bc92212de5d9e939d9dc735bd0212d888b1b04a71d319e82e5ddb18008e383130fd0409113264d1cbc0db42d997ccf99510b168c80e2f39f2983382457f031d5aa5ec7a2d61f4fc92c62117e4eed59afa4a17d7cb0aae3ec5fa0d4",
      "algorithm": "pbkdf2",
      "n": 50000,
      "r": 0,
      "p": 0
    }
    

    Export the wallet's master hd private key. This is normally censored in the wallet info route. The provided API key must have admin access.

    HTTP Request

    GET /wallet/:id/master

    Parameters Description
    id
    string
    wallet id

    List all Wallets

    curl http://x:api-key@127.0.0.1:14039/wallet
    
    hsw-cli wallets
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.getWallets();
      console.log(result);
    })();
    

    Sample Response Body:

    [
      "primary",
      "newWallet",
      "multisig1",
      "multisig2",
      "watchonly1",
      "multisig3",
      "witness1"
    ]
    

    List all wallet IDs. Returns an array of strings.

    HTTP Request

    GET /wallet

    Wallet - Accounts

    Account Object

    An account object looks like this:

    {
      "name": "default",
      "initialized": true,
      "watchOnly": false,
      "type": "pubkeyhash",
      "m": 1,
      "n": 1,
      "accountIndex": 0,
      "receiveDepth": 5,
      "changeDepth": 7,
      "lookahead": 10,
      "receiveAddress": "rs1qy9uplxpt5cur32rw3zmyf8e7tp87w8slly2fms",
      "changeAddress": "rs1q30ppv5gyrwpy4wyk0v6uzawxygdtvrpux8yrg2",
      "accountKey": "rpubKBAXPkng2Zk4FTt7GwatsRAivjckuySyYydDXhcDFKvvQXN4wDvMtazgTAzq7gHA4ZcyXJp5VoYE8AcacXc1AgNmrnJt1YuAkbovBRSJ4Fuo",
      "keys": [],
      "balance": {
        "tx": 10,
        "coin": 10,
        "unconfirmed": 2499997200,
        "confirmed": 2500000000,
        "lockedUnconfirmed": 0,
        "lockedConfirmed": 0
      }
    }
    

    Represents a BIP44 Account belonging to a Wallet. Note that this object does not enforce locks. Any method that does a write is internal API only and will lead to race conditions if used elsewhere.

    From the BIP44 Specification:

    This level splits the key space into independent user identities, so the wallet never mixes the coins across different accounts. Users can use these accounts to organize the funds in the same fashion as bank accounts; for donation purposes (where all addresses are considered public), for saving purposes, for common expenses etc. Accounts are numbered from index 0 in sequentially increasing manner. This number is used as child index in BIP32 derivation. Hardened derivation is used at this level.

    Get Wallet Account List

    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/account
    
    hsw-cli account --id=$id list
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getAccounts();
      console.log(result);
    })();
    

    Sample response:

    [
      "default"
    ]
    

    List all account names (array indices map directly to bip44 account indices) associated with a specific wallet id.

    HTTP Request

    GET /wallet/:id/account

    Parameters Description
    id
    string
    id of wallet you would like to retrieve the account list for

    Get Account Information

    let id, account;
    
    id='primary'
    account='default'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/account/$account
    
    hsw-cli --id=$id account get $account
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getAccount(account);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "default",
      "initialized": true,
      "watchOnly": false,
      "type": "pubkeyhash",
      "m": 1,
      "n": 1,
      "accountIndex": 0,
      "receiveDepth": 6,
      "changeDepth": 9,
      "nestedDepth": 0,
      "lookahead": 10,
      "receiveAddress": "RLY9z6PCB3fggt36mnfA75jESRtvkALKX5",
      "changeAddress": "RPSppa2YUzTK5jWWZ7k74NfMEJtnNKn4vs",
      "nestedAddress": null,
      "accountKey": "rpubKBBuJXusEYaDdxTwH1nPYRXQnd3XgLAFfNYxVhjrtvLAkDAXaps1nURZVmWuFsXK8RBXiDQu7grCBv6fRtQxgPH3FkKe4UQV7F2sfNBK47sA",
      "keys": [],
      "balance": {
        "tx": 505,
        "coin": 501,
        "unconfirmed": 1339989996774,
        "confirmed": 1339989999000
      }
    }
    

    Get account info.

    HTTP Request

    GET /wallet/:id/account/:account

    Parameters Description
    id
    string
    id of wallet you would like to query
    account
    string
    id of account you would to retrieve information for

    Create new wallet account

    let id, passphrase, name, type;
    
    id='primary'
    passphrase='secret123'
    name='menace'
    type='multisig'
    
    hsw-cli --id=$id account create --name=$name --type=$type --passphrase=$passphrase 
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/account/$name \
        -X PUT \
        --data '{"type": "'$type'", "passphrase": "'$passphrase'"}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    const options = {name: name, type: type, passphrase: passphrase}
    
    (async () => {
      const result = await wallet.createAccount(name, options);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "null",
      "initialized": true,
      "watchOnly": false,
      "type": "pubkeyhash",
      "m": 1,
      "n": 1,
      "accountIndex": 1,
      "receiveDepth": 1,
      "changeDepth": 1,
      "lookahead": 10,
      "receiveAddress": "rs1qnkc22uz2hp9qz8tphyqy8ujftmz0zstrwn6lju",
      "changeAddress": "rs1qk6me5r699v24jn4u9jhdwxg4cykn2akr89g59p",
      "accountKey": "rpubKBAXPkng2Zk4FX87zf5LehvNn7Hy5P4eVwKp58YZ1CV7uZwgbDd1PHPKuyj7UTnvzFMMziK2kGtqMpZaKa6zUUM7YBsUB6pzQtojUFM4dnQM",
      "keys": [],
      "balance": {
        "tx": 0,
        "coin": 0,
        "unconfirmed": 0,
        "confirmed": 0,
        "lockedUnconfirmed": 0,
        "lockedConfirmed": 0
      }
    }
    

    Create account with specified account name.

    HTTP Request

    PUT /wallet/:id/account/:name

    Options object

    Parameter Description
    name
    string
    name to give the account. Option can be account or name
    accountKey
    string
    the extended public key for the account. This is ignored for non watch only wallets. Watch only accounts can't accept private keys for import (or sign transactions)
    type
    string
    what type of wallet to make it ('multisig', 'pubkeyhash')
    m
    int
    for multisig accounts, what to make m in m-of-n
    n
    int
    for multisig accounts, what to make the n in m-of-n

    Wallet - Transactions

    Get Wallet TX Details

    let id, hash
    
    id="primary"
    hash="580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9"
    
    hsw-cli --id=$id tx $hash
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/tx/$hash
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getTX(hash);
      console.log(result);
    })();
    

    Sample Response

    {
      "hash": "580d7de114490f623fe6cc395540be80495e6cb5b0f5a176df89325465d789b9",
      "height": 5,
      "block": "ae127a29c02d7b13ed0a3d57f913392a7f8f82b50295970585cbfad8bc6577b2",
      "time": 1528427154,
      "mtime": 1528427143,
      "date": "2018-06-08T03:05:54Z",
      "mdate": "2018-06-08T03:05:43Z",
      "size": 215,
      "virtualSize": 140,
      "fee": 2800,
      "rate": 20000,
      "confirmations": 1,
      "inputs": [
        {
          "value": 500000000,
          "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/0"
          }
        }
      ],
      "outputs": [
        {
          "value": 100000000,
          "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
          "covenant": {
            "type": 0,
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/1"
          }
        },
        {
          "value": 399997200,
          "address": "rs1q5rjhy20r2hmcxjpc8zv70xkck05pecdew6a798",
          "covenant": {
            "type": 0,
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/1"
          }
        }
      ],
      "tx": "0000000001b724ff8521fd9e7b86afc29070d52e9709927a6c8023360ea86d906f8ea6dcb300000000024126538396dcf0a498bdcebc40f09e17ac7e36f28dead9cecbdcb2fcbb1d64bc241de35734009b4bbf0363578191b56e7bb391b10ff24ccdf9db77e9d291978714012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9ffffffff0200e1f505000000000014f0d9374a2ce80c377187f4bc6c68993c561cb13600001079d717000000000014a0e57229e355f78348383899e79ad8b3e81ce1b9000000000000"
    }
    

    Get wallet transaction details.

    HTTP Request

    GET /wallet/:id/tx/:hash

    Request Parameters

    Parameter Description
    id
    string
    id of wallet that handled the transaction
    hash
    string
    hash of the transaction you're trying to retrieve

    Delete Transaction

    let id, hash, passphrase;
    
    id="primary"
    hash="a97a9993389ae321b263dffb68ba1312ad0655da83aeca75b2372d5abc70544a"
    
    # Not available in CLI
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/tx/$hash \
      -X DELETE
    
     // Not available in javascript wallet client.
    

    Abandon single pending transaction. Confirmed transactions will throw an error. "TX not eligible"

    HTTP Request

    DEL /wallet/:id/tx/:hash

    Parameters Description
    id
    string
    id of wallet where the transaction is that you want to remove
    hash
    string
    hash of transaction you would like to remove.

    Get Wallet TX History

    let id;
    
    id='primary'
    
    hsw-cli --id=$id history
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/tx/history
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    const account = 'default';
    
    (async () => {
      const result = await wallet.getHistory(account);
      console.log(result);
    })();
    

    Sample Response

    [
      {
        "hash": "bc0f93bb233fdf42a25a086ffb744fcb4f64afe6f5d4243da8e3745835fd57b3",
        "height": -1,
        "block": null,
        "time": 0,
        "mtime": 1528468930,
        "date": "1970-01-01T00:00:00Z",
        "mdate": "2018-06-08T14:42:10Z",
        "size": 215,
        "virtualSize": 140,
        "fee": 2800,
        "rate": 20000,
        "confirmations": 0,
        "inputs": [
          {
            "value": 500002800,
            "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
            "path": {
              "name": "default",
              "account": 0,
              "change": false,
              "derivation": "m/0'/0/0"
            }
          }
        ],
        "outputs": [
          {
            "value": 100000000,
            "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
            "covenant": {
              "type": 0,
              "items": []
            },
            "path": {
              "name": "default",
              "account": 0,
              "change": false,
              "derivation": "m/0'/0/1"
            }
          },
          {
            "value": 400000000,
            "address": "rs1q2x2suqr44gjn2plm3f99v2ae6ead3rpat9qtzg",
            "covenant": {
              "type": 0,
              "items": []
            },
            "path": {
              "name": "default",
              "account": 0,
              "change": true,
              "derivation": "m/0'/1/4"
            }
          }
        ],
        "tx": "0000000001758758e600061e62b92831cb40163011e07bd42cac34467f7d34f57c4a921e35000000000241825ebb96f395c02d3cdce7f88594dab343347879dd96af29320bf020f2c5677d4ab7ef79349007d562a4cdafb54d8e1cbd538275deef1b78eb945155315ae648012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9ffffffff0200e1f505000000000014f0d9374a2ce80c377187f4bc6c68993c561cb13600000084d71700000000001451950e0075aa253507fb8a4a562bb9d67ad88c3d000000000000"
      },
     ...
    ]
    

    Get wallet TX history. Returns array of tx details.

    HTTP Request

    GET /wallet/:id/tx/history

    Request Parameters

    Parameter Description
    id
    string
    id of wallet to get history of

    Get Pending Transactions

    let id;
    
    id='primary'
    
    hsw-cli --id=$id pending
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/tx/unconfirmed
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getPending();
      console.log(result);
    })();
    

    Get pending wallet transactions. Returns array of tx details.

    HTTP Request

    GET /wallet/:id/tx/unconfirmed

    Request Parameters

    Parameter Description
    id
    string
    id of wallet to get pending/unconfirmed txs

    Get Range of Transactions

    let id, account, start, end;
    
    id="primary"
    account="default"
    start="1527184612"
    end="1527186612"
    
    # range not available in CLI
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/tx/range?start=$start'&'end=$end
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getRange(account, {start: start, end: end});
      console.log(result);
    })();
    

    Sample Response

    [
      {
        "hash": "bc0f93bb233fdf42a25a086ffb744fcb4f64afe6f5d4243da8e3745835fd57b3",
        "height": -1,
        "block": null,
        "time": 0,
        "mtime": 1528468930,
        "date": "1970-01-01T00:00:00Z",
        "mdate": "2018-06-08T14:42:10Z",
        "size": 215,
        "virtualSize": 140,
        "fee": 2800,
        "rate": 20000,
        "confirmations": 0,
        "inputs": [
          {
            "value": 500002800,
            "address": "rs1q7qumafugfglg268djelwr7ps4l2uh2vsdpfnuc",
            "path": {
              "name": "default",
              "account": 0,
              "change": false,
              "derivation": "m/0'/0/0"
            }
          }
        ],
        "outputs": [
          {
            "value": 100000000,
            "address": "rs1q7rvnwj3vaqxrwuv87j7xc6ye83tpevfkvhzsap",
            "covenant": {
              "type": 0,
              "items": []
            },
            "path": {
              "name": "default",
              "account": 0,
              "change": false,
              "derivation": "m/0'/0/1"
            }
          },
          {
            "value": 400000000,
            "address": "rs1q2x2suqr44gjn2plm3f99v2ae6ead3rpat9qtzg",
            "covenant": {
              "type": 0,
              "items": []
            },
            "path": {
              "name": "default",
              "account": 0,
              "change": true,
              "derivation": "m/0'/1/4"
            }
          }
        ],
        "tx": "0000000001758758e600061e62b92831cb40163011e07bd42cac34467f7d34f57c4a921e35000000000241825ebb96f395c02d3cdce7f88594dab343347879dd96af29320bf020f2c5677d4ab7ef79349007d562a4cdafb54d8e1cbd538275deef1b78eb945155315ae648012102deb957b2e4ebb246e1ecb27a4dc7d142504e70a420adb3cf40f9fb5d3928fdf9ffffffff0200e1f505000000000014f0d9374a2ce80c377187f4bc6c68993c561cb13600000084d71700000000001451950e0075aa253507fb8a4a562bb9d67ad88c3d000000000000"
      }
      ...
    ]
    

    Get range of wallet transactions by timestamp. Returns array of tx details.

    HTTP Request

    GET /wallet/:id/tx/range

    Body Parameters

    Parameter Description
    account
    string
    account to get the tx history from
    start
    int
    start time to get range from
    end
    int
    end time to get range from

    Wallet - Auctions

    Get Wallet Names

    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/name
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getNames();
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "state": "BIDDING",
        "height": 245,
        "renewal": 245,
        "owner": {
          "hash": "0000000000000000000000000000000000000000000000000000000000000000",
          "index": 4294967295
        },
        "value": 0,
        "highest": 0,
        "data": "",
        "transfer": 0,
        "revoked": 0,
        "claimed": 0,
        "renewals": 0,
        "registered": false,
        "expired": false,
        "weak": false,
        "stats": {
          "bidPeriodStart": 251,
          "bidPeriodEnd": 256,
          "blocksUntilReveal": 2,
          "hoursUntilReveal": 0.33
        }
      }
    ]
    

    List the states of all names known to the wallet.

    HTTP Request

    GET /wallet/:id/name

    Parameters Description
    id
    string
    wallet id

    Get Wallet Name

    id='primary'
    name='handshake'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/name/$name
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getName(name);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "handshake",
      "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
      "state": "BIDDING",
      "height": 245,
      "renewal": 245,
      "owner": {
        "hash": "0000000000000000000000000000000000000000000000000000000000000000",
        "index": 4294967295
      },
      "value": 0,
      "highest": 0,
      "data": "",
      "transfer": 0,
      "revoked": 0,
      "claimed": 0,
      "renewals": 0,
      "registered": false,
      "expired": false,
      "weak": false,
      "stats": {
        "bidPeriodStart": 251,
        "bidPeriodEnd": 256,
        "blocksUntilReveal": 2,
        "hoursUntilReveal": 0.33
      }
    }
    

    List the status of a single name known to the wallet.

    HTTP Request

    GET /wallet/:id/name/:name

    Parameters Description
    id
    string
    wallet id
    name
    string
    name

    Get Wallet Auctions

    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/auction
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getAuctions();
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "easyhandshake",
        "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
        "state": "CLOSED",
        "height": 105,
        "renewal": 135,
        "owner": {
          "hash": "b87a69556f924735876acb57c2ef46ff9c5a044ab61e5f0566ecc9357107a67e",
          "index": 0
        },
        "value": 0,
        "highest": 1000000,
        "data": "00060114737076206e6f646520696e2062726f7773657221",
        "transfer": 0,
        "revoked": 0,
        "claimed": 0,
        "renewals": 0,
        "registered": true,
        "expired": false,
        "weak": false,
        "stats": {
          "renewalPeriodStart": 135,
          "renewalPeriodEnd": 5135,
          "blocksUntilExpire": 4881,
          "daysUntilExpire": 33.9
        },
        "bids": [
          {
            "name": "easyhandshake",
            "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
            "prevout": {
              "hash": "0702d5f7cf4afd626189c1f8362676a5e7b7edfa5110d256a57185f32a3d12e1",
              "index": 0
            },
            "value": 1000000,
            "lockup": 2000000,
            "blind": "3d694cb7529caae741b6e70db09a0102c61813420b161cee65fb657e116d1f5b",
            "own": true
          }
        ],
        "reveals": [
          {
            "name": "easyhandshake",
            "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
            "prevout": {
              "hash": "10f18571b6b7af1f256ebe74d5da06d792da91ceb7f3f93302c0d216e1f899b8",
              "index": 0
            },
            "value": 1000000,
            "height": 125,
            "own": true
          }
        ]
      }
    ]
    

    List the states of all auctions known to the wallet.

    HTTP Request

    GET /wallet/:id/auction

    Parameters Description
    id
    string
    wallet id

    Get Wallet Auction by Name

    id='primary'
    name='handshake'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/auction/$name
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getAuctionByName(name);
      console.log(result);
    })();
    

    Sample response:

    {
      "name": "handshake",
      "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
      "state": "CLOSED",
      "height": 105,
      "renewal": 135,
      "owner": {
        "hash": "b87a69556f924735876acb57c2ef46ff9c5a044ab61e5f0566ecc9357107a67e",
        "index": 0
      },
      "value": 0,
      "highest": 1000000,
      "data": "00060114737076206e6f646520696e2062726f7773657221",
      "transfer": 0,
      "revoked": 0,
      "claimed": 0,
      "renewals": 0,
      "registered": true,
      "expired": false,
      "weak": false,
      "stats": {
        "renewalPeriodStart": 135,
        "renewalPeriodEnd": 5135,
        "blocksUntilExpire": 4881,
        "daysUntilExpire": 33.9
      },
      "bids": [
        {
          "name": "handshake",
          "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
          "prevout": {
            "hash": "0702d5f7cf4afd626189c1f8362676a5e7b7edfa5110d256a57185f32a3d12e1",
            "index": 0
          },
          "value": 1000000,
          "lockup": 2000000,
          "blind": "3d694cb7529caae741b6e70db09a0102c61813420b161cee65fb657e116d1f5b",
          "own": true
        }
      ],
      "reveals": [
        {
          "name": "handshake",
          "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
          "prevout": {
            "hash": "10f18571b6b7af1f256ebe74d5da06d792da91ceb7f3f93302c0d216e1f899b8",
            "index": 0
          },
          "value": 1000000,
          "height": 125,
          "own": true
        }
      ]
    }
    

    List the states of all auctions known to the wallet.

    HTTP Request

    GET /wallet/:id/auction/:name

    Parameters Description
    id
    string
    wallet id
    name
    string
    name

    Get Wallet Bids

    id='primary'
    own=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/bid?own=$own
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const options = {own};
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getBids(options);
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "easyhandshake",
        "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
        "prevout": {
          "hash": "0702d5f7cf4afd626189c1f8362676a5e7b7edfa5110d256a57185f32a3d12e1",
          "index": 0
        },
        "value": 1000000,
        "lockup": 2000000,
        "blind": "3d694cb7529caae741b6e70db09a0102c61813420b161cee65fb657e116d1f5b",
        "own": true
      }
    ]
    

    List all bids for all names known to the wallet.

    HTTP Request

    GET /wallet/:id/bid

    Parameters Description
    id
    string
    wallet id
    own
    bool
    whether to only show bids from this wallet

    Get Wallet Bids by Name

    id='primary'
    name='handshake'
    own=false
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/bid/$name?own=$own
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const options = {own};
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getBidsByName(name, options);
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "handshake",
        "nameHash": "7550acc639a10fd7bb2e6e1d183f364127c3adfcb4d171d98b0319f973286324",
        "prevout": {
          "hash": "0702d5f7cf4afd626189c1f8362676a5e7b7edfa5110d256a57185f32a3d12e1",
          "index": 0
        },
        "value": 1000000,
        "lockup": 2000000,
        "blind": "3d694cb7529caae741b6e70db09a0102c61813420b161cee65fb657e116d1f5b",
        "own": true
      },
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "prevout": {
          "hash": "b8ba9dfc78bdf0f0b1bf67abb9244af0b73c58a9c5bb79b98b72d14cf98c5c08",
          "index": 0
        },
        "lockup": 20000000,
        "blind": "47e8cf3dacfe6aeb14187ebd52f25c55c6f63fd24fed666c676c8ada0b132c10",
        "own": false
      }
    ]
    

    List the bids for a specific name known to the wallet.

    HTTP Request

    GET /wallet/:id/bid/:name

    Parameters Description
    id
    string
    wallet id
    name
    string
    name
    own
    bool
    whether to only show bids from this wallet

    Get Wallet Reveals

    id='primary'
    own=false
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/reveal?own=$own
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const options = {own};
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getReveals(options);
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "prevout": {
          "hash": "6b90495db28d71bc96ad6211d87b78ab6a3b548b702a98f3149e41c3a0892140",
          "index": 0
        },
        "value": 1000000,
        "height": 221,
        "own": true
      },
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "prevout": {
          "hash": "d8acd574cba75c32f5e671fad2adf7cc93854303be02212fe8628a727229d610",
          "index": 0
        },
        "value": 10000000,
        "height": 221,
        "own": false
      }
    ]
    

    List all reveals for all names known to the wallet.

    HTTP Request

    GET /wallet/:id/reveal

    Parameters Description
    id
    string
    wallet id
    own
    bool
    whether to only show reveals from this wallet

    Get Wallet Reveals by Name

    id='primary'
    name='handshake'
    own=false
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/reveal/$name?own=$own
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const options = {own};
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getRevealsByName(name, options);
      console.log(result);
    })();
    

    Sample response:

    [
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "prevout": {
          "hash": "6b90495db28d71bc96ad6211d87b78ab6a3b548b702a98f3149e41c3a0892140",
          "index": 0
        },
        "value": 1000000,
        "height": 221,
        "own": true
      },
      {
        "name": "handshake",
        "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6",
        "prevout": {
          "hash": "d8acd574cba75c32f5e671fad2adf7cc93854303be02212fe8628a727229d610",
          "index": 0
        },
        "value": 10000000,
        "height": 221,
        "own": false
      }
    ]
    

    List the reveals for a specific name known to the wallet.

    HTTP Request

    GET /wallet/:id/reveal/:name

    Parameters Description
    id
    string
    wallet id
    name
    string
    name
    own
    bool
    whether to only show reveals from this wallet

    Get Wallet Resource by Name

    id='primary'
    name='handshake'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/resource/$name
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getResource(name);
      console.log(result);
    })();
    

    Sample response:

    {
      "records": [
        {
          "type": "TXT",
          "txt": [
            "A decentralized DNS root zone!"
          ]
        }
      ]
    }
    

    Get the data resource associated with a name.

    HTTP Request

    GET /wallet/:id/resource

    Parameters Description
    id
    string
    wallet id
    name
    string
    name

    Get Nonce for Bid

    id='primary'
    name='handshake'
    bid=2000000
    address='rs1q3qavv25ye6zsntszsj4awvq7gr4akq59k9y8hw'
    
    curl "http://x:api-key@127.0.0.1:14039/wallet/$id/nonce/$name?address=$address&bid=$bid"
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const options = {address, bid};
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.getNonce(name, options);
      console.log(result);
    })();
    

    Sample response:

    {
      "address": "rs1q3qavv25ye6zsntszsj4awvq7gr4akq59k9y8hw",
      "blind": "4c20a52be340636137e703db9031e0d3ab0fbc503c5b97463a814665595ed71f",
      "nonce": "69bbe132244d91b9fd13019f372e7dc79e487c44b126a226b39c8c287c15aff5",
      "bid": 1,
      "name": "handshake",
      "nameHash": "3aa2528576f96bd40fcff0bd6b60c44221d73c43b4e42d4b908ed20a93b8d1b6"
    }
    

    Deterministically generate a nonce to blind a bid.

    Note that since multiple parameters are expected in the URL and therefore a & must be used, the URL is wrapped in double-quotes to prevent the shell from starting the process in the background.

    HTTP Request

    GET /wallet/:id/nonce/:name

    Parameters Description
    id
    string
    wallet id
    name
    string
    name
    bid
    float
    value of bid to blind
    address
    string
    address controlling bid

    Create Auction Transactions

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcastBid=true
    sign=true
    bid=1234000
    lockup=4567000
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/auction \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcastBid":'$broadcastBid',
        "sign":'$sign',
        "bid":'$bid',
        "lockup":'$lockup'
      }'
    
    hsw-cli mkauctiontxs $name $bid $lockup $broadcastBid
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {passphrase, name, broadcastBid, sign, bid, lockup};
    
    (async () => {
      const result = await wallet.createAuctionTxs(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "bid": {
        "hash": "10c407bb1e6a0d0dcbab0ddf49aa08294ad0bf3bd6152b81cdfc62907314d0a0",
        "witnessHash": "ad77ea70597bd73baedaf71a6c125fecc502ea3da0935e3d92190ff9da3d7dc8",
        "mtime": 1651427559,
        "version": 0,
        "inputs": [
          {
            "prevout": {
              "hash": "f3e2e4063e8d043257445d876fe98d85c5a0ce00644f30b352fb794b37cfd6da",
              "index": 0
            },
            "witness": [
              "8a5cbb894354b8a360ce10c7b1f34758140d5f2058b840ec5213febba31b561168b2fb111017f707c61d6c09dfca434aca911fa565f8ef663a6dc3a9ab0d970901",
              "02814c58de377368bea87237f46ac724bb11d4c77586e25c63a6c6583fb643b69b"
            ],
            "sequence": 4294967295,
            "address": "rs1qzjjz55uxvqaj0t3ydl3t9z0q785kxghj0s4q48"
          }
        ],
        "outputs": [
          {
            "value": 4567000,
            "address": "rs1qvh3pgxwt8y6pnt9rk5rpyunf6c4v9x4xpg8d73",
            "covenant": {
              "type": 3,
              "action": "BID",
              "items": [
                "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
                "5b000000",
                "6272656164",
                "ebaa2b017f895b43065f418b051dc9d93999fd97a6a6af1182f85421ed228447"
              ]
            }
          },
          {
            "value": 1995432340,
            "address": "rs1q25jevu4txctxljch3gcz2mcnnls6cm06z036yk",
            "covenant": {
              "type": 0,
              "action": "NONE",
              "items": []
            }
          }
        ],
        "locktime": 0,
        "hex": "0000000001f3e2e4063e8d043257445d876fe98d85c5a0ce00644f30b352fb794b37cfd6da00000000ffffffff02d8af450000000000001465e21419cb393419aca3b506127269d62ac29aa6030420e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a045b00000005627265616420ebaa2b017f895b43065f418b051dc9d93999fd97a6a6af1182f85421ed22844794e1ef7600000000001455259672ab36166fcb178a30256f139fe1ac6dfa00000000000002418a5cbb894354b8a360ce10c7b1f34758140d5f2058b840ec5213febba31b561168b2fb111017f707c61d6c09dfca434aca911fa565f8ef663a6dc3a9ab0d9709012102814c58de377368bea87237f46ac724bb11d4c77586e25c63a6c6583fb643b69b"
      },
      "reveal": {
        "hash": "4b28461244fd97386e9105bcfaa0ce5f6446b2dbed5bdd34e5d5d36f4cacc3bc",
        "witnessHash": "5bc63fa4a0e5d64734967ef27c1f42df505a0241347bfaff0117c4c82ffbb6cd",
        "fee": 4220,
        "rate": 20000,
        "mtime": 1651427559,
        "version": 0,
        "inputs": [
          {
            "prevout": {
              "hash": "10c407bb1e6a0d0dcbab0ddf49aa08294ad0bf3bd6152b81cdfc62907314d0a0",
              "index": 0
            },
            "witness": [
              "f6ed9f4eea4c7ebc820db84f73879bf549463edcb9a11ef86cce55c32210cba715e7c8895851642c8b236f28052b4da29f6c9b419b43da04929a4cc79ab3c55501",
              "0254c0a8397058f934979de1147ef5ada72af93619b9979fcc88a7b4bdec378f2c"
            ],
            "sequence": 4294967295,
            "coin": {
              "version": 0,
              "height": -1,
              "value": 4567000,
              "address": "rs1qvh3pgxwt8y6pnt9rk5rpyunf6c4v9x4xpg8d73",
              "covenant": {
                "type": 3,
                "action": "BID",
                "items": [
                  "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
                  "5b000000",
                  "6272656164",
                  "ebaa2b017f895b43065f418b051dc9d93999fd97a6a6af1182f85421ed228447"
                ]
              },
              "coinbase": false
            }
          }
        ],
        "outputs": [
          {
            "value": 1234000,
            "address": "rs1qvh3pgxwt8y6pnt9rk5rpyunf6c4v9x4xpg8d73",
            "covenant": {
              "type": 4,
              "action": "REVEAL",
              "items": [
                "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
                "5b000000",
                "d5c90238841f4cd57e0874c82920670b2c188cff5255902253c7c83895beae50"
              ]
            }
          },
          {
            "value": 3328780,
            "address": "rs1q25jevu4txctxljch3gcz2mcnnls6cm06z036yk",
            "covenant": {
              "type": 0,
              "action": "NONE",
              "items": []
            }
          }
        ],
        "locktime": 0,
        "hex": "000000000110c407bb1e6a0d0dcbab0ddf49aa08294ad0bf3bd6152b81cdfc62907314d0a000000000ffffffff0250d4120000000000001465e21419cb393419aca3b506127269d62ac29aa6040320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a045b00000020d5c90238841f4cd57e0874c82920670b2c188cff5255902253c7c83895beae500ccb320000000000001455259672ab36166fcb178a30256f139fe1ac6dfa0000000000000241f6ed9f4eea4c7ebc820db84f73879bf549463edcb9a11ef86cce55c32210cba715e7c8895851642c8b236f28052b4da29f6c9b419b43da04929a4cc79ab3c55501210254c0a8397058f934979de1147ef5ada72af93619b9979fcc88a7b4bdec378f2c"
      }
    }
    

    Create BID and REVEAL transactions in advance. Optionally sign and broadcast the bid.

    HTTP Request

    POST /wallet/:id/auction

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to BID / REVEAL
    sign
    bool
    whether to sign the transaction
    broadcastBid
    bool
    whether to broadcast the bid tx (must sign if true)
    bid
    int
    value (in dollarydoos) to bid for name
    lockup
    int
    value (in dollarydoos) to actually send in the transaction,
    blinding the actual bid value

    Send OPEN

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/open \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign'
      }'
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {passphrase, name, broadcast, sign};
    
    (async () => {
      const result = await wallet.createOpen(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "6901ec5576eb618e012058e62b34a0883c3832e1324ac9942bb5852e8a2e4a1f",
      "witnessHash": "2391068a2a3082468e77934973bdb9f18fab33437074428946d78443a2519d84",
      "mtime": 1580940345,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "a94415c789656239cf7fe2f642215c2d51814f09dad5486058bbb09a0be2084f",
            "index": 1
          },
          "witness": [
            "87ac7546878c9cbd4258d024698020d37b642150fec20c8950a1e26cfa06f0e70d4c882f2de05129c6c1c601ae5a89bd6874bea03dfeca8e89435b0fc44f151e01",
            "03c66829e94b4644a3d5481e192af62e5b0e0eb91cd78d45594c9c59e1a5b16360"
          ],
          "sequence": 4294967295,
          "address": "rs1q9k8ktktnrfsr8p677gfxgkf5g45x7vzez7egqv"
        }
      ],
      "outputs": [
        {
          "value": 0,
          "address": "rs1qx2wrlhtwg0exsa4sm3u7d7pz7ah3yld374jwd5",
          "covenant": {
            "type": 2,
            "action": "OPEN",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "00000000",
              "6272656164"
            ]
          }
        },
        {
          "value": 2000010260,
          "address": "rs1q30pw3zmgkktlr58fsycyuta3szgz0ldwnrg2wf",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001a94415c789656239cf7fe2f642215c2d51814f09dad5486058bbb09a0be2084f01000000ffffffff0200000000000000000014329c3fdd6e43f26876b0dc79e6f822f76f127db1020320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a040000000005627265616414bc35770000000000148bc2e88b68b597f1d0e981304e2fb1809027fdae000000000000024187ac7546878c9cbd4258d024698020d37b642150fec20c8950a1e26cfa06f0e70d4c882f2de05129c6c1c601ae5a89bd6874bea03dfeca8e89435b0fc44f151e012103c66829e94b4644a3d5481e192af62e5b0e0eb91cd78d45594c9c59e1a5b16360"
    }
    

    Create, sign, and send a name OPEN.

    HTTP Request

    POST /wallet/:id/open

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to OPEN
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    Send BID

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    bid=1234000
    lockup=4567000
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/bid \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign',
        "bid":'$bid',
        "lockup":'$lockup'
      }'
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {passphrase, name, broadcast, sign, bid, lockup};
    
    (async () => {
      const result = await wallet.createBid(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "5f86ba9b968a872b079947314c789735c2ad52eefc54e726d7e9e6b7fdf9a566",
      "witnessHash": "9e39c91a3dd9c0eaa352ed277d42f4f53920c4f89dce671389c0683586b70c2f",
      "mtime": 1580940435,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "d69f3282a74ef79755a22e01fed308ebad77bf62a3a55434d22761a010ffb04f",
            "index": 1
          },
          "witness": [
            "872456ed9c7da4105840b626690a793be881506866b2dca894b1a165dd528cc608cd03eee1cd46c3ce61accfa2da0cf31bfa3734f54ef693aaa8e480dc25277501",
            "03c25f5b28395ef101a38da38094e29bf57c3c618ffaef4e1c2a532efca9798722"
          ],
          "sequence": 4294967295,
          "address": "rs1qgw8df4vh4wg9w0le3xe7dv4ypq75h5fa0qst5v"
        }
      ],
      "outputs": [
        {
          "value": 4567000,
          "address": "rs1qrx9matjmly5l6cnz4ed7ujxcy9tf4cfcl0szeg",
          "covenant": {
            "type": 3,
            "action": "BID",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "6272656164",
              "135333369e5d91671cafe97904663692546d10b8ded8cd7662480074fd2f1ab0"
            ]
          }
        },
        {
          "value": 1995440140,
          "address": "rs1qn4r8xq7pfyhmf0z2rja38kgrpmavdufd03jfn5",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001d69f3282a74ef79755a22e01fed308ebad77bf62a3a55434d22761a010ffb04f01000000ffffffff02d8af4500000000000014198bbeae5bf929fd6262ae5bee48d821569ae138030420e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e304000005627265616420135333369e5d91671cafe97904663692546d10b8ded8cd7662480074fd2f1ab00c00f0760000000000149d467303c1492fb4bc4a1cbb13d9030efac6f12d0000000000000241872456ed9c7da4105840b626690a793be881506866b2dca894b1a165dd528cc608cd03eee1cd46c3ce61accfa2da0cf31bfa3734f54ef693aaa8e480dc252775012103c25f5b28395ef101a38da38094e29bf57c3c618ffaef4e1c2a532efca9798722"
    }
    

    Create, sign, and send a name BID.

    HTTP Request

    POST /wallet/:id/bid

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to BID on
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)
    bid
    int
    value (in dollarydoos) to bid for name
    lockup
    int
    value (in dollarydoos) to actually send in the transaction,
    blinding the actual bid value

    Send REVEAL

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/reveal \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign'
      }'
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {passphrase, name, broadcast, sign};
    
    (async () => {
      const result = await wallet.createReveal(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "f2a58686813a66621f8a814c9cabf59a76342914ff56a0f44260a44ce095eadd",
      "height": -1,
      "block": null,
      "time": 0,
      "mtime": 1580941108,
      "date": "1970-01-01T00:00:00Z",
      "mdate": "2020-02-05T22:18:28Z",
      "size": 530,
      "virtualSize": 379,
      "fee": 7600,
      "rate": 20052,
      "confirmations": 0,
      "inputs": [
        {
          "value": 4567000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/10"
          }
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 4,
            "action": "REVEAL",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "5254fd6ae23148c8efbb4cb013c8d1c1048e412165632861f47535060c174736"
            ]
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/10"
          }
        },
        {
          "value": 6658400,
          "address": "rs1qmchpnu3ktztqhlkk9ydkehd6qldemd9prvgvrp",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/10"
          }
        }
      ],
      "tx": "00000000021d9b7b7d829fa307f602d0c4057a6d733ccfca06c622ecf2456149c5c3da915600000000ffffffff5f86ba9b968a872b079947314c789735c2ad52eefc54e726d7e9e6b7fdf9a56600000000ffffffff0350d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004040320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000205254fd6ae23148c8efbb4cb013c8d1c1048e412165632861f47535060c17473650d41200000000000014198bbeae5bf929fd6262ae5bee48d821569ae138040320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e304000020707bc55fdeb283cdc2114d3de30ed8bf7d4946eb589cf2239160566fb3683d8a60996500000000000014de2e19f23658960bfed6291b6cddba07db9db4a10000000000000241867a6e0d151fdc689eae00932b101af381ef99a19fc3535e740e6f3baca63b5b45db61413c7130b45ef546beda84f46f8adda8944d6dbae251c82062e17333da0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88024181532acdd7b591eed4e62c6123d14cfefbb11723c855728d3012286210536bb4192a58622dbd66cd3d876f14a906d2a04d1053247340b9985c2f0fa2c85004a7012102fcd5c0914405f04b12c5936c50642fb2cb10a6262dd2dd8ca243e26cbc984ead"
    }
    

    Create, sign, and send a name REVEAL. If multiple bids were placed on a name, all bids will be revealed by this transaction. If no value is passed in for name, all reveals for all names in the wallet will be sent.

    HTTP Request

    POST /wallet/:id/reveal

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to REVEAL bids for (or null for all names)
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    Send REDEEM

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/redeem \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign'
      }'
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const options = {passphrase, name, broadcast, sign};
    
    (async () => {
      const result = await wallet.createRedeem(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "9cc3c9f665ad79563667f74864bcfdfe280f9f3a2df4ee02d427b8dea34fe388",
      "height": -1,
      "block": null,
      "time": 0,
      "mtime": 1580942277,
      "date": "1970-01-01T00:00:00Z",
      "mdate": "2020-02-05T22:37:57Z",
      "size": 394,
      "virtualSize": 243,
      "fee": 4880,
      "rate": 20082,
      "confirmations": 0,
      "inputs": [
        {
          "value": 1234000,
          "address": "rs1qrx9matjmly5l6cnz4ed7ujxcy9tf4cfcl0szeg",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/9"
          }
        },
        {
          "value": 2000010260,
          "address": "rs1q30pw3zmgkktlr58fsycyuta3szgz0ldwnrg2wf",
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/7"
          }
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrx9matjmly5l6cnz4ed7ujxcy9tf4cfcl0szeg",
          "covenant": {
            "type": 5,
            "action": "REDEEM",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000"
            ]
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/9"
          }
        },
        {
          "value": 2000005380,
          "address": "rs1qtw3nhk8t5waujzwm5vh4ylkp0ytjamnx0efu8s",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/11"
          }
        }
      ],
      "tx": "0000000002f2a58686813a66621f8a814c9cabf59a76342914ff56a0f44260a44ce095eadd01000000ffffffff6901ec5576eb618e012058e62b34a0883c3832e1324ac9942bb5852e8a2e4a1f01000000ffffffff0250d41200000000000014198bbeae5bf929fd6262ae5bee48d821569ae138050220e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e304000004a935770000000000145ba33bd8eba3bbc909dba32f527ec179172eee660000000000000241bd37183812b9ae232e2b1400eea3b36afa420c8eb1c2a7c54402f88b61fb2680733da29697a0713bf7a3cc2f5176ed2d6f957fa8988d6c952d32443cf49a8ce9012102fcd5c0914405f04b12c5936c50642fb2cb10a6262dd2dd8ca243e26cbc984ead0241a33f7b362d9c0fb94c75c37d795ab6ab6e2566288cb278a1cb275d35f9e454f351c805c2c74cc9ff278694169a8b818d41d04488daf534f4223a803fc13eac0e012102b87379bf21a7a8b19edcbd4826406e7880e7f6352bd9068de57c8f7d7d2a7703"
    }
    

    Create, sign, and send a REDEEM. This transaction sweeps the value from losing bids back into the wallet. If multiple bids (and reveals) were placed on a name, all losing bids will be redeemed by this transaction. If no value is passed in for name, all qualifying bids are redeemed.

    HTTP Request

    POST /wallet/:id/redeem

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to REDEEM bids for (or null for all names)
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    Send UPDATE

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    type='TXT'
    key='txt'
    value='Bread is a delicious food.'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/update \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign',
        "data": {"records": [ {"type": "'$type'", "'$key'": ["'"$value"'"]} ]}
      }'
    
    > no CLI command available
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const walletOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    const data = {records: []};
    const record = {type};
    record[key] = [value];
    data.records.push(record);
    
    const options = {passphrase, name, broadcast, sign, data};
    
    (async () => {
      const result = await wallet.createUpdate(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "31da65987a9b1573e4d051a07ec9e3d3845c649cba64c5789566369ba6ac9cbc",
      "witnessHash": "87d283aa0a863ca3f0d913f4b11281d8315e166c73a5cb46c19f94d721aefc43",
      "mtime": 1580943569,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "f2a58686813a66621f8a814c9cabf59a76342914ff56a0f44260a44ce095eadd",
            "index": 0
          },
          "witness": [
            "aab532bcd307bea84d7abb7926f598a9d63ac503cac8e416c7683ef71032e932133735464a92f7dc1f697a9a40b0f4cb13c4a5db0114b6a961de0cf924dac2a401",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        },
        {
          "prevout": {
            "hash": "ed85504acb5e5005fe07567d17a5d2bd8c30a235ad15eb114f64e75fff172bbb",
            "index": 0
          },
          "witness": [
            "7948b87e5e42a4276bfbc548b0a23e3a01388a6158bfd872fc413fb1a8313ca023dcdcd6f28e2d97b542fe28c303dc2f861b1d4c8e41b5d99973e02a22ff1fc701",
            "02737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
          ],
          "sequence": 4294967295,
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 6,
            "action": "REGISTER",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "0006011a427265616420697320612064656c6963696f757320666f6f642e",
              "71e4ac7bd9a9eebe6aaaa99e8e08d10c8f2c184774feb844b6a180f8f7bba7ae"
            ]
          }
        },
        {
          "value": 2000002520,
          "address": "rs1qzgvngp7jtluup39rc2atfp6q3g2vuklj6qfrtq",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002f2a58686813a66621f8a814c9cabf59a76342914ff56a0f44260a44ce095eadd00000000ffffffffed85504acb5e5005fe07567d17a5d2bd8c30a235ad15eb114f64e75fff172bbb00000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004060420e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e30400001e0006011a427265616420697320612064656c6963696f757320666f6f642e2071e4ac7bd9a9eebe6aaaa99e8e08d10c8f2c184774feb844b6a180f8f7bba7aed89d357700000000001412193407d25ff9c0c4a3c2bab487408a14ce5bf20000000000000241aab532bcd307bea84d7abb7926f598a9d63ac503cac8e416c7683ef71032e932133735464a92f7dc1f697a9a40b0f4cb13c4a5db0114b6a961de0cf924dac2a40121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c8802417948b87e5e42a4276bfbc548b0a23e3a01388a6158bfd872fc413fb1a8313ca023dcdcd6f28e2d97b542fe28c303dc2f861b1d4c8e41b5d99973e02a22ff1fc7012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create, sign, and send an UPDATE. This transaction updates the resource data associated with a given name.

    HTTP Request

    POST /wallet/:id/update

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name to UPDATE
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)
    data
    object
    JSON object containing an array of DNS records (see next section)

    Resource Object

    The resource object must contain one property records, which is an array of record objects. Each record object must have a property type which defines the DNS record type. Depending on the type, the record object may have various additional properties.

    // Example of a valid resource object
    // containing examples of all available record types:
    
    {
      records: [
        {
          type: 'DS',
          keyTag: 57355,
          algorithm: 8, // RSASHA256
          digestType: 2, // SHA256
          digest:
            '95a57c3bab7849dbcddf7c72ada71a88146b141110318ca5be672057e865c3e2'
        },
        {
          type: 'NS',
          ns: 'ns1.hns.'
        },
        {
          type: 'GLUE4',
          ns: 'ns2.hns.',
          address: '127.0.0.1'
        },
        {
          type: 'GLUE6',
          ns: 'ns2.hns.',
          address: '::1'
        },
        {
          type: 'SYNTH4',
          address: '127.0.0.2'
        },
        {
          type: 'SYNTH6',
          address: '::2'
        },
        {
          type: 'TXT',
          txt: ['hello world']
        }
      ]
    }
    

    Send RENEW

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/renewal \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'