bithodl-service

2.0.0 • Public • Published

BitHodl Service

npm Package Build Status Coverage Status

Bitcore service to expose necessary endpoints for the BitHodl app.

Getting started

  1. Create a Bitcore node
  2. Install the BitHodl service:
$ npm install --save bithodl-service
  1. Open bitcore-node.json and set services to:
"bitcoind",
"web",
"bithodl-service"
  1. Start the node:
$ bitcored

Hacks

Bitcore Library will complain about multiple instances. To workaround this, comment out line 12 in bithodl-service/node_modules/bitcore-lib/index.js:

//throw new Error(message);

https://github.com/bitpay/bitcore/issues/1454

API

GET /v1/public-key/:publicKey/addresses

Scans the UTXO set for addresses matching a public key (as a DER hex encoded string). Only time locked P2SH addresses generated by BitHodl will be returned.

Returns
Returns the addresses together with UTXO data as JSON.

GET /v1/address/:address/utxos

Returns the unspent outputs for the given address.

Returns
Returns the unspent outputs as a JSON array.

GET /v1/fee/estimate

Estimates the transaction fee based on the fees from the last 3 blocks.

Returns
Returns the estimated fee per byte in satoshis, e.g.

{
    "satoshisPerByte": 4
}

POST /v1/transaction

Broadcasts a transaction to the Bitcoin network. Body must be a serialized transaction in raw format (https://bitcoin.org/en/developer-reference#raw-transaction-format).

Returns
The txid of the transaction.

Error handling

Errors are returned as JSON in the following format:

{
    "error": "<error message>"
}

Use with testnet

During development and testing it is recommended to use the testnet network. By doing so you can use testnet coins and don't risk losing any real money. Running a testnet node is also much lighter than running a mainnet node.

  1. Run the Bitcore node with testnet

    Open bitcore-node.json and set network to testnet instead of livenet.

  2. Configure the BitHodl Service to use testnet

    Open node_modules/bithodl-service/src/config.js and set network to testnet instead of livenet.

  3. Configure the BitHodl app to use testnet

    You need to configure the app to use testnet and point it to your testnet node. This requires you to build and run the app yourself. Follow the instructions in the BitHodl app repo.

Contributing

Want to help us making BitHodl better? Great, but first read the CONTRIBUTING.md file for instructions.

Licensing

BitHodl is licensed under the Apache License, Version 2.0. See LICENSE for full license text.

Readme

Keywords

none

Package Sidebar

Install

npm i bithodl-service

Weekly Downloads

3

Version

2.0.0

License

Apache-2.0

Last publish

Collaborators

  • blockfirm