NAV Navbar
cURL CLI javascript
  • Introduction
  • Authentication
  • Configuring Clients
  • bcoin - Node
  • bcoin - Coins
  • bcoin - Transactions
  • RPC Calls - Node
  • RPC Calls - Chain
  • RPC Calls - Block
  • RPC Calls - Mempool
  • RPC Calls - Transactions
  • RPC Calls - Mining
  • RPC Calls - Network
  • Wallet
  • Wallet Admin Commands
  • Wallet Transactions
  • Wallet Accounts
  • Wallet Events
  • RPC Calls - Wallet
  • Errors
  • Introduction

    Welcome to the bcoin API!

    The default bcoin HTTP server listens on the standard RPC port (8332 for main, 18332 for testnet, 48332 for regtest, and 18556 default for simnet). It exposes a REST JSON, as well as a JSON-RPC api.

    Authentication

    Auth

    # default regtest port is 48332 (may be reconfigured by user), API key is required in URL
    curl http://x:api-key@127.0.0.1:48332/
    
    # examples in these docs will use an environment variable:
    url=http://x:api-key@127.0.0.1:48332/
    curl $url
    
    bcoin-cli --api-key=api-key --network=regtest info
    
    # store API key and network type in environment variables:
    export BCOIN_API_KEY=api-key
    export BCOIN_NETWORK=regtest
    bcoin-cli info
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    // network type derived from bcoin object, client object stores API key
    const clientOptions = {
      network: network.type,
      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:48332/ # will get info from regtest
    

    By default the API server listens on these localhost ports:

    Network API Port
    main 8332
    testnet 18332
    regtest 48332
    simnet 18556

    You can interact with bcoin 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 bcoin-cli

    # You can configure it by passing arguments:
    bcoin-cli --network=regtest info
    bcoin-cli info --network=regtest
    
    # Or use environment variables (Starting with BCOIN_)
    export BCOIN_NETWORK=regtest
    export BCOIN_API_KEY=$YOUR-API-KEY
    bcoin-cli info
    

    Install bcoin-cli and bwallet-cli command line tools with the bclient package. Included with bcoin by default, but can be installed separately: npm install -g bclient

    bcoin-cli params:

    General configurations are:

    Config Options Description
    network main, testnet, regtest This will configure which network to load, also where to look for bcoin.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

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

    bcoin.conf and wallet.conf files

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

    A sample bcoin.conf file is included in the code repository

    Using Javascript Clients

    const {NodeClient, WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const walletOptions = {
      network: network.type,
      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 bcoin-cli). There are two objects: NodeClient for general API and WalletClient for wallet API. bcoin 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
    network string Network to use: main, testnet, regtest
    port int bcoin socket port (specific for each network)
    apiKey string API secret

    bcoin - Node

    bcoin 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
    /mempool GET Mempool snapshot
    /broadcast POST Broadcast TX
    /fee GET Estimate fee
    /reset POST Reset chain to specific height

    Get server info

    curl $url/
    
    bcoin-cli info
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "v1.0.0-pre",
      "network": "regtest",
      "chain": {
        "height": 205,
        "tip": "38d4ff72bca6737d958e1456be90443c0e09186349f28b952564118ace222331",
        "progress": 1
      },
      "pool": {
        "host": "18.188.224.12",
        "port": 48444,
        "agent": "/bcoin:v1.0.0-pre/",
        "services": "1001",
        "outbound": 1,
        "inbound": 1
      },
      "mempool": {
        "tx": 0,
        "size": 0
      },
      "time": {
        "uptime": 1744,
        "system": 1527028546,
        "adjusted": 1527028546,
        "offset": 0
      },
      "memory": {
        "total": 90,
        "jsHeap": 19,
        "jsHeapTotal": 26,
        "nativeHeap": 64,
        "external": 9
      }
    }
    

    Get server Info.

    HTTP Request

    Get server info. No params.

    GET /

    No Params.

    Get mempool snapshot

    curl $url/mempool
    
    bcoin-cli mempool
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 block by hash or height

    let blockHash, blockHeight;
    
    blockHash='4003e57eb1c60f3d1b774d8a281353c35cd30dca0d76b751c8dd862da11c41de';
    blockHeight='94';
    
    curl $url/block/$blockHash # by hash
    curl $url/block/$blockHeight # by height
    
    bcoin-cli block $blockHash # by hash
    bcoin-cli block $blockHeight # by height
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "4003e57eb1c60f3d1b774d8a281353c35cd30dca0d76b751c8dd862da11c41de",
      "height": 94,
      "depth": 112,
      "version": 536870912,
      "prevBlock": "353cbab0d0ae1583ceb6bd88d90f44a7bb2cb2aec824eac688dbf1832e648962",
      "merkleRoot": "b23e398ccf2fe2dcf81c6e7b4cc3c710a79c78bf7e8a63dd819acf83952f960f",
      "time": 1527028558,
      "bits": 545259519,
      "nonce": 4,
      "txs": [
        {
          "hash": "b23e398ccf2fe2dcf81c6e7b4cc3c710a79c78bf7e8a63dd819acf83952f960f",
          "witnessHash": "b23e398ccf2fe2dcf81c6e7b4cc3c710a79c78bf7e8a63dd819acf83952f960f",
          "fee": 0,
          "rate": 0,
          "mtime": 1527028763,
          "index": 0,
          "version": 1,
          "inputs": [
            {
              "prevout": {
                "hash": "0000000000000000000000000000000000000000000000000000000000000000",
                "index": 4294967295
              },
              "script": "015e0e6d696e65642062792062636f696e04899fe44e080000000000000000",
              "witness": "00",
              "sequence": 4294967295,
              "address": null
            }
          ],
          "outputs": [
            {
              "value": 5000000000,
              "script": "76a91420a060fec9a7dfac723c521e168876909aa37ce588ac",
              "address": "RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo"
            }
          ],
          "locktime": 0,
          "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f015e0e6d696e65642062792062636f696e04899fe44e080000000000000000ffffffff0100f2052a010000001976a91420a060fec9a7dfac723c521e168876909aa37ce588ac00000000"
        }
      ]
    }
    

    Returns block info by block hash or height.

    HTTP Request

    GET /block/:blockhashOrHeight

    URL Parameters

    Parameter Description
    :blockhashOrHeight Hash or Height of block

    Broadcast transaction

    let tx;
    
    tx='010000000106b014e37704109fefe2c5c9f4227d68840c3497fc89a9832db8504df039a6c7000000006a47304402207dc8173fbd7d23c3950aaf91b1bc78c0ed9bf910d47a977b24a8478a91b28e69022024860f942a16bc67ec54884e338b5b87f4a9518a80f9402564061a3649019319012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff0280c3c901000000001976a91400ba915c3d18907b79e6cfcd8b9fdf69edc7a7db88acc41c3c28010000001976a91437f306a0154e1f0de4e54d6cf9d46e07722b722688ac00000000';
    
    curl $url/broadcast \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "tx": "'$tx'" }'
    
    bcoin-cli broadcast $tx
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 transaction hash

    bcoin - Coins

    Getting coin information via API.

    Coin stands for UTXO

    Get coin by Outpoint

    let hash, index;
    
    hash='53faa103e8217e1520f5149a4e8c84aeb58e55bdab11164a95e69a8ca50f8fcc';
    index=0;
    
    curl $url/coin/$hash/$index
    
    bcoin-cli coin $hash $index
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 1,
      "height": -1,
      "value": 30000000,
      "script": "76a91400ba915c3d18907b79e6cfcd8b9fdf69edc7a7db88ac",
      "address": "R9M3aUWCcKoiqDPusJvqNkAbjffLgCqYip",
      "coinbase": false,
      "hash": "53faa103e8217e1520f5149a4e8c84aeb58e55bdab11164a95e69a8ca50f8fcc",
      "index": 0
    }
    

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

    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='R9M3aUWCcKoiqDPusJvqNkAbjffLgCqYip';
    
    curl $url/coin/address/$address
    
    bcoin-cli coin $address
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 1,
        "height": -1,
        "value": 10000000,
        "script": "76a91400ba915c3d18907b79e6cfcd8b9fdf69edc7a7db88ac",
        "address": "R9M3aUWCcKoiqDPusJvqNkAbjffLgCqYip",
        "coinbase": false,
        "hash": "2ef8051e6c38e136ba4d195c048e78f9077751758db710475fa532b9d9489324",
        "index": 0
      },
      ...
      ...
      {
        "version": 1,
        "height": -1,
        "value": 50000000,
        "script": "76a91400ba915c3d18907b79e6cfcd8b9fdf69edc7a7db88ac",
        "address": "R9M3aUWCcKoiqDPusJvqNkAbjffLgCqYip",
        "coinbase": false,
        "hash": "b3c71dd8959ea97d41324779604b210ae881cdaa5d5abfcbfb3502a0e75c1283",
        "index": 0
      }
    ]
    

    Get coin objects array by address.

    HTTP Request

    GET /coin/address/:address

    URL Parameters

    Parameter Description
    :address bitcoin address

    Get coins by addresses

    let address0, address1;
    
    address0='RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ';
    address1='RHpAA3ZmmmWF6FW8qSfaEvh1jR1nUmVYnj';
    
    curl $url/coin/address \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "addresses":[ "'$address0'", "'$address1'" ]}'
    
    No CLI Option.
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 1,
        "height": -1,
        "value": 87654321,
        "script": "76a914a4ecde9642f8070241451c5851431be9b658a7fe88ac",
        "address": "RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ",
        "coinbase": false,
        "hash": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
        "index": 0
      },
      {
        "version": 1,
        "height": -1,
        "value": 12345678,
        "script": "76a9145d9c4bf7f9934668c054f1b1a5589632ddc2b5b088ac",
        "address": "RHpAA3ZmmmWF6FW8qSfaEvh1jR1nUmVYnj",
        "coinbase": false,
        "hash": "c87c13635f6004a802676a7f93bf90a4b27b433cf26db0c41a656f377406f3e3",
        "index": 0
      }
    ]
    
    

    Get coins by addresses, returns array of coin objects.

    HTTP Request

    POST /coin/address

    POST Parameters (JSON)

    Parameter Description
    addresses List of bitcoin addresses

    bcoin - Transactions

    Getting transaction information via API.

    Get tx by txhash

    let txhash;
    
    txhash='4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586';
    
    curl $url/tx/$txhash
    
    bcoin-cli tx $txhash
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
      "witnessHash": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
      "fee": 4540,
      "rate": 20088,
      "mtime": 1527029380,
      "height": -1,
      "block": null,
      "time": 0,
      "index": -1,
      "version": 1,
      "inputs": [
        {
          "prevout": {
            "hash": "a88387ca68a67f7f74e91723de0069154b532bf024c0e4054e36ea2234251181",
            "index": 0
          },
          "script": "4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46a",
          "witness": "00",
          "sequence": 4294967295,
          "coin": {
            "version": 1,
            "height": 36,
            "value": 5000000000,
            "script": "76a91420a060fec9a7dfac723c521e168876909aa37ce588ac",
            "address": "RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo",
            "coinbase": true
          }
        }
      ],
      "outputs": [
        {
          "value": 87654321,
          "script": "76a914a4ecde9642f8070241451c5851431be9b658a7fe88ac",
          "address": "RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ"
        },
        {
          "value": 4912341139,
          "script": "76a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac",
          "address": "RHefJ5hLW9jyEwwdxhci6r7AH7SAxdpGW3"
        }
      ],
      "locktime": 0,
      "hex": "01000000018111253422ea364e05e4c024f02b534b156900de2317e9747f7fa668ca8783a8000000006b4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff02b17f3905000000001976a914a4ecde9642f8070241451c5851431be9b658a7fe88ac9360cc24010000001976a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac00000000",
      "confirmations": 207
    }
    

    HTTP Request

    GET /tx/:txhash

    URL Parameters

    Parameter Description
    :txhash Hash of tx.

    Get tx by address

    let address;
    
    address='RHefJ5hLW9jyEwwdxhci6r7AH7SAxdpGW3';
    
    curl $url/tx/address/$address
    
    bcoin-cli tx $address
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
        "witnessHash": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
        "fee": 4540,
        "rate": 20088,
        "mtime": 1527029380,
        "height": -1,
        "block": null,
        "time": 0,
        "index": -1,
        "version": 1,
        "inputs": [
          {
            "prevout": {
              "hash": "a88387ca68a67f7f74e91723de0069154b532bf024c0e4054e36ea2234251181",
              "index": 0
            },
            "script": "4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46a",
            "witness": "00",
            "sequence": 4294967295,
            "coin": {
              "version": 1,
              "height": 36,
              "value": 5000000000,
              "script": "76a91420a060fec9a7dfac723c521e168876909aa37ce588ac",
              "address": "RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo",
              "coinbase": true
            }
          }
        ],
        "outputs": [
          {
            "value": 87654321,
            "script": "76a914a4ecde9642f8070241451c5851431be9b658a7fe88ac",
            "address": "RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ"
          },
          {
            "value": 4912341139,
            "script": "76a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac",
            "address": "RHefJ5hLW9jyEwwdxhci6r7AH7SAxdpGW3"
          }
        ],
        "locktime": 0,
        "hex": "01000000018111253422ea364e05e4c024f02b534b156900de2317e9747f7fa668ca8783a8000000006b4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff02b17f3905000000001976a914a4ecde9642f8070241451c5851431be9b658a7fe88ac9360cc24010000001976a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac00000000",
        "confirmations": 207
      }
      ...
    ]
    

    Returns transaction objects array by address

    HTTP Request

    GET /tx/address/:address

    URL Parameters

    Parameter Description
    :address Bitcoin address.

    Get tx by addresses

    let address0, address1;
    
    address0='RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ';
    address1='RHpAA3ZmmmWF6FW8qSfaEvh1jR1nUmVYnj';
    
     curl $url/tx/address \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "addresses":[ "'$address0'", "'$address1'" ]}'
    
    No CLI Option.
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
        "witnessHash": "4c7846a8ff8415945e96937dea27bdb3144c15d793648d725602784826052586",
        "fee": 4540,
        "rate": 20088,
        "mtime": 1527029380,
        "height": -1,
        "block": null,
        "time": 0,
        "index": -1,
        "version": 1,
        "inputs": [
          {
            "prevout": {
              "hash": "a88387ca68a67f7f74e91723de0069154b532bf024c0e4054e36ea2234251181",
              "index": 0
            },
            "script": "4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46a",
            "witness": "00",
            "sequence": 4294967295,
            "coin": {
              "version": 1,
              "height": 36,
              "value": 5000000000,
              "script": "76a91420a060fec9a7dfac723c521e168876909aa37ce588ac",
              "address": "RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo",
              "coinbase": true
            }
          }
        ],
        "outputs": [
          {
            "value": 87654321,
            "script": "76a914a4ecde9642f8070241451c5851431be9b658a7fe88ac",
            "address": "RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ"
          },
          {
            "value": 4912341139,
            "script": "76a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac",
            "address": "RHefJ5hLW9jyEwwdxhci6r7AH7SAxdpGW3"
          }
        ],
        "locktime": 0,
        "hex": "01000000018111253422ea364e05e4c024f02b534b156900de2317e9747f7fa668ca8783a8000000006b4830450221009fcb51c7b5956f4524490ee5f2c446faf29cc159f750d93455a9af393cd5b78d02201c3b8b0388dba8cfe3f5bef52a39e980be581d87e06433390f2b099df3855913012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff02b17f3905000000001976a914a4ecde9642f8070241451c5851431be9b658a7fe88ac9360cc24010000001976a9145bd075f5e3c5ff3e8467d94dee593d410967d93d88ac00000000",
        "confirmations": 207
      },
      {
        "hash": "c87c13635f6004a802676a7f93bf90a4b27b433cf26db0c41a656f377406f3e3",
        "witnessHash": "c87c13635f6004a802676a7f93bf90a4b27b433cf26db0c41a656f377406f3e3",
        "fee": 4540,
        "rate": 20177,
        "mtime": 1527029368,
        "height": -1,
        "block": null,
        "time": 0,
        "index": -1,
        "version": 1,
        "inputs": [
          {
            "prevout": {
              "hash": "ec25d3b6d62135eb7bba6443f0257363d961ed59526f9b4474814aeeddacbe80",
              "index": 0
            },
            "script": "473044022076644f57ae5a77f5dd511b61cd7349cf85a5646d4e17c7954dfe664c87e812c2022011c91b45c3274074215d32b6dc4599f5d4bf30f7963140e4dfe9f7ce3a9512ff012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46a",
            "witness": "00",
            "sequence": 4294967295,
            "coin": {
              "version": 1,
              "height": 63,
              "value": 5000000000,
              "script": "76a91420a060fec9a7dfac723c521e168876909aa37ce588ac",
              "address": "RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo",
              "coinbase": true
            }
          }
        ],
        "outputs": [
          {
            "value": 12345678,
            "script": "76a9145d9c4bf7f9934668c054f1b1a5589632ddc2b5b088ac",
            "address": "RHpAA3ZmmmWF6FW8qSfaEvh1jR1nUmVYnj"
          },
          {
            "value": 4987649782,
            "script": "76a91438530a92842d2912ea8003b934214b05c713c31888ac",
            "address": "RER1Q4xkZ4WdyYSLvWVzeH2o8KVB4yHoXh"
          }
        ],
        "locktime": 0,
        "hex": "010000000180beacddee4a8174449b6f5259ed61d9637325f04364ba7beb3521d6b6d325ec000000006a473044022076644f57ae5a77f5dd511b61cd7349cf85a5646d4e17c7954dfe664c87e812c2022011c91b45c3274074215d32b6dc4599f5d4bf30f7963140e4dfe9f7ce3a9512ff012103cb25dc2929ea58675113e60f4c08d084904189ab44a9a142179684c6cdd8d46affffffff024e61bc00000000001976a9145d9c4bf7f9934668c054f1b1a5589632ddc2b5b088acf67e4929010000001976a91438530a92842d2912ea8003b934214b05c713c31888ac00000000",
        "confirmations": 207
      }
    ]
    

    Returns transaction objects array by addresses

    HTTP Request

    POST /tx/address

    POST Parameters (JSON)

    Parameter Description
    addresses array of bitcoin addresses

    RPC Calls - Node

    curl $url \
      -X POST \
      --data '{ "method": "<method>", "params": [...] "id": "some-id" }'
    
    bcoin-cli rpc <method> <params>
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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.

    bcoin RPC calls mimic Bitcoin Core's RPC.

    RPC Calls are accepted at: POST /

    Notes:

    bcoin-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 $url/ \
      -H 'Content-Type: application/json' \
      -X POST \
      --data '{ "method": "stop" }'
    
    bcoin-cli rpc stop
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{ "method": "getinfo" }'
    
    bcoin-cli rpc getinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "v1.0.0-pre",
      "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 $url \
      -X POST \
      --data '{ "method": "getmemoryinfo" }'
    
    bcoin-cli rpc getmemoryinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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. Identical to node RPC call wallet-getmemoryinfo.

    Params

    N. Name Default Description
    None.

    setloglevel

    curl $url \
      -X POST \
      --data '{
        "method": "setloglevel",
        "params": [ "none" ]
      }'
    
    bcoin-cli rpc setloglevel none
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ';
    
    curl $url/ \
      -X POST \
      --data '{
        "method": "validateaddress",
        "params": [ "'$address'" ]
      }'
    
    bcoin-cli rpc validateaddress $address
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "RQKEexR9ZufYP6AKbwhzdv8iuiMFDh4sNZ",
      "scriptPubKey": "76a914a4ecde9642f8070241451c5851431be9b658a7fe88ac",
      "ismine": false,
      "iswatchonly": false
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "createmultisig",
        "params": [ '$nrequired', [ "'$pubkey0'", "'$pubkey1'", "'$pubkey2'" ] ]
      }'
    
    bcoin-cli rpc createmultisig $nrequired '[ "'$pubkey0'", "'$pubkey1'", "'$pubkey2'" ]'
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "GfNqJAAyrCLr2bVHxn8wjMMYMh1EBPzUNk",
      "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

    createwitnessaddress

    let script;
    
    script='5221021f1dbc575db95a44e016fe6ecf00231109e7799d9b1e007dbe8814017cf0d65c2102b3280e779a7c849f9d6460e926097fe4b0f6280fa6fd038ce8e1236a4688c358210315613667e3ebe065c0b8d86ae0443d97de56545bdf38c99a6ee584f300206d9a53ae';
    
    curl $url \
      -X POST \
      --data '{
        "method": "createwitnessaddress",
        "params": [ "'$script'" ]
      }'
    
    bcoin-cli rpc createwitnessaddress $script
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('createwitnessaddress', [ script ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "address": "rb1qlfgqame3n0dt2ldjl2m9qjg6n2vut26jw3ezm25hqx9ez4m9wp5qjres8a",
      "witnessScript": "0020fa500eef319bdab57db2fab650491a9a99c5ab5274722daa97018b9157657068"
    }
    

    Creates witness address.

    Params

    N. Name Default Description
    1 script Required Bitcoin script.

    signmessagewithprivkey

    let privkey, message;
    
    privkey='EMyedBwL5mb476uhWZ2wzEsSpu8kZwYgYaw5rGbjJh1kRjXF3M2d';
    message='hello';
    
    curl $url \
      -X POST \
      --data '{
        "method": "signmessagewithprivkey",
        "params": [ "'$privkey'", "'$message'"]
      }'
    
    bcoin-cli rpc signmessagewithprivkey $privkey $message
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:

    "MEUCIQCGLPYuLuSU1XQ7ctRvRzrY4M0dKAxShzEN3fwVoelGvgIgPmQ2RcRpeu0o68YsN42yzykI9VfTPooWHMvsFbIFEkg="
    

    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='RGCudRpNcn299Ja1EaVzgpnPD3YJgfMMiB';
    signature='MEUCIQCGLPYuLuSU1XQ7ctRvRzrY4M0dKAxShzEN3fwVoelGvgIgPmQ2RcRpeu0o68YsN42yzykI9VfTPooWHMvsFbIFEkg=';
    message='hello';
    
    curl $url \
      -X POST \
      --data '{
        "method": "verifymessage",
        "params": [ "'$address'", "'$signature'", "$message" ]
      }'
    
    bcoin-cli rpc verifymessage $address $signature "$message"
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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

    setmocktime

    let timestamp;
    
    timestamp=1503058155;
    
    curl $url \
      -X POST \
      --data '{
        "method": "setmocktime",
        "params": [ '$timestamp' ]
      }'
    
    bcoin-cli rpc setmocktime $timestamp
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "pruneblockchain",
        "params": []
      }'
    
    bcoin-cli rpc pruneblockchain
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "invalidateblock",
        "params": [ "'$blockhash'" ]
      }'
    
    bcoin-cli rpc invalidateblock $blockhash
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "reconsiderblock",
        "params": [ "'$blockhash'" ]
      }'
    
    bcoin-cli rpc reconsiderblock $blockhash
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{ "method": "getblockchaininfo" }'
    
    bcoin-cli rpc getblockchaininfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 98,
      "headers": 98,
      "bestblockhash": "498d003ecfc60ee829cdc3640dc305583057d88e2c38a7d57dbe0f92aa2bb512",
      "difficulty": 4.6565423739069247e-10,
      "mediantime": 1527028558,
      "verificationprogress": 0.9997162305340502,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000c6",
      "pruned": false,
      "softforks": [
        {
          "id": "bip34",
          "version": 2,
          "reject": {
            "status": false
          }
        },
        {
          "id": "bip66",
          "version": 3,
          "reject": {
            "status": false
          }
        },
        {
          "id": "bip65",
          "version": 4,
          "reject": {
            "status": false
          }
        }
      ],
      "bip9_softforks": {
        "csv": {
          "status": "defined",
          "bit": 0,
          "startTime": 0,
          "timeout": 4294967295
        },
        "segwit": {
          "status": "defined",
          "bit": 1,
          "startTime": 0,
          "timeout": 4294967295
        },
        "segsignal": {
          "status": "defined",
          "bit": 4,
          "startTime": 4294967295,
          "timeout": 4294967295
        },
        "testdummy": {
          "status": "defined",
          "bit": 28,
          "startTime": 0,
          "timeout": 4294967295
        }
      },
      "pruneheight": null
    }
    

    Returns blockchain information.

    Params

    N. Name Default Description
    None.

    getbestblockhash

    curl $url \
      -X POST \
      --data '{ "method": "getbestblockhash" }'
    
    bcoin-cli rpc getbestblockhash
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{ "method": "getblockcount" }'
    
    bcoin-cli rpc getblockcount
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='498d003ecfc60ee829cdc3640dc305583057d88e2c38a7d57dbe0f92aa2bb512';
    verbose=1;
    details=0;
    
    curl $url \
      -X POST \
      --data '{
        "method": "getblock",
        "params": [ "'$blockhash'", '$verbose', '$details' ]
      }'
    
    bcoin-cli rpc getblock $blockhash $verbose $details
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "498d003ecfc60ee829cdc3640dc305583057d88e2c38a7d57dbe0f92aa2bb512",
      "confirmations": 1,
      "strippedsize": 197,
      "size": 197,
      "weight": 788,
      "height": 98,
      "version": 536870912,
      "versionHex": "20000000",
      "merkleroot": "674527b1b1b8604677a0b9e3f7a62fd733af9eba254d9f98748d3d0afdf35602",
      "coinbase": "01620e6d696e65642062792062636f696e046d2df7a0080000000000000000",
      "tx": [
        "674527b1b1b8604677a0b9e3f7a62fd733af9eba254d9f98748d3d0afdf35602"
      ],
      "time": 1527028559,
      "mediantime": 1527028558,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "00000000000000000000000000000000000000000000000000000000000000c6",
      "previousblockhash": "267bec5755cb8362828351a1bedb0de8c8ab37a58627070a79b7aa48d09c7276",
      "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=50;
    verbose=1;
    details=0;
    
    curl $url \
      -X POST \
      --data '{
        "method": "getblockbyheight",
        "params": [ '$blockheight', '$verbose', '$details' ]
      }'
    
    bcoin-cli rpc getblockbyheight $blockheight $verbose $details
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "51726259de9560e1924f3cb554ad16e889b6170eb4d01d01f5a4ca8a81d1e318",
      "confirmations": 49,
      "strippedsize": 197,
      "size": 197,
      "weight": 788,
      "height": 50,
      "version": 536870912,
      "versionHex": "20000000",
      "merkleroot": "8e2d404a039a7a3e1768b161aa23546aab0444b73905bdd3d68b3d6f1769e8c0",
      "coinbase": "01320e6d696e65642062792062636f696e04a829b925080000000000000000",
      "tx": [
        "8e2d404a039a7a3e1768b161aa23546aab0444b73905bdd3d68b3d6f1769e8c0"
      ],
      "time": 1527028551,
      "mediantime": 1527028550,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "0000000000000000000000000000000000000000000000000000000000000066",
      "previousblockhash": "69eef02e5b7e2558f96a7e9ecb47dbbc4dd9fb1aa46cc22f36d8e7ee1edde33d",
      "nextblockhash": "7f734e621cc3e08834063b9482aa89e0bcaf29e7812b83494f3891c7955958fb"
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "getblockhash",
        "params": [ '$blockheight' ]
      }'
    
    bcoin-cli rpc getblockhash $blockheight
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='51726259de9560e1924f3cb554ad16e889b6170eb4d01d01f5a4ca8a81d1e318';
    verbose=1;
    
    curl $url \
      -X POST \
      --data '{
        "method": "getblockheader",
        "params": [ "'$blockhash'", '$verbose' ]
      }'
    
    bcoin-cli rpc getblockheader $blockhash $verbose
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "51726259de9560e1924f3cb554ad16e889b6170eb4d01d01f5a4ca8a81d1e318",
      "confirmations": 49,
      "height": 50,
      "version": 536870912,
      "versionHex": "20000000",
      "merkleroot": "8e2d404a039a7a3e1768b161aa23546aab0444b73905bdd3d68b3d6f1769e8c0",
      "time": 1527028551,
      "mediantime": 1527028550,
      "bits": 545259519,
      "difficulty": 4.6565423739069247e-10,
      "chainwork": "0000000000000000000000000000000000000000000000000000000000000066",
      "previousblockhash": "69eef02e5b7e2558f96a7e9ecb47dbbc4dd9fb1aa46cc22f36d8e7ee1edde33d",
      "nextblockhash": "7f734e621cc3e08834063b9482aa89e0bcaf29e7812b83494f3891c7955958fb"
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "getchaintips"
      }'
    
    bcoin-cli rpc getchaintips
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 98,
        "hash": "498d003ecfc60ee829cdc3640dc305583057d88e2c38a7d57dbe0f92aa2bb512",
        "branchlen": 0,
        "status": "active"
      }
      ...
    ]
    

    Params

    N. Name Default Description
    None.

    getdifficulty

    curl $url \
      -X POST \
      --data '{
        "method": "getdifficulty"
      }'
    
    bcoin-cli rpc getdifficulty
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getmempoolinfo"
      }'
    
    bcoin-cli rpc getmempoolinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getmempoolancestors",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    bcoin-cli rpc getmempoolancestors $txhash $verbose
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getmempooldescendants",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    bcoin-cli rpc getmempooldescendants $txhash $verbose
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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"
        ]
      }
    ]
    

    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 $url \
      -X POST \
      --data '{
        "method": "getmempoolentry",
        "params": [ "'$txhash'" ]
      }'
    
    bcoin-cli rpc getmempoolentry $txhash
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getrawmempool",
        "params": [ '$verbose' ]
      }'
    
    bcoin-cli rpc getrawmempool $verbose
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "prioritisetransaction",
        "params": [ "'$txhash'", '$priorityDelta', '$feeDelta' ]
      }'
    
    bcoin-cli rpc prioritisetransaction $txhash $priorityDelta $feeDelta
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "estimatefee",
        "params": [ '$nblocks' ]
      }'
    
    bcoin-cli rpc estimatefee $nblocks
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "estimatepriority",
        "params": [ '$nblocks' ]
      }'
    
    bcoin-cli rpc estimatepriority $nblocks
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "estimatesmartfee",
        "params": [ '$nblocks' ]
      }'
    
    bcoin-cli rpc estimatesmartfee $nblocks
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "estimatesmartpriority",
        "params": [ '$nblocks' ]
      }'
    
    bcoin-cli rpc estimatesmartpriority $nblocks
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    index=0;
    includemempool=1;
    
    curl $url \
      -X POST \
      --data '{
        "method": "gettxout",
        "params": [ "'$txhash'", '$index', '$includemempool' ]
      }'
    
    bcoin-cli rpc gettxout $txhash $index $includemempool
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "0e11d85b2081b84e131ba6692371737e6bb2aa7bc6d16e92954ffb1f9ad762e5",
      "confirmations": 0,
      "value": 0.4,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 fe7e0711287688b33b9a5c239336c4700db34e63 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914fe7e0711287688b33b9a5c239336c4700db34e6388ac",
        "type": "PUBKEYHASH",
        "reqSigs": 1,
        "addresses": [
          "RYUpgnvLvfi5T7q3hGSVvFrUy14kt61FC1"
        ]
      },
      "version": 1,
      "coinbase": false
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "gettxoutsetinfo",
        "params": []
      }'
    
    bcoin-cli rpc gettxoutsetinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    verbose=0;
    
    curl $url \
      -X POST \
      --data '{
        "method": "getrawtransaction",
        "params": [ "'$txhash'", '$verbose' ]
      }'
    
    bcoin-cli rpc getrawtransaction $txhash $verbose
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:

    "0100000001eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6010000006a4730440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add656012103142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057abffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac10ca0f24010000001976a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac00000000"
    

    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='0100000001eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6010000006a4730440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add656012103142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057abffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac10ca0f24010000001976a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac00000000';
    
    curl $url \
      -X POST \
      --data '{
        "method": "decoderawtransaction",
        "params": [ "'$rawtx'" ]
      }'
    
    bcoin-cli rpc decoderawtransaction $rawtx
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8",
      "hash": "0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8",
      "size": 225,
      "vsize": 225,
      "version": 1,
      "locktime": 0,
      "vin": [
        {
          "txid": "e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea",
          "scriptSig": {
            "asm": "30440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add65601 03142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057ab",
            "hex": "4730440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add656012103142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057ab"
          },
          "sequence": 4294967295,
          "vout": 1
        }
      ],
      "vout": [
        {
          "value": 0.4,
          "n": 0,
          "scriptPubKey": {
            "asm": "OP_DUP OP_HASH160 fe7e0711287688b33b9a5c239336c4700db34e63 OP_EQUALVERIFY OP_CHECKSIG",
            "hex": "76a914fe7e0711287688b33b9a5c239336c4700db34e6388ac",
            "type": "PUBKEYHASH",
            "reqSigs": 1,
            "addresses": [
              "RYUpgnvLvfi5T7q3hGSVvFrUy14kt61FC1"
            ]
          }
        },
        {
          "value": 48.9998184,
          "n": 1,
          "scriptPubKey": {
            "asm": "OP_DUP OP_HASH160 af92ad98c7f77559f96430dfef2a6805b87b24f8 OP_EQUALVERIFY OP_CHECKSIG",
            "hex": "76a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac",
            "type": "PUBKEYHASH",
            "reqSigs": 1,
            "addresses": [
              "RRHY3TejXvTh6B1V5auViS9jVUcNxAUcrj"
            ]
          }
        }
      ],
      "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='76a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac';
    
    curl $url \
      -X POST \
      --data '{
        "method": "decodescript",
        "params": [ "'$script'" ]
      }'
    
    bcoin-cli rpc decodescript $script
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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_HASH160 af92ad98c7f77559f96430dfef2a6805b87b24f8 OP_EQUALVERIFY OP_CHECKSIG",
      "type": "PUBKEYHASH",
      "reqSigs": 1,
      "addresses": [
        "RRHY3TejXvTh6B1V5auViS9jVUcNxAUcrj"
      ],
      "p2sh": "GYtKY86R5JdPqDGEa3meuhE1tz3f7M45uD"
    }
    

    Decodes script

    Params

    N. Name Default Description
    1 script Required Script hex

    sendrawtransaction

    let rawtx;
    
    rawtx='0100000001eaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6010000006a4730440220718954e28983c875858b5a0094df4607ce2e7c6e9ffea47f3876792b01755c1202205e2adc7c32ff64aaef6d26045f96181e8741e560b6f3a8ef2f4ffd2892add656012103142355370728640592109c3d2bf5592020a6b9226303c8bc98ab2ebcadf057abffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac10ca0f24010000001976a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac00000000';
    
    curl $url \
      -X POST \
      --data '{
        "method": "sendrawtransaction",
        "params": [ "'$rawtx'" ]
      }'
    
    bcoin-cli rpc sendrawtransaction $rawtx
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    txindex=1;
    amount=48.99900000;
    address='RStiqGLWA3aSMrWDyJvur4287GQ81AtLh1';
    data='';
    
    curl $url \
      -X POST \
      --data '{
        "method": "createrawtransaction",
        "params": [
          [{ "txid": "'$txhash'", "vout": '$txindex' }],
          { "'$address'": '$amount', "data": "'$data'" }
        ]
      }'
    
    bcoin-cli rpc createrawtransaction \
      '[{ "txid": "'$txhash'", "vout": '$txindex' }]' \
      '{ "'$address'": '$amount', "data": "'$data'" }'
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:

    "0100000001e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e0100000000ffffffff02608a0e24010000001976a914c1325e8fb60bd71d23532c39b4c9e743a2cc764988ac0000000000000000026a0000000000"
    

    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 List of addresses with amounts that we are sending to.
    2.1 address 0 address: amount key pairs (string: float)
    2.2 data nullData Data output (added as OP_RETURN)
    3 locktime earliest time a transaction can be added

    signrawtransaction

    let rawtx, txhash, txindex, scriptPubKey, amount, privkey;
    
    rawtx='0100000001e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e0100000000ffffffff02608a0e24010000001976a914c1325e8fb60bd71d23532c39b4c9e743a2cc764988ac0000000000000000026a0000000000';
    txhash='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    txindex=1;
    scriptPubKey='76a914af92ad98c7f77559f96430dfef2a6805b87b24f888ac';
    amount=48.99900000;
    privkey='ELvsQiH9X1kgmbzD1j4ESAJnN47whh8qZHVF8B9DpSpecKQDcfX6';
    
    curl $url \
      -X POST \
      --data '{
        "method": "signrawtransaction",
        "params": [
          "'$rawtx'",
          [{
            "txid": "'$txhash'",
            "vout": '$txindex',
            "scriptPubKey": "'$scriptPubKey'",
            "amount": '$amount'
          }],
          [ "'$privkey'" ]
        ]
      }'
    
    bcoin-cli rpc signrawtransaction $rawtx \
      '[{ "txid": "'$txhash'", "vout": '$txindex', "scriptPubKey": "'$scriptPubKey'", "amount": '$amount' }]' \
      '[ "'$privkey'" ]'
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      port: network.rpcPort,
      apiKey: 'api-key'
    }
    
    const client = new NodeClient(clientOptions);
    
    (async () => {
      const result = await client.execute('signrawtransaction', [ rawtx,
        [{
          txid: txhash,
          vout: txindex,
          scriptPubKey: scriptPubKey,
          amount: amount
        }],
        [ privkey ]
      ]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    {
      "hex": "0100000001e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e010000006a47304402205088870d469e5a878c54186e971cdc59d4e0c74f1c88709f584590ba76a9b97002202b4810a122fc4977e5a77c80dc68d4ffa73d22dbf385e46241dda6bddfd7993901210284a937f256393b3ba686556e90bd000706600bdbee4169abd092f392689307d2ffffffff02608a0e24010000001976a914c1325e8fb60bd71d23532c39b4c9e743a2cc764988ac0000000000000000026a0000000000",
      "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 scriptPubKey script with pubkey you are going to sign
    2.4 redeemScript redeemScript if tx is P2SH
    2.5 amount value of output in BTC
    3 privkeylist List of private keys
    4 sighashtype Type of signature hash

    gettxoutproof

    let txid0, txid1;
    
    txid0='0e690d6655767c8b388e7403d13dc9ebe49b68e3bd46248c840544f9da87d1e8';
    txid1='e66c029a755d326f14cc32f485ea43e705ef59ed4a8061e8f47e681fbdefefea';
    
    curl $url \
      -X POST \
      --data '{
        "method": "gettxoutproof",
        "params": [ ["'$txid0'", "'$txid1'"] ]
      }'
    
    bcoin-cli rpc gettxoutproof '[ "'$txid0'", "'$txid1'" ]'
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "verifytxoutproof",
        "params": [ "'$proof'" ]
      }'
    
    bcoin-cli rpc verifytxoutproof $proof
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 bcoin 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 $url \
      -X POST \
      --data '{
        "method": "getnetworkhashps",
        "params": [ '$blocks', '$height' ]
      }'
    
    bcoin-cli rpc getnetworkhashps $blocks $height
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getmininginfo",
        "params": []
      }'
    
    bcoin-cli rpc getmininginfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 bcoin itself is mining.

    Params

    N. Name Default Description
    None.

    getwork

    curl $url \
      -X POST \
      --data '{
        "method": "getwork",
        "params": []
      }'
    
    bcoin-cli rpc getwork
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:

    {
      "data": "200000001072adb70d69fc2b5a6601eeaaa54e31b7c57417028b429a0b98aa374413799c12c94351d52da980c8fa67eaddf6053dee141b14f4e6a3e10bb7db21c0d533b05b05ec88207fffff00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
      "target": "0000000000000000000000000000000000000000000000000000000000ffff7f",
      "height": 102
    }
    

    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 $url \
      -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.
    bcoin-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('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:

    {
      "data": "200000001072adb70d69fc2b5a6601eeaaa54e31b7c57417028b429a0b98aa374413799c09e651f7a930c198755993bf7348fd807836d1560b6baded56857def309a03855b05ecf1207fffff00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
      "target": "0000000000000000000000000000000000000000000000000000000000ffff7f",
      "height": 102
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "getblocktemplate",
        "params": []
      }'
    
    bcoin-cli rpc getblocktemplate
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": 536870912,
      "rules": [],
      "vbavailable": {},
      "vbrequired": 0,
      "height": 102,
      "previousblockhash": "4413799c0b98aa37028b429ab7c57417aaa54e315a6601ee0d69fc2b1072adb7",
      "target": "7fffff0000000000000000000000000000000000000000000000000000000000",
      "bits": "207fffff",
      "noncerange": "00000000ffffffff",
      "curtime": 1527115118,
      "mintime": 1527103506,
      "maxtime": 1527122318,
      "expires": 1527122318,
      "sigoplimit": 20000,
      "sizelimit": 1000000,
      "longpollid": "4413799c0b98aa37028b429ab7c57417aaa54e315a6601ee0d69fc2b1072adb700000003",
      "submitold": false,
      "coinbaseaux": {
        "flags": "6d696e65642062792062636f696e"
      },
      "coinbasevalue": 5000016600,
      "transactions": [
        {
          "data": "01000000017efbcc72a5733c7b9bcb1b763a81480425425bc10a4157e9553f0fd32eda710b000000006a47304402206a04f6c4fa9be51206e3fb9a48c5960198d7b27ce1b7c1915a4535e63ffdc60b022050796a1e0c09f60384379c2a477bedbce548cbaaa0e42183b737115b4ea77c5d0121020987e993a946a058d0969bd296b08783229fd1a0a779d8bfb376ebe30a164e89ffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac4486a327010000001976a914b1a4d7b11dad88f767d0ad894e11b53d766400a888ac00000000",
          "txid": "7444ea74eaee01ed7c7871f355bb5cb244a4ef2c05ae16ad49b4b06cbf34f539",
          "hash": "7444ea74eaee01ed7c7871f355bb5cb244a4ef2c05ae16ad49b4b06cbf34f539",
          "depends": [],
          "fee": 4540,
          "sigops": 2,
          "weight": 900
        },
        {
          "data": "0100000002e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e000000006b483045022100eeae86adccb31514ca25d3ddf265b21de05230fd6c93db7fbd185c133647fe640220392c3b5ebd50f4f0538c686b88e1d7051a81c2e5dff8c96f2a5c61154fa3c43a0121032cbf9d9b3beb61004d158ae897257fab6ce46efbad6b1e51b4a64e74732c3b4dffffffffeaefefbd1f687ef4e861804aed59ef05e743ea85f432cc146f325d759a026ce6000000006a47304402203e3ca4312bee4c465e6d5fcaee7aae1301d043444fe7a8f20b7df9f555ca1b4f022060104fc66cdb68af8cc674e94bb1900328cda94a8f6580d12ef0ad9810f24a290121032cbf9d9b3beb61004d158ae897257fab6ce46efbad6b1e51b4a64e74732c3b4dffffffff0220a6c901000000001976a914253d160f8a14c9586c9204553b50b279c71d2c8888ac005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac00000000",
          "txid": "c0f7dc9540629f6e1623cb25edba1d07cab4dd441b71cd247e629a6d817ed1ad",
          "hash": "c0f7dc9540629f6e1623cb25edba1d07cab4dd441b71cd247e629a6d817ed1ad",
          "depends": [],
          "fee": 7520,
          "sigops": 2,
          "weight": 1492
        },
        {
          "data": "0100000001e8d187daf94405848c2446bde3689be4ebc93dd103748e388b7c7655660d690e010000006b483045022100977567f80741451fe1407fbe453e75d371cc38a0de1411efc7df5c8c3c35d8ec02207a5899976628c19a22dae0058f60f86f43b379991bbf93383b17932310e497b001210284a937f256393b3ba686556e90bd000706600bdbee4169abd092f392689307d2ffffffff02005a6202000000001976a914fe7e0711287688b33b9a5c239336c4700db34e6388ac545ead21010000001976a914520b23898b775a4a5dc19d07a88ca4a4a87b92bf88ac00000000",
          "txid": "fa36691ec5f18a9dc56b1dfce3dff293352ebde8bc1b77489cba4921bc5b0c69",
          "hash": "fa36691ec5f18a9dc56b1dfce3dff293352ebde8bc1b77489cba4921bc5b0c69",
          "depends": [],
          "fee": 4540,
          "sigops": 2,
          "weight": 904
        }
      ]
    }
    

    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 $url \
      -X POST \
      --data '{
        "method": "submitblock",
        "params": [ "'$blockdata'" ]
      }'
    
    bcoin-cli rpc submitblock $blockdata
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "verifyblock",
        "params": [ "'$blockdata'" ]
      }'
    
    bcoin-cli rpc verifyblock $blockdata
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "setgenerate",
        "params": [ '$mining', '$proclimit' ]
      }'
    
    bcoin-cli rpc setgenerate $mining $proclimit
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getgenerate",
        "params": []
      }'
    
    bcoin-cli rpc getgenerate
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "generate",
        "params": [ '$numblocks' ]
      }'
    
    bcoin-cli rpc generate $numblocks
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "generatetoaddress",
        "params": [ '$numblocks', "'$address'" ]
      }'
    
    # Timeout error
    bcoin-cli rpc generatetoaddress $numblocks $address
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 blocknumber 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 $url \
      -X POST \
      --data '{
        "method": "getconnectioncount",
        "params": []
      }'
    
    bcoin-cli rpc getconnectioncount
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "ping",
        "params": []
      }'
    
    bcoin-cli rpc ping
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getpeerinfo",
        "params": []
      }'
    
    bcoin-cli rpc getpeerinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:48444",
        "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": "/bcoin:v1.0.0-pre/",
        "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:48444';
    cmd='add'
    
    curl $url \
      -X POST \
      --data '{
        "method": "addnode",
        "params": [ "'$nodeAddr'", "'$cmd'" ]
      }'
    
    bcoin-cli rpc addnode $nodeAddr $cmd
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:48444';
    
    curl $url \
      -X POST \
      --data '{
        "method": "disconnectnode",
        "params": [ "'$nodeAddr'" ]
      }'
    
    bcoin-cli rpc disconnectnode $nodeAddr
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:48444';
    
    curl $url \
      -X POST \
      --data '{
        "method": "getaddednodeinfo",
        "params": [ "'$nodeAddr'" ]
      }'
    
    bcoin-cli rpc getaddednodeinfo $nodeAddr
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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:48444",
        "connected": true,
        "addresses": [
          {
            "address": "127.0.0.1:48444",
            "connected": "outbound"
          }
        ]
      }
    ]
    

    Returns node information from host list.

    Params

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

    getnettotals

    curl $url \
      -X POST \
      --data '{
        "method": "getnettotals",
        "params": []
      }'
    
    bcoin-cli rpc getnettotals
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "getnetworkinfo",
        "params": []
      }'
    
    bcoin-cli rpc getnetworkinfo
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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": "v1.0.0-pre",
      "subversion": "/bcoin:v1.0.0-pre/",
      "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": 48444,
          "score": 3
        }
      ],
      "warnings": ""
    }
    

    Returns local node's network information

    Params

    N. Name Default Description
    None.

    setban

    let nodeAddr, cmd;
    
    nodeAddr='127.0.0.1:48444';
    cmd='add'
    
    curl $url \
      -X POST \
      --data '{
        "method": "setban",
        "params": [ "'$nodeAddr'", "'$cmd'" ]
      }'
    
    bcoin-cli rpc setban $nodeAddr $cmd
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "listbanned",
        "params": []
      }'
    
    bcoin-cli rpc listbanned
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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 $url \
      -X POST \
      --data '{
        "method": "clearbanned",
        "params": []
      }'
    
    bcoin-cli rpc clearbanned
    
    const {NodeClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const clientOptions = {
      network: network.type,
      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.

    Wallet

    The Wallet Client

    npm i -g bclient
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 bwallet-cli in the bclient package. Installing globally with npm i -g bclient 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 bcoin.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 8334
    testnet 18334
    regtest 48334
    simnet 18558

    The WalletDB and Object

    let id;
    
    id="primary"
    
    curl http://x:api-key@127.0.0.1:48334/wallet # will list regtest (default port 48334) wallets
    
    # examples in these docs will use an environment variable:
    walleturl=http://x:api-key@127.0.0.1:48334/wallet/
    curl $walleturl/$id
    
    # Like the node client, you can configure it by passing arguments:
    bwallet-cli --network=regtest --id=$id get
    
    # ...or you can use environment variables. The default `id` is `primary`:
    export BCOIN_API_KEY=yoursecret
    export BCOIN_NETWORK=regtest
    bwallet-cli get
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "17715756779e4a5f7c9b26c48d90a09d276752625430b41b5fcf33cf41aa7615",
      "tokenDepth": 0,
      "master": {
        "encrypted": false
      },
      "balance": {
        "tx": 5473,
        "coin": 5472,
        "unconfirmed": 1504999981750,
        "confirmed": 1494999998350
      }
    }
    

    bcoin 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 bcoin 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. bcoin 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

    bclient 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.

    Configuration

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

    Example Configuration:

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

    Wallet Options

    Wallet options object will look something like this:

    {
      "id": "walletId",
      "witness": true,
      "watchOnly": false,
      "accountKey": "rpubKB4S62xohva5NNbR3a3e84ybBb6E5AszR713RHzUrefCrbmqYuSEhvC2Reehdzz6v9vu6xN3XuMuFEC57esDUu38Af1ZZFgFydot9Zzs4ixT",
      "accountIndex": 1,
      "type": "pubkeyhash"
      "m": 1,
      "n": 1,
      "keys": [],
      "mnemonic": 'differ trigger sight sun undo fine sheriff mountain prison remove fantasy arm'
    }
    

    Options are used for wallet creation. None are required.

    Options Object

    Name Type Default Description
    id String Wallet ID (used for storage)
    master HDPrivateKey Master HD key. If not present, it will be generated
    witness Boolean false Whether to use witness programs
    watchOnly Boolean false
    accountKey String The extended public key for the primary account in the new wallet. This value is ignored if watchOnly is false
    accountIndex Number 0 The BIP44 account index
    receiveDepth Number The index of the next receiving address
    changeDepth Number The index of the next change address
    type String 'pubkeyhash' Type of wallet (pubkeyhash, multisig)
    compressed Boolean true Whether to use compressed public keys
    m Number 1 m value for multisig (m-of-n)
    n Number 1 n value for multisig (m-of-n)
    mnemonic String A mnemonic phrase to use to instantiate an hd private key. One will be generated if none provided

    Wallet Auth

    The following samples return a wallet object using a wallet token

    let token, id;
    
    id='primary'
    token='17715756779e4a5f7c9b26c48d90a09d276752625430b41b5fcf33cf41aa7615'
    
    curl $walleturl/$id?token=$token
    
    bwallet-cli get --token=$token
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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);
    })();
    

    Individual wallets have their own api keys, referred to internally as "tokens" (a 32 byte hash - calculated as HASH256(m/44'->ec-private-key|tokenDepth)).

    A wallet is always created with a corresponding token. When using API endpoints for a specific wallet, the token must be sent back in the query string or JSON body.

    Reset Authentication Token

    let id;
    
    id='primary'
    passphrase='secret123'
    
    bwallet-cli retoken --id=$id --passphrase=$passphrase
    
    curl $walleturl/$id/retoken \
      -X POST \
      --data '{"passphrase":"'$passphrase'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walleturl/$id
    
    bwallet-cli get --id=$id
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walleturl/$id/master
    
    bwallet-cli master --id=$id
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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",
          "passphrase": ""
        }
      }
    }
    

    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

    Create A Wallet

    let id, passphrase, witness, watchOnly, accountKey;
    
    id='newWallet'
    passphrase='secret456'
    witness=false
    watchOnly=true
    accountKey='rpubKBAoFrCN1HzSEDye7jcQaycA8L7MjFGmJD1uuvUZ21d9srAmAxmB7o1tCZRyXmTRuy5ZDQDV6uxtcxfHAadNFtdK7J6RV9QTcHTCEoY5FtQD'
    
    curl $walleturl/$id \
      -X PUT \
      --data '{"witness":'$witness', "passphrase":"'$passphrase'", "watchOnly": '$watchOnly', "accountKey":"'$accountKey'"}'
    
    # watchOnly defaults to true if --key flag is set
    
    bwallet-cli mkwallet $id --witness=$witness --passphrase=$passphrase --watchOnly=$watchOnly --accountKey=$accountKey
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    const options = {
      passphrase: passphrase,
      witness: witness,
      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 Description
    id
    string
    id of wallet you would like to create

    Change Passphrase

    let id, oldPass, newPass;
    
    id='newWallet'
    oldPass='secret456'
    newPass='789secret'
    
    > No cli command available
    
    curl $walleturl/$id/passphrase \
      -X POST \
      --data '{"old":"'$oldPass'", "passphrase":"'$newPass'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    Paramters 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="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    bwallet-cli send --id=$id --value=$value --address=$address ---passphrase=$passphrase
    
    id="primary"
    passphrase="secret123"
    rate=500
    value=1000
    address="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    curl $walleturl/$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="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "8fafdf2a6c44fc48dbe01147339a59fa11f2c5a7254d2e6df27ce0a61df29cf7",
      "height": -1,
      "block": null,
      "time": 0,
      "mtime": 1527181979,
      "date": "1970-01-01T00:00:00Z",
      "mdate": "2018-05-24T17:12:59Z",
      "size": 225,
      "virtualSize": 225,
      "fee": 4540,
      "rate": 20177,
      "confirmations": 0,
      "inputs": [
        {
          "value": 5000000000,
          "address": "R9cS4kuYVWHaDJmRGMpwx7zCNjw97Zm5LL",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/0"
          }
        }
      ],
      "outputs": [
        {
          "value": 1000,
          "address": "RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8",
          "path": null
        },
        {
          "value": 4999994460,
          "address": "RX3ZPBURVYzjRPR3wYdGepMBa26CGK8VMu",
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/0"
          }
        }
      ],
      "tx": "01000000017a2c5144386ed317c1f2ff484e7e11be718721d7ddab15773d0dd6133fb38a14000000006a4730440220710c42d68bd02789c31e7d351a6795c2a9386749e1d8a6aa61d46d5ba345843e022023d83a31e657f043d08d7e86379b818c98d788bb34bfe71ad2d9fa6dcb44b48b0121036b90b9f76925944b238239115f0c12ecee1b7e060e50850b4884aa0e0daea0c4ffffffff02e8030000000000001976a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac5cdc052a010000001976a914eebeba5a5b40bb11ca70f48b71bdb2c2b89f0c5c88ac00000000"
    }
    

    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
    whether or not to choose smart coins, will also used unconfirmed transactions
    blocks
    int
    number of blocks to use for fee estimation.
    rate
    int
    the rate for transaction fees. Denominated in satoshis per kb
    sort
    bool
    Sort outputs and inputs according BIP69
    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 satoshis (or whole BTC, see warning above)
    address
    string
    destination address for transaction

    Create a Transaction

    id="multisig1"
    passphrase="multisecret123"
    rate=0.00000500
    value=0.05000000
    address="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    bwallet-cli mktx --id=$id --value=$value --address=$address ---passphrase=$passphrase
    
    id="multisig1"
    passphrase="multisecret123"
    rate=500
    value=5000000
    address="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    curl $walleturl/$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="RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "2c550d94e3de0de48d82199442aec45bbc75e253eaf67c953db4265691cc60ec",
      "witnessHash": "2c550d94e3de0de48d82199442aec45bbc75e253eaf67c953db4265691cc60ec",
      "fee": 6800,
      "rate": 25855,
      "mtime": 1527182869,
      "version": 1,
      "inputs": [
        {
          "prevout": {
            "hash": "31ebd87739a0e58098d127d76ee80ebfd8b5d923a8fcaf2d0908c16f123043be",
            "index": 0
          },
          "script": "0000473044022064ac064f8b0e224413cf7e7c3aa2758013dd0cff6b421a273fb6f870894b200f022064da80d0ea08110b1c18817a66b1e576f945f73256407175b0fcc9936644b3320147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652ae",
          "witness": "00",
          "sequence": 4294967295,
          "coin": {
            "version": 1,
            "height": -1,
            "value": 10000000,
            "script": "a9143ddf94d382bc20b256748e0ab20b040efc07344c87",
            "address": "GPV5UXtx3Zbb7CGL7k31kykXkbNUxM6hXW",
            "coinbase": false
          }
        }
      ],
      "outputs": [
        {
          "value": 4993200,
          "script": "a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887",
          "address": "GR8dHeLMn8CPVAztoEjkAxHS6eWSgf6Hcr"
        },
        {
          "value": 5000000,
          "script": "76a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac",
          "address": "RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
        }
      ],
      "locktime": 0,
      "hex": "0100000001be4330126fc108092daffca823d9b5d8bf0ee86ed727d19880e5a03977d8eb3100000000920000473044022064ac064f8b0e224413cf7e7c3aa2758013dd0cff6b421a273fb6f870894b200f022064da80d0ea08110b1c18817a66b1e576f945f73256407175b0fcc9936644b3320147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652aeffffffff02b0304c000000000017a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887404b4c00000000001976a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac00000000"
    }
    

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

    HTTP Request

    POST /wallet/:id/create

    Post Paramters

    Paramter Description
    outputs
    array
    An array of outputs to send for the transaction
    passphrase
    string
    passphrase to unlock the account
    smart
    bool
    whether or not to choose smart coins, will also used unconfirmed transactions
    rate
    int
    the rate for transaction fees. Denominated in satoshis 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 satoshis (or whole BTC, see warning above)
    address
    string
    destination address for transaction

    Sign Transaction

    let id, tx, passphrase;
    
    id="multisig2"
    passphrase="multisecret456"
    tx="0100000001be4330126fc108092daffca823d9b5d8bf0ee86ed727d19880e5a03977d8eb3100000000920000473044022064ac064f8b0e224413cf7e7c3aa2758013dd0cff6b421a273fb6f870894b200f022064da80d0ea08110b1c18817a66b1e576f945f73256407175b0fcc9936644b3320147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652aeffffffff02b0304c000000000017a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887404b4c00000000001976a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac00000000"
    
    bwallet-cli sign --id=$id --passphrase=$passphrase --tx=$tx
    
    curl $walleturl/$id/sign \
      -X POST \
      --data '{"tx": "'$tx'", "passphrase":"'$passphrase'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "a355e0fcfb727c8161f3b2e55e0cda40f4614ea38d4834f82460cfdc9941381a",
      "witnessHash": "a355e0fcfb727c8161f3b2e55e0cda40f4614ea38d4834f82460cfdc9941381a",
      "fee": 170,
      "rate": 507,
      "mtime": 1527183237,
      "version": 1,
      "inputs": [
        {
          "prevout": {
            "hash": "31ebd87739a0e58098d127d76ee80ebfd8b5d923a8fcaf2d0908c16f123043be",
            "index": 0
          },
          "script": "004730440220764ce5fa17f7d6fc8921a85ddd81e3378e88aae92a02ab8ff72646bb9d2ad3c102203075f1c8f97d48626ed22e86495c28c19386c1adb9160d84ab28fb5c7c65b103014830450221008bbc87270043e0c701cb4ba8bb7b0b8014f7bdac66fb8ae104bfe91e0469983f022003734c66e3c1f40293e90b2327fe509f68ada13c44b69bec364c01763a0699940147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652ae",
          "witness": "00",
          "sequence": 4294967295,
          "coin": {
            "version": 1,
            "height": -1,
            "value": 10000000,
            "script": "a9143ddf94d382bc20b256748e0ab20b040efc07344c87",
            "address": "GPV5UXtx3Zbb7CGL7k31kykXkbNUxM6hXW",
            "coinbase": false
          }
        }
      ],
      "outputs": [
        {
          "value": 4999830,
          "script": "a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887",
          "address": "GR8dHeLMn8CPVAztoEjkAxHS6eWSgf6Hcr"
        },
        {
          "value": 5000000,
          "script": "76a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac",
          "address": "RPipJ9yeeQxHn6YcBXd9WPy2V6cezzAuY8"
        }
      ],
      "locktime": 0,
      "hex": "0100000001be4330126fc108092daffca823d9b5d8bf0ee86ed727d19880e5a03977d8eb3100000000da004730440220764ce5fa17f7d6fc8921a85ddd81e3378e88aae92a02ab8ff72646bb9d2ad3c102203075f1c8f97d48626ed22e86495c28c19386c1adb9160d84ab28fb5c7c65b103014830450221008bbc87270043e0c701cb4ba8bb7b0b8014f7bdac66fb8ae104bfe91e0469983f022003734c66e3c1f40293e90b2327fe509f68ada13c44b69bec364c01763a0699940147522102fac079263a41252f1602406313cc26caf76029135fda4f2423b997b6c89ce78f210304ea9eddb0c0fe241c89ceb2ee8b15870ede2757dfbd42fee60ba9f63d91290652aeffffffff02964a4c000000000017a9144ff1a73bf41d28a8a60e057a5c4bb0a38c0bbaf887404b4c00000000001976a9149e6a64a9dfdf49bfa72e1402663ac40aa5e30a7188ac00000000"
    }
    

    Sign a templated transaction (useful for multisig).

    HTTP Request

    POST /wallet/:id/sign

    Post Paramters

    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
    
    bwallet-cli zap --id=$id --account=$account --age=$age
    
    id="primary"
    account="default"
    age=259200 # 72 hours
    
    curl $walleturl/$id/zap \
      -X POST \
      --data '{
        "account": "'$account'",
        "age": '$age'
      }'
    
    let id, age, account;
    id="primary"
    account="default"
    age=259200 // 72 hours
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 (unix time)

    Unlock Wallet

    let id, pass, timeout
    
    id='primary'
    pass='secret123'
    timeout=60
    
    bwallet-cli unlock --id=$id $pass $timeout
    
    curl $walleturl/$id/unlock \
      -X POST \
      --data '{"passphrase":"'$pass'", "timeout": '$timeout'}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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'
    
    bwallet-cli lock --id=$id
    
    curl $walleturl/$id/lock \
      -X POST
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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'
    
    bwallet-cli --id=$id --account=$account import $privkey
    bwallet-cli --id=$watchid --account=$account import $pubkey
    
    curl $walleturl/$id/import \
      -X POST \
      --data '{"account":"'$account'", "privateKey":"'$privkey'"}'
    
    curl $walleturl/$watchid/import \
      -X POST \
      --data '{"account":"'$account'", "publicKey":"'$pubkey'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Paramters

    Paramter Description
    id
    string
    id of target wallet to import key into
    privateKey
    string
    Base58Check 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='RUkNXekA1QcDzNZhn2TqNavPUxmaosCzJC'
    
    bwallet-cli watch --id=$id --account=$account $address
    
    curl $walleturl/$id/import \
      -X POST \
      --data '{"account":"'$account'", "address":"'$address'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Base58Check 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 Paramters

    Paramter Description
    id
    string
    id of target wallet to import key into
    address
    string
    Base58Check encoded address

    Get Blocks with Wallet Txs

    let id;
    
    id="primary"
    
    curl $walleturl/$id/block
    
    bwallet-cli blocks --id=$id
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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
    
    bwallet-cli --id=$id block $height
    
    curl $walleturl/$id/block/$height
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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"
    
    bwallet-cli --id=$id --account=$account shared add $key
    
    curl $walleturl/$id/shared-key \
      -X PUT \
      --data '{"accountKey": "'$key'", "account": "'$account'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    Paramter 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"
    
    bwallet-cli --id=$id --account=$account shared remove $key
    
    curl $walleturl/$id/shared-key \
      -X DELETE \
      --data '{"accountKey": "'$key'", "account": "'$account'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    Paramter 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="RM4xYH2GrcHmiptfsDEF7Kqqbm2Humjm2E"
    
    bwallet-cli --id=$id key $address
    
    curl $walleturl/$id/key/$address
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 2,
      "witness": false,
      "nested": false,
      "publicKey": "02548e0a23b90505f1b4017f52cf2beeaa399fce7ff2961e29570c6afdfa9bfc5b",
      "script": null,
      "program": null,
      "type": "pubkeyhash",
      "address": "RM4xYH2GrcHmiptfsDEF7Kqqbm2Humjm2E"
    }
    

    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
    Base58 encoded address to get corresponding public key for

    Get Private Key By Address

    let id, address;
    
    id='primary'
    passphrase='secret123'
    address='RM4xYH2GrcHmiptfsDEF7Kqqbm2Humjm2E'
    
    bwallet-cli --id=$id --passphrase=$passphrase dump $address
    
    curl $walleturl/$id/wif/$address?passphrase=$passphrase
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "EPAcwFM5E6CS1sGCv3PDeJ68nXSfUZwViZ8HyrP9T8GcGSF14EsK"
    }
    

    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
    Base58 encoded address to get corresponding public key for

    Generate Receiving Address

    let id, account;
    
    id="primary"
    account="default"
    
    bwallet-cli --id=$id --account=$account address
    
    curl $walleturl/$id/address -X POST --data '{"account":"'$account'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 5,
      "witness": false,
      "nested": false,
      "publicKey": "030429c7a7007b9da542c029ea72a21852c2e4dfcce339d626df022068f0149680",
      "script": null,
      "program": null,
      "type": "pubkeyhash",
      "address": "RUkNXekA1QcDzNZhn2TqNavPUxmaosCzJC"
    }
    
    

    Derive new receiving address for account.

    HTTP Request

    POST /wallet/:id/address

    Post Paramters

    Parameter Description
    account
    string
    BIP44 account to generate address from

    Generate Change Address

    let id, account;
    
    id="primary"
    account="default"
    
    bwallet-cli --id=$id --account=$account change
    
    curl $walleturl/$id/change -X POST --data '{"account":"'$account'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 27,
      "witness": false,
      "nested": false,
      "publicKey": "02fb03c9c45cbc6436c7c009391bc1410f86da9f6548675e7521856d3b372dfb42",
      "script": null,
      "program": null,
      "type": "pubkeyhash",
      "address": "R9oeK9hgbBEYjmUffYyvPfh7eMw7q4v4XY"
    }
    [ec
    

    Derive new change address for account.

    HTTP Request

    POST /wallet/:id/change

    Post Paramters

    Parameter Description
    account
    string
    BIP44 account to generate address from

    Derive Nested Address

    let id, account;
    
    id="witness1"
    account='default'
    
    bwallet-cli --id=$id nested --account=$account
    
    curl $walleturl/$id/nested -X POST --data '{"account": "'$account'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    const wallet = walletClient.wallet(id);
    
    (async () => {
      const result = await wallet.createNested(account);
      console.log(result);
    })();
    

    Sample response

    {
      "name": "default",
      "account": 0,
      "branch": 2,
      "index": 1,
      "witness": true,
      "nested": true,
      "publicKey": "02d10d018aad643382a77f6f6305bd209879ae450f9d3fdbcc406a666a20b40332",
      "script": null,
      "program": "001421457f563883db273f4cefd519882dfefcb6ba82",
      "type": "scripthash",
      "address": "GX9yN5m5dUcSqfmNgkfQ7XJAHdyvbTHLhU"
    }
    

    Derive new nested p2sh receiving address for account. Note that this can't be done on a non-witness account otherwise you will receive the following error:

    [error] (node) Cannot derive nested on non-witness account.

    HTTP Request

    POST /wallet/:id/nested

    Post Paramters

    Paramter Description
    account
    string
    account to derive the nested address for (default='default')

    Get Balance

    let id, account;
    
    id='primary'
    account='default'
    
    bwallet-cli --id=$id balance --account=$account
    
    curl $walleturl/$id/balance?account=$account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 307,
      "coin": 287,
      "unconfirmed": 1122500000000,
      "confirmed": 1122500000000
    }
    

    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 unconfimred and confirmed are expressed in satoshis.

    HTTP Request

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

    Request Paramters

    Paramters 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 $walleturl/$id/coin
    
    bwallet-cli --id=$id coins
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 1,
        "height": -1,
        "value": 4999998887,
        "script": "76a914a2133747754faf7fbacc31bf0f74808f8409c4b388ac",
        "address": "RQ4AZjpaoyXhEk3mjcWYR74YR8XhxoXGzV",
        "coinbase": false,
        "hash": "7c7de4c48744b09b69bd36ffdb354199407321e305c0a4bd366a6168e0ff7244",
        "index": 1
      },
      {
        "version": 1,
        "height": -1,
        "value": 4999998887,
        "script": "76a9149433dbda44a1f23396a1bd231443b0d29eb8cf2888ac",
        "address": "RNnpD7tGaTpqEuTfBaqrtAqDK1927FLkW2",
        "coinbase": false,
        "hash": "a97a9993389ae321b263dffb68ba1312ad0655da83aeca75b2372d5abc70544a",
        "index": 1
      },
      ...
    ]
    

    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 $walleturl/$id/locked/$hash/$index -X PUT
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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. Also see lockunspent and listlockunspent.

    HTTP Request

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

    Request Parameters

    Paramters 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 Paramters

    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 $walleturl/$id/locked/$hash/$index -X DELETE
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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. Also see lockunspent and listlockunspent.

    HTTP Request

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

    Request Parameters

    Paramters 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 Paramters

    Parameter Description
    passphrase
    string
    passphrase of wallet being referenced

    Get Locked Outpoints

    let id;
    
    id="primary"
    
    # Not supported in CLI
    
    curl $walleturl/$id/locked
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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. Also see lockunspent and listlockunspent.

    HTTP Request

    GET /wallet/:id/locked

    Request Parameters

    Paramters 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
    
    bcoin-cli coin $hash $index
    
    curl $walleturl/$id/coin/$hash/$index
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    Paramters 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:48334 # will access admin functions for regtest (port 48334) wallets
    
    # examples in these docs will use an environment variable:
    walletadminurl=http://x:api-key@127.0.0.1:48334/
    curl $walletadminurl/<METHOD>
    

    Admin commands are simply commands no specific to any particular wallet, and may impact all wallets on the system.

    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 $walletadminurl/rescan \
      -X POST \
      --data '{"height": '$height'}'
    
    bwallet-cli rescan $height
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletadminurl/resend \
    -X POST
    
    bwallet-cli resend
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletadminurl/backup?path=$path \
      -X POST
    
    bwallet-cli backup $path
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    List all Wallets

    curl $walletadminurl/wallet
    
    bwallet-cli wallets
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Transactions

    Get Wallet TX Details

    let id, hash
    
    id="primary"
    hash="c7dcd8f8923f8cd0d44d0d980ddd4da80f67290ef872aab0f7be5858210712f7"
    
    bwallet-cli --id=$id tx $hash
    
    curl $walleturl/$id/tx/$hash
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "c7dcd8f8923f8cd0d44d0d980ddd4da80f67290ef872aab0f7be5858210712f7",
      "height": 501,
      "block": "05b1fa9da2acc862dd8e329bbcd158f240a844951016d9e9cd1a1bf9f61b9ac9",
      "time": 1527184717,
      "mtime": 1527184717,
      "date": "2018-05-24T17:58:37Z",
      "mdate": "2018-05-24T17:58:37Z",
      "size": 200,
      "virtualSize": 173,
      "fee": 0,
      "rate": 0,
      "confirmations": 1,
      "inputs": [
        {
          "value": 0,
          "address": null,
          "path": null
        }
      ],
      "outputs": [
        {
          "value": 625009040,
          "address": "RQCqU5msz7DbNGtti6fYQajEGDY2oabsvN",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/1"
          }
        },
        {
          "value": 0,
          "address": null,
          "path": null
        }
      ],
      "tx": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff2002f5010e6d696e65642062792062636f696e04f410f00b080000000000000000ffffffff0290e14025000000001976a914a3b7048d9f72788e1e2e161dc63585322689d01388ac0000000000000000266a24aa21a9ed9dae2d79e9b97a2b1f19bb16dd1c1c633f2fce683fba82eb85248fac3e32f3d90120000000000000000000000000000000000000000000000000000000000000000000000000"
    }
    

    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 $walleturl/$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

    Paramters 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'
    
    bwallet-cli --id=$id history
    
    curl $walleturl/$id/tx/history
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    [
      {
         "wid": 1,
         "id": "primary",
         "hash": "f5968051ce275d89b7a6b797eb6e6b081243ecf027872fc6949fae443e21b858",
         "height": -1,
         "block": null,
         "time": 0,
         "mtime": 1503690544,
         "date": "2017-08-25T19:49:04Z",
         "size": 226,
         "virtualSize": 226,
         "fee": 0,
         "rate": 0,
         "confirmations": 0,
         "inputs": [
           {
             "value": 0,
             "address": "mp2w1u4oqZnHDd1zDeAvCTX9B3SaFsUFQx",
             "path": null
           }
         ],
         "outputs": [
           {
             "value": 100000,
             "address": "myCkrhQbJwqM8wKi9YuhyTjN3pukNuWxZ9",
             "path": {
               "name": "default",
               "account": 0,
               "change": false,
               "derivation": "m/0'/0/3"
             }
           },
           {
             "value": 29790920,
             "address": "mqNm1rSYVqD23Aj6fkupApuSok9DNZAeBk",
             "path": null
           }
         ],
         "tx": "0100000001ef8a38cc946c57634c2db05fc298bf94f5c88829c5a6e2b0610fcc7b38a9264f010000006b483045022100e98db5ddb92686fe77bb44f86ce8bf6ff693c1a1fb2fb434c6eeed7cf5e7bed4022053dca3980a902ece82fb8e9e5204c26946893388e4663dbb71e78946f49dd0f90121024c4abc2a3683891b35c04e6d40a07ee78e7d86ad9d7a14265fe214fe84513676ffffffff02a0860100000000001976a914c2013ac1a5f6a9ae91f66e71bbfae4cc762c2ca988acc892c601000000001976a9146c2483bf52052e1125fc75dd77dad06d65b70a8288ac00000000"
       },
     ...
    ]
    

    Get wallet TX history. Returns array of tx details.

    HTTP Request

    GET /wallet/:id/tx/history

    Request Parameters

    Paramter Description
    id
    string
    id of wallet to get history of

    Get Pending Transactions

    let id;
    
    id='primary'
    
    bwallet-cli --id=$id pending
    
    curl $walleturl/$id/tx/unconfirmed
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    Paramter 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 $walleturl/$id/tx/range?start=$start'&'end=$end
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "c7dcd8f8923f8cd0d44d0d980ddd4da80f67290ef872aab0f7be5858210712f7",
        "height": 501,
        "block": "05b1fa9da2acc862dd8e329bbcd158f240a844951016d9e9cd1a1bf9f61b9ac9",
        "time": 1527184717,
        "mtime": 1527184717,
        "date": "2018-05-24T17:58:37Z",
        "mdate": "2018-05-24T17:58:37Z",
        "size": 200,
        "virtualSize": 173,
        "fee": 0,
        "rate": 0,
        "confirmations": 1,
        "inputs": [
          {
            "value": 0,
            "address": null,
            "path": null
          }
        ],
        "outputs": [
          {
            "value": 625009040,
            "address": "RQCqU5msz7DbNGtti6fYQajEGDY2oabsvN",
            "path": {
              "name": "default",
              "account": 0,
              "change": false,
              "derivation": "m/0'/0/1"
            }
          },
          {
            "value": 0,
            "address": null,
            "path": null
          }
        ],
        "tx": "010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff2002f5010e6d696e65642062792062636f696e04f410f00b080000000000000000ffffffff0290e14025000000001976a914a3b7048d9f72788e1e2e161dc63585322689d01388ac0000000000000000266a24aa21a9ed9dae2d79e9b97a2b1f19bb16dd1c1c633f2fce683fba82eb85248fac3e32f3d90120000000000000000000000000000000000000000000000000000000000000000000000000"
      },
      ...
    ]
    

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

    HTTP Request

    GET /wallet/:id/tx/range

    Body Parameters

    Paramter 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 Accounts

    Account Object

    An account object looks like this:

    {
      "name": "default",
      "initialized": true,
      "witness": false,
      "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
      }
    }
    

    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 $walleturl/$id/account
    
    bwallet-cli account --id=$id list
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walleturl/$id/account/$account
    
    bwallet-cli --id=$id account get $account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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,
      "witness": false,
      "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'
    
    bwallet-cli --id=$id account create --name=$name --type=$type --passphrase=$passphrase 
    
    curl $walleturl/$id/account/$name \
        -X PUT \
        --data '{"type": "'$type'", "passphrase": "'$passphrase'"}'
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "menace",
      "initialized": true,
      "witness": false,
      "watchOnly": false,
      "type": "multisig",
      "m": 1,
      "n": 1,
      "accountIndex": 1,
      "receiveDepth": 1,
      "changeDepth": 1,
      "nestedDepth": 0,
      "lookahead": 10,
      "receiveAddress": "GWzk797i4UCw9iG5uSj9DPQWsgt8nGWDA2",
      "changeAddress": "GbqDrwBWDfKGgYuu4VvJGEjCpwxS5TiBdM",
      "nestedAddress": null,
      "accountKey": "rpubKBBuJXusEYaDe2o6iEVjceYB4r7rGhfQGsHRynZ1pbaNvNB5eyo4GvvT3e6dfttpt6x5tomFjbooFj6vBjwpXMwJZcoFWr8LcmbW3BABQoxJ",
      "keys": [],
      "balance": {
        "tx": 0,
        "coin": 0,
        "unconfirmed": 0,
        "confirmed": 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
    witness
    bool
    whether or not to act as segregated witness wallet account
    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 Events

    Using Wallet Sockets

    Wallet events use the socket.io protocol.

    Socket IO implementations:

    Wallet Socket Auth

    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 wallet auth event must still be sent to complete the handshake.

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

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

    Listening on a wallet

    After creating a websocket and authing with the server, you must send a wallet join event to listen for events on a wallet.

    emit('wallet join', 'wallet-id', 'wallet-token')

    Unlistening on a wallet

    emit('wallet leave', 'wallet-id')

    version

    Emitted on connection.

    Returns version. Object in the form: [{ version: 'v1.0.0-alpha', agent: '/bcoin:v1.0.0-alpha/', network: 'main' }].

    wallet tx

    Received on transaction.

    Example:

    {
      "wid": 1,
      "id": "primary",
      "hash": "0de09025e68b78e13f5543f46a9516fa37fcc06409bf03eda0e85ed34018f822",
      "height": -1,
      "block": null,
      "time": 0,
      "mtime": 1486685530,
      "date": "2017-02-10T00:12:10Z",
      "index": -1,
      "size": 226,
      "virtualSize": 226,
      "fee": "0.0000454",
      "rate": "0.00020088",
      "confirmations": 0,
      "inputs": [
        {
          "value": "50.0",
          "address": "n4UANJbj2ZWy1kgt9g45XFGp57FQvqR8ZJ",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/0"
          }
        }
      ],
      "outputs": [
        {
          "value": "5.0",
          "address": "mu5Puppq4Es3mibRskMwoGjoZujHCFRwGS",
          "path": {
            "name": "default",
            "account": 0,
            "change": false,
            "derivation": "m/0'/0/7"
          }
        },
        {
          "value": "44.9999546",
          "address": "n3nFYgQR2mrLwC3X66xHNsx4UqhS3rkSnY",
          "path": {
            "name": "default",
            "account": 0,
            "change": true,
            "derivation": "m/0'/1/0"
          }
        }
      ],
      "tx": "0100000001c5b23b4348b7fa801f498465e06f9e80cf2f61eead23028de14b67fa78df3716000000006b483045022100d3d4d945cdd85f0ed561ae8da549cb083ab37d82fcff5b9023f0cce608f1dffe02206fc1fd866575061dcfa3d12f691c0a2f03041bdb75a36cd72098be096ff62a810121021b018b19426faa59fdda7f57e68c42d925752454d9ea0d6feed8ac186074a4bcffffffff020065cd1d000000001976a91494bc546a84c481fbd30d34cfeeb58fd20d8a59bc88ac447b380c010000001976a914f4376876aa04f36fc71a2618878986504e40ef9c88ac00000000"
    }
    

    wallet conflict

    Received on double spend.

    Returns tx details of removed double spender.

    wallet confirmed

    Received when a transaction is confirmed.

    Returns tx details.

    wallet unconfirmed

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

    Returns tx details.

    wallet balance

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

    Example:

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

    wallet address

    Received when a new address is derived.

    Example:

    {
      "network": "regtest",
      "wid": 1,
      "id": "primary",
      "name": "default",
      "account": 0,
      "branch": 0,
      "index": 9,
      "witness": false,
      "nested": false,
      "publicKey": "02801d9457837ed50e9538ee1806b6598e12a3c259fdc9258bbd32934f22cb1f80",
      "script": null,
      "program": null,
      "type": "pubkeyhash",
      "address": "mwX8J1CDGUqeQcJPnjNBG4s97vhQsJG7Eq"
    }
    

    RPC Calls - Wallet

    # examples in these docs will use a DIFFERENT environment variable
    # than the built-in bcoin wallet API calls above:
    walletrpcurl=http://x:api-key@127.0.0.1:48334/
    
    curl $walletrpcurl \
      -X POST \
      --data '{ "method": "<method>", "params": [...] "id": "some-id" }'
    
    bwallet-cli rpc <method> <params>
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.execute('<method>', [ <params> ]);
      console.log(result);
    })();
    

    Like the bcoin 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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "selectwallet",
        "params": [ "'$id'" ]
      }'
    
    bwallet-cli rpc selectwallet $id
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{ "method": "getwalletinfo" }'
    
    bwallet-cli rpc getwalletinfo
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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
      },
      "error": null,
      "id": null
    }
    

    Get basic wallet details.

    Params

    N. Name Default Description
    None.

    fundrawtransaction

    let tx;
    let options={"changeAddress": "RGexEyDWWeHFMow51GYLYyfcRYzV4dq8CM", "feeRate": 0.00001000};
    
    tx='0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420ccf0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722510fce9f37f0423b88ac00000000'
    
    options='{"changeAddress": "RGexEyDWWeHFMow51GYLYyfcRYzV4dq8CM", "feeRate": 0.00001000}'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "fundrawtransaction",
        "params": [ "'$tx'", '"$options"']
      }'
    
    options='{"changeAddress": "RGexEyDWWeHFMow51GYLYyfcRYzV4dq8CM", "feeRate": 0.00001000}'
    
    bwallet-cli rpc fundrawtransaction $tx "$options"
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 BTC/kb
    changeAddress Bitcoin address for change output of transaction

    resendwallettransactions

    curl $walletrpcurl \
      -X POST \
      --data '{ "method": "resendwallettransactions" }'
    
    bwallet-cli rpc resendwallettransactions
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "abandontransaction",
        "params": [ "'$tx'" ]
      }'
    
    bwallet-cli rpc abandontransaction $tx
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    addmultisigaddress

    Not implemented -- Impossible to implement in bcoin (no address book).

    addwitnessaddress

    Not implemented -- Deprecated in Bitcoin Core 0.16.0

    backupwallet

    let path;
    
    path='/home/user/WalletBackup'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "backupwallet",
        "params": [ "'$path'" ]
      }'
    
    bwallet-cli rpc backupwallet $path
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Path and name of destination directory for backup

    dumpprivkey

    let address;
    
    address='RBQUN7J1earPLbu97MyvG4zhW5b8RAQxoG'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "dumpprivkey",
        "params": [ "'$address'" ]
      }'
    
    bwallet-cli rpc dumpprivkey $address
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    EPni2gZW3WrTU9sKRL8j73cZEffujYwx81LSvpMATGYavC88QN63
    

    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 Bitcoin address

    dumpwallet

    let path;
    
    path='/home/user/WalletDump'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "dumpwallet",
        "params": [ "'$path'" ]
      }'
    
    bwallet-cli rpc dumpwallet $path
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Bcoin v1.0.0-pre
    # * Created on 2018-07-10T21:03:58Z
    # * Best block at time of backup was 501 (12bd2d79bb2ee31ae109485fcb859c398e5e462bae3243a10c307e07c2a1144f).
    # * File: /home/ec2-user/WalletDump
    
    EP3HH7RgveJ5CriwhDkZXXv3ZggtJ7ceooMoSBCG2PcaML2CYJ5y 2018-07-10T21:03:58Z label= addr=R9p6pdP7HmS7xYF1BofRWdb5Cgi2B1Xucf
    EMaRiAPcg4KACS4SvkxpxtMaJWkRnk5a1w8bwgX3avuycUJuRcZE 2018-07-10T21:03:58Z change=1 addr=RAyQMPqKdJHgGCD1DtZkjQ7LkhgnkdwhBP
    ...
    
    # 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 Path and name of destination file for dump

    encryptwallet

    let passphrase;
    
    passphrase='bikeshed'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "encryptwallet",
        "params": [ "'$passphrase'" ]
      }'
    
    bwallet-cli rpc encryptwallet $passphrase
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "getaccountaddress",
        "params": [ "'$account'" ]
      }'
    
    bwallet-cli rpc getaccountaddress $account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    RAxFD5Ffxs9JuGDiu29DLstK9wfw8TMykU
    

    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='RAxFD5Ffxs9JuGDiu29DLstK9wfw8TMykU'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "getaccount",
        "params": [ "'$address'" ]
      }'
    
    bwallet-cli rpc getaccount $address
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "getaddressesbyaccount",
        "params": [ "'$account'" ]
      }'
    
    bwallet-cli rpc getaddressesbyaccount $account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    [
      "RA15R2pAaz7WC3UGyVi5eSZTp77ADXJkih",
      "RAur4Z6Af2E2YCZBSubFChZsPpWaNoypWE",
      "RAxFD5Ffxs9JuGDiu29DLstK9wfw8TMykU",
      "RBsWtxTNH6XFB2exRMTexuztTt6LGxBPw7",
      "RDRPc4QRsot2Evxjt8HUa4wVsHyWRWDkhS",
    ...
      "RYCio4u5MYETZHa5yiGf1vsUAdeoMhLEoA"
    ]
    

    Get all addresses for a specified account.

    Params

    N. Name Default Description
    1 account Required Account name

    getbalance

    curl $walletrpcurl \
      -X POST \
      --data '{ "method": "getbalance" }'
    
    bwallet-cli rpc getbalance 
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.01205819
    

    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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "getnewaddress",
        "params": [ "'$account'" ]
      }'
    
    bwallet-cli rpc getnewaddress $account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    RFkJezDrGMyY6yvpY6PSknM8B2vtCNYcRM
    

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

    Params

    N. Name Default Description
    1 account Optional Account name

    getrawchangeaddress

    curl $walletrpcurl \
      -X POST \
      --data '{ "method": "getrawchangeaddress" }'
    
    bwallet-cli rpc getrawchangeaddress
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    RQbTXByrN77yhi232QSUCWc4NUmKtzfkiQ
    

    Get the next change address from specified account.

    Params

    N. Name Default Description
    None.

    getreceivedbyaccount

    let account, minconf;
    
    account='default'
    minconf=6
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "getreceivedbyaccount",
        "params": [ "'$account'", '$minconf' ]
      }'
    
    bwallet-cli rpc getreceivedbyaccount $account $minconf
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.00001234
    

    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='RHstcGRQWYojDPrrpazjLMjLgcnwd1mvCb'
    minconf=6
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "getreceivedbyaddress",
        "params": [ "'$address'", '$minconf' ]
      }'
    
    bwallet-cli rpc getreceivedbyaddress $address $minconf
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.00001234
    

    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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "gettransaction",
        "params": [ "'$txid'" ]
      }'
    
    bwallet-cli rpc gettransaction $txid
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": 50,
      "blockhash": "0cb30fe6b2e2cb036103a15ad293c086d5f32846033f8d1dc1488bde0af945c1",
      "blocktime": 1530218983,
      "txid": "36cbb7ad0cc98ca86640a04c485f164dd741c20339af34516d359ecba2892c21",
      "walletconflicts": [],
      "time": 1530218983,
      "timereceived": 1530218983,
      "bip125-replaceable": "no",
      "details": [
        {
          "account": "default",
          "address": "RHstcGRQWYojDPrrpazjLMjLgcnwd1mvCb",
          "category": "receive",
          "amount": 50,
          "label": "default",
          "vout": 0
        }
      ],
      "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1e510e6d696e65642062792062636f696e048e0e9256080000000000000000ffffffff0100f2052a010000001976a9145e50fb5b7475ebe2f7276ed3f29662e5321d1d7288ac00000000"
    }
    

    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 $walletrpcurl \
      -X POST \
      --data '{ "method": "getunconfirmedbalance" }'
    
    bwallet-cli rpc getunconfirmedbalance
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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='ETHW2rL2CYrXBT57oWRWPvzcjgq79fvDobj2PsF1Y5onqyo4JTCV'
    label='this_is_ignored'
    rescan=false
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "importprivkey",
        "params": [ "'$key'", "'$label'", '$rescan' ]
      }'
    
    bwallet-cli rpc importprivkey $key $label $rescan
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "importwallet",
        "params": [ "'$file'", '$rescan' ]
      }'
    
    bwallet-cli rpc importwallet $file $rescan
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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='RCFhpyWXkz5GxskL96q4KtceRXuAMnWUQo'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "importaddress",
        "params": [ "'$address'" ]
      }'
    
    bwallet-cli rpc importaddress $address
    
    # P2SH example, imports script as address GViEoofSJ7FywQVc1LcXKAbA8TvqDx5Rqv
    bwallet-cli rpc importaddress 76a9145e50fb5b7475ebe2f7276ed3f29662e5321d1d7288ac "this_is_ignored" true true
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Bitcoin script (in hex) as pay-to-script-hash (P2SH) 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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "importprunedfunds",
        "params": [ "'$rawtx'", "'$txoutproof'" ]
      }'
    
    bwallet-cli rpc importprunedfunds $rawtx $txoutproof
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "importpubkey",
        "params": [ "'$pubkey'" ]
      }'
    
    bwallet-cli rpc importpubkey $pubkey
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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

    keypoolrefill

    let newsize;
    
    newsize=100
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "keypoolrefill",
        "params": [ '$newsize' ]
      }'
    
    bwallet-cli rpc keypoolrefill $newsize
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.execute('keypoolrefill', [newsize]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    null
    

    Params

    N. Name Default Description
    1 newsize Required The new keypool size

    listaccounts

    let minconf, watchonly;
    
    minconf=6
    watchonly=false
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "listaccounts",
        "params": [ '$minconf', '$watchonly' ]
      }'
    
    bwallet-cli rpc listaccounts $minconf $watchonly
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.87650028,
      "savings": 9.37345432
    }
    

    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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "lockunspent",
        "params": [ '$unlock', '"$outputs"' ]
      }'
    
    outputs='[{ "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72", "vout": 1 }]'
    
    bwallet-cli rpc lockunspent $unlock "$outputs"
    
    # unlock all coins
    bwallet-cli rpc lockunspent true
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{ "method": "listlockunspent" }'
    
    bwallet-cli rpc listlockunspent
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "listreceivedbyaccount",
        "params": [ '$minconf', '$includeEmpty', '$watchOnly' ]
      }'
    
    bwallet-cli rpc listreceivedbyaccount $minconf $includeEmpty $watchOnly
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.2500454,
        "confirmations": 0,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "account": "default",
        "amount": 96.87650028,
        "confirmations": 0,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "account": "savings",
        "amount": 9.37345432,
        "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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "listreceivedbyaddress",
        "params": [ '$minconf', '$includeEmpty', '$watchOnly' ]
      }'
    
    bwallet-cli rpc listreceivedbyaddress $minconf $includeEmpty $watchOnly 
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "RCmX71juh4q2CnKGP8U1UhtbSwj8rP92Vi",
        "account": "hot",
        "amount": 6.2500454,
        "confirmations": 1,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "address": "RHstcGRQWYojDPrrpazjLMjLgcnwd1mvCb",
        "account": "default",
        "amount": 50,
        "confirmations": 503,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "address": "RMY3VYzTQibiRZ4FiydqavrF3PdBVKuT4r",
        "account": "default",
        "amount": 46.87650028,
        "confirmations": 1,
        "label": ""
      },
      {
        "involvesWatchonly": false,
        "address": "RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG",
        "account": "savings",
        "amount": 9.37345432,
        "confirmations": 1,
        "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='26b5e76dcdfc51b94e8e09ca1cf55b453e6c542b7abb863df0a306c6f00ebc8e'
    minconf=1
    watchOnly=false
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "listsinceblock",
        "params": [ "'$block'", '$minconf', '$watchOnly' ]
      }'
    
    bwallet-cli rpc listsinceblock $block $minconf $watchOnly 
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "savings",
          "address": "RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG",
          "category": "receive",
          "amount": 0,
          "label": "savings",
          "vout": 0,
          "confirmations": 1,
          "blockhash": "26b5e76dcdfc51b94e8e09ca1cf55b453e6c542b7abb863df0a306c6f00ebc8e",
          "blockindex": -1,
          "blocktime": 1531503617,
          "blockheight": 503,
          "txid": "3962a06342fc62a733700d74c075a5d24c4f44f7108f6d9a318b66e92e3bdc72",
          "walletconflicts": [],
          "time": 1531434894,
          "timereceived": 1531434894,
          "bip125-replaceable": "no"
        },
        {
          "account": "hot",
          "address": "RCmX71juh4q2CnKGP8U1UhtbSwj8rP92Vi",
          "category": "receive",
          "amount": 6.2500454,
          "label": "hot",
          "vout": 0,
          "confirmations": 1,
          "blockhash": "26b5e76dcdfc51b94e8e09ca1cf55b453e6c542b7abb863df0a306c6f00ebc8e",
          "blockindex": -1,
          "blocktime": 1531503617,
          "blockheight": 503,
          "txid": "1c526091b6bdff300cbdf8430e6dca9ea1ab2869d0b5d67e2097f9c9178b34b5",
          "walletconflicts": [],
          "time": 1531503618,
          "timereceived": 1531503618,
          "bip125-replaceable": "no"
        }
      ],
      "lastblock": "26b5e76dcdfc51b94e8e09ca1cf55b453e6c542b7abb863df0a306c6f00ebc8e"
    }
    

    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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "listtransactions",
        "params": [ "'$account'" ]
      }'
    
    bwallet-cli rpc listtransactions $account
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "hot",
        "address": "RCmX71juh4q2CnKGP8U1UhtbSwj8rP92Vi",
        "category": "receive",
        "amount": 6.2500454,
        "label": "hot",
        "vout": 0,
        "confirmations": 11,
        "blockhash": "26b5e76dcdfc51b94e8e09ca1cf55b453e6c542b7abb863df0a306c6f00ebc8e",
        "blockindex": -1,
        "blocktime": 1531503617,
        "blockheight": 503,
        "txid": "1c526091b6bdff300cbdf8430e6dca9ea1ab2869d0b5d67e2097f9c9178b34b5",
        "walletconflicts": [],
        "time": 1531503618,
        "timereceived": 1531503618,
        "bip125-replaceable": "no"
      }
    ]
    

    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=["RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG"];
    
    minconf=0
    maxconf=20
    
    addrs='["RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG"]'
    
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "listunspent",
        "params": [ '$minconf', '$maxconf', '"$addrs"' ]
      }'
    
    addrs='["RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG"]'
    
    bwallet-cli rpc listunspent $minconf $maxconf $addrs
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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": "210e0393071dbfb029336238a5b9aa8f0608e0bb5e03a734d1f9d849d25707f5",
        "vout": 0,
        "address": "RYAhEzn27d7P7kcyhWbisFhe9u69SR6ajG",
        "account": "savings",
        "scriptPubKey": "76a914fb105362e7419bd437d3648fc926ebcd939ca4d888ac",
        "amount": 6.25,
        "confirmations": 12,
        "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

    move

    Not implemented -- Deprecated in Bitcoin Core

    sendfrom

    let fromaccount, tobitcoinaddress, amount;
    
    fromaccount='hot'
    tobitcoinaddress='RAxFD5Ffxs9JuGDiu29DLstK9wfw8TMykU'
    amount=0.0195
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "sendfrom",
        "params": [ "'$fromaccount'", "'$tobitcoinaddress'", '$amount' ]
      }'
    
    bwallet-cli rpc sendfrom $fromaccount $tobitcoinaddress $amount
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      port: network.walletPort,
      apiKey: 'api-key'
    }
    
    const walletClient = new WalletClient(walletOptions);
    
    (async () => {
      const result = await walletClient.execute('sendfrom', [fromaccount, tobitcoinaddress, amount]);
      console.log(result);
    })();
    

    The above command returns JSON "result" like this:

    94f8a6dbaea9b5863d03d3b606c24e2e588d9e82564972148d54058660308e6a
    

    Send Bitcoin from an account to an address.

    Params

    N. Name Default Description
    1 fromaccount Required Wallet account to spend outputs from
    2 tobitcoinaddress Required Bitcoin address to send funds to
    3 amount Required Amount (in BTC) to send
    4 minconf Optional Minimum confirmations for output to be spent from
    5 comment Optional not implemented in bcoin
    6 comment_to Optional not implemented in bcoin

    sendmany

    let fromaccount, outputs, minconf, label, subtractFee;
    outputs={"REchKNnZ8ZMmLtWk57pCyLJWC9bUXKRUWW": 0.123, "RSj4jWhPWp6dyFKw8NaCHxWhzfUorfoskT": 0.321}
    
    fromaccount='hot'
    minconf=1
    label="this_is_ignored"
    subtractfee=false
    
    outputs='{"REchKNnZ8ZMmLtWk57pCyLJWC9bUXKRUWW": 0.123, "RSj4jWhPWp6dyFKw8NaCHxWhzfUorfoskT": 0.321}'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "sendmany",
        "params": [ "'$fromaccount'", '"$outputs"', '$minconf', "'$label'", '$subtractfee' ]
      }'
    
    outputs='{"REchKNnZ8ZMmLtWk57pCyLJWC9bUXKRUWW": 0.123, "RSj4jWhPWp6dyFKw8NaCHxWhzfUorfoskT": 0.321}'
    
    bwallet-cli rpc sendmany $fromaccount "$outputs" $minconf $label $subtractfee
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Bitcoin 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 Bitcoin 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

    sendtoaddress

    let address, amount, comment, comment_to, subtractFee;
    
    address='REchKNnZ8ZMmLtWk57pCyLJWC9bUXKRUWW'
    amount=1.01010101
    comment="this_is_ignored"
    comment_to="this_is_ignored"
    subtractfee=true
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "sendtoaddress",
        "params": [ "'$address'", '$amount', "'$comment'", "'$comment_to'", '$subtractfee' ]
      }'
    
    bwallet-cli rpc sendtoaddress $address $amount $comment $commnt_to $subtractfee
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 Bitcoin to an address.

    Params

    N. Name Default Description
    1 address Required Bitcoin address to send funds to
    2 amount Required Amount (in BTC) 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

    setaccount

    Not implemented

    settxfee

    let rate;
    
    rate=0.00001
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "settxfee",
        "params": [ '$rate' ]
      }'
    
    bwallet-cli rpc settxfee $rate
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 BTC/kB

    signmessage

    let address, message;
    
    address='RFi4gigMWzFCNw774Cj67nomVZCRM6MpPn'
    message='Satoshi'
    
    curl $walletrpcurl \
      -X POST \
      --data '{
        "method": "signmessage",
        "params": [ "'$address'", "'$message'" ]
      }'
    
    bwallet-cli rpc signmessage $address $message
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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:

    MEUCIQDHeECM3HRwD+FzueXV3iVxdX3ZT3tJurVOAgrRUnQeYgIgRIe1Onn/MrDQBF1nrwCZ2QkyaDWEXwsWo9C36kB4nGY=
    

    Sign an arbitrary message with the private key corresponding to a specified Bitcoin 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

    walletlock

    curl $walletrpcurl \
      -X POST \
      --data '{ "method": "walletlock" }'
    
    bwallet-cli rpc walletlock
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "walletpassphrasechange",
        "params": [ "'$old'", "'$passphrase'" ]
      }'
    
    bwallet-cli rpc walletpassphrasechange $old $passphrase
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "walletpassphrase",
        "params": [ "'$passphrase'", '$timeout' ]
      }'
    
    bwallet-cli rpc walletpassphrase $passphrase $timeout
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "removeprunedfunds",
        "params": [ "'$txid'" ]
      }'
    
    bwallet-cli rpc removeprunedfunds $txid
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{ "method": "getmemoryinfo" }'
    
    bwallet-cli rpc getmemoryinfo
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{
        "method": "setloglevel",
        "params": [ "'$level'" ]
      }'
    
    bwallet-cli rpc setloglevel $level
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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 $walletrpcurl \
      -X POST \
      --data '{ "method": "stop" }'
    
    bwallet-cli rpc stop
    
    const {WalletClient} = require('bclient');
    const {Network} = require('bcoin');
    const network = Network.get('regtest');
    
    const walletOptions = {
      network: network.type,
      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.

    Errors

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

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