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":'$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};
    
    (async () => {
      const result = await wallet.createRenewal(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "1e198eea5803646f58ccc74f2cd5a69942907f18d1c4fa6d5069920eda1634a4",
      "witnessHash": "78ca00baa443912e03aa5b32fa59b03b80e34d1aff94602b211b9fa58e03e4d2",
      "mtime": 1580995594,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "78ff6f7d974006bb6ab02631b09bd4896a3ebf000d23696562e7f07445ac7c0e",
            "index": 0
          },
          "witness": [
            "b599baa320a7118e600a26d26a1c89dcb8742b22a31953e57c1452914ccbdda23d727e894b4abfb250f1826f4e5c0393176c55cc521ffeae0b02477e84fbd58601",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        },
        {
          "prevout": {
            "hash": "9cc3c9f665ad79563667f74864bcfdfe280f9f3a2df4ee02d427b8dea34fe388",
            "index": 1
          },
          "witness": [
            "8404a9d05c8baeb00a98f43b3aa332cc2be733ec53f226e2778f685b3b99b4f723877957e9db731ff86c2c0efe49edd85ba8c299e17005079612a0c4d6319f9901",
            "02f231291526e240e57ee2552cea5b8f7ac78f49cabbadb859930f9c4fb4316009"
          ],
          "sequence": 4294967295,
          "address": "rs1qtw3nhk8t5waujzwm5vh4ylkp0ytjamnx0efu8s"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 8,
            "action": "RENEW",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "31008b4f5f79c4fa4de0766d9c5be5a49e0b39e18dc5a8701325e4b66611e07c"
            ]
          }
        },
        {
          "value": 1999999840,
          "address": "rs1qfepqfvsshhlq0555lsxvu6xetzydzaxxs6cvhe",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000278ff6f7d974006bb6ab02631b09bd4896a3ebf000d23696562e7f07445ac7c0e00000000ffffffff9cc3c9f665ad79563667f74864bcfdfe280f9f3a2df4ee02d427b8dea34fe38801000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004080320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e30400002031008b4f5f79c4fa4de0766d9c5be5a49e0b39e18dc5a8701325e4b66611e07c609335770000000000144e4204b210bdfe07d294fc0cce68d95888d174c60000000000000241b599baa320a7118e600a26d26a1c89dcb8742b22a31953e57c1452914ccbdda23d727e894b4abfb250f1826f4e5c0393176c55cc521ffeae0b02477e84fbd5860121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c8802418404a9d05c8baeb00a98f43b3aa332cc2be733ec53f226e2778f685b3b99b4f723877957e9db731ff86c2c0efe49edd85ba8c299e17005079612a0c4d6319f99012102f231291526e240e57ee2552cea5b8f7ac78f49cabbadb859930f9c4fb4316009"
    }
    

    Create, sign, and send a RENEW.

    HTTP Request

    POST /wallet/:id/renew

    Post Parameters

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

    Send TRANSFER

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    address='rs1qe4tnr7zhx95uvfw220k7eh9ke0rtducpp3hgjc'
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/transfer \
      -X POST \
      --data '{
        "passphrase":"'$passphrase'",
        "name":"'$name'",
        "broadcast":'$broadcast',
        "sign":'$sign',
        "address":"'$address'"
      }'
    
    > 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, address};
    
    (async () => {
      const result = await wallet.createTransfer(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "b5d3c0caaa14913c15cf219095c23feb0b6b7fa2327428d377da2bb21044045e",
      "witnessHash": "6d88b3910c047ca69d0a8a833ba17888dc31f8111d5da59e9db5978499607e6e",
      "mtime": 1580995968,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "0b90f30f05e1073e5a34426eea244e66eaa0878b3d065b45cad9a5247dd36425",
            "index": 0
          },
          "witness": [
            "ea9ca5c0d619fa548f51384c443d01e34099ba2d590a2f5b9b334d35d1c1fc3e6e739b4f9a9c415c43cd70aa567d4cd820a7a91d0f76164838a9e0967ffdabad01",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        },
        {
          "prevout": {
            "hash": "29d8311eebb36fcb64cc2c5094120ba966feb494b277763abdba0d6766668166",
            "index": 0
          },
          "witness": [
            "57c79c840a1a62f74129a18da6d648999c61c2a270a660851815d5bc48729380612a08d7a8a3f7608f351a2a7a0dfa858cd2f951f6868b902617dd2d61ba8e9801",
            "02737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
          ],
          "sequence": 4294967295,
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 9,
            "action": "TRANSFER",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "00",
              "cd5731f8573169c625ca53edecdcb6cbc6b6f301"
            ]
          }
        },
        {
          "value": 2000000200,
          "address": "rs1q5w4jvv9rkv3w2tdvegzmdv3a7gzucefc45xqsw",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000020b90f30f05e1073e5a34426eea244e66eaa0878b3d065b45cad9a5247dd3642500000000ffffffff29d8311eebb36fcb64cc2c5094120ba966feb494b277763abdba0d676666816600000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004090420e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000010014cd5731f8573169c625ca53edecdcb6cbc6b6f301c8943577000000000014a3ab2630a3b322e52dacca05b6b23df205cc65380000000000000241ea9ca5c0d619fa548f51384c443d01e34099ba2d590a2f5b9b334d35d1c1fc3e6e739b4f9a9c415c43cd70aa567d4cd820a7a91d0f76164838a9e0967ffdabad0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88024157c79c840a1a62f74129a18da6d648999c61c2a270a660851815d5bc48729380612a08d7a8a3f7608f351a2a7a0dfa858cd2f951f6868b902617dd2d61ba8e98012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create, sign, and send a TRANSFER.

    HTTP Request

    POST /wallet/:id/transfer

    Post Parameters

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

    Cancel TRANSFER

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/cancel \
      -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};
    
    (async () => {
      const result = await wallet.createCancel(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "c67f89be56413deef37c07a38450e3bb0098f179abc30281bb55e5656039a64e",
      "witnessHash": "b4feded954a6371bb6e7e6699f842643e2387403612ebe1690c54d25e89532ec",
      "mtime": 1580996955,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "b5d3c0caaa14913c15cf219095c23feb0b6b7fa2327428d377da2bb21044045e",
            "index": 0
          },
          "witness": [
            "59698c78326150a7ba75e769d6c127ade0849127d89730c48c50d44684f4553a43f938b5dc70ee275f9d9290ef6225468c0ab5fb0bcb6609257cec0c0053bbcb01",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        },
        {
          "prevout": {
            "hash": "76eb16e8b65826f0d411c3b78a5c2c349fde4d363b9818232eb0be48e3d108c3",
            "index": 0
          },
          "witness": [
            "51f2b83295fafbbdaf2b239cf347dae2182f318b8ddef6e075497cd9e50a486d465ddd934acd7630d93568db0602014bc6304f0f62bc9f51e293d9cf0b4cea4601",
            "02737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
          ],
          "sequence": 4294967295,
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 7,
            "action": "UPDATE",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              ""
            ]
          }
        },
        {
          "value": 2000000440,
          "address": "rs1qp7ru55hjw96llagrhcjvznurra4tw60ucg409y",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002b5d3c0caaa14913c15cf219095c23feb0b6b7fa2327428d377da2bb21044045e00000000ffffffff76eb16e8b65826f0d411c3b78a5c2c349fde4d363b9818232eb0be48e3d108c300000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004070320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e304000000b89535770000000000140f87ca52f27175fff503be24c14f831f6ab769fc000000000000024159698c78326150a7ba75e769d6c127ade0849127d89730c48c50d44684f4553a43f938b5dc70ee275f9d9290ef6225468c0ab5fb0bcb6609257cec0c0053bbcb0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88024151f2b83295fafbbdaf2b239cf347dae2182f318b8ddef6e075497cd9e50a486d465ddd934acd7630d93568db0602014bc6304f0f62bc9f51e293d9cf0b4cea46012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create, sign, and send a transaction that cancels a TRANSFER.

    This transaction is not a unique covenant type, but spends from a TRANSFER to an UPDATE covenant (with an empty resource object) in order to cancel a transfer already in progress.

    HTTP Request

    POST /wallet/:id/cancel

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name in transferred state to cancel transfer for
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    Send FINALIZE

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/finalize \
      -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};
    
    (async () => {
      const result = await wallet.createFinalize(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "164e610fc166fc26ac426c54924fc0b6b25e74523f57bec3f064f23b36e3e4c9",
      "witnessHash": "df5c9c4a7f4f1f02df1d28ab5a6040bdb13161bb674f14eeaa790080e265fb92",
      "mtime": 1580997210,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "3f650357a4de12f4d6b764f13ccfd473ab56d4390b6afb71941a429dc4b8cfc4",
            "index": 0
          },
          "witness": [
            "183b5de76722cf361c3cb1b509f537b9fafdab25d724e1d8f37db75c77684496208cbaca9ac59362ab70ef16d483f7371a28a231272c8e481f1af99fe931e48a01",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        },
        {
          "prevout": {
            "hash": "de7a5680851d3b3bb4509d2559ebd1d61f61e0ca6eaae82225c4c5c4b8e89d1a",
            "index": 0
          },
          "witness": [
            "db8152812f0b5db8c94663020019806c6b441a0ff8d5ab9c01a1aca2ac4a98a70a90a6fff5ccda93fe80c39a6dd04c7119635b908ccefcd91cb0d5e18af97a7b01",
            "02737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
          ],
          "sequence": 4294967295,
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qe4tnr7zhx95uvfw220k7eh9ke0rtducpp3hgjc",
          "covenant": {
            "type": 10,
            "action": "FINALIZE",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "6272656164",
              "00",
              "00000000",
              "02000000",
              "4942bbed4ebc9baf39e5a636884ac0d08b72ce5ae301d825726d210d24324fe8"
            ]
          }
        },
        {
          "value": 1999999440,
          "address": "rs1qrayzddcwjeqs93ejpxdrq5uxn5yxp68rp0fcxq",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000023f650357a4de12f4d6b764f13ccfd473ab56d4390b6afb71941a429dc4b8cfc400000000ffffffffde7a5680851d3b3bb4509d2559ebd1d61f61e0ca6eaae82225c4c5c4b8e89d1a00000000ffffffff0250d41200000000000014cd5731f8573169c625ca53edecdcb6cbc6b6f3010a0720e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000056272656164010004000000000402000000204942bbed4ebc9baf39e5a636884ac0d08b72ce5ae301d825726d210d24324fe8d09135770000000000141f4826b70e964102c732099a3053869d0860e8e30000000000000241183b5de76722cf361c3cb1b509f537b9fafdab25d724e1d8f37db75c77684496208cbaca9ac59362ab70ef16d483f7371a28a231272c8e481f1af99fe931e48a0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c880241db8152812f0b5db8c94663020019806c6b441a0ff8d5ab9c01a1aca2ac4a98a70a90a6fff5ccda93fe80c39a6dd04c7119635b908ccefcd91cb0d5e18af97a7b012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create, sign, and send a FINALIZE.

    HTTP Request

    POST /wallet/:id/finalize

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name in transferred state to finalize transfer for
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    Send REVOKE

    id='primary'
    name='bread'
    passphrase='secret123'
    broadcast=true
    sign=true
    
    curl http://x:api-key@127.0.0.1:14039/wallet/$id/revoke \
      -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};
    
    (async () => {
      const result = await wallet.createRevoke(options);
      console.log(result);
    })();
    

    Sample response:

    {
      "hash": "6785ee323e4619b29bcdc7f321dd428f4023ebabe81524e014b7d9c6b72c93cc",
      "witnessHash": "88bf88f2bcfbb4769b3172924641ef5104fdc5ac5eacb7a82efa47a4b9cda150",
      "mtime": 1580997666,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "8a8f44c1984ad59e5d69f8bab69abb048940ac9afcb6b69f5db7fa26b963383b",
            "index": 0
          },
          "witness": [
            "75b04e8eb6b9a8f8accbb0c4c4e7615bc9482b4a9d32cb280c05d6aae0cd1d9a4dbdd03a68b1e4599a99223067a2071fb772c7a5df7a284d614c6420adc863a601",
            "0340b9a23ad22b1031aebafbcde816f385f8ce37d4364b22415ea5e74d305a1752"
          ],
          "sequence": 4294967295,
          "address": "rs1qe4tnr7zhx95uvfw220k7eh9ke0rtducpp3hgjc"
        },
        {
          "prevout": {
            "hash": "7f468990f5cc5c63e88a1ab635e2534f2d731e34caee0a6a88d349251d8b292d",
            "index": 0
          },
          "witness": [
            "bf03452993be0678d8a25f87ea261a45a6237665c89dac89dc8a41cb7470fc1735d4d1336c880786a4b7b8dd3ae865add239f244d11c2a5a633131b0d267c5e201",
            "02737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
          ],
          "sequence": 4294967295,
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qe4tnr7zhx95uvfw220k7eh9ke0rtducpp3hgjc",
          "covenant": {
            "type": 11,
            "action": "REVOKE",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000"
            ]
          }
        },
        {
          "value": 2000000460,
          "address": "rs1q8utpm2zqajrwcaju0ldxjwwaad6cu8awkjevap",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000028a8f44c1984ad59e5d69f8bab69abb048940ac9afcb6b69f5db7fa26b963383b00000000ffffffff7f468990f5cc5c63e88a1ab635e2534f2d731e34caee0a6a88d349251d8b292d00000000ffffffff0250d41200000000000014cd5731f8573169c625ca53edecdcb6cbc6b6f3010b0220e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000cc9535770000000000143f161da840ec86ec765c7fda6939ddeb758e1fae000000000000024175b04e8eb6b9a8f8accbb0c4c4e7615bc9482b4a9d32cb280c05d6aae0cd1d9a4dbdd03a68b1e4599a99223067a2071fb772c7a5df7a284d614c6420adc863a601210340b9a23ad22b1031aebafbcde816f385f8ce37d4364b22415ea5e74d305a17520241bf03452993be0678d8a25f87ea261a45a6237665c89dac89dc8a41cb7470fc1735d4d1336c880786a4b7b8dd3ae865add239f244d11c2a5a633131b0d267c5e2012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create, sign, and send a REVOKE.

    This method is a fail-safe for name owners whose keys are compromised and lose control of their name. Before the transfer is finalized, a REVOKE can be sent that not only cancels the transfer, but burns the name preventing any further updates or transfers. The name can be reopened with a new auction after a set time.

    HTTP Request

    POST /wallet/:id/revoke

    Post Parameters

    Parameter Description
    id
    string
    wallet id
    passphrase
    string
    passphrase to unlock the wallet
    name
    string
    name in transferred state to revoke transfer for
    sign
    bool
    whether to sign the transaction
    broadcast
    bool
    whether to broadcast the transaction (must sign if true)

    RPC Calls - Wallet Auctions

    getnames (hsw)

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

    getnames returns JSON structured like this:

    [
      {
        "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": "trees",
        "nameHash": "92ec68524dbcc44bc3ff4847ed45e3a86789009d862499ce558c793498413cec",
        "state": "CLOSED",
        "height": 67,
        "renewal": 276,
        "owner": {
          "hash": "5d04759a92c5d3bd4ef6856ebcde45cd5ce4e8563a6377d9edac5161014940c9",
          "index": 0
        },
        "value": 5000000,
        "highest": 20000000,
        "data": "000a8c000906036e7331076578616d706c6503636f6d00010203040000000000000000000000000000000000",
        "transfer": 0,
        "revoked": 0,
        "claimed": false,
        "weak": false,
        "stats": {
          "renewalPeriodStart": 276,
          "renewalPeriodEnd": 10276,
          "blocksUntilExpire": 9795,
          "daysUntilExpire": 34.01
        }
      },
      {
        "name": "tba",
        "nameHash": "a73f93785b1fc9b1973579cf2b3f1a08a832d462a5e8ad6e5ec75883ccd90f50",
        "state": "CLOSED",
        "height": 434,
        "renewal": 477,
        "owner": {
          "hash": "ded558796b20bead377c618c76641de0560dc4323a4b24d4131e7434d3077509",
          "index": 0
        },
        "value": 0,
        "highest": 1000000,
        "data": "00000000",
        "transfer": 0,
        "revoked": 0,
        "claimed": false,
        "weak": false,
        "stats": {
          "renewalPeriodStart": 477,
          "renewalPeriodEnd": 10477,
          "blocksUntilExpire": 9996,
          "daysUntilExpire": 34.71
        }
      },
    ]
    

    Your wallet tracks any name on which you have bid or opened. getnames returns info on each. This is different from the hsd-rpc getnames call which returns info on all names for which the node has data.

    getauctioninfo

    name='possibility'
    
    hsw-rpc getauctioninfo $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('getauctioninfo', [ name ]);
      console.log(result);
    })();
    

    getauctioninfo returns JSON structured like this:

    {
      "name": "possibility",
      "nameHash": "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
      "state": "OPENING",
      "height": 2003,
      "renewal": 2003,
      "owner": {
        "hash": "0000000000000000000000000000000000000000000000000000000000000000",
        "index": 4294967295
      },
      "value": 0,
      "highest": 0,
      "data": "",
      "transfer": 0,
      "revoked": 0,
      "claimed": false,
      "weak": false,
      "stats": {
        "openPeriodStart": 2003,
        "openPeriodEnd": 2014,
        "blocksUntilBidding": 10,
        "hoursUntilBidding": 0.83
      },
      "bids": [],
      "reveals": []
    }
    

    Once the open period begins, we can monitor the auction using getauctioninfo. Use hsd-rpc getnameinfo to monitor a name prior to the start of bidding.

    Note, by default your wallet will not track an auction unless you have participated in some form (sendopen, sendbid).

    Params

    Name Default Description
    name Required name to get auction info of

    getbids

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

    getbids returns JSON structured like this:

    [
      {
        "name": "why",
        "nameHash": "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
        "prevout": {
          "hash": "044aef8c1e61a3975bfa75dc9d6e1b19ce231ffcc019f97049543b2e12a692a6",
          "index": 0
        },
        "value": 3000000,
        "lockup": 4000000,
        "blind": "0ddd08f20581b7adadf881b80c5d044b17cf6b1965bf4c56815cca390d9c41db",
        "own": true
      },
      {
        "name": "trees",
        "nameHash": "92ec68524dbcc44bc3ff4847ed45e3a86789009d862499ce558c793498413cec",
        "prevout": {
          "hash": "9ae840429110809efde0f0743178ce2f66d021a3c9c875f486293f132e37151f",
          "index": 0
        },
        "value": 5000000,
        "lockup": 10000000,
        "blind": "a0943b12aa57ec0b3e6371be5b75cc895d0f78a7c5367c065bd388aebe6051a5",
        "own": true
      }
    ]
    
    

    getbids returns a list of all the bids placed by your wallet.

    Params

    none

    getreveals

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

    getreveals returns JSON structured like this:

    [
       {
        "name": "why",
        "nameHash": "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
        "prevout": {
          "hash": "e3f45c48985a0722a8a124065af972be05356a6be124263f4b86590da0e61e36",
          "index": 0
        },
        "value": 3000000,
        "height": 211,
        "own": true
      },
      {
        "name": "trees",
        "nameHash": "92ec68524dbcc44bc3ff4847ed45e3a86789009d862499ce558c793498413cec",
        "prevout": {
          "hash": "bd64231b5c28ad6b2b9c463900856676c67beedeb6e3a9e94cf6a1d8563bcba3",
          "index": 0
        },
        "value": 5000000,
        "height": 89,
        "own": true
      }
    ]
    

    getreveals returns all the reveal transactions sent by the wallet.

    Params

    none

    sendopen

    name='possibility'
    
    hsw-rpc sendopen $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendopen', [ name ]);
      console.log(result);
    })();
    

    sendopen returns JSON structured like this:

    {
      "hash": "05ba8ab476f41213613813ebc63a14d7154857efc9a19b7e181852ab19c05e82",
      "witnessHash": "6afe4493d6b68d855db9685380ea6316a9d4b48212e584cbf383dccf1acbf94b",
      "mtime": 1537401957,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "837b802fbad06cab6c8f789c4745cc56d1498a651a04973c8b3db310d90fec42",
            "index": 0
          },
          "witness": [
            "cc603c24fd90881b00899751d634fad8cfc67ac1289de2475f5c09117db3037335eb9983d38113be4d7c1895514f7d0ff411d2e72dc3ebb444e811146958ebc601",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 0,
          "address": "rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye",
          "covenant": {
            "type": 2,
            "action": "OPEN",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "00000000",
              "706f73736962696c697479"
            ]
          }
        },
        {
          "value": 999996200,
          "address": "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001837b802fbad06cab6c8f789c4745cc56d1498a651a04973c8b3db310d90fec4200000000ffffffff0200000000000000000014b5b4aad6b9e5a76276a0740b8447328f78aacf5102032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04000000000b706f73736962696c69747928bb9a3b000000000014cb8e33e158f5441ddaeed9b9a9587776d1947e970000000000000241cc603c24fd90881b00899751d634fad8cfc67ac1289de2475f5c09117db3037335eb9983d38113be4d7c1895514f7d0ff411d2e72dc3ebb444e811146958ebc6012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    Once a name is available, a sendopen transaction starts the opening phase.

    Params

    Name Default Description
    name Required name to open bidding on

    sendbid

    name='possibility'
    amount=5.000000
    lockup=10.000000
    
    hsw-rpc sendbid $name $amount $lockup
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendbid', [ name, amount, lockup ]);
      console.log(result);
    })();
    

    sendbid returns JSON structured like this:

    {
      "hash": "85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a",
      "witnessHash": "78a33edde952c80dd05476afe1e5e6e0a942484feb914e8ecf4c4b66329940a9",
      "mtime": 1537402434,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "5f7892816226f3f753dfd003eea4f565fa699a5b29bafde27b6628b1a2966910",
            "index": 0
          },
          "witness": [
            "bfab12daf81378ad40c46d037a52ffd4f3374c6f71cd6997b067ea9b498e29ac359cf9b267265f31741b28916a7d3da3021ca60539473d59cef3dc88b25c9e9801",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 10000000,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5",
          "covenant": {
            "type": 3,
            "action": "BID",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "706f73736962696c697479",
              "001361beb541240738829f101e842c76b9666d1bc4a87299a8ed6a9d2127ed61"
            ]
          }
        },
        {
          "value": 990004940,
          "address": "rs1qd7xx0qnn5qpnmcuadhnz99q6sydfgq8fvg6e4v",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000015f7892816226f3f753dfd003eea4f565fa699a5b29bafde27b6628b1a296691000000000ffffffff0280969800000000000014946419b0703f520ddc20ecd9f263db551bce9a5503042001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d30700000b706f73736962696c69747920001361beb541240738829f101e842c76b9666d1bc4a87299a8ed6a9d2127ed61cc46023b0000000000146f8c678273a0033de39d6de622941a811a9400e90000000000000241bfab12daf81378ad40c46d037a52ffd4f3374c6f71cd6997b067ea9b498e29ac359cf9b267265f31741b28916a7d3da3021ca60539473d59cef3dc88b25c9e98012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    The OPEN period is followed by the BIDDING period. Use sendbid to place a bid.

    Params

    Name Default Description
    name Required name to bid on
    amount Required amount to bid (in HNS)
    lockup Required amount to lock up to blind your bid (must be greater than bid amount)

    sendreveal

    name='possibility'
    
    hsw-rpc sendreveal $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendreveal', [ name ]);
      console.log(result);
    })();
    

    sendreveal returns JSON structured like this:

    {
      "hash": "e8f576a85d87adffeef7a9bfbf79cf8782750592911f095fe39dd9fa1e73b650",
      "witnessHash": "9f3458a6e1d32c9aad971cb52792f106f9f9a0a640a597098e98b47befe31be6",
      "mtime": 1537403274,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "22ebf77857e063c45dd0656ade0b8c5a29e255fefe55b1905fb799a9d075a552",
            "index": 0
          },
          "witness": [
            "5a43e3d1b90e28a550cca1da5950f846f82dc71d2f61b78ca1a4aadfef7d963e30fb33f1866139f02d24470948120e92a35ea3d6f7fa3ab569e9893f9983f86801",
            "03b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef65"
          ],
          "sequence": 4294967295,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp"
        },
        {
          "prevout": {
            "hash": "85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a",
            "index": 0
          },
          "witness": [
            "286caf0d7901660c5c6efffede32be2ba4811495c6afdc23ece3f53537aed85f4829e7c47516d15e02456f1efb798e0692a43ca06d96499c01954d2f23ac0a6801",
            "023bedd07f6cd16dc2699ec2b2451e2d8004fab99666e8e6dbc7286ed24be01f08"
          ],
          "sequence": 4294967295,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5"
        }
      ],
      "outputs": [
        {
          "value": 6000000,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp",
          "covenant": {
            "type": 4,
            "action": "REVEAL",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "5b0e235bdc68fd23cc4877b566831490ea5be1a309af991027c89ff7be6822a8"
            ]
          }
        },
        {
          "value": 5000000,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5",
          "covenant": {
            "type": 4,
            "action": "REVEAL",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "6cffbc155303695d2d974155bfd1dac48b267b41238a7d7ff4b39d1d23affe2a"
            ]
          }
        },
        {
          "value": 10992400,
          "address": "rs1qva23vffrfmru8euzvnqdxsudc2c6f7rlk4fszz",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000222ebf77857e063c45dd0656ade0b8c5a29e255fefe55b1905fb799a9d075a55200000000ffffffff85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a00000000ffffffff03808d5b00000000000014d4af1e4a45ea8f06082ceabfddc00431d9bf1c5904032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d3070000205b0e235bdc68fd23cc4877b566831490ea5be1a309af991027c89ff7be6822a8404b4c00000000000014946419b0703f520ddc20ecd9f263db551bce9a5504032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d3070000206cffbc155303695d2d974155bfd1dac48b267b41238a7d7ff4b39d1d23affe2a10bba70000000000001467551625234ec7c3e78264c0d3438dc2b1a4f87f00000000000002415a43e3d1b90e28a550cca1da5950f846f82dc71d2f61b78ca1a4aadfef7d963e30fb33f1866139f02d24470948120e92a35ea3d6f7fa3ab569e9893f9983f868012103b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef650241286caf0d7901660c5c6efffede32be2ba4811495c6afdc23ece3f53537aed85f4829e7c47516d15e02456f1efb798e0692a43ca06d96499c01954d2f23ac0a680121023bedd07f6cd16dc2699ec2b2451e2d8004fab99666e8e6dbc7286ed24be01f08"
    }
    

    The BIDDING period is followed by the REVEAL period, during which bidders must reveal their bids.

    Params

    Name Default Description
    name Required name to reveal bid for (null for all names)

    sendredeem

    name='possibility'
    
    hsw-rpc sendredeem $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendredeem', [ name ]);
      console.log(result);
    })();
    

    sendredeem returns JSON structured like this:

    {
      "hash": "eca1bae09d78312f1f3177eafcde9f48c8d933f807cc276a9224003aba922018",
      "witnessHash": "f883350cefade0671380fdce71b88996d2a49be30bfd7e3ebb02020e097efe51",
      "mtime": 1537224055,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "76ad90abcde417d41d017b8d15b6980a804405aff72537c5cb99eb61a60cfee0",
            "index": 0
          },
          "witness": [
            "c5af2d7cee71f3079ec24d4e20387388ec44f6617b068e86a495f0b5649f99e916618d25be6d04a038071de074429bd4dbeda021916fc98e4a5a7c0a4e03ca2801",
            "0329d8c1750b74815e568f2c57ac5492a8e93b3b919334025d37c239b466988590"
          ],
          "sequence": 4294967295,
          "address": "rs1q79u92rxyaxejj3rqyu0kxhzaydxk4ruendeu42"
        },
        {
          "prevout": {
            "hash": "00c61039848c77220ecafdef2e189c30093ae086c5ed5fce473bd1ec0d0f37fd",
            "index": 0
          },
          "witness": [
            "264a2153120ae936dd1dd75a0d2174089158b99e77f10db34253ed87216a76de13baa857f0ae5e1c77ac85f0402d74cd3d3154cfafe06e59e07b15c6958c5b4101",
            "020eb07bca66b10617ffb17fe298a104a21789f4990cedee84577f66fe69656458"
          ],
          "sequence": 4294967295,
          "address": "rs1q0n93g7979gflgq680daemzx8slfg0tqreasrnf"
        }
      ],
      "outputs": [
        {
          "value": 2000000,
          "address": "rs1q79u92rxyaxejj3rqyu0kxhzaydxk4ruendeu42",
          "covenant": {
            "type": 5,
            "action": "REDEEM",
            "items": [
              "a761e2b31b2a10714810b3cb439b1ffe347a1019af1932db7e8ac4c62a34224a",
              "0c000000"
            ]
          }
        },
        {
          "value": 1000000720,
          "address": "rs1qx7yfyscwrwjw86spx88wdhgnj7ljkrxjmljx6j",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000276ad90abcde417d41d017b8d15b6980a804405aff72537c5cb99eb61a60cfee000000000ffffffff00c61039848c77220ecafdef2e189c30093ae086c5ed5fce473bd1ec0d0f37fd00000000ffffffff0280841e00000000000014f178550cc4e9b3294460271f635c5d234d6a8f99050220a761e2b31b2a10714810b3cb439b1ffe347a1019af1932db7e8ac4c62a34224a040c000000d0cc9a3b000000000014378892430e1ba4e3ea0131cee6dd1397bf2b0cd20000000000000241c5af2d7cee71f3079ec24d4e20387388ec44f6617b068e86a495f0b5649f99e916618d25be6d04a038071de074429bd4dbeda021916fc98e4a5a7c0a4e03ca2801210329d8c1750b74815e568f2c57ac5492a8e93b3b919334025d37c239b4669885900241264a2153120ae936dd1dd75a0d2174089158b99e77f10db34253ed87216a76de13baa857f0ae5e1c77ac85f0402d74cd3d3154cfafe06e59e07b15c6958c5b410121020eb07bca66b10617ffb17fe298a104a21789f4990cedee84577f66fe69656458"
    }
    

    After the REVEAL period, the auction is CLOSED. The value locked up by losing bids can be spent using a REDEEM covenant like any other coin. The winning bid can not be redeemed.

    Params

    Name Default Description
    name Required name to redeem a losing bid for (null for all names)

    sendupdate

    name='possibility'
    
    hsw-rpc sendupdate $name '{"records": [ {"type": "NS", "ns": "ns1.example.com."} ]}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute(
        'sendupdate',
        [
          name,
          {records: [ {type: "NS", "ns": "ns1.example.com."} ]}
        ]
      );
      console.log(result);
    })();
    

    sendupdate returns JSON structured like this:

    {
      "hash": "70a7bb8a015514934344590330bac7b2ed3adf716a41c3ead54fff83271e4462",
      "witnessHash": "9826b176811030b992c913ff2b9c7ac540216f97d9ea97a12aa170238ff1176d",
      "mtime": 1580945169,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "fba2b7020060ef7da7d0fb016e0e6fc7eefe6472521da6d1e096c3508154b97f",
            "index": 0
          },
          "witness": [
            "fda534512d04e56628d786a5d25a60f96a55462a5879b8f0c57941a3e89f33546d69a04b4fa035d856bd7dad9f089646fa937864d85bdddbea22478fac835ffe01",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 7,
            "action": "UPDATE",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "0001036e7331076578616d706c6503636f6d00"
            ]
          }
        },
        {
          "value": 2000000880,
          "address": "rs1qvnzn8krtydw39stqx0a0cwdly68tyus88r0qkt",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002fba2b7020060ef7da7d0fb016e0e6fc7eefe6472521da6d1e096c3508154b97f00000000ffffffff4ce418e3fa835b63a5c93397c807cd07fd711501c7840163a9ca660cb4c0b10900000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004070320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000130001036e7331076578616d706c6503636f6d007097357700000000001464c533d86b235d12c16033fafc39bf268eb272070000000000000241fda534512d04e56628d786a5d25a60f96a55462a5879b8f0c57941a3e89f33546d69a04b4fa035d856bd7dad9f089646fa937864d85bdddbea22478fac835ffe0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c880241f6d7da1c9d3a8dd87c5c8b1726399f5f41396f5143f8bf4db50ccc4c7c1506c62c5b7ccb1ded95a7de110c38110d5aa72bbee3c0a04d07683e639bbddb2899dd012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    After the REVEAL period, the auction is CLOSED. The value locked up by the winning bid is locked forever, although the name owner and the name state can still change. The winning bidder can update the data resource associated with their name by sending an UPDATE.

    See the Resource Object section for details on formatting the name resource data.

    Params

    Name Default Description
    name Required name to update the data for
    data Required JSON-encoded resource

    sendrenewal

    hsw-rpc sendrenewal $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendrenewal', [ name ]);
      console.log(result);
    })();
    

    sendrenewal returns JSON structured like this:

    {
      "hash": "9903a0083675a01b325ed01154bc36714591f5854eb9cc307d611b50a8507240",
      "witnessHash": "1b0707f8b7e04d880afd134a17ea6564c4e6ee71b0151694315e5701bd8d1827",
      "mtime": 1537461760,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "d3b7fbb819ecc817cacb17458d946dacbc4b4501e730d8022f2ab079ad40bdac",
            "index": 0
          },
          "witness": [
            "d9438712c602f69bf9129f5ec49d9b7b4dd0c7a46328d7037723fd3a5454ca245262e90836173832ca9a5616fd1f7271ea0eb0c65a0fbabfbe1e72ebf8aef0e101",
            "03b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef65"
          ],
          "sequence": 4294967295,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp"
        },
        {
          "prevout": {
            "hash": "069fe62ea77e0ca1705eb3c5cdff19ea419868243d7f41b18d9af6f78221e152",
            "index": 0
          },
          "witness": [
            "f9ed8ffd9e73a13dbb5a411071ff7a14ff54e084a59d9831a6a28e94781b253d513cc52cee51d644249c045d68ec0a1d0812399549ca3cf6c3b185c3ae669a1301",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 5000000,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp",
          "covenant": {
            "type": 8,
            "action": "RENEW",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "40e9f4c63507c0e05b44b5944dac4dbed3603a330dda2691067e17079fa8b5b3"
            ]
          }
        },
        {
          "value": 1000003100,
          "address": "rs1qc4hu9nh28nea6wz0p9sla70lzzxcyas3mshnv3",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002d3b7fbb819ecc817cacb17458d946dacbc4b4501e730d8022f2ab079ad40bdac00000000ffffffff069fe62ea77e0ca1705eb3c5cdff19ea419868243d7f41b18d9af6f78221e15200000000ffffffff02404b4c00000000000014d4af1e4a45ea8f06082ceabfddc00431d9bf1c5908032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d30700002040e9f4c63507c0e05b44b5944dac4dbed3603a330dda2691067e17079fa8b5b31cd69a3b000000000014c56fc2ceea3cf3dd384f0961fef9ff108d8276110000000000000241d9438712c602f69bf9129f5ec49d9b7b4dd0c7a46328d7037723fd3a5454ca245262e90836173832ca9a5616fd1f7271ea0eb0c65a0fbabfbe1e72ebf8aef0e1012103b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef650241f9ed8ffd9e73a13dbb5a411071ff7a14ff54e084a59d9831a6a28e94781b253d513cc52cee51d644249c045d68ec0a1d0812399549ca3cf6c3b185c3ae669a13012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    On mainnet, name ownership expires after two years. If the name owner does not RENEW the name, it can be re-opened by any user. RENEW covenants commit to a a recent block hash to prevent pre-signing and prove physical ownership of controlling keys. There is no cost besides the miner fee.

    Params

    Name Default Description
    name Required name to renew ownership of

    sendtransfer

    name='possibility'
    address='rs1qhrnda3ct3237e6hl0vyh4tz2e90wvaxnmdldfq'
    
    hsw-rpc sendtransfer $name $address
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendtransfer', [ name, address ]);
      console.log(result);
    })();
    

    sendtransfer returns JSON structured like this:

    {
      "hash": "c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a04",
      "witnessHash": "909d816d51471d0706eb3b2fb697bfdd8a8a77bab7965fc8dca595971d79d68a",
      "mtime": 1538011636,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf334",
            "index": 0
          },
          "witness": [
            "26ae1f8b5886b458b0e68571195d69270f1ea574d6c94c69c8720389247543fe3ac23705fe10e1eec520ca567cb2836d5ba444e1aae1f8c884047b14873a186901",
            "02896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff"
          ],
          "sequence": 4294967295,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40"
        },
        {
          "prevout": {
            "hash": "d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf334",
            "index": 1
          },
          "witness": [
            "9c8df6c7719a21f042dc6779fde9fd3cc208316b703b64e78685795d79cfc0db790c989055c6c0a83c34e95f8f8c68264a69a1c9b8399fa78c5983e9616ee0e201",
            "0287b251961dba18b138ff59e692024c0962c355cd328c78de0fb2176739209f88"
          ],
          "sequence": 4294967295,
          "address": "rs1qx40lfr2q8wknz3mxr4zknc44e3n88qm65y9vag"
        }
      ],
      "outputs": [
        {
          "value": 3000000,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40",
          "covenant": {
            "type": 9,
            "action": "TRANSFER",
            "items": [
              "08141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894",
              "8b000000",
              "00",
              "ba1889638506b69aa1b4b6c5c867c09345d8a7c1"
            ]
          }
        },
        {
          "value": 1000004320,
          "address": "rs1qvylezfasshnad0v55403n6prttueaam6t4vt3t",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf33400000000ffffffffd90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf33401000000ffffffff02c0c62d00000000000014e63a33c0867b57154f70d5afa891e6c221df57d209042008141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894048b000000010014ba1889638506b69aa1b4b6c5c867c09345d8a7c1e0da9a3b000000000014613f9127b085e7d6bd94a55f19e8235af99ef77a000000000000024126ae1f8b5886b458b0e68571195d69270f1ea574d6c94c69c8720389247543fe3ac23705fe10e1eec520ca567cb2836d5ba444e1aae1f8c884047b14873a1869012102896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff02419c8df6c7719a21f042dc6779fde9fd3cc208316b703b64e78685795d79cfc0db790c989055c6c0a83c34e95f8f8c68264a69a1c9b8399fa78c5983e9616ee0e201210287b251961dba18b138ff59e692024c0962c355cd328c78de0fb2176739209f88"
    }
    
    

    TRANSFER a name to a new address. Note that the output value of the UTXO still does not change. On mainnet, the TRANSFER period lasts two days, after which the original owner can FINALIZE the transfer. Any time before it is final, the original owner can still CANCEL or REVOKE the transfer.

    Params

    Name Default Description
    name Required name to transfer
    address Required address to transfer name ownership to

    sendfinalize

    name='possibility'
    
    hsw-rpc sendfinalize $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendfinalize', [ name ]);
      console.log(result);
    })();
    

    sendfinalize returns JSON structured like this:

    {
      "hash": "6f82bf94fdc12794aeac0a99e2428dbf0456f3ab15624129f898c505a1deb26d",
      "witnessHash": "cd4487c4d19924f5d58d828327e97eff5c1051a3a8cfaf3380af054960407fee",
      "mtime": 1538012719,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "e3c2874727805184562b3bbe7ebea8a23646eb045c36d69449ae236d3242dbc4",
            "index": 0
          },
          "witness": [
            "54fdde711cd3e0ce60e33a9db4c66b7a097c899dd39c8c3ba81905391bfcfd594afe4121e679985c6b8343635a595dcb4be50eadba66857550d0e16b25c20aaf01",
            "035e3c18b9a34de4c6a0be3a51f293d9cdd634cb85351e5c6b0152e7b292ce34a5"
          ],
          "sequence": 4294967295,
          "address": "rs1qwyssp6plp4qhqag6yejd2ywp4s8dg4dcgzsj7g"
        },
        {
          "prevout": {
            "hash": "0a50562585e67f3e5754c57ed5a94c893f047a06d9efba3b5b29f69903b54a56",
            "index": 0
          },
          "witness": [
            "200c11b6e091df0230a95a62264a30f0f674d572d82c638430c64ecfaadef15f20425fcb44ade602107314cfeea954714bbff2fde43dad370ecc90a0b4ca176901",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 1000000,
          "address": "rs1qhgvgjcu9q6mf4gd5kmzuse7qjdza3f7pm8gnmh",
          "covenant": {
            "type": 10,
            "action": "FINALIZE",
            "items": [
              "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
              "bd000000",
              "776879",
              "00",
              "3addb4abe0cc60dad8dcd25688883c62c328c025095d26125b8ff9005cc0823b"
            ]
          }
        },
        {
          "value": 1000003540,
          "address": "rs1q5y4lfnlvdvewe6wxfqzscv4j4l008fey82txyz",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002e3c2874727805184562b3bbe7ebea8a23646eb045c36d69449ae236d3242dbc400000000ffffffff0a50562585e67f3e5754c57ed5a94c893f047a06d9efba3b5b29f69903b54a5600000000ffffffff0240420f00000000000014ba1889638506b69aa1b4b6c5c867c09345d8a7c10a052027b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a404bd000000037768790100203addb4abe0cc60dad8dcd25688883c62c328c025095d26125b8ff9005cc0823bd4d79a3b000000000014a12bf4cfec6b32ece9c648050c32b2afdef3a724000000000000024154fdde711cd3e0ce60e33a9db4c66b7a097c899dd39c8c3ba81905391bfcfd594afe4121e679985c6b8343635a595dcb4be50eadba66857550d0e16b25c20aaf0121035e3c18b9a34de4c6a0be3a51f293d9cdd634cb85351e5c6b0152e7b292ce34a50241200c11b6e091df0230a95a62264a30f0f674d572d82c638430c64ecfaadef15f20425fcb44ade602107314cfeea954714bbff2fde43dad370ecc90a0b4ca1769012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    About 48 hours after a TRANSFER, the original owner can send a FINALIZE transaction, completing the transfer to a new address. The output address of the FINALIZE is the new owner's address.

    Params

    Name Default Description
    name Required name to finalize

    sendcancel

    name='possibility'
    
    hsw-rpc sendcancel $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendcancel', [ name ]);
      console.log(result);
    })();
    

    sendcancel returns JSON structured like this:

    {
      "hash": "7bd7c709e5d5e5cc2382f45daad29d280641bf9d1fdf5f88efb6a1809b16a01b",
      "witnessHash": "244ccd42d9c20e783b4249959b75aef2601ec2ef7edd4d527342644fcd0b04a4",
      "mtime": 1538022969,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "40694cc1ffbe6009d15446258aea876e74392f46be0844d5a67cf50e0b419ed6",
            "index": 0
          },
          "witness": [
            "f2511d7c5dd174773ab1dc9023f5a1a26e70f324b345eb31f5093394633faf8b5b84ccd1fb6bd8db661cf7ab6aaca02bda34acad47e15db9cfc666e517a536c601",
            "023341e7b9a5dbd22050d71fed525a1380096bb947b7f79f17828eb8b81546e3df"
          ],
          "sequence": 4294967295,
          "address": "rs1qgaxr4vg3y00ctlnyszy9hx36n7cxycfc6h59f3"
        },
        {
          "prevout": {
            "hash": "aa24214cb776499cc0aa40d6c05d31bd0327b7639149f9766d7e22d184ec858b",
            "index": 0
          },
          "witness": [
            "6816716ef14e9dfaebfb1b74d80ed00b839d86a5d77f99bb935d67d0b4a2bff5628e2c5fb6ca4ad34535355ad197e4162d7a2a09a9147805bd24d351dbfb7cec01",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 1000000,
          "address": "rs1qgaxr4vg3y00ctlnyszy9hx36n7cxycfc6h59f3",
          "covenant": {
            "type": 7,
            "action": "UPDATE",
            "items": [
              "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
              "bd000000",
              ""
            ]
          }
        },
        {
          "value": 1000000440,
          "address": "rs1qrm0fu5axhfeclqacw6maxsshzx9vcm9lecaj67",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000240694cc1ffbe6009d15446258aea876e74392f46be0844d5a67cf50e0b419ed600000000ffffffffaa24214cb776499cc0aa40d6c05d31bd0327b7639149f9766d7e22d184ec858b00000000ffffffff0240420f00000000000014474c3ab11123df85fe6480885b9a3a9fb062613807032027b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a404bd00000000b8cb9a3b0000000000141ede9e53a6ba738f83b876b7d34217118acc6cbf0000000000000241f2511d7c5dd174773ab1dc9023f5a1a26e70f324b345eb31f5093394633faf8b5b84ccd1fb6bd8db661cf7ab6aaca02bda34acad47e15db9cfc666e517a536c60121023341e7b9a5dbd22050d71fed525a1380096bb947b7f79f17828eb8b81546e3df02416816716ef14e9dfaebfb1b74d80ed00b839d86a5d77f99bb935d67d0b4a2bff5628e2c5fb6ca4ad34535355ad197e4162d7a2a09a9147805bd24d351dbfb7cec012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    After sending a TRANSFER but before sending a FINALIZE, the original owner can cancel the transfer. The owner will retain control of the name. This is the recommended means of canceling a transfer. Not to be confused with a REVOKE, which is only to be used in the case of a stolen key. There is no "cancel" covenant -- this transaction actually sends an UPDATE.

    Params

    Name Default Description
    name Required name to cancel the in-progress transfer of

    sendrevoke

    name='possibility'
    
    hsw-rpc sendrevoke $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('sendrevoke', [ name ]);
      console.log(result);
    })();
    

    sendrevoke returns JSON structured like this:

    {
      "hash": "fb7761c46161c736853f56d1be41e76ff8f004b7a4b5f096b880221544ee99f8",
      "witnessHash": "2fc85765999cd443f660b8af1c44e86d755ad706f8cb9f21632eaebc165ec9c0",
      "mtime": 1538011729,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a04",
            "index": 0
          },
          "witness": [
            "078cf39beab769eb3331b00c1d6c92f152883fcd3ee62f54c69db5b33dd2919d568e52f89ac1d3cd0cb88cba6e88b703a872d61d7a953886bb4b8dce4938e33e01",
            "02896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff"
          ],
          "sequence": 4294967295,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40"
        },
        {
          "prevout": {
            "hash": "5e0a26e6ba89dfafd7cd5436ddd5c26180f8619dd8dfebfe27459c4b4ac2093f",
            "index": 0
          },
          "witness": [
            "cf4ce38d371515c47bc51d28476adc288bcd06d39a1d1acf85bc6d39fd88799d578768e873263723e4012f181f071dcde145998107f1d37ad476b6c594cf7de401",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 3000000,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40",
          "covenant": {
            "type": 11,
            "action": "REVOKE",
            "items": [
              "08141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894",
              "8b000000"
            ]
          }
        },
        {
          "value": 1000000460,
          "address": "rs1qk9qqak6mqp7lfd7dxpfdntdhsep7xj75ajracs",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a0400000000ffffffff5e0a26e6ba89dfafd7cd5436ddd5c26180f8619dd8dfebfe27459c4b4ac2093f00000000ffffffff02c0c62d00000000000014e63a33c0867b57154f70d5afa891e6c221df57d20b022008141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894048b000000cccb9a3b000000000014b1400edb5b007df4b7cd3052d9adb78643e34bd40000000000000241078cf39beab769eb3331b00c1d6c92f152883fcd3ee62f54c69db5b33dd2919d568e52f89ac1d3cd0cb88cba6e88b703a872d61d7a953886bb4b8dce4938e33e012102896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff0241cf4ce38d371515c47bc51d28476adc288bcd06d39a1d1acf85bc6d39fd88799d578768e873263723e4012f181f071dcde145998107f1d37ad476b6c594cf7de4012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    After sending a TRANSFER but before sending a FINALIZE, the original owner can REVOKE the name transfer. This renders the name's output forever unspendable, and puts the name back up for bidding. This is intended as an action of last resort in the case that the owner's key has been compromised, leading to a grief battle between an attacker and the owner.

    Params

    Name Default Description
    name Required name to revoke the in-progress transfer of

    importnonce

    name='possibility'
    address='rs1qhrnda3ct3237e6hl0vyh4tz2e90wvaxnmdldfq'
    bid=1.123456
    
    hsw-rpc importnonce $name $address $bid
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('importnonce', [ name, address, bid ]);
      console.log(result);
    })();
    

    importnonce deterministically regenerates a bid's nonce

    064802bfe52159d6c744625b17b887834d26dcc04605190fb82e4b41862adf60
    

    Deterministically regenerate the nonce for a bid.

    Params

    Name Default Description
    name Required name to bid on
    address Required address submitting the bid
    value Required value of the bid (in HNS)

    createopen

    name='possibility'
    force=true
    account=default
    
    hsw-rpc createopen $name $force $account
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createopen', [ name ]);
      console.log(result);
    })();
    

    createopen returns JSON structured like this:

    {
      "hash": "05ba8ab476f41213613813ebc63a14d7154857efc9a19b7e181852ab19c05e82",
      "witnessHash": "6afe4493d6b68d855db9685380ea6316a9d4b48212e584cbf383dccf1acbf94b",
      "mtime": 1537401957,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "837b802fbad06cab6c8f789c4745cc56d1498a651a04973c8b3db310d90fec42",
            "index": 0
          },
          "witness": [
            "cc603c24fd90881b00899751d634fad8cfc67ac1289de2475f5c09117db3037335eb9983d38113be4d7c1895514f7d0ff411d2e72dc3ebb444e811146958ebc601",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 0,
          "address": "rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye",
          "covenant": {
            "type": 2,
            "action": "OPEN",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "00000000",
              "706f73736962696c697479"
            ]
          }
        },
        {
          "value": 999996200,
          "address": "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000001837b802fbad06cab6c8f789c4745cc56d1498a651a04973c8b3db310d90fec4200000000ffffffff0200000000000000000014b5b4aad6b9e5a76276a0740b8447328f78aacf5102032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04000000000b706f73736962696c69747928bb9a3b000000000014cb8e33e158f5441ddaeed9b9a9587776d1947e970000000000000241cc603c24fd90881b00899751d634fad8cfc67ac1289de2475f5c09117db3037335eb9983d38113be4d7c1895514f7d0ff411d2e72dc3ebb444e811146958ebc6012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    Creates OPEN transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to open bidding on
    force (bool) Optional currently ignored but required if additional parameters are passed
    account Optional account to use

    createbid

    name='possibility'
    amount=5.000000
    lockup=10.000000
    
    hsw-rpc createbid $name $amount $lockup
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createbid', [ name, amount, lockup ]);
      console.log(result);
    })();
    

    createbid returns JSON structured like this:

    {
      "hash": "85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a",
      "witnessHash": "78a33edde952c80dd05476afe1e5e6e0a942484feb914e8ecf4c4b66329940a9",
      "mtime": 1537402434,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "5f7892816226f3f753dfd003eea4f565fa699a5b29bafde27b6628b1a2966910",
            "index": 0
          },
          "witness": [
            "bfab12daf81378ad40c46d037a52ffd4f3374c6f71cd6997b067ea9b498e29ac359cf9b267265f31741b28916a7d3da3021ca60539473d59cef3dc88b25c9e9801",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 10000000,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5",
          "covenant": {
            "type": 3,
            "action": "BID",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "706f73736962696c697479",
              "001361beb541240738829f101e842c76b9666d1bc4a87299a8ed6a9d2127ed61"
            ]
          }
        },
        {
          "value": 990004940,
          "address": "rs1qd7xx0qnn5qpnmcuadhnz99q6sydfgq8fvg6e4v",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000015f7892816226f3f753dfd003eea4f565fa699a5b29bafde27b6628b1a296691000000000ffffffff0280969800000000000014946419b0703f520ddc20ecd9f263db551bce9a5503042001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d30700000b706f73736962696c69747920001361beb541240738829f101e842c76b9666d1bc4a87299a8ed6a9d2127ed61cc46023b0000000000146f8c678273a0033de39d6de622941a811a9400e90000000000000241bfab12daf81378ad40c46d037a52ffd4f3374c6f71cd6997b067ea9b498e29ac359cf9b267265f31741b28916a7d3da3021ca60539473d59cef3dc88b25c9e98012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    Create BID transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to bid on
    amount Required amount to bid (in HNS)
    lockup Required amount to lock up to blind your bid (must be greater than bid amount)
    account Optional account to use

    createreveal

    name='possibility'
    
    hsw-rpc createreveal $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createreveal', [ name ]);
      console.log(result);
    })();
    

    createreveal returns JSON structured like this:

    {
      "hash": "e8f576a85d87adffeef7a9bfbf79cf8782750592911f095fe39dd9fa1e73b650",
      "witnessHash": "9f3458a6e1d32c9aad971cb52792f106f9f9a0a640a597098e98b47befe31be6",
      "mtime": 1537403274,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "22ebf77857e063c45dd0656ade0b8c5a29e255fefe55b1905fb799a9d075a552",
            "index": 0
          },
          "witness": [
            "5a43e3d1b90e28a550cca1da5950f846f82dc71d2f61b78ca1a4aadfef7d963e30fb33f1866139f02d24470948120e92a35ea3d6f7fa3ab569e9893f9983f86801",
            "03b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef65"
          ],
          "sequence": 4294967295,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp"
        },
        {
          "prevout": {
            "hash": "85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a",
            "index": 0
          },
          "witness": [
            "286caf0d7901660c5c6efffede32be2ba4811495c6afdc23ece3f53537aed85f4829e7c47516d15e02456f1efb798e0692a43ca06d96499c01954d2f23ac0a6801",
            "023bedd07f6cd16dc2699ec2b2451e2d8004fab99666e8e6dbc7286ed24be01f08"
          ],
          "sequence": 4294967295,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5"
        }
      ],
      "outputs": [
        {
          "value": 6000000,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp",
          "covenant": {
            "type": 4,
            "action": "REVEAL",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "5b0e235bdc68fd23cc4877b566831490ea5be1a309af991027c89ff7be6822a8"
            ]
          }
        },
        {
          "value": 5000000,
          "address": "rs1qj3jpnvrs8afqmhpqanvlyc7m25duaxj4txaru5",
          "covenant": {
            "type": 4,
            "action": "REVEAL",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "6cffbc155303695d2d974155bfd1dac48b267b41238a7d7ff4b39d1d23affe2a"
            ]
          }
        },
        {
          "value": 10992400,
          "address": "rs1qva23vffrfmru8euzvnqdxsudc2c6f7rlk4fszz",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000222ebf77857e063c45dd0656ade0b8c5a29e255fefe55b1905fb799a9d075a55200000000ffffffff85bce02cc5cb8ba9ff4e23d84ce389310f50074a6b9a8b20b8643a56a4cb9f9a00000000ffffffff03808d5b00000000000014d4af1e4a45ea8f06082ceabfddc00431d9bf1c5904032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d3070000205b0e235bdc68fd23cc4877b566831490ea5be1a309af991027c89ff7be6822a8404b4c00000000000014946419b0703f520ddc20ecd9f263db551bce9a5504032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d3070000206cffbc155303695d2d974155bfd1dac48b267b41238a7d7ff4b39d1d23affe2a10bba70000000000001467551625234ec7c3e78264c0d3438dc2b1a4f87f00000000000002415a43e3d1b90e28a550cca1da5950f846f82dc71d2f61b78ca1a4aadfef7d963e30fb33f1866139f02d24470948120e92a35ea3d6f7fa3ab569e9893f9983f868012103b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef650241286caf0d7901660c5c6efffede32be2ba4811495c6afdc23ece3f53537aed85f4829e7c47516d15e02456f1efb798e0692a43ca06d96499c01954d2f23ac0a680121023bedd07f6cd16dc2699ec2b2451e2d8004fab99666e8e6dbc7286ed24be01f08"
    }
    

    Create REVEAL transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to reveal bid for (null for all names)
    account Optional account to use

    createredeem

    name='possibility'
    
    hsw-rpc createredeem $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createredeem', [ name ]);
      console.log(result);
    })();
    

    createredeem returns JSON structured like this:

    {
      "hash": "eca1bae09d78312f1f3177eafcde9f48c8d933f807cc276a9224003aba922018",
      "witnessHash": "f883350cefade0671380fdce71b88996d2a49be30bfd7e3ebb02020e097efe51",
      "mtime": 1537224055,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "76ad90abcde417d41d017b8d15b6980a804405aff72537c5cb99eb61a60cfee0",
            "index": 0
          },
          "witness": [
            "c5af2d7cee71f3079ec24d4e20387388ec44f6617b068e86a495f0b5649f99e916618d25be6d04a038071de074429bd4dbeda021916fc98e4a5a7c0a4e03ca2801",
            "0329d8c1750b74815e568f2c57ac5492a8e93b3b919334025d37c239b466988590"
          ],
          "sequence": 4294967295,
          "address": "rs1q79u92rxyaxejj3rqyu0kxhzaydxk4ruendeu42"
        },
        {
          "prevout": {
            "hash": "00c61039848c77220ecafdef2e189c30093ae086c5ed5fce473bd1ec0d0f37fd",
            "index": 0
          },
          "witness": [
            "264a2153120ae936dd1dd75a0d2174089158b99e77f10db34253ed87216a76de13baa857f0ae5e1c77ac85f0402d74cd3d3154cfafe06e59e07b15c6958c5b4101",
            "020eb07bca66b10617ffb17fe298a104a21789f4990cedee84577f66fe69656458"
          ],
          "sequence": 4294967295,
          "address": "rs1q0n93g7979gflgq680daemzx8slfg0tqreasrnf"
        }
      ],
      "outputs": [
        {
          "value": 2000000,
          "address": "rs1q79u92rxyaxejj3rqyu0kxhzaydxk4ruendeu42",
          "covenant": {
            "type": 5,
            "action": "REDEEM",
            "items": [
              "a761e2b31b2a10714810b3cb439b1ffe347a1019af1932db7e8ac4c62a34224a",
              "0c000000"
            ]
          }
        },
        {
          "value": 1000000720,
          "address": "rs1qx7yfyscwrwjw86spx88wdhgnj7ljkrxjmljx6j",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000276ad90abcde417d41d017b8d15b6980a804405aff72537c5cb99eb61a60cfee000000000ffffffff00c61039848c77220ecafdef2e189c30093ae086c5ed5fce473bd1ec0d0f37fd00000000ffffffff0280841e00000000000014f178550cc4e9b3294460271f635c5d234d6a8f99050220a761e2b31b2a10714810b3cb439b1ffe347a1019af1932db7e8ac4c62a34224a040c000000d0cc9a3b000000000014378892430e1ba4e3ea0131cee6dd1397bf2b0cd20000000000000241c5af2d7cee71f3079ec24d4e20387388ec44f6617b068e86a495f0b5649f99e916618d25be6d04a038071de074429bd4dbeda021916fc98e4a5a7c0a4e03ca2801210329d8c1750b74815e568f2c57ac5492a8e93b3b919334025d37c239b4669885900241264a2153120ae936dd1dd75a0d2174089158b99e77f10db34253ed87216a76de13baa857f0ae5e1c77ac85f0402d74cd3d3154cfafe06e59e07b15c6958c5b410121020eb07bca66b10617ffb17fe298a104a21789f4990cedee84577f66fe69656458"
    }
    

    Create REDEEM transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to redeem a losing bid for (null for all names)
    account Optional account to use

    createupdate

    name='possibility'
    
    hsw-rpc createupdate $name '{"records": [ {"type": "NS", "ns": "ns1.example.com."} ]}'
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute(
        'createupdate',
        [
          name,
          {records: [ {type: "NS", "ns": "ns1.example.com."} ]}
        ]
      );
      console.log(result);
    })();
    

    createupdate returns JSON structured like this:

    {
      "hash": "70a7bb8a015514934344590330bac7b2ed3adf716a41c3ead54fff83271e4462",
      "witnessHash": "9826b176811030b992c913ff2b9c7ac540216f97d9ea97a12aa170238ff1176d",
      "mtime": 1580945169,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "fba2b7020060ef7da7d0fb016e0e6fc7eefe6472521da6d1e096c3508154b97f",
            "index": 0
          },
          "witness": [
            "fda534512d04e56628d786a5d25a60f96a55462a5879b8f0c57941a3e89f33546d69a04b4fa035d856bd7dad9f089646fa937864d85bdddbea22478fac835ffe01",
            "031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c88"
          ],
          "sequence": 4294967295,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3"
        }
      ],
      "outputs": [
        {
          "value": 1234000,
          "address": "rs1qrw8kdf4nehpam42s9h767qrucgpccuqyk5y9j3",
          "covenant": {
            "type": 7,
            "action": "UPDATE",
            "items": [
              "e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a",
              "e3040000",
              "0001036e7331076578616d706c6503636f6d00"
            ]
          }
        },
        {
          "value": 2000000880,
          "address": "rs1qvnzn8krtydw39stqx0a0cwdly68tyus88r0qkt",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002fba2b7020060ef7da7d0fb016e0e6fc7eefe6472521da6d1e096c3508154b97f00000000ffffffff4ce418e3fa835b63a5c93397c807cd07fd711501c7840163a9ca660cb4c0b10900000000ffffffff0250d412000000000000141b8f66a6b3cdc3ddd5502dfdaf007cc2038c7004070320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a04e3040000130001036e7331076578616d706c6503636f6d007097357700000000001464c533d86b235d12c16033fafc39bf268eb272070000000000000241fda534512d04e56628d786a5d25a60f96a55462a5879b8f0c57941a3e89f33546d69a04b4fa035d856bd7dad9f089646fa937864d85bdddbea22478fac835ffe0121031a7b023f3baf31ec7e730cc1535bdf26c642be367b3de2fb6b6a30d3c5cd5c880241f6d7da1c9d3a8dd87c5c8b1726399f5f41396f5143f8bf4db50ccc4c7c1506c62c5b7ccb1ded95a7de110c38110d5aa72bbee3c0a04d07683e639bbddb2899dd012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Create UPDATE transaction without signing or broadcasting it.

    See the Resource Object section for details on formatting the name resource data.

    Params

    Name Default Description
    name Required name to update the data for
    data Required JSON-encoded resource
    account Optional account to use

    createrenewal

    hsw-rpc createrenewal $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createrenewal', [ name ]);
      console.log(result);
    })();
    

    createrenewal returns JSON structured like this:

    {
      "hash": "9903a0083675a01b325ed01154bc36714591f5854eb9cc307d611b50a8507240",
      "witnessHash": "1b0707f8b7e04d880afd134a17ea6564c4e6ee71b0151694315e5701bd8d1827",
      "mtime": 1537461760,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "d3b7fbb819ecc817cacb17458d946dacbc4b4501e730d8022f2ab079ad40bdac",
            "index": 0
          },
          "witness": [
            "d9438712c602f69bf9129f5ec49d9b7b4dd0c7a46328d7037723fd3a5454ca245262e90836173832ca9a5616fd1f7271ea0eb0c65a0fbabfbe1e72ebf8aef0e101",
            "03b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef65"
          ],
          "sequence": 4294967295,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp"
        },
        {
          "prevout": {
            "hash": "069fe62ea77e0ca1705eb3c5cdff19ea419868243d7f41b18d9af6f78221e152",
            "index": 0
          },
          "witness": [
            "f9ed8ffd9e73a13dbb5a411071ff7a14ff54e084a59d9831a6a28e94781b253d513cc52cee51d644249c045d68ec0a1d0812399549ca3cf6c3b185c3ae669a1301",
            "03b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
          ],
          "sequence": 4294967295,
          "address": "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss"
        }
      ],
      "outputs": [
        {
          "value": 5000000,
          "address": "rs1q6jh3ujj9a28svzpva2lamsqyx8vm78zer8rfyp",
          "covenant": {
            "type": 8,
            "action": "RENEW",
            "items": [
              "01c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb",
              "d3070000",
              "40e9f4c63507c0e05b44b5944dac4dbed3603a330dda2691067e17079fa8b5b3"
            ]
          }
        },
        {
          "value": 1000003100,
          "address": "rs1qc4hu9nh28nea6wz0p9sla70lzzxcyas3mshnv3",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002d3b7fbb819ecc817cacb17458d946dacbc4b4501e730d8022f2ab079ad40bdac00000000ffffffff069fe62ea77e0ca1705eb3c5cdff19ea419868243d7f41b18d9af6f78221e15200000000ffffffff02404b4c00000000000014d4af1e4a45ea8f06082ceabfddc00431d9bf1c5908032001c05e8ea3d1c347342ef11c50fe5a1f621c942f7f8f7e0ee329eb883f93f9eb04d30700002040e9f4c63507c0e05b44b5944dac4dbed3603a330dda2691067e17079fa8b5b31cd69a3b000000000014c56fc2ceea3cf3dd384f0961fef9ff108d8276110000000000000241d9438712c602f69bf9129f5ec49d9b7b4dd0c7a46328d7037723fd3a5454ca245262e90836173832ca9a5616fd1f7271ea0eb0c65a0fbabfbe1e72ebf8aef0e1012103b98187d5521400df71917c0cded095e12a0134532e9db36b2f2d5e7958c9ef650241f9ed8ffd9e73a13dbb5a411071ff7a14ff54e084a59d9831a6a28e94781b253d513cc52cee51d644249c045d68ec0a1d0812399549ca3cf6c3b185c3ae669a13012103b9843c1c40c210790e55052c3e8c56b49d2f0f1d00e8bdeb0237f076a128365a"
    }
    

    Create RENEW transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to renew ownership of
    account Optional account to use

    createtransfer

    name='possibility'
    address='rs1qhrnda3ct3237e6hl0vyh4tz2e90wvaxnmdldfq'
    
    hsw-rpc createtransfer $name $address
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createtransfer', [ name, address ]);
      console.log(result);
    })();
    

    createtransfer returns JSON structured like this:

    {
      "hash": "c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a04",
      "witnessHash": "909d816d51471d0706eb3b2fb697bfdd8a8a77bab7965fc8dca595971d79d68a",
      "mtime": 1538011636,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf334",
            "index": 0
          },
          "witness": [
            "26ae1f8b5886b458b0e68571195d69270f1ea574d6c94c69c8720389247543fe3ac23705fe10e1eec520ca567cb2836d5ba444e1aae1f8c884047b14873a186901",
            "02896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff"
          ],
          "sequence": 4294967295,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40"
        },
        {
          "prevout": {
            "hash": "d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf334",
            "index": 1
          },
          "witness": [
            "9c8df6c7719a21f042dc6779fde9fd3cc208316b703b64e78685795d79cfc0db790c989055c6c0a83c34e95f8f8c68264a69a1c9b8399fa78c5983e9616ee0e201",
            "0287b251961dba18b138ff59e692024c0962c355cd328c78de0fb2176739209f88"
          ],
          "sequence": 4294967295,
          "address": "rs1qx40lfr2q8wknz3mxr4zknc44e3n88qm65y9vag"
        }
      ],
      "outputs": [
        {
          "value": 3000000,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40",
          "covenant": {
            "type": 9,
            "action": "TRANSFER",
            "items": [
              "08141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894",
              "8b000000",
              "00",
              "ba1889638506b69aa1b4b6c5c867c09345d8a7c1"
            ]
          }
        },
        {
          "value": 1000004320,
          "address": "rs1qvylezfasshnad0v55403n6prttueaam6t4vt3t",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002d90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf33400000000ffffffffd90af01fda660069d6a83f857a5779d099ff342d0e6a2a0a3f869e70b9bcf33401000000ffffffff02c0c62d00000000000014e63a33c0867b57154f70d5afa891e6c221df57d209042008141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894048b000000010014ba1889638506b69aa1b4b6c5c867c09345d8a7c1e0da9a3b000000000014613f9127b085e7d6bd94a55f19e8235af99ef77a000000000000024126ae1f8b5886b458b0e68571195d69270f1ea574d6c94c69c8720389247543fe3ac23705fe10e1eec520ca567cb2836d5ba444e1aae1f8c884047b14873a1869012102896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff02419c8df6c7719a21f042dc6779fde9fd3cc208316b703b64e78685795d79cfc0db790c989055c6c0a83c34e95f8f8c68264a69a1c9b8399fa78c5983e9616ee0e201210287b251961dba18b138ff59e692024c0962c355cd328c78de0fb2176739209f88"
    }
    
    

    Create TRANSFER transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to transfer
    address Required address to transfer name ownership to
    account Optional account to use

    createfinalize

    name='possibility'
    
    hsw-rpc createfinalize $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createfinalize', [ name ]);
      console.log(result);
    })();
    

    createfinalize returns JSON structured like this:

    {
      "hash": "6f82bf94fdc12794aeac0a99e2428dbf0456f3ab15624129f898c505a1deb26d",
      "witnessHash": "cd4487c4d19924f5d58d828327e97eff5c1051a3a8cfaf3380af054960407fee",
      "mtime": 1538012719,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "e3c2874727805184562b3bbe7ebea8a23646eb045c36d69449ae236d3242dbc4",
            "index": 0
          },
          "witness": [
            "54fdde711cd3e0ce60e33a9db4c66b7a097c899dd39c8c3ba81905391bfcfd594afe4121e679985c6b8343635a595dcb4be50eadba66857550d0e16b25c20aaf01",
            "035e3c18b9a34de4c6a0be3a51f293d9cdd634cb85351e5c6b0152e7b292ce34a5"
          ],
          "sequence": 4294967295,
          "address": "rs1qwyssp6plp4qhqag6yejd2ywp4s8dg4dcgzsj7g"
        },
        {
          "prevout": {
            "hash": "0a50562585e67f3e5754c57ed5a94c893f047a06d9efba3b5b29f69903b54a56",
            "index": 0
          },
          "witness": [
            "200c11b6e091df0230a95a62264a30f0f674d572d82c638430c64ecfaadef15f20425fcb44ade602107314cfeea954714bbff2fde43dad370ecc90a0b4ca176901",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 1000000,
          "address": "rs1qhgvgjcu9q6mf4gd5kmzuse7qjdza3f7pm8gnmh",
          "covenant": {
            "type": 10,
            "action": "FINALIZE",
            "items": [
              "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
              "bd000000",
              "776879",
              "00",
              "3addb4abe0cc60dad8dcd25688883c62c328c025095d26125b8ff9005cc0823b"
            ]
          }
        },
        {
          "value": 1000003540,
          "address": "rs1q5y4lfnlvdvewe6wxfqzscv4j4l008fey82txyz",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002e3c2874727805184562b3bbe7ebea8a23646eb045c36d69449ae236d3242dbc400000000ffffffff0a50562585e67f3e5754c57ed5a94c893f047a06d9efba3b5b29f69903b54a5600000000ffffffff0240420f00000000000014ba1889638506b69aa1b4b6c5c867c09345d8a7c10a052027b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a404bd000000037768790100203addb4abe0cc60dad8dcd25688883c62c328c025095d26125b8ff9005cc0823bd4d79a3b000000000014a12bf4cfec6b32ece9c648050c32b2afdef3a724000000000000024154fdde711cd3e0ce60e33a9db4c66b7a097c899dd39c8c3ba81905391bfcfd594afe4121e679985c6b8343635a595dcb4be50eadba66857550d0e16b25c20aaf0121035e3c18b9a34de4c6a0be3a51f293d9cdd634cb85351e5c6b0152e7b292ce34a50241200c11b6e091df0230a95a62264a30f0f674d572d82c638430c64ecfaadef15f20425fcb44ade602107314cfeea954714bbff2fde43dad370ecc90a0b4ca1769012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    Create FINALIZE transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to finalize
    account Optional account to use

    createcancel

    name='possibility'
    
    hsw-rpc createcancel $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createcancel', [ name ]);
      console.log(result);
    })();
    

    createcancel returns JSON structured like this:

    {
      "hash": "7bd7c709e5d5e5cc2382f45daad29d280641bf9d1fdf5f88efb6a1809b16a01b",
      "witnessHash": "244ccd42d9c20e783b4249959b75aef2601ec2ef7edd4d527342644fcd0b04a4",
      "mtime": 1538022969,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "40694cc1ffbe6009d15446258aea876e74392f46be0844d5a67cf50e0b419ed6",
            "index": 0
          },
          "witness": [
            "f2511d7c5dd174773ab1dc9023f5a1a26e70f324b345eb31f5093394633faf8b5b84ccd1fb6bd8db661cf7ab6aaca02bda34acad47e15db9cfc666e517a536c601",
            "023341e7b9a5dbd22050d71fed525a1380096bb947b7f79f17828eb8b81546e3df"
          ],
          "sequence": 4294967295,
          "address": "rs1qgaxr4vg3y00ctlnyszy9hx36n7cxycfc6h59f3"
        },
        {
          "prevout": {
            "hash": "aa24214cb776499cc0aa40d6c05d31bd0327b7639149f9766d7e22d184ec858b",
            "index": 0
          },
          "witness": [
            "6816716ef14e9dfaebfb1b74d80ed00b839d86a5d77f99bb935d67d0b4a2bff5628e2c5fb6ca4ad34535355ad197e4162d7a2a09a9147805bd24d351dbfb7cec01",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 1000000,
          "address": "rs1qgaxr4vg3y00ctlnyszy9hx36n7cxycfc6h59f3",
          "covenant": {
            "type": 7,
            "action": "UPDATE",
            "items": [
              "27b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a4",
              "bd000000",
              ""
            ]
          }
        },
        {
          "value": 1000000440,
          "address": "rs1qrm0fu5axhfeclqacw6maxsshzx9vcm9lecaj67",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "000000000240694cc1ffbe6009d15446258aea876e74392f46be0844d5a67cf50e0b419ed600000000ffffffffaa24214cb776499cc0aa40d6c05d31bd0327b7639149f9766d7e22d184ec858b00000000ffffffff0240420f00000000000014474c3ab11123df85fe6480885b9a3a9fb062613807032027b118c11562ebb2b11d94bbc1f23f3d78daea533766d929d39b580a2d37d4a404bd00000000b8cb9a3b0000000000141ede9e53a6ba738f83b876b7d34217118acc6cbf0000000000000241f2511d7c5dd174773ab1dc9023f5a1a26e70f324b345eb31f5093394633faf8b5b84ccd1fb6bd8db661cf7ab6aaca02bda34acad47e15db9cfc666e517a536c60121023341e7b9a5dbd22050d71fed525a1380096bb947b7f79f17828eb8b81546e3df02416816716ef14e9dfaebfb1b74d80ed00b839d86a5d77f99bb935d67d0b4a2bff5628e2c5fb6ca4ad34535355ad197e4162d7a2a09a9147805bd24d351dbfb7cec012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    Create CANCEL transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to cancel the in-progress transfer of
    account Optional account to use

    createrevoke

    name='possibility'
    
    hsw-rpc createrevoke $name
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createrevoke', [ name ]);
      console.log(result);
    })();
    

    createrevoke returns JSON structured like this:

    {
      "hash": "fb7761c46161c736853f56d1be41e76ff8f004b7a4b5f096b880221544ee99f8",
      "witnessHash": "2fc85765999cd443f660b8af1c44e86d755ad706f8cb9f21632eaebc165ec9c0",
      "mtime": 1538011729,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a04",
            "index": 0
          },
          "witness": [
            "078cf39beab769eb3331b00c1d6c92f152883fcd3ee62f54c69db5b33dd2919d568e52f89ac1d3cd0cb88cba6e88b703a872d61d7a953886bb4b8dce4938e33e01",
            "02896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff"
          ],
          "sequence": 4294967295,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40"
        },
        {
          "prevout": {
            "hash": "5e0a26e6ba89dfafd7cd5436ddd5c26180f8619dd8dfebfe27459c4b4ac2093f",
            "index": 0
          },
          "witness": [
            "cf4ce38d371515c47bc51d28476adc288bcd06d39a1d1acf85bc6d39fd88799d578768e873263723e4012f181f071dcde145998107f1d37ad476b6c594cf7de401",
            "03fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
          ],
          "sequence": 4294967295,
          "address": "rs1qj6340u3vv0vqe0uyjjlnlvqaljv07nydvdz2jv"
        }
      ],
      "outputs": [
        {
          "value": 3000000,
          "address": "rs1qucar8syx0dt32nms6kh63y0xcgsa747jaexn40",
          "covenant": {
            "type": 11,
            "action": "REVOKE",
            "items": [
              "08141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894",
              "8b000000"
            ]
          }
        },
        {
          "value": 1000000460,
          "address": "rs1qk9qqak6mqp7lfd7dxpfdntdhsep7xj75ajracs",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "0000000002c7fc96fa1b865a6139286b29626edf00ff286cb242c5fc65b3a78e0db1613a0400000000ffffffff5e0a26e6ba89dfafd7cd5436ddd5c26180f8619dd8dfebfe27459c4b4ac2093f00000000ffffffff02c0c62d00000000000014e63a33c0867b57154f70d5afa891e6c221df57d20b022008141335637fff1366102f06f2f7d7ac306e5d85c6d8e0f979c765db6a9ec894048b000000cccb9a3b000000000014b1400edb5b007df4b7cd3052d9adb78643e34bd40000000000000241078cf39beab769eb3331b00c1d6c92f152883fcd3ee62f54c69db5b33dd2919d568e52f89ac1d3cd0cb88cba6e88b703a872d61d7a953886bb4b8dce4938e33e012102896c8c128f86f155e61b74aced241304dd7f94feee6510d22f70e1d1b6e42fff0241cf4ce38d371515c47bc51d28476adc288bcd06d39a1d1acf85bc6d39fd88799d578768e873263723e4012f181f071dcde145998107f1d37ad476b6c594cf7de4012103fc902c7ebd0f4bb7437f86c41a3a88f0940a0566746159b581cd4684f725c7c0"
    }
    

    Create REVOKE transaction without signing or broadcasting it.

    Params

    Name Default Description
    name Required name to revoke the in-progress transfer of
    account Optional account to use

    importname

    name='test-txt'
    height=100
    
    hsw-rpc importname $name $height
    
    const {WalletClient} = require('hs-client');
    const {Network} = require('hsd');
    const network = Network.get('regtest');
    
    const clientOptions = {
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const client = new WalletClient(clientOptions);
    
    (async () => {
      const result = await client.execute('importname', [ name, height ]);
      console.log(result);
    })();
    

    importname adds a name to the wallet without sending a transaction

    null
    

    Add a name to the wallet "watchlist" without sending a transaction. Optionally rescan the blockchain to recover OPEN and BIDs for the name. This action will fail if the name already exists in the wallet.

    The purpose of this action is to "subscribe" to BIDs for a name auction before participating in that auction. If a user is interested in BIDs that have already been placed on a name they are interested in bidding on themselves, they may execute this RPC call and include a height parameter, which should be any block before the OPEN for the name was confirmed. The OPEN transaction must be included in the rescan or the wallet will not track BIDs on the name.

    Once the auction is rescanned, rpc getbids can be used to return all current BIDs on a name, even if the wallet has not placed any BIDs itself.

    Params

    Name Default Description
    name Required name to import
    height Optional if present, perform a wallet rescan from specified height

    RPC Calls - Wallet

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "<method>", "params": [...] "id": "some-id" }'
    
    hsw-rpc <method> <params>
    
    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.execute('<method>', [ <params> ]);
      console.log(result);
    })();
    

    Like the hsd node RPC calls, the wallet RPC calls mimic Bitcoin Core's RPC.

    Refer to the sections on the wallet client and the wallet db object for host, port, and authentication information.

    RPC Calls are accepted at: POST /

    wallet RPC POST Parameters

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

    selectwallet

    let id;
    
    id='primary'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "selectwallet",
        "params": [ "'$id'" ]
      }'
    
    hsw-rpc selectwallet $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);
    
    (async () => {
      const result = await walletClient.execute('selectwallet', [id]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Switch target wallet for all future RPC calls.

    Params

    N. Name Default Description
    1 id Required id of selected wallet

    getwalletinfo

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "getwalletinfo" }'
    
    hsw-rpc getwalletinfo
    
    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.execute('getwalletinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "result": {
        "walletid": "primary",
        "walletversion": 6,
        "balance": 50,
        "unconfirmed_balance": 50,
        "txcount": 1,
        "keypoololdest": 0,
        "keypoolsize": 0,
        "unlocked_until": 0,
        "paytxfee": 0,
        "height": 50
      }
    }
    

    Get basic wallet details.

    Params

    N. Name Default Description
    None.

    fundrawtransaction

    let tx;
    let options={"changeAddress": "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3", "feeRate": 0.001000};
    
    tx='0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420ccf0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722510fce9f37f0423b88ac00000000'
    
    options='{"changeAddress": "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3", "feeRate": 0.001000}'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "fundrawtransaction",
        "params": [ "'$tx'", '"$options"']
      }'
    
    options='{"changeAddress": "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3", "feeRate": 0.001000}'
    
    hsw-rpc fundrawtransaction $tx "$options"
    
    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.execute('fundrawtransaction', [tx, options]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    
    

    Add inputs to a transaction until it has enough in value to meet its out value.

    Params

    N. Name Default Description
    1 hexstring Required raw transaction
    2 options Optional Object containing options

    Options

    Option Description
    feeRate Sets fee rate for transaction in HNS/kb
    changeAddress Handshake address for change output of transaction

    resendwallettransactions

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "resendwallettransactions" }'
    
    hsw-rpc resendwallettransactions
    
    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.execute('resendwallettransactions');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      "147c2527e2bb7ddfa855cc4b933ab288e05aa7816c487db69db344971f1b0951",
      "c3c92d6686442755d70d2ea44401437d9fab51bc7a504b041d6d6b950ba45e85",
      "77f09f2f307aaa62c8d36a9b8efeac368381c84ebd195e8aabc8ba3023ade390",
      "2c0fa5740c494e8c86637c1fad645511d0379d3b6f18f84c1e8f7b6a040a399c",
      "ef38a6b68afe74f637c1e1bc605f7dc810ef50c6f475a0a978bac9546cac25d8",
      "1146d21bb5c46f1de745d9def68dafe97bbf917fe0f32cef31937731865f10e9"
    ]
    

    Re-broadcasts all unconfirmed transactions to the network.

    Params

    N. Name Default Description
    None.

    abandontransaction

    let tx;
    
    tx='a0a65cd0508450e8acae76f35ae622e7b1e7980e95f50026b98b2c6e025dae6c'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "abandontransaction",
        "params": [ "'$tx'" ]
      }'
    
    hsw-rpc abandontransaction $tx
    
    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.execute('abandontransaction', [tx]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Remove transaction from the database. This allows "stuck" coins to be respent.

    Params

    N. Name Default Description
    1 txid Required Transaction ID to remove

    backupwallet

    let path;
    
    path='/home/user/WalletBackup'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "backupwallet",
        "params": [ "'$path'" ]
      }'
    
    hsw-rpc backupwallet $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.execute('backupwallet', [path]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Back up wallet database and files to directory created at specified path.

    Params

    N. Name Default Description
    1 path Required Absolute path (including directories and filename) to write backup file

    dumpprivkey

    let address;
    
    address='rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "dumpprivkey",
        "params": [ "'$address'" ]
      }'
    
    hsw-rpc dumpprivkey $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);
    
    (async () => {
      const result = await walletClient.execute('dumpprivkey', [address]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    cNRiqwzRfcUfokNV8nSnDKb3NsKPhfRV2z5kBN11GKFb3GXkk1Hj
    

    Get the private key (WIF format) corresponding to specified address. Also see importprivkey

    Params

    N. Name Default Description
    1 address Required Reveal the private key for this Handshake address

    dumpwallet

    let path;
    
    path='/home/user-1/secretfiles/dump1.txt'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "dumpwallet",
        "params": [ "'$path'" ]
      }'
    
    hsw-rpc dumpwallet $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.execute('dumpwallet', [path]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    The contents of the wallet dump file are formatted like this:

    # Wallet Dump created by hsd 2.0.1
    # * Created on 2019-10-22T18:29:15Z
    # * Best block at time of backup was 845 (72365e9f4b4ed638bb1600116a67e3fa59b6ad6be2a449b675db607a984da4f8).
    # * File: /home/user-1/secretfiles/dump1.txt
    
    cNUUoZYmUGoJyodrNaohzfu6LmKy7pBk6yqubJcTeL5WPWw97DQ1 2019-10-22T18:29:15Z label= addr=mg54SV2ZubNQ5urTbd42mUsQ54byPvSg5j
    cNH7YBw6haTB3yWkAndoPhwXRLNibXjWAYpqRQdvqPKLeW7JAj6h 2019-10-22T18:29:15Z change=1 addr=mgj4oGTbvCHxvx4EESYJKPkXWamxh2R6ef
    cNmBeL4kpjLtNZcvjSezftq4ks6ajzZRi1z2AGpuBGy6XjxzytiQ 2019-10-22T18:29:15Z label= addr=mhX1xHbKGzw3r8FoN5bUkmRixHPEDNywxh
    cUEfRrvPpKCy87QReCmPmd74Hz68kgZEHAErkuvEDFqwJKcCLsMn 2019-10-22T18:29:15Z label= addr=mhcx3M1AitoiwDQS3sz42CQLpVCEVkJLfq
    cP4N8mxe81DhZfrgTz2GoV3croXD2o6Hern4DTB6Gr5jUwoLkT8h 2019-10-22T18:29:15Z change=1 addr=mhpSYq8bnM5XJVbpafdLNUtLZefr2d6xSq
    ...
    
    # End of dump
    

    Creates a new human-readable file at specified path with all wallet private keys in Wallet Import Format (base58).

    Params

    N. Name Default Description
    1 path Required Absolute path (including directories and filename) to write backup file

    encryptwallet

    let passphrase;
    
    passphrase='bikeshed'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "encryptwallet",
        "params": [ "'$passphrase'" ]
      }'
    
    hsw-rpc encryptwallet $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);
    
    (async () => {
      const result = await walletClient.execute('encryptwallet', [passphrase]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    wallet encrypted; we do not need to stop!
    

    Encrypts wallet with provided passphrase. This action can only be done once on an unencrypted wallet. See walletpassphrasechange or change passphrase if wallet has already been encrypted.

    Params

    N. Name Default Description
    1 passphrase Required Strong passphrase with which to encrypt wallet

    getaccountaddress

    let account;
    
    account='default'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getaccountaddress",
        "params": [ "'$account'" ]
      }'
    
    hsw-rpc getaccountaddress $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);
    
    (async () => {
      const result = await walletClient.execute('getaccountaddress', [account]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3
    

    Get the current receiving address for specified account.

    Params

    N. Name Default Description
    1 account Required Account to retrieve address from

    getaccount

    let address;
    
    address='rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getaccount",
        "params": [ "'$address'" ]
      }'
    
    hsw-rpc getaccount $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);
    
    (async () => {
      const result = await walletClient.execute('getaccount', [address]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    default
    

    Get the account associated with a specified address.

    Params

    N. Name Default Description
    1 address Required Address to search for

    getaddressesbyaccount

    let account;
    
    account='default'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getaddressesbyaccount",
        "params": [ "'$account'" ]
      }'
    
    hsw-rpc getaddressesbyaccount $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);
    
    (async () => {
      const result = await walletClient.execute('getaddressesbyaccount', [account]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3",
      "rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye",
      "rs1q9jd8fgq8xa0drggyd6azggpeslacdzx5gr04ss",
      ...
    ]
    

    Get all addresses for a specified account.

    Params

    N. Name Default Description
    1 account Required Account name

    getbalance

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "getbalance" }'
    
    hsw-rpc getbalance 
    
    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.execute('getbalance');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    50.012058
    

    Get total balance for entire wallet or a single, specified account.

    Params

    N. Name Default Description
    1 account Optional Account name

    getnewaddress

    let account;
    
    account='default'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getnewaddress",
        "params": [ "'$account'" ]
      }'
    
    hsw-rpc getnewaddress $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);
    
    (async () => {
      const result = await walletClient.execute('getnewaddress', [account]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3
    

    Get the next receiving address from specified account, or default account.

    Params

    N. Name Default Description
    1 account Optional Account name

    getrawchangeaddress

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "getrawchangeaddress" }'
    
    hsw-rpc getrawchangeaddress
    
    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.execute('getrawchangeaddress');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3
    

    Get the next change address from specified account.

    Params

    N. Name Default Description
    None.

    getreceivedbyaccount

    let account, minconf;
    
    account='default'
    minconf=6
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getreceivedbyaccount",
        "params": [ "'$account'", '$minconf' ]
      }'
    
    hsw-rpc getreceivedbyaccount $account $minconf
    
    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.execute('getreceivedbyaccount', [account, minconf]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    50.001234
    

    Get total amount received by specified account. Optionally only count transactions with minconf number of confirmations.

    Params

    N. Name Default Description
    1 account Required Account name
    2 minconf Optional Only include transactions with this many confirmations

    getreceivedbyaddress

    let address, minconf;
    
    address='rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3'
    minconf=6
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "getreceivedbyaddress",
        "params": [ "'$address'", '$minconf' ]
      }'
    
    hsw-rpc getreceivedbyaddress $address $minconf
    
    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.execute('getreceivedbyaddress', [address, minconf]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    50.001234
    

    Get total amount received by specified address. Optionally only count transactions with minconf number of confirmations.

    Params

    N. Name Default Description
    1 address Required Address to request balance of
    2 minconf Optional Only include transactions with this many confirmations

    gettransaction

    let address, minconf;
    
    txid='36cbb7ad0cc98ca86640a04c485f164dd741c20339af34516d359ecba2892c21'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "gettransaction",
        "params": [ "'$txid'" ]
      }'
    
    hsw-rpc gettransaction $txid
    
    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.execute('gettransaction', [txid]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "amount": 0,
      "blockhash": "5c00755bf5b4cede330ae0f1ec68e0656d1c576ff4cdfed4404dc9d6fac5641c",
      "blocktime": 1580999686,
      "txid": "1e426d5914f2dcac62ac1eba1bd4e4c7d070a08802acf1ec3cc85ef580f18609",
      "walletconflicts": [],
      "time": 1580997713,
      "timereceived": 1580997713,
      "bip125-replaceable": "no",
      "details": [
        {
          "account": "default",
          "address": "rs1qqf90c9tycnr74ahvtdjhv7jfxa6vwxjqmepymv",
          "category": "receive",
          "amount": 0,
          "label": "default",
          "vout": 0
        }
      ],
      "hex": "0000000001575b771894c8be6da7fe86111190b97cf30333cccc8ea7d33fcad2733bf25bea00000000ffffffff0200000000000000000014024afc1564c4c7eaf6ec5b65767a493774c71a40020320e7a31a66848e215f978d8354f09ef148f17e1aa0812584dee98a128e9ec9222a0400000000056272656164c498357700000000001488dbfe1341aff133fed3e9ac26c5fa37c3591c0b0000000000000241b9c26b6583117bfbfae894052336139a5233a1903b53e0fe9346eed546c7ea7d7c8833d320860ea315dd854fcd1c99201223f787cf8619b158acbc76b976d711012102737c83b6d4f0e5ef855908de87a62f68992881581f1659549c9ad43035d692f9"
    }
    

    Get details about a transaction in the wallet.

    Params

    N. Name Default Description
    1 txid Required ID of transaction to fetch
    2 watchonly Optional (bool) Whether to include watch-only addresses in balance details

    getunconfirmedbalance

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "getunconfirmedbalance" }'
    
    hsw-rpc getunconfirmedbalance
    
    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.execute('getunconfirmedbalance');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    50
    

    Get the unconfirmed balance from the wallet.

    Params

    N. Name Default Description
    None.

    importprivkey

    let key, label, rescan;
    
    key='cNH7YBw6haTB3yWkAndoPhwXRLNibXjWAYpqRQdvqPKLeW7JAj6h'
    label='this_is_ignored'
    rescan=false
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "importprivkey",
        "params": [ "'$key'", "'$label'", '$rescan' ]
      }'
    
    hsw-rpc importprivkey $key $label $rescan
    
    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.execute('importprivkey', [key, label, rescan]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Import a private key into wallet. Also see dumpprivkey.

    Params

    N. Name Default Description
    1 key Required Private key to import (WIF format)
    2 label Optional Ignored but required if additional parameters are passed
    3 rescan Optional (bool) Whether to rescan wallet after importing

    importwallet

    let file, rescan;
    
    file='/home/user/WalletDump'
    rescan=false
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "importwallet",
        "params": [ "'$file'", '$rescan' ]
      }'
    
    hsw-rpc importwallet $file $rescan
    
    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.execute('importwallet', [file, rescan]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Import all keys from a wallet backup file. Also see dumpwallet.

    Params

    N. Name Default Description
    1 file Required Path to wallet file
    2 rescan Optional (bool) Whether to rescan wallet after importing

    importaddress

    let address;
    
    address='rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "importaddress",
        "params": [ "'$address'" ]
      }'
    
    hsw-rpc importaddress $address
    
    # P2SH example, imports script as address rs1qdph22fv5u38yqdpqza94n5gqfwnc5t9e9uhcl7rtnezn66t22fwswttnsx
    hsw-rpc importaddress 76a9145e50fb5b7475ebe2f7276ed3f29662e5321d1d7288ac "this_is_ignored" true true
    
    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.execute('importaddress', [address]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Import address to a watch-only wallet. May also import a Handshake output script (in hex) as pay-to-script-hash (P2WSH) address.

    Params

    N. Name Default Description
    1 address Required Address to watch in wallet
    2 label Optional Ignored but required if additional parameters are passed
    3 rescan Optional (bool) Whether to rescan wallet after importing
    4 p2sh Optional (bool) Whether to generate P2SH address from given script

    importprunedfunds

    let rawtx, txoutproof;
    
    rawtx='01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1e510e6d696e65642062792062636f696e048e0e9256080000000000000000ffffffff0100f2052a010000001976a9145e50fb5b7475ebe2f7276ed3f29662e5321d1d7288ac00000000'
    txoutproof='0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f212c89a2cb9e356d5134af3903c241d74d165f484ca04066a88cc90cadb7cb36e749355bffff7f20040000000100000001212c89a2cb9e356d5134af3903c241d74d165f484ca04066a88cc90cadb7cb360101'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "importprunedfunds",
        "params": [ "'$rawtx'", "'$txoutproof'" ]
      }'
    
    hsw-rpc importprunedfunds $rawtx $txoutproof
    
    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.execute('importprunedfunds', [rawtx, txoutproof]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Imports funds (without rescan) into pruned wallets. Corresponding address or script must previously be included in wallet. Does NOT check if imported coins are already spent, rescan may be required after the point in time in which the specified transaciton was included in the blockchain. See gettxoutproof and removeprunedfunds.

    Params

    N. Name Default Description
    1 rawtx Required Raw transaction in hex that funds an address already in the wallet
    2 txoutproof Required Hex output from gettxoutproof containing the tx

    importpubkey

    let pubkey;
    
    pubkey='02548e0a23b90505f1b4017f52cf2beeaa399fce7ff2961e29570c6afdfa9bfc5b'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "importpubkey",
        "params": [ "'$pubkey'" ]
      }'
    
    hsw-rpc importpubkey $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);
    
    (async () => {
      const result = await walletClient.execute('importpubkey', [pubkey]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Import public key to a watch-only wallet.

    Params

    N. Name Default Description
    1 pubkey Required Hex-encoded public key
    2 label Optional Ignored but required if additional parameters are passed
    3 rescan Optional (bool) Whether to rescan wallet after importing

    listaccounts

    let minconf, watchonly;
    
    minconf=6
    watchonly=false
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listaccounts",
        "params": [ '$minconf', '$watchonly' ]
      }'
    
    hsw-rpc listaccounts $minconf $watchonly
    
    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.execute('listaccounts', [minconf, watchonly]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "default": 46.876028,
      "savings": 9.373432
    }
    

    Get list of account names and balances.

    Params

    N. Name Default Description
    1 minconf Optional Minimum confirmations for transaction to be included in balance
    2 watchonly Optional (bool) Include watch-only addresses

    listaddressgroupings

    Not implemented.

    lockunspent

    let unlock, outputs;
    outputs=[{ "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72", "vout": 1 }];
    
    unlock=false
    
    outputs='[{ "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72", "vout": 1 }]'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "lockunspent",
        "params": [ '$unlock', '"$outputs"' ]
      }'
    
    outputs='[{ "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72", "vout": 1 }]'
    
    hsw-rpc lockunspent $unlock "$outputs"
    
    # unlock all coins
    hsw-rpc lockunspent true
    
    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.execute('lockunspent', [unlock, outputs]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Lock or unlock specified transaction outputs. If no outputs are specified, ALL coins will be unlocked (unlock only).

    Params

    N. Name Default Description
    1 unlock Required (bool) true = unlock coins, false = lock coins
    2 outputs Optional Array of outputs to lock or unlock

    listlockunspent

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "listlockunspent" }'
    
    hsw-rpc listlockunspent
    
    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.execute('listlockunspent');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72",
        "vout": 1
      }
    ]
    

    Get list of currently locked (unspendable) outputs. See lockunspent and lock-coin-outpoints.

    Params

    N. Name Default Description
    None.

    listreceivedbyaccount

    let minconf, includeEmpty, watchOnly;
    
    minconf=1
    includeEmpty=true
    watchOnly=true
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listreceivedbyaccount",
        "params": [ '$minconf', '$includeEmpty', '$watchOnly' ]
      }'
    
    hsw-rpc listreceivedbyaccount $minconf $includeEmpty $watchOnly
    
    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.execute('listreceivedbyaccount', [minconf, includeEmpty, watchOnly]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "involvesWatchonly": false,
        "account": "hot",
        "amount": 6.250004,
        "confirmations": 0,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "account": "default",
        "amount": 96.876528,
        "confirmations": 0,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "account": "savings",
        "amount": 9.373452,
        "confirmations": 0,
        "label": ""
      }
    ]
    

    Get balances for all accounts in wallet.

    Params

    N. Name Default Description
    1 minconf Optional Minimum confirmations required to count a transaction
    2 includeEmpty Optional (bool) Whether to include accounts with zero balance
    3 watchOnly Optional (bool) Whether to include watch-only addresses

    listreceivedbyaddress

    let minconf, includeEmpty, watchOnly;
    
    minconf=1
    includeEmpty=false
    watchOnly=false
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listreceivedbyaddress",
        "params": [ '$minconf', '$includeEmpty', '$watchOnly' ]
      }'
    
    hsw-rpc listreceivedbyaddress $minconf $includeEmpty $watchOnly 
    
    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.execute('listreceivedbyaddress', [minconf, includeEmpty, watchOnly]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "involvesWatchonly": false,
        "address": "rs1qu76q03eh26j9c6zet63w859qu7eprdgkx29eu9",
        "account": "default",
        "amount": 2000,
        "confirmations": 260,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "address": "rs1qarnfdzqpuxmh224s9fqnf20msnwpa88av7hdvw",
        "account": "default",
        "amount": 2000.00022,
        "confirmations": 280,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "address": "rs1q7w7qm0cjtsxnkkssjxs05ud4jyfgwsgrundcw6",
        "account": "default",
        "amount": 280000.04264,
        "confirmations": 1361,
        "label": ""
      },
      ...
    ]
    

    Get balances for all addresses in wallet.

    Params

    N. Name Default Description
    1 minconf Optional Minimum confirmations required to count a transaction
    2 includeEmpty Optional (bool) Whether to include addresses with zero balance
    3 watchOnly Optional (bool) Whether to include watch-only addresses

    listsinceblock

    let block, minconf, watchOnly;
    
    block='584aec6d0cbb033bbe0423ac9cff0249a0e0adc4d67dab79e244558175dd94d8'
    minconf=1
    watchOnly=false
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listsinceblock",
        "params": [ "'$block'", '$minconf', '$watchOnly' ]
      }'
    
    hsw-rpc listsinceblock $block $minconf $watchOnly 
    
    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.execute('listsinceblock', [block, minconf, watchOnly]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "transactions": [
        {
          "account": "default",
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl",
          "category": "receive",
          "amount": 2000,
          "label": "default",
          "vout": 0,
          "confirmations": 520,
          "blockhash": "26f5d8379fee2ac3a2434acf00e73bb0539d9af20ba6860bee430ad9e0df548f",
          "blockindex": -1,
          "blocktime": 1580929964,
          "blockheight": 1081,
          "txid": "ff09bd1a48a2682d157cb391b3a53ef5efcea50641d4199d12d62b438833f150",
          "walletconflicts": [],
          "time": 1580929833,
          "timereceived": 1580929833
        },
        {
          "account": "default",
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl",
          "category": "receive",
          "amount": 2000,
          "label": "default",
          "vout": 0,
          "confirmations": 537,
          "blockhash": "040a79d7a441e6c111153fc0c951b050b921ce2866b41845988afa5f387fe947",
          "blockindex": -1,
          "blocktime": 1580929961,
          "blockheight": 1064,
          "txid": "ff7daf0e76feddf1299fe948511b3247b7d9ff71157d4b8c9a3538e54384bac5",
          "walletconflicts": [],
          "time": 1580929833,
          "timereceived": 1580929833
        },
        {
          "account": "default",
          "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl",
          "category": "receive",
          "amount": 2000,
          "label": "default",
          "vout": 0,
          "confirmations": 481,
          "blockhash": "739342930f4216b8065a4e833d0d78170b6fb67c129036000dbb9a9d67dca865",
          "blockindex": -1,
          "blocktime": 1580929970,
          "blockheight": 1120,
          "txid": "fff4047ac27acb9bdf20128a4558b563eb9838ea328908d06194cbaf323f488e",
          "walletconflicts": [],
          "time": 1580929833,
          "timereceived": 1580929833
        }
      ],
      "lastblock": "584aec6d0cbb033bbe0423ac9cff0249a0e0adc4d67dab79e244558175dd94d8"
    }
    

    Get all transactions in blocks since a block specified by hash, or all transactions if no block is specifiied.

    Params

    N. Name Default Description
    1 block Optional Hash of earliest block to start listing from
    2 minconf Optional Minimum confirmations required to count a transaction
    3 watchOnly Optional (bool) Whether to include watch-only addresses

    listtransactions

    let account, count, from, watchOnly;
    
    account='hot'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listtransactions",
        "params": [ "'$account'" ]
      }'
    
    hsw-rpc listtransactions $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);
    
    (async () => {
      const result = await walletClient.execute('listtransactions', [account]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "account": "default",
        "address": "rs1q7w7qm0cjtsxnkkssjxs05ud4jyfgwsgrundcw6",
        "category": "receive",
        "amount": 2000,
        "label": "default",
        "vout": 0,
        "confirmations": 1497,
        "blockhash": "7295cec3fd81a2c2ddddf3faf6c000614b429ae0f8c1b2ef83ec937ac227d8e1",
        "blockindex": -1,
        "blocktime": 1580917307,
        "blockheight": 104,
        "txid": "adb098a6b38e7c4b2dd0af454f0c9537a3ec735a0b84c3d20b6f241768be12f2",
        "walletconflicts": [],
        "time": 1580917307,
        "timereceived": 1580917307
      },
      {
        "account": "default",
        "address": "rs1q7w7qm0cjtsxnkkssjxs05ud4jyfgwsgrundcw6",
        "category": "receive",
        "amount": 2000,
        "label": "default",
        "vout": 0,
        "confirmations": 1499,
        "blockhash": "0e7cc9e0dff3d0b3322cec63dad7160fc68a4e7ec3e7a32b5aa84418dfdb7d7c",
        "blockindex": -1,
        "blocktime": 1580917305,
        "blockheight": 102,
        "txid": "c256c4d550227f5ecd3d6f2af2e9d7005738f5b7b93c62f73746d68f067e9041",
        "walletconflicts": [],
        "time": 1580917307,
        "timereceived": 1580917307
      },
      {
        "account": "default",
        "address": "rs1q7w7qm0cjtsxnkkssjxs05ud4jyfgwsgrundcw6",
        "category": "receive",
        "amount": 2000,
        "label": "default",
        "vout": 0,
        "confirmations": 1492,
        "blockhash": "167fc99c384ee2ab6e2e3b0a32f4d0d979aaf99cc3b285fbf642f704a6a939c3",
        "blockindex": -1,
        "blocktime": 1580917308,
        "blockheight": 109,
        "txid": "cfef79516a5f0159ec95a49e5ec25295315dafcbbed408d2a13a0aec05005953",
        "walletconflicts": [],
        "time": 1580917307,
        "timereceived": 1580917307
      }
    ]
    

    Get all recent transactions for specified account up to a limit, starting from a specified index.

    Params

    N. Name Default Description
    1 account Optional Account name
    2 count Optional Max number of transactions to return
    3 from Optional Number of oldest transactions to skip
    4 watchOnly Optional Whether to include watch-only addresses

    listunspent

    let minconf, maxconf, addrs;
    addrs=["rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"];
    
    minconf=0
    maxconf=20
    
    addrs='["rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"]'
    
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "listunspent",
        "params": [ '$minconf', '$maxconf', '"$addrs"' ]
      }'
    
    addrs='["rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl"]'
    
    hsw-rpc listunspent $minconf $maxconf $addrs
    
    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.execute('listunspent', [minconf, maxconf, addrs]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    [
      {
        "txid": "7f57842a6d03adfe064590db2ab735e600a10e66d5942dac79cf451ddae83fc6",
        "vout": 0,
        "address": "rs1q3qm3e6sxd0mzax54jx6p3th0p2adzxdx2tm3zl",
        "account": "default",
        "amount": 2000,
        "confirmations": 1,
        "spendable": true,
        "solvable": true
      }
    ]
    

    Get unsepnt transaction outputs from all addreses, or a specific set of addresses.

    Params

    N. Name Default Description
    1 minconf Optional Minimum confirmations required to return tx
    2 maxconf Optional Maximum confirmations required to return tx
    3 addrs Optional Array of addresses to filter

    sendfrom

    let fromaccount, toaddress, amount;
    
    fromaccount='hot'
    toaddress='rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3'
    amount=0.0195
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "sendfrom",
        "params": [ "'$fromaccount'", "'$toaddress'", '$amount' ]
      }'
    
    hsw-rpc sendfrom $fromaccount $toaddress $amount
    
    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.execute('sendfrom', [fromaccount, toaddress, amount]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    94f8a6dbaea9b5863d03d3b606c24e2e588d9e82564972148d54058660308e6a
    

    Send HNS from an account to an address.

    Params

    N. Name Default Description
    1 fromaccount Required Wallet account to spend outputs from
    2 toaddress Required Handshake address to send funds to
    3 amount Required Amount (in HNS) to send
    4 minconf Optional Minimum confirmations for output to be spent from

    sendmany

    let fromaccount, outputs, minconf, label, subtractFee;
    outputs={"rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye": 0.123, "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3": 0.321}
    
    fromaccount='hot'
    minconf=1
    label="this_is_ignored"
    subtractfee=false
    
    outputs='{"rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye": 0.123, "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3": 0.321}'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "sendmany",
        "params": [ "'$fromaccount'", '"$outputs"', '$minconf', "'$label'", '$subtractfee' ]
      }'
    
    outputs='{"rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye": 0.123, "rs1qew8r8c2c74zpmkhwmxu6jkrhwmgegl5h6cfaz3": 0.321}'
    
    hsw-rpc sendmany $fromaccount "$outputs" $minconf $label $subtractfee
    
    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.execute('sendmany', [fromaccount, outputs, minconf, label, subtractfee]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    121d1e44f8125f02433e96c7b672a34af00be9906895f0ee51aaf504f4d76b78
    

    Send different amounts of HNS from an account to multiple addresses.

    Params

    N. Name Default Description
    1 fromaccount Required Wallet account to spend outputs from
    2 outputs Required Array of Handshake addresses and amounts to send
    3 minconf Optional Minimum confirmations for output to be spent from
    5 label Optional Ignored but required if additional parameters are passed
    6 subtractfee Optional (bool) Subtract the transaction fee equally from the output amounts

    createsendtoaddress

    let address, amount, comment, comment_to, subtractFee;
    
    address='rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye'
    amount=1.010101
    comment="this_is_ignored"
    comment_to="this_is_ignored"
    subtractfee=true
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "createsendtoaddress",
        "params": [ "'$address'", '$amount', "'$comment'", "'$comment_to'", '$subtractfee' ]
      }'
    
    hsw-rpc createsendtoaddress $address $amount $comment $commnt_to $subtractfee
    
    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.execute('createsendtoaddress', [address, amount, comment, comment_to, subtractfee]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hash": "5be265aa80f064cbb59e94cb11f6e776a86c7d2d38e0312e37ba68fada837f8c",
      "witnessHash": "26f507c272f678600477dae02dc0a9387235061cf5adb770d554a5b7ad2c52e2",
      "fee": 2800,
      "rate": 22764,
      "mtime": 1613139645,
      "version": 0,
      "inputs": [
        {
          "prevout": {
            "hash": "0028bf4d6f924f3d0fd814fe8676cff797645e259641bf5d6a6dad4a3898bcd2",
            "index": 0
          },
          "witness": [
            "",
            "0265154cccfb952c96ed76985d1c02a660aca300a936fc2407bfb51abfbb9c0e5f"
          ],
          "sequence": 4294967295,
          "coin": {
            "version": 0,
            "height": 316,
            "value": 2000000000,
            "address": "rs1q9454p2e89yrywvatjq64rhl2lr89ule6zr887p",
            "covenant": {
              "type": 0,
              "action": "NONE",
              "items": []
            },
            "coinbase": true
          },
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/44'/5355'/0'/0/11"
          }
        }
      ],
      "outputs": [
        {
          "value": 1010101,
          "address": "rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        },
        {
          "value": 1998987099,
          "address": "rs1qepurdt8x5p7d69mgma5pyepxm6d47gw4sa3tg3",
          "covenant": {
            "type": 0,
            "action": "NONE",
            "items": []
          }
        }
      ],
      "locktime": 0,
      "hex": "00000000010028bf4d6f924f3d0fd814fe8676cff797645e259641bf5d6a6dad4a3898bcd200000000ffffffff02b5690f00000000000014b5b4aad6b9e5a76276a0740b8447328f78aacf5100005b1f2677000000000014c87836ace6a07cdd1768df68126426de9b5f21d50000000000000200210265154cccfb952c96ed76985d1c02a660aca300a936fc2407bfb51abfbb9c0e5f"
    }
    

    Create transaction sending HNS to a given address without signing or broadcasting it.

    Params

    N. Name Default Description
    1 address Required Handshake address to send funds to
    2 amount Required Amount (in HNS) to send
    4 comment Optional Ignored but required if additional parameters are passed
    5 comment_to Optional Ignored but required if additional parameters are passed
    6 subtractfee Optional (bool) Subtract the transaction fee equally from the output amount

    sendtoaddress

    let address, amount, comment, comment_to, subtractFee;
    
    address='rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye'
    amount=1.010101
    comment="this_is_ignored"
    comment_to="this_is_ignored"
    subtractfee=true
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "sendtoaddress",
        "params": [ "'$address'", '$amount', "'$comment'", "'$comment_to'", '$subtractfee' ]
      }'
    
    hsw-rpc sendtoaddress $address $amount $comment $commnt_to $subtractfee
    
    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.execute('sendtoaddress', [address, amount, comment, comment_to, subtractfee]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    552006b288266ab26fa30d9048b758a469a4101fd8235eff2384141ca5cf604d
    

    Send HNS to an address.

    Params

    N. Name Default Description
    1 address Required Handshake address to send funds to
    2 amount Required Amount (in HNS) to send
    4 comment Optional Ignored but required if additional parameters are passed
    5 comment_to Optional Ignored but required if additional parameters are passed
    6 subtractfee Optional (bool) Subtract the transaction fee equally from the output amount

    settxfee

    let rate;
    
    rate=0.001
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "settxfee",
        "params": [ '$rate' ]
      }'
    
    hsw-rpc settxfee $rate
    
    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.execute('settxfee', [rate]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    true
    

    Set the fee rate for all new transactions until the fee is changed again, or set to 0 (will return to automatic fee).

    Params

    N. Name Default Description
    1 rate Required Fee rate in HNS/kB

    signmessage

    let address, message;
    
    address='rs1qkk62444euknkya4qws9cg3ej3au24n635n4qye'
    message='Satoshi'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "signmessage",
        "params": [ "'$address'", "'$message'" ]
      }'
    
    hsw-rpc signmessage $address $message
    
    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.execute('signmessage', [address, message]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    MEUCIQC5Zzr+JoenWHy7m9XxpbDVVeg3DvKvJVQNyYPvLOuB2gIgP/BT3dRItxarNbE8ajEoTI66q3eB4lo+/SLsp7bbP70=
    

    Sign an arbitrary message with the private key corresponding to a specified Handshake address in the wallet.

    Params

    N. Name Default Description
    1 address Required Wallet address to use for signing
    2 message Required The message to sign

    signmessagewithname

    let name, message;
    
    name='handshake'
    message='Satoshi'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "signmessagewithname",
        "params": [ "'$name'", "'$message'" ]
      }'
    
    hsw-rpc signmessagewithname $name $message
    
    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.execute('signmessagewithname', [name, message]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    MEUCIQC5Zzr+JoenWHy7m9XxpbDVVeg3DvKvJVQNyYPvLOuB2gIgP/BT3dRItxarNbE8ajEoTI66q3eB4lo+/SLsp7bbP70=
    

    Sign an arbitrary message with the private key corresponding to a Handshake address that owns the specified name in the wallet.

    Params

    N. Name Default Description
    1 name Required Name to use for signing
    2 message Required The message to sign

    walletlock

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "walletlock" }'
    
    hsw-rpc walletlock
    
    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.execute('walletlock');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Locks the wallet by removing the decryption key from memory. See walletpassphrase.

    Params

    N. Name Default Description
    None.

    walletpassphrasechange

    let old, passphrase;
    
    old='OneTwoThreeFour'
    passphrase='CorrectHorseBatteryStaple'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "walletpassphrasechange",
        "params": [ "'$old'", "'$passphrase'" ]
      }'
    
    hsw-rpc walletpassphrasechange $old $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);
    
    (async () => {
      const result = await walletClient.execute('walletpassphrasechange', [old, passphrase]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Change the wallet encryption pasphrase

    Params

    N. Name Default Description
    1 old Required The current wallet passphrase
    2 passphrase Required New passphrase

    walletpassphrase

    let passphrase, timeout;
    
    passphrase='CorrectHorseBatteryStaple'
    timeout=600
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "walletpassphrase",
        "params": [ "'$passphrase'", '$timeout' ]
      }'
    
    hsw-rpc walletpassphrase $passphrase $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);
    
    (async () => {
      const result = await walletClient.execute('walletpassphrase', [passphrase, timeout]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Store wallet decryption key in memory, unlocking the wallet keys.

    Params

    N. Name Default Description
    1 passphrase Required The current wallet passphrase
    2 timeout Required Amount of time in seconds decryption key will stay in memory

    removeprunedfunds

    let txid;
    
    txid='6478cafe0c91e5ed4c55ade3b1726209caa0d290c8a3a84cc345caad60073ad5'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "removeprunedfunds",
        "params": [ "'$txid'" ]
      }'
    
    hsw-rpc removeprunedfunds $txid
    
    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.execute('removeprunedfunds', [txid]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Deletes the specified transaction from the wallet database. See importprunedfunds.

    Params

    N. Name Default Description
    1 txid Required txid of the transaction to remove

    wallet getmemoryinfo

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "getmemoryinfo" }'
    
    hsw-rpc getmemoryinfo
    
    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.execute('getmemoryinfo');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "total": 133,
      "jsHeap": 17,
      "jsHeapTotal": 20,
      "nativeHeap": 112,
      "external": 30
    }
    

    Get information about memory usage. Identical to node RPC call getmemoryinfo.

    Params

    N. Name Default Description
    None.

    wallet setloglevel

    let level;
    
    level='debug'
    
    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{
        "method": "setloglevel",
        "params": [ "'$level'" ]
      }'
    
    hsw-rpc setloglevel $level
    
    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.execute('setloglevel', [level]);
      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

    wallet stop

    curl http://x:api-key@127.0.0.1:14039 \
      -X POST \
      --data '{ "method": "stop" }'
    
    hsw-rpc stop
    
    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.execute('stop');
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    "Stopping."
    

    Closes the wallet database.

    Params

    N. Name Default Description
    None.

    Sockets

    Socket events use the socket.io protocol.

    Socket IO implementations:

    bsock is a minimal websocket-only implementation of the socket.io protocol, complete with ES6/ES7 features, developed by the bcoin team. bsock is used throughout the bcoin and hsd ecosystem including hs-client. Examples below describe usage with bsock specifically.

    For a deeper dive into events and sockets in hsd, including a tutorial on using bsock and hs-client, see the handshake.org Events and Sockets Guide.

    Node Sockets

    Node sockets - bsock

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {ChainEntry, TX} = require('hsd');
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    // Authenticate and subscribe to channels after connection
    nodeSocket.on('connect', async () => {
      // Auth
      await nodeSocket.call('auth', '<api-key>');
    
      // Subscribe to chain events to listen for blocks
      await nodeSocket.call('watch chain');
    
      // Subscribe to mempool events to listen for transactions
      await nodeSocket.call('watch mempool');
    });
    
    // Listen for new blocks -- from chain channel
    nodeSocket.bind('chain connect', (raw) => {
      console.log('Node -- Chain Connect Event:\n', ChainEntry.fromRaw(raw));
    });
    
    // Listen for new transactions -- from mempool channel (bloom filter required)
    nodeSocket.bind('tx', (raw) => {
      console.log('Node -- TX Event:\n', TX.fromRaw(raw));
    });
    

    Node Socket Authentication

    Authentication with the API server must be completed before any other events will be accepted.

    Joining a channel

    Instead of joining wallets, the node server offers two "channels" of events: chain and mempool. When the node has no mempool (for example in SPV mode) transaction events will be relayed from the pool of peers instead. In both channels, transactions are only returned if they match a bloom filter sent in advance (see set filter).

    Listening for events

    Unlike the wallet events, data returned by node events are not converted into JSON format. The results are raw Buffers or arrays of Buffers. Be sure to observe how the examples use library modules from hsd and fromRaw() methods to recreate the objects. The only exception to this is get name.

    Making calls

    The node socket server can also respond to more calls than the wallet socket server.

    Node sockets - hs-client

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {NodeClient} = require('hs-client');
    const {Network, ChainEntry} = require('hsd');
    const network = Network.get('regtest');
    
    const nodeOptions = {
      port: network.rpcPort,
      apiKey: '<api-key>'
    }
    
    const nodeClient = new NodeClient(nodeOptions);
    
    (async () => {
      // Connection and both channel subscriptions handled by opening client
      await nodeClient.open();
    })();
    
    // Listen for new blocks
    nodeClient.bind('chain connect', (raw) => {
      console.log('Node -- Chain Connect Event:\n', ChainEntry.fromRaw(raw));
    });
    

    hs-client abstracts away the connection, subscription, and authentication steps to make listening for events much easier.

    Node sockets - Calls

    watch chain

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    nodeSocket.on('connect', async () => {
      // Auth
      await nodeSocket.call('auth', '<api-key>');
    
      // Subscribe to chain events to listen for blocks
      await nodeSocket.call('watch chain');
    });
    

    Subscribe to chain events:

    chain connect

    block connect

    chain disconnect

    block disconnect

    chain reset

    Unsubscribe by calling unwatch chain.

    watch mempool

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    nodeSocket.on('connect', async () => {
      // Auth
      await nodeSocket.call('auth', '<api-key>');
    
      // Subscribe to chain events to listen for blocks
      await nodeSocket.call('watch mempool');
    });
    

    Subscribe to mempool/pool events:

    tx

    Unsubscribe by calling unwatch mempool.

    set filter

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {Address} = require('hsd');
    const {BloomFilter} = require('bfilter');
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
    
      // Create new Bloom filter with standard false-positive parameters
      const filter = BloomFilter.fromRate(20000, 0.001, BloomFilter.flags.ALL);
    
      // Add address hash to Bloom filter
      const addr = Address.fromString('rs1qyf5f64rz9e5ngz3us34s0lm22wez5vjlmv8zp5', 'regtest');
      filter.add(addr.getHash());
    
      // Send the entire serialized BloomFilter to server.
      nodeSocket.call('set filter', filter.encode());
    })();
    

    Load a bloom filter to the node socket server. Only transactions matching the filter will be returned. Applies to node tx events and the array of transactions returned by the block connect event.

    add filter

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {Address} = require('hsd');
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
      // Bloom filter set required
    
      // Get address hash
      const addr = Address.fromString('rs1qd0h7e4v7snllsn77z6czsmt70mg6t2zd3zvvph', 'regtest');
    
      // Send to server to add to filter.
      nodeSocket.call('add filter', [addr.getHash()]);
    })();
    

    Add an array of Buffers to the existing Bloom filter. set filter required in advance.

    reset filter

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
      // Bloom filter set required
    
      nodeSocket.call('reset filter');
    })();
    

    Resets the Bloom filter on the server to an empty buffer.

    get tip

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {ChainEntry} = require('hsd');
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
    
      const tip = nodeSocket.call('get tip');
      console.log(ChainEntry.fromRaw(tip));
    })();
    

    Returns the chain tip.

    get entry

    (See JavaScript example)
    
    (See JavaScript example)
    
    const {ChainEntry} = require('hsd');
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<regtest node RPC port>');
    
    (async () => {
      // Authentication required
    
      // Get the regtest genesis block by its hash
      const hash = Buffer.from('0d01d7d33445511df6b6db9c17ada717a91b5fa557d057befd29d26701d4b8a2', 'hex')
      const entryByHash = await nodeSocket.call('get entry', hash);
      console.log(ChainEntry.fromRaw(entryByHash));
    
      // Get block at height 5
      const entryByHeight = await nodeSocket.call('get entry', 5);
      console.log(ChainEntry.fromRaw(entryByHeight));
    })();
    

    Returns a chain entry requested by block hash or by integer height. No response if entry is not found.

    get hashes

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
    
      // Get all block hashes from height 10 through 20
      const hashes = await nodeSocket.call('get hashes', 10, 20);
      console.log(hashes);
    })();
    

    Returns an array of block hashes (as Buffers) in the specified range of height (inclusive).

    estimate fee

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
    
      // Request fee estimation for inclusion within 6 blocks
      const estimate = await nodeSocket.call('estimate fee', 6);
      console.log(estimate);
    })();
    

    Returns an estimated fee rate (in dollarydoos per kB) necessary to include a transaction in the specified number of blocks.

    send

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<network node RPC port>');
    
    (async () => {
      // Authentication required
    
      // Send raw transaction
      const rawtx = Buffer.from(
        '00000000018694b6d98ed016fc7aef12c6c446ebcd11040ca8d0c6b3e8b7d22c50aa3ad' +
        '71e01000000ffffffff02a086010000000000001422689d54622e69340a3c846b07ff6a' +
        '53b22a325f0000e070327700000000001425852d90b0001a267d5b8afc64c31515bef9b' +
        '8b40000000000000241fa7e967813812156527829358ea76b3e0940b3399634147f812a' +
        'f3346c30768439b427e493e0d7b10caf3be8bb84a5d7a286d6cfa0683230ca69263c388' +
        'fcc8d012102252b10247d1ce7c0505f96e3d633e4ba4b444f3cb5cd04d1b4191459b1c1' +
        'b8e4',
        'hex'
      );
      nodeSocket.call('send', rawtx);
    })();
    

    Send a raw transaction (as Buffer) to node server to broadcast. Server will attempt to broadcast the transaction without any checks.

    send claim

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<regtest node RPC port>');
    
    (async () => {
      // Authentication required
    
    
      // Send claim to be broadcast
      await nodeSocket.call('send claim', <Raw buffer of claim>);
    })();
    

    Send a raw claim transaction (as Buffer) to node to broadcast.

    get name

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<regtest node RPC port>');
    
    (async () => {
      // Authentication required
    
    
      // Get information for the name `hello` by passing its sha3 hash as a Buffer
      const info = await nodeSocket.call(
        'get name',
        Buffer.from(
          '3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392',
          'hex'
        )
      );
      console.log(info)
    })();
    

    Example:

    { 
      name: 'hello',
      nameHash:
       '3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392',
      state: 'CLOSED',
      height: 222,
      renewal: 252,
      owner:
       { hash:
          '4e6c03cc8e5d779457f751603fbcf0518dc97cd284ee6fb131aeb2142e9cb4e1',
         index: 0 },
      value: 0,
      highest: 10000000,
      data: '0000000105776f726c640d0180',
      transfer: 0,
      revoked: 0,
      claimed: 0,
      renewals: 0,
      registered: true,
      expired: false,
      weak: false,
      stats:
       { renewalPeriodStart: 252,
         renewalPeriodEnd: 5252,
         blocksUntilExpire: 4990,
         daysUntilExpire: 34.65 } 
    }
    

    Get namestate of a name, given its sha3 hash as a Buffer. This is the ONLY node server socket call that conviniently converts the return value to JSON.

    rescan

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const nodeSocket = bsock.connect('<regtest node RPC port>');
    
    // Establish a socket hook to process the filter-matched blocks and transactions
    nodeSocket.hook('block rescan', (entry, txs) => {
      // Do something (like update your wallet DB)
    });
    
    (async () => {
      // Authentication required
      // Bloom filter set required
    
      // Rescan the blockchain from height 5
      const entry = await nodeSocket.call('rescan', 5);
    })();
    

    Rescan the chain from the specified integer height OR block hash (as Buffer). Requires Bloom filter. Returns a call back to the client after scanning each block:

    socket.call('block rescan', block, txs)

    Where block is a raw ChainEntry and txs is an array of filter-matched transactions (as Buffers).

    Note that this is NOT a wallet rescan, but the returned data can be used by a client-side wallet to update its state.

    Node sockets - Events

    chain connect

    Example:

    # ChainEntry.fromRaw(raw)
    {
      hash: '6bd658d12d78eb0beeae433eac4260a0869ec148d41faa99a4ae4bda22395b58',
      height: 232,
      version: '10000000',
      prevBlock: '70aa2e0562b1d56205affac0d46617d27b1e1363a8ff488a4f60e2172f0c6a25',
      merkleRoot: '76ca3bc6c5a3e6e7a5fdb5866e3b10875a93fe34718d0a7bfa47c6af5a54723e',
      witnessRoot: '5a55edd233ae732c4dcaeb2ee0f788c8d510858c1ef23f39f195716bb6b0a23d',
      treeRoot: 'cdb49fa8353829452f0cf57dad3ef22554e223ec8d7437027e7811d5a3cb0b82',
      reservedRoot: '0000000000000000000000000000000000000000000000000000000000000000',
      time: 1580412623,
      bits: 545259519,
      nonce: 3,
      extraNonce: '000000000000000000000000000000000000000000000000',
      mask: '0000000000000000000000000000000000000000000000000000000000000000',
      chainwork: '00000000000000000000000000000000000000000000000000000000000001d2'
    }
    

    Channel: chain

    Emitted when a block is added to the chain. Returns raw ChainEntry of new block.

    block connect

    Example:

    # ChainEntry.fromRaw(raw), txs
    {
      hash: '6bd658d12d78eb0beeae433eac4260a0869ec148d41faa99a4ae4bda22395b58',
      height: 232,
      version: '10000000',
      prevBlock: '70aa2e0562b1d56205affac0d46617d27b1e1363a8ff488a4f60e2172f0c6a25',
      merkleRoot: '76ca3bc6c5a3e6e7a5fdb5866e3b10875a93fe34718d0a7bfa47c6af5a54723e',
      witnessRoot: '5a55edd233ae732c4dcaeb2ee0f788c8d510858c1ef23f39f195716bb6b0a23d',
      treeRoot: 'cdb49fa8353829452f0cf57dad3ef22554e223ec8d7437027e7811d5a3cb0b82',
      reservedRoot: '0000000000000000000000000000000000000000000000000000000000000000',
      time: 1580412623,
      bits: 545259519,
      nonce: 3,
      extraNonce: '000000000000000000000000000000000000000000000000',
      mask: '0000000000000000000000000000000000000000000000000000000000000000',
      chainwork: '00000000000000000000000000000000000000000000000000000000000001d2'
    }
    
    [
      <Buffer 00 00 00 00 01 00 00 00 ff ff ff ff 33 4d 8b 58 01 00 94 35 77 ... >
    ]
    

    Channel: chain

    Emitted when a block is added to the chain. Returns raw ChainEntry of new block. If a Bloom filter has been loaded in advance, this call will also return an array of filter-matching transactions (as raw Buffers).

    chain disconnect

    Example:

    # ChainEntry.fromRaw(raw)
    {
      hash: '6bd658d12d78eb0beeae433eac4260a0869ec148d41faa99a4ae4bda22395b58',
      height: 232,
      version: '10000000',
      prevBlock: '70aa2e0562b1d56205affac0d46617d27b1e1363a8ff488a4f60e2172f0c6a25',
      merkleRoot: '76ca3bc6c5a3e6e7a5fdb5866e3b10875a93fe34718d0a7bfa47c6af5a54723e',
      witnessRoot: '5a55edd233ae732c4dcaeb2ee0f788c8d510858c1ef23f39f195716bb6b0a23d',
      treeRoot: 'cdb49fa8353829452f0cf57dad3ef22554e223ec8d7437027e7811d5a3cb0b82',
      reservedRoot: '0000000000000000000000000000000000000000000000000000000000000000',
      time: 1580412623,
      bits: 545259519,
      nonce: 3,
      extraNonce: '000000000000000000000000000000000000000000000000',
      mask: '0000000000000000000000000000000000000000000000000000000000000000',
      chainwork: '00000000000000000000000000000000000000000000000000000000000001d2'
    }
    

    Channel: chain

    Emitted when a block is removed from the chain. Returns raw ChainEntry of the block being removed.

    block disconnect

    Identical to chain disconnect

    chain reset

    Example:

    # ChainEntry.fromRaw(raw)
    {
      hash: '6bd658d12d78eb0beeae433eac4260a0869ec148d41faa99a4ae4bda22395b58',
      height: 232,
      version: '10000000',
      prevBlock: '70aa2e0562b1d56205affac0d46617d27b1e1363a8ff488a4f60e2172f0c6a25',
      merkleRoot: '76ca3bc6c5a3e6e7a5fdb5866e3b10875a93fe34718d0a7bfa47c6af5a54723e',
      witnessRoot: '5a55edd233ae732c4dcaeb2ee0f788c8d510858c1ef23f39f195716bb6b0a23d',
      treeRoot: 'cdb49fa8353829452f0cf57dad3ef22554e223ec8d7437027e7811d5a3cb0b82',
      reservedRoot: '0000000000000000000000000000000000000000000000000000000000000000',
      time: 1580412623,
      bits: 545259519,
      nonce: 3,
      extraNonce: '000000000000000000000000000000000000000000000000',
      mask: '0000000000000000000000000000000000000000000000000000000000000000',
      chainwork: '00000000000000000000000000000000000000000000000000000000000001d2'
    }
    

    Channel: chain

    Returns raw ChainEntry of the new current tip.

    Node tx

    Example:

     # TX.fromRaw(raw)
    { 
      hash:
       'd3f31c0f86f563daf1413570b04b26e39e0a011ed87be16dce31db1237bde14b',
      witnessHash:
       'a852e21c16f389aa6d503fcb6fe58cde09c94a2aa3553382c549c4b0e74fc28e',
      size: 215,
      virtualSize: 140,
      value: '1999.8944',
      fee: '0.0',
      rate: '0.0',
      minFee: '0.00014',
      height: -1,
      block: null,
      time: 0,
      date: null,
      index: -1,
      version: 0,
      inputs:
       [ { address:
            <Address: version=0 str=hs1q52kcp6yn2wg7vpakjmjf648sq8zxaklr002pgx>,
           prevout:
            <Outpoint: 8694b6d98ed016fc7aef12c6c446ebcd11040ca8d0c6b3e8b7d22c50aa3ad71e/1>,
           witness:
            <Witness: fa7e967813812156527829358ea76b3e0940b3399634147f812af3346c30768439b427e493e0d7b10caf3be8bb84a5d7a286d6cfa0683230ca69263c388fcc8d01 02252b10247d1ce7c0505f96e3d633e4ba4b444f3cb5cd04d1b4191459b1c1b8e4>,
           sequence: 4294967295,
           coin: null } ],
      outputs:
       [ { value: '0.1',
           address:
            <Address: version=0 str=hs1qyf5f64rz9e5ngz3us34s0lm22wez5vjlckeppx>,
           covenant: <Covenant: 0:00> },
         { value: '1999.7944',
           address:
            <Address: version=0 str=hs1qykzjmy9sqqdzvl2m3t7xfsc4zkl0nw95pce92z>,
           covenant: <Covenant: 0:00> } ],
      locktime: 0
    }
    

    Channel: mempool

    Emitted when a transaction that matches a previously set Bloom filter is received by the node server. Returns transaction as raw Buffer.

    Wallet Sockets

    Wallet sockets - bsock

    (See JavaScript example)
    
    (See JavaScript example)
    
    const bsock = require('bsock');
    const walletSocket = bsock.connect('<network wallet RPC port>');
    
    // Authenticate and join wallet after connection to listen for events
    walletSocket.on('connect', async () => {
      // Auth
      await walletSocket.call('auth', '<api-key>');
    
      // Join - All wallets
      await walletSocket.call('join', '*', '<admin token>');
    
      // Join - Specific wallet
      await walletSocket.call('join', '<wallet id>', '<wallet token>');
    });
    
    // Listen for new transactions
    walletSocket.bind('tx', (walletID, details) => {
      console.log('Wallet -- TX Event, Wallet ID:\n', walletID);
      console.log('Wallet -- TX Event, TX Details:\n', details);
    });
    
    // Leave
    walletSocket.call('leave', <wallet id>);
    

    Wallet Socket Authentication

    Authentication with the API server must be completed before any other events will be accepted.

    Note that even if the server API key is disabled on the test server, the auth event must still be sent to complete the handshake.

    emit('auth', 'server-api-key')

    The server will respond with a socket.io ACK packet once auth is completed.

    Joining a wallet

    After creating a websocket and authing with the server, you must send a join event to listen for events on a wallet. Join all wallets by passing '*'. Leave a wallet with the leave event. Wallet or admin token is required if wallet-auth is true.

    Listening for events

    All wallet events return the wallet-id in addition to the JSON data described below.

    Wallet sockets - hs-client

    (See JavaScript example)
    
    (See JavaScript example)
    
    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 () => {
      // Connection and auth handled by opening client
      await walletClient.open();
      await walletClient.join('*', '<admin token>');
    })();
    
    // Listen for new transactions
    walletClient.bind('tx', (walletID, details) => {
      console.log('Wallet -- TX Event, Wallet ID:\n', walletID);
      console.log('Wallet -- TX Event, TX Details:\n', details);
    });
    
    // Leave all wallets
    walletClient.leave('*');
    

    hs-client abstracts away the connection and authentication steps to make listening for events much easier.

    Wallet sockets - Calls

    The only wallet calls available are covered in the previous section.

    They are:

    auth join leave

    Wallet sockets - Events

    wallet tx

    Example:

    {
      "wid": 1,
      "id": "primary",
      "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"
    }
    

    Emitted on transaction.

    Returns tx details.

    conflict

    Emitted on double spend.

    Returns tx details of removed double spender.

    confirmed

    Emitted when a transaction is confirmed.

    Returns tx details.

    unconfirmed

    Emitted if a transaction was changed from confirmed->unconfirmed as the result of a reorg.

    Returns tx details.

    balance

    Example:

    {
      "wid": 1,
      "id": "primary",
      "unconfirmed": "8149.9999546",
      "confirmed": "8150.0",
      "lockedUnconfirmed": 0,
      "lockedConfirmed": 0
    }
    

    Emitted on balance update. Only emitted for entire wallet balance (not individual accounts).

    Returns Balance object.

    address

    Example:

    [
      {
        "wid": 1,
        "id": "primary",
        "name": "default",
        "account": 0,
        "branch": 0,
        "index": 9,
        "nested": false,
        "publicKey": "031a407b5219789b36b368a926fd9f0ea4817e3f6691a46454d8d01c71bff1096e",
        "script": null,
        "type": "pubkeyhash",
        "address": "rs1qryvfn5wzdd0wajpjjzs00s64nqxv0w077jz9gd"
      }
    ]
    

    Emitted when a transaction is received by the wallet account's current receive address, causing the wallet to derive a new receive address.

    Returns an array of KeyRing objects with new address details.

    Errors

    Any errors will be returned with an http status code other than 200, containing a JSON object in the form:

    {"error": { message: "message" } }